2016-03-01 07:34:27 +09:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using BenchmarkDotNet.Attributes;
|
2016-04-18 05:37:36 +09:00
|
|
|
|
using Markdig.Renderers;
|
2016-03-01 07:34:27 +09:00
|
|
|
|
|
|
|
|
|
|
namespace Testamina.Markdig.Benchmarks
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TestStringPerf
|
|
|
|
|
|
{
|
|
|
|
|
|
private string text;
|
|
|
|
|
|
|
|
|
|
|
|
public TestStringPerf()
|
|
|
|
|
|
{
|
|
|
|
|
|
text = new string('a', 1000);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Benchmark]
|
|
|
|
|
|
public void TestIndexOfAny()
|
|
|
|
|
|
{
|
2016-03-01 07:56:50 +09:00
|
|
|
|
var writer = new HtmlRenderer(new StringWriter());
|
2016-03-01 07:34:27 +09:00
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
writer.WriteEscape(text, 0, text.Length);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//[Benchmark]
|
|
|
|
|
|
//public void TestCustomIndexOfAny()
|
|
|
|
|
|
//{
|
2016-03-01 07:56:50 +09:00
|
|
|
|
// var writer = new HtmlRenderer(new StringWriter());
|
2016-03-01 07:34:27 +09:00
|
|
|
|
// for (int i = 0; i < 100; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// writer.WriteEscapeOptimized(text, 0, text.Length);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|