Skip to content

Instantly share code, notes, and snippets.

@dmrazzy
Forked from charles-cooper/transient_benchmark.py
Created November 17, 2024 00:23
Show Gist options
  • Save dmrazzy/dbfd5d0d56a055493d334a036e63aa97 to your computer and use it in GitHub Desktop.
Save dmrazzy/dbfd5d0d56a055493d334a036e63aa97 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