I ran some crude benchmarks using revm. The tools and methodology are below, but the tl;dr is:
plain dup2+mul 10k times ~20ns / operation
mload of the same address 10k times ~12ns / operation
tstore of the same address 10k times ~25ns / operation
tstore of 10k different addresses comes ~40ns / operation
tstore + tload of 10k different addresses ~70ns / operation
sha3 costs about 500ns / operation (sha3 of a 32 byte buffer)
script to generate evm scripts: generate benchmarks for transient storage · GitHub
revm script: feat: add evm script by charles-cooper · Pull Request #1039 · bluealloy/revm · GitHub
i want to point out that the summary numbers are estimates, since there is some jitter from stack operations which throw off the numbers a bit (however, i do think they are more or less in the correct ranges). i added two control scripts which do some stack fiddling to mimic what the later operations do, so their timings can be subtracted from the relevant scripts.
results (from revm/bins/revm-test, running for file in *.evm; do cargo run --release --bin evm $file; done
):
Finished release [optimized + debuginfo] target(s) in 0.15s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_control2.evm`
Run bytecode (3.0s) ... 108_523.678 ns/iter (0.992 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_control.evm`
Run bytecode (3.0s) ... 222_961.624 ns/iter (1.000 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_easy_mload.evm`
Run bytecode (3.0s) ... 126_342.356 ns/iter (1.000 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_easy_tstore.evm`
Run bytecode (3.0s) ... 370_559.161 ns/iter (1.000 R²)
Finished release [optimized + debuginfo] target(s) in 0.13s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_sha3.evm`
Run bytecode (3.1s) ... 4_947_213.996 ns/iter (1.000 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_tload_pure.evm`
Run bytecode (3.0s) ... 215_596.323 ns/iter (0.997 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_tstore.evm`
Run bytecode (3.0s) ... 619_875.709 ns/iter (0.999 R²)
Finished release [optimized + debuginfo] target(s) in 0.12s
Running `/home/charles/src-references/revm/target/release/evm /home/charles/src-references/EIPs/benchmark_tstore_tload.evm`
Run bytecode (3.1s) ... 936_628.376 ns/iter (0.998 R²)