-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathProgram.cs
41 lines (37 loc) · 1.24 KB
/
Program.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
31
32
33
34
35
36
37
38
39
40
41
// See https://aka.ms/new-console-template for more information
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using LinkDotNet;
BenchmarkRunner.Run<Benchi>();
[MemoryDiagnoser]
public class Benchi
{
[Benchmark(Baseline = true)]
public string DotNet()
{
var reference = new StringBuilder();
return reference
.AppendLine("Hello World")
.AppendLine("Here some other text")
.AppendLine("And again some other text as well for good measure")
.AppendLine("You are still here?")
.AppendLine("Hmmm.")
.AppendLine("I wish you a very nice day and all the best.")
.AppendLine("Sincerly Steven")
.ToString();
}
[Benchmark]
public string Fast()
{
var fast = new ValueStringBuilder();
fast.AppendLine("Hello World");
fast.AppendLine("Here some other text");
fast.AppendLine("And again some other text as well for good measure");
fast.AppendLine("You are still here?");
fast.AppendLine("Hmmm.");
fast.AppendLine("I wish you a very nice day and all the best.");
fast.AppendLine("Sincerly Steven");
return fast.ToString();
}
}