Created
March 28, 2022 14:21
-
-
Save kkokosa/6251cd0753a7b862178110d54c9d8b0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Engines; | |
using BenchmarkDotNet.Running; | |
using System.Text; | |
BenchmarkRunner.Run<Benchmarks>(); | |
[MemoryDiagnoser] | |
public class Benchmarks | |
{ | |
private byte[] data; | |
private Consumer consumer; | |
public Benchmarks() | |
{ | |
data = new byte[128]; | |
consumer = new Consumer(); | |
} | |
[Benchmark] | |
public StringBuilder A() => new StringBuilder(); | |
[Benchmark] | |
public (int, (int, (int, int, int)), string) B() => (1, (1, (1, 1, 1)), "x"); | |
[Benchmark] | |
public void C() => data.Where(x => x > 0).Select(x => x * x).Consume(consumer); | |
[Benchmark] | |
public string D() => new string('x', 64); | |
} | |
internal class DataClass | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment