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-08-22 · single run — not yet median-of-N · 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.7× faster than the baseline.
RESULTS — 1024
methodnet9.0net10.0ratioallocatedΔ net10.0
Sha256 baseline325 ns ±6 ns320 ns ±4 ns1.00×56 B-1%
XxHash64_hash55 ns ±2 ns54 ns ±0 ns0.17×32 B-2%
XxHash3_hash23 ns ±2 ns23 ns ±0 ns0.07×32 B-0%
RATIO VS BASELINE — 1024 · net10.0
Sha256
1.00×
XxHash64_hash
0.17×
XxHash3_hash
0.07×
RESULTS — 1048576
methodnet9.0net10.0ratioallocatedΔ net10.0
Sha256 baseline213.2 µs ±2.5 µs209.6 µs ±839 ns1.00×56 B-2%
XxHash64_hash45.9 µs ±45 ns47.1 µs ±717 ns0.22×32 B+3%
XxHash3_hash18.6 µs ±37 ns17.5 µs ±133 ns0.08×32 B-6%
RATIO VS BASELINE — 1048576 · net10.0
Sha256
1.00×
XxHash64_hash
0.22×
XxHash3_hash
0.08×
SCALING · net10.0 · MEAN TIME BY INPUT SIZE (LOG)
Sha256XxHash64_hashXxHash3_hash
235.1 µs2.2 µs21 ns10241048576
THE LEDGER · SAME WORKLOAD ACROSS RELEASES (LOG)
Sha256XxHash64_hashXxHash3_hash
369 ns88 ns21 ns10.0.201 · 08-22 v210.0.201 · 08-22 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.3 µs ±534 ns34.7 µs ±214 ns1.00×-2%
Guid_v760.2 µs ±752 ns58.4 µs ±334 ns1.68×-3%
RATIO VS BASELINE · net10.0
Guid_v4
1.00×
Guid_v7
1.68×
THE LEDGER · SAME WORKLOAD ACROSS RELEASES (LOG)
Guid_v4Guid_v7
67.1 µs45.6 µs31.0 µs10.0.201 · 08-22 v210.0.201 · 08-22 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