Last active
September 25, 2022 20:27
-
-
Save israellot/4547e9504794807650ea76929d44f0bc to your computer and use it in GitHub Desktop.
BenchmarkDotNet for the Checksum function
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 CrcBenchmark | |
{ | |
public byte[]? SourceBytes { get; set; } | |
[Params(1_000_000)] | |
public int Length { get; set; } | |
[GlobalSetup] | |
public void Setup() | |
{ | |
SourceBytes = new byte[Length]; | |
Random.Shared.NextBytes(SourceBytes); | |
} | |
[Benchmark] | |
public uint Baseline() | |
{ | |
return Crc32.Checksum(SourceBytes); | |
} | |
} | |
public static void Main(string[] args) | |
{ | |
BenchmarkRunner.Run<CrcBenchmark>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment