-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAppendFormatBenchmark.cs
More file actions
37 lines (32 loc) · 866 Bytes
/
AppendFormatBenchmark.cs
File metadata and controls
37 lines (32 loc) · 866 Bytes
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
31
32
33
34
35
36
37
using BenchmarkDotNet.Attributes;
namespace LinkDotNet.StringBuilder.Benchmarks;
[MemoryDiagnoser]
public class AppendFormatBenchmark
{
[Benchmark]
public string ValueStringBuilderAppendFormat()
{
using var builder = new ValueStringBuilder();
for (var i = 0; i < 100; i++)
{
builder.Append(true);
builder.Append(false);
builder.Append(true);
builder.Append(false);
}
return builder.ToString();
}
[Benchmark]
public string StringBuilderAppendFormat()
{
var builder = new System.Text.StringBuilder();
for (var i = 0; i < 100; i++)
{
builder.Append(true);
builder.Append(false);
builder.Append(true);
builder.Append(false);
}
return builder.ToString();
}
}