BENCHMARKS · HASHING & IDS

Cryptographic vs non-cryptographic hashing; Guid v4 vs v7. Suite and raw reports: github.com/gdhami-net/dotnet-benchmarks.

Intel Core Ultra 9 285HX · Windows 11 · BenchmarkDotNet 0.15.8 · SDK 10.0.201 · 2026-09-01 · median of 4 quiet runs · typical spread ±3.3% · bars/tables: mean time, lower is better

HashPayload

Hash the same payload: cryptographic SHA-256 vs the non-cryptographic XxHash family — pick by threat model, know the cost.

TAKEAWAY Pick by threat model, not speed: content addressing and checksums can take XxHash3's 10x win; anything security-relevant stays SHA-256 - which is already hardware-fast.
In this run: XxHash3_hash is fastest — 13.8× faster than the baseline.
RESULTS — 1024
methodnet9.0net10.0ratioallocatedΔ net10.0
Sha256 baseline328 ns ±1 ns325 ns ±1 ns1.00×56 B-1%
XxHash64_hash55 ns ±0 ns54 ns ±0 ns0.17×32 B-1%
XxHash3_hash24 ns ±0 ns24 ns ±0 ns0.07×32 B-0%
RATIO VS BASELINE — 1024 · net10.0
Sha2561.00×
XxHash64_hash0.17×
XxHash3_hash0.07×
RESULTS — 1048576
methodnet9.0net10.0ratioallocatedΔ net10.0
Sha256 baseline215.4 µs ±559 ns215.4 µs ±57 ns1.00×56 B-0%
XxHash64_hash45.9 µs ±57 ns46.7 µs ±74 ns0.22×32 B+2%
XxHash3_hash18.8 µs ±226 ns17.9 µs ±252 ns0.08×32 B-5%
RATIO VS BASELINE — 1048576 · net10.0
Sha2561.00×
XxHash64_hash0.22×
XxHash3_hash0.08×
SCALING · net10.0 · MEAN TIME BY INPUT SIZE (LOG)
Sha256XxHash64_hashXxHash3_hash
241.7 µs2.3 µs21 ns10241048576
THE LEDGER · SAME WORKLOAD ACROSS RELEASES (LOG)
Sha256XxHash64_hashXxHash3_hash
369 ns88 ns21 ns10.0.201 · 08-22 v210.0.201 · 09-01 v3
THE CODE BEING MEASURED
Sha256 — what this measures

SHA-256 — cryptographic, hardware-accelerated on modern CPUs.

[Benchmark (Baseline)]
public byte[] Sha256()
=> SHA256.HashData(_payload);
XxHash64_hash — what this measures

XxHash64 — fast non-cryptographic checksum (System.IO.Hashing).

[Benchmark]
public byte[] XxHash64_hash()
=> XxHash64.Hash(_payload);
XxHash3_hash — what this measures

XxHash3 — the newer, usually faster member of the family.

[Benchmark]
public byte[] XxHash3_hash()
=> XxHash3.Hash(_payload);

MakeIds

Make 1,000 ids: random Guid v4 vs .NET 9's time-ordered v7 — v7 exists so your database index stops fragmenting.

TAKEAWAY Guid.CreateVersion7 costs a whisker more to create and saves you from fragmented clustered indexes forever. For database keys, v7 is the new default.
In this run: Guid_v4 is fastest (it is the baseline).
RESULTS
methodnet9.0net10.0ratioallocatedΔ net10.0
Guid_v4 baseline35.8 µs ±316 ns35.2 µs ±242 ns1.00×—-2%
Guid_v760.1 µs ±199 ns59.6 µs ±76 ns1.70×—-1%
RATIO VS BASELINE · net10.0
Guid_v41.00×
Guid_v71.70×
THE LEDGER · SAME WORKLOAD ACROSS RELEASES (LOG)
Guid_v4Guid_v7
67.1 µs45.9 µs31.3 µs10.0.201 · 08-22 v210.0.201 · 09-01 v3
THE CODE BEING MEASURED
Guid_v4 — what this measures

Guid.NewGuid — random v4.

[Benchmark (Baseline)]
public Guid Guid_v4()
{
    var g = Guid.Empty;
    for (var i = 0; i < 1_000; i++) g = Guid.NewGuid();
    return g;
}
Guid_v7 — what this measures

Guid.CreateVersion7 (.NET 9+) — time-ordered, index-friendly.

[Benchmark]
public Guid Guid_v7()
{
    var g = Guid.Empty;
    for (var i = 0; i < 1_000; i++) g = Guid.CreateVersion7();
    return g;
}

speed vs allocation

Fast is one axis. What it costs the GC is the other.

Sha256XxHash64_hashXxHash3_hashGuid_v4Guid_v7
mean time → (log)allocated → (log)Sha256XxHash64_hashXxHash3_hashGuid_v4Guid_v7