-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathAppendBenchmark.cs
30 lines (27 loc) · 1.21 KB
/
AppendBenchmark.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using BenchmarkDotNet.Attributes;
namespace LinkDotNet.StringBuilder.Benchmarks;
[MemoryDiagnoser]
public class AppendBenchmarks
{
[Benchmark(Baseline = true)]
public string DotNetStringBuilder()
{
var builder = new System.Text.StringBuilder();
builder.AppendLine("That is the first line of our benchmark.");
builder.AppendLine("We can multiple stuff in here if want.");
builder.AppendLine("The idea is that we can resize the internal structure from time to time.");
builder.AppendLine("We can also add other Append method if we want. But we keep it easy for now.");
return builder.ToString();
}
[Benchmark]
public string ValueStringBuilder()
{
using var builder = new ValueStringBuilder();
builder.AppendLine("That is the first line of our benchmark.");
builder.AppendLine("We can multiple stuff in here if want.");
builder.AppendLine("We can multiple stuff in here if want.");
builder.AppendLine("The idea is that we can resize the internal structure from time to time.");
builder.AppendLine("We can also add other Append method if we want. But we keep it easy for now.");
return builder.ToString();
}
}