Skip to content

Commit b24c873

Browse files
committed
bench: add 2MB throughput benchmarks
Covers one-shot intdigest/hexdigest and streaming constructors across all four algorithms at 2MB where hashing dominates.
1 parent 82d4c70 commit b24c873

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

tests/test_benchmark.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import hashlib
21
import os
32
import random
43

@@ -12,6 +11,7 @@
1211
DATA_5B = os.urandom(5)
1312
DATA_1KB = os.urandom(1000)
1413
DATA_10KB = os.urandom(10000)
14+
DATA_2MB = os.urandom(2 * 1024 * 1024)
1515

1616

1717
# ── macro bench: larger inputs where hashing dominates ───────────────
@@ -146,3 +146,60 @@ def test_xxh3_64_ctor():
146146
@pytest.mark.benchmark
147147
def test_xxh3_128_ctor():
148148
xxhash.xxh3_128(DATA_STR, seed=SEED_64)
149+
150+
151+
# ── 2MB throughput: hashing dominates, call overhead negligible ─────
152+
153+
154+
@pytest.mark.benchmark
155+
def test_xxh32_intdigest_2mb():
156+
xxhash.xxh32_intdigest(DATA_2MB, seed=SEED_32)
157+
158+
159+
@pytest.mark.benchmark
160+
def test_xxh64_intdigest_2mb():
161+
xxhash.xxh64_intdigest(DATA_2MB, seed=SEED_64)
162+
163+
164+
@pytest.mark.benchmark
165+
def test_xxh3_64_intdigest_2mb():
166+
xxhash.xxh3_64_intdigest(DATA_2MB, seed=SEED_64)
167+
168+
169+
@pytest.mark.benchmark
170+
def test_xxh3_128_intdigest_2mb():
171+
xxhash.xxh3_128_intdigest(DATA_2MB, seed=SEED_64)
172+
173+
174+
@pytest.mark.benchmark
175+
def test_xxh32_hexdigest_2mb():
176+
xxhash.xxh32_hexdigest(DATA_2MB, seed=SEED_32)
177+
178+
179+
@pytest.mark.benchmark
180+
def test_xxh3_64_hexdigest_2mb():
181+
xxhash.xxh3_64_hexdigest(DATA_2MB, seed=SEED_64)
182+
183+
184+
@pytest.mark.benchmark
185+
def test_xxh32_stream_intdigest_2mb():
186+
h = xxhash.xxh32(DATA_2MB, seed=SEED_32)
187+
h.intdigest()
188+
189+
190+
@pytest.mark.benchmark
191+
def test_xxh64_stream_intdigest_2mb():
192+
h = xxhash.xxh64(DATA_2MB, seed=SEED_64)
193+
h.intdigest()
194+
195+
196+
@pytest.mark.benchmark
197+
def test_xxh3_64_stream_intdigest_2mb():
198+
h = xxhash.xxh3_64(DATA_2MB, seed=SEED_64)
199+
h.intdigest()
200+
201+
202+
@pytest.mark.benchmark
203+
def test_xxh3_128_stream_intdigest_2mb():
204+
h = xxhash.xxh3_128(DATA_2MB, seed=SEED_64)
205+
h.intdigest()

0 commit comments

Comments
 (0)