Skip to content

Instantly share code, notes, and snippets.

@israellot
Last active September 25, 2022 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israellot/4547e9504794807650ea76929d44f0bc to your computer and use it in GitHub Desktop.
Save israellot/4547e9504794807650ea76929d44f0bc to your computer and use it in GitHub Desktop.
BenchmarkDotNet for the Checksum function
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