Last active
August 14, 2024 20:38
-
-
Save jason-c-daniels/24bb046e39b9a96dc491ec714456f04d to your computer and use it in GitHub Desktop.
BenchmarkDotNet - 0.14.0 - working on home laptop
This file contains 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
public class AllocationsBenchmarks | |
{ | |
[Benchmark] | |
[ArgumentsSource(nameof(SizesToAllocate))] | |
public byte[] Allocate_Byte_Array_With_Size(int size) | |
=> new byte[size]; | |
[Benchmark] | |
[ArgumentsSource(nameof(SizesToAllocate))] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public List<byte> Allocate_List_With_Size(int size) | |
=> new List<byte>(size); | |
public IEnumerable<int> SizesToAllocate() | |
{ | |
yield return 0; | |
yield return 1; | |
yield return 2; | |
yield return 4; | |
yield return 16; | |
yield return 32; | |
yield return 64; | |
yield return 128; | |
yield return 256; | |
yield return 512; | |
yield return 1024; | |
yield return 0xFFFF/2; // 32K | |
yield return 0xFFFF; // 64K | |
} | |
} |
This file contains 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
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment