Skip to content

Instantly share code, notes, and snippets.

@charles-cooper
Created February 1, 2024 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charles-cooper/cfee0460891d3e0f1d3e433610773e53 to your computer and use it in GitHub Desktop.
Save charles-cooper/cfee0460891d3e0f1d3e433610773e53 to your computer and use it in GitHub Desktop.
generate benchmarks for transient storage
#!/usr/bin/env python
with open("benchmark_control.easm", "w") as f:
print("PUSH1 251", file=f)
print("PUSH1 1", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP2 MUL", file=f)
print("DUP1 DUP1 POP POP", file=f)
with open("benchmark_easy_mload.easm", "w") as f:
print("PUSH1 0", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP1 MLOAD POP", file=f)
with open("benchmark_sha3.easm", "w") as f:
print("PUSH1 1", file=f)
print("PUSH1 0", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP2 ADD", file=f)
print("DUP1 PUSH1 0 MSTORE PUSH1 32 PUSH1 0 SHA3 POP", file=f)
# 251 is the largest prime number <= 256
with open("benchmark_tload_pure.easm", "w") as f:
print("PUSH1 251", file=f)
print("PUSH1 1", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP2 MUL", file=f)
print("DUP1 TLOAD POP", file=f)
with open("benchmark_tstore.easm", "w") as f:
print("PUSH1 251", file=f)
print("PUSH1 1", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP2 MUL", file=f)
print("DUP1 DUP1 TSTORE", file=f)
with open("benchmark_easy_tstore.easm", "w") as f:
print("PUSH1 251", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP1 DUP1 TSTORE", file=f)
with open("benchmark_tstore_tload.easm", "w") as f:
print("PUSH1 251", file=f)
print("PUSH1 1", file=f)
for _ in range(10_000): # stay roughly within codesize limit, still large enough for benchmark
print("DUP2 MUL", file=f)
print("DUP1 DUP1 TSTORE DUP1 TLOAD POP", file=f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment