CI test - #133526
Draft
MihaZupan wants to merge 1 commit into
Draft
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-io-hashing, @bartonjs, @vcsjones |
This comment was marked as outdated.
This comment was marked as outdated.
Member
Author
|
@EgorBot -amd -ubuntu24_azure_cobalt100 -osx_arm64 using System;
using System.IO.Hashing;
using BenchmarkDotNet.Attributes;
[MemoryDiagnoser]
public class XxHashBenchmarks
{
private const int BatchSize = 65_536;
private byte[] _data = null!;
private int[] _lengths = null!;
// Bytes. -1: random 0..240; -2: random 0..4096.
[Params(0, 16, 17, 32, 33, 64, 65, 96, 97, 128, 129, 240, 241,
1024, 1025, 16384, -1, -2)]
public int Length { get; set; }
[Params(0L, 42L)]
public long Seed { get; set; }
[GlobalSetup]
public void Setup()
{
int maximumLength = Length switch
{
-1 => 240,
-2 => 4096,
_ => Length
};
_data = new byte[maximumLength];
new Random(43).NextBytes(_data);
Random random = new Random(42);
_lengths = new int[BatchSize];
for (int i = 0; i < _lengths.Length; i++)
{
_lengths[i] = Length < 0
? random.Next(maximumLength + 1)
: Length;
}
}
[Benchmark(OperationsPerInvoke = BatchSize)]
public ulong XxHash3_OneShot()
{
ulong result = 0;
foreach (int length in _lengths)
{
result = unchecked(
result + XxHash3.HashToUInt64(_data.AsSpan(0, length), Seed));
}
return result;
}
[Benchmark(OperationsPerInvoke = BatchSize)]
public UInt128 XxHash128_OneShot()
{
UInt128 result = 0;
foreach (int length in _lengths)
{
result = unchecked(
result + XxHash128.HashToUInt128(_data.AsSpan(0, length), Seed));
}
return result;
}
}Note Benchmark prepared with GitHub Copilot. |
This was referenced Sep 9, 2026
Open
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.