Skip to content

Commit 5c477d5

Browse files
perf(benchmarks): broaden address benchmark inputs (#236)
Summary - Expand address benchmark inputs to include uppercase, precompile, dead, and sample addresses. Rationale - A broader address mix reflects real RPC payloads and improves checksum/construct timing representativeness. Details - Updated `benchmarks/data.py` with additional address cases and IDs consumed by `benchmarks/test_address_benchmarks.py`. - Tests: `python setup.py build_ext --inplace` (mypy-compiled extensions; verified `evmspec/_new.cpython-314-x86_64-linux-gnu.so`), `python -m pytest benchmarks/`.
1 parent 0f02831 commit 5c477d5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

benchmarks/data.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22

33
ADDRESS_CHECKSUM = "0x52908400098527886E0F7030069857D2E4169EE7"
44
ADDRESS_LOWER = "0xde709f2102306220921060314715629080e2fb77"
5+
ADDRESS_UPPER = "0xDE709F2102306220921060314715629080E2FB77"
56
ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"
7+
ADDRESS_PRECOMPILE_1 = "0x0000000000000000000000000000000000000001"
8+
ADDRESS_PRECOMPILE_9 = "0x0000000000000000000000000000000000000009"
9+
ADDRESS_DEAD = "0x000000000000000000000000000000000000dead"
10+
ADDRESS_SAMPLE = "0x1234567890abcdef1234567890abcdef12345678"
611

712
ADDRESS_CASES = [
813
ADDRESS_CHECKSUM,
914
ADDRESS_LOWER,
15+
ADDRESS_UPPER,
1016
ADDRESS_ZERO,
17+
ADDRESS_PRECOMPILE_1,
18+
ADDRESS_PRECOMPILE_9,
19+
ADDRESS_DEAD,
20+
ADDRESS_SAMPLE,
1121
]
1222
ADDRESS_CASE_IDS = [
1323
"checksummed",
1424
"lower",
25+
"upper",
1526
"zero",
27+
"precompile-1",
28+
"precompile-9",
29+
"dead",
30+
"sample",
1631
]
1732

1833
HASH_1 = "0x" + "11" * 32

benchmarks/test_address_benchmarks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
@pytest.mark.benchmark(group="address_checksum")
1111
@pytest.mark.parametrize("address", ADDRESS_CASES, ids=ADDRESS_CASE_IDS)
1212
def test_address_checksum(benchmark: BenchmarkFixture, address: str) -> None:
13-
benchmark(batch, 100, Address.checksum, address)
13+
benchmark(batch, 1000, Address.checksum, address)
1414

1515

1616
@pytest.mark.benchmark(group="address_construct")
1717
@pytest.mark.parametrize("address", ADDRESS_CASES, ids=ADDRESS_CASE_IDS)
1818
def test_address_construct(benchmark: BenchmarkFixture, address: str) -> None:
19-
benchmark(batch, 100, Address, address)
19+
benchmark(batch, 1000, Address, address)

0 commit comments

Comments
 (0)