Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Benchmarks.CollectionBenchmarks;
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Benchmarks.CollectionBenchmarks;
[SimpleJob(RuntimeMoniker.Net80)]
[MeanColumn, MemoryDiagnoser]
public class ArrayCopy
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Benchmarks.Mocks;
namespace Benchmarks;
[SimpleJob(RuntimeMoniker.Net70)]
[MeanColumn, MemoryDiagnoser]
public class ListInitializerBenchmark
using System;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Benchmarks.GlossaryBenchmarks;
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net60)]
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Storage.Benchmark;
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
[SimpleJob(RuntimeMoniker.Net48)]
[MeanColumn]
public class ArrayReadBenchmark
Method Runtime Count Mean Ratio RatioSD Gen 0 Gen 1 Allocated
Builder .NET 6.0 5 49.91 ns 0.89 0.03 0.0249 - 208 B
BuilderWithCapacity .NET 6.0 5 55.82 ns 1.00 0.00 0.1310 0.0005 1,096 B
CachedBuilder .NET 6.0 5 19.95 ns 0.36 0.00 - - -
ValueBuilder .NET 6.0 5 40.94 ns 0.73 0.01 - - -
Builder .NET Core 3.1 5 50.78 ns 0.87 0.01 0.0249 - 208 B
BuilderWithCapacity .NET Core 3.1 5 58.20 ns 1.00 0.00 0
Method Runtime TaskCount Mean Ratio Gen 0 Gen 1 Gen 2 Allocated
AutoClosure .NET 6.0 10 6.252 ms 1.00 203.1250 - - 1,709 KB
ParallelFor .NET 6.0 10 1.891 ms 0.30 263.6719 - - 2,154 KB
ParallelForeach .NET 6.0 10 1.909 ms 0.31 269.5313 - - 2,220 KB
SelfClosure .NET 6.0 10 5.747 ms 0.88 93.7500 - - 773 KB
AutoClosure .NET Core 3.1 10 6.706 ms 1.00 203.1250 - - 1,710 KB
ParallelFor .NET Core 3.1 10
Method Runtime Mean Ratio Gen 0 Gen 1 Gen 2 Allocated
AutoClosure .NET 6.0 6.131 ms 1.00 203.1250 - - 1,711 KB
ParallelFor .NET 6.0 1.850 ms 0.30 265.6250 - - 2,158 KB
ParallelForeach .NET 6.0 1.916 ms 0.31 271.4844 - - 2,221 KB
SelfClosure .NET 6.0 5.883 ms 0.96 93.7500 - - 774 KB
AutoClosure .NET Core 3.1 6.727 ms 1.00 203.1250 - - 1,713 KB
ParallelFor .NET Core 3.1 1.925 ms 0.29 257.8125 - - 2,108 KB
ParallelForeach .NET Core 3.1 2.015 ms 0.30 265.6250
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Storage.Benchmark.Glo;
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
[SimpleJob(RuntimeMoniker.Net48)]
[MeanColumn]
public class DictionaryGetWriteValueBenchmark
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Storage.Benchmark.Glo;
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
[SimpleJob(RuntimeMoniker.Net48)]
[MeanColumn]
public class DictionaryGetValueBenchmark