using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
internal const int FnvOffsetBias = unchecked((int)2166136261);
internal const int FnvPrime = 16777619;
internal const int MaxSlots = 8;
public static void Main()
var ids = Enumerable.Range(1, 50).Select(_ => System.Text.Encoding.Default.GetBytes(Guid.NewGuid().ToString())).ToArray();
for (var i = 0; i < ids.Length; i++)
var fnvSlot = (GetFNVHashCode(ids[i]) % MaxSlots) + 1;
for (var i = 0; i < ids.Length; i++)
var mmSlot = (GetMurmurHash3(ids[i]) % MaxSlots) + 1;
internal static uint GetFNVHashCode(ReadOnlySpan<byte> data)
int hashCode = FnvOffsetBias;
for (int i = 0; i < data.Length; i++)
hashCode = unchecked((hashCode ^ b) * FnvPrime);
public static uint GetMurmurHash3(ReadOnlySpan<byte> bytes)
var length = bytes.Length;
var h1 = (uint)Math.Abs(FnvOffsetBias);
var remainder = length & 3;
var position = length - remainder;
for (var start = 0; start < position; start += 4)
h1 = (uint)((int)RotateLeft(h1 ^ RotateLeft(BitConverter.ToUInt32(bytes.Slice(start, 4)) * 3432918353U, 15) * 461845907U, 13) * 5 - 430675100);
num ^= (uint)bytes[position];
num ^= (uint)bytes[position + 1] << 8;
num ^= (uint)bytes[position + 2] << 16;
h1 ^= RotateLeft(num * 3432918353U, 15) * 461845907U;
h1 = FMix(h1 ^ (uint)length);
internal static uint RotateLeft(uint x, byte r)
return x << (int)r | x >> 32 - (int)r;
internal static uint FMix(uint h)
h = (uint)(((int)h ^ (int)(h >> 16)) * -2048144789);
h = (uint)(((int)h ^ (int)(h >> 13)) * -1028477387);