Benchmark tool for the Solidity compiler: compile-time performance, memory,
hardware counters (perf stat), bytecode size, and gas usage across
real-world projects.
SOLC1=../solidity/build/solc/solc
SOLC2=../solidity-new/build/solc/solc
solc-bench run --benchmark-dir ./benchmark_data --solc $SOLC1 --tags fast -o old.json
solc-bench run --benchmark-dir ./benchmark_data --solc $SOLC2 --tags fast -o new.json
solc-bench compare old.json new.jsongit clone https://github.com/argotorg/solc-bench
cd solc-bench
nix develop
# you are now in a nix develop shell
python -m venv .venv && source .venv/bin/activate
pip install -e '.[plot]'
solc-bench ...Needs Python 3.11+. Optional:
perf: for hardware countersforge: to extract benchmarks, gas measurementevmone: to capture and replay mainnet gas fixtures
git clone https://github.com/argotorg/solc-bench
cd solc-bench
python -m venv .venv && source .venv/bin/activate
pip install -e '.[plot]'
solc-bench ...Each benchmark is compiled under one or more codegen pipelines. run uses
the pipelines in each benchmark's TOML entry (or all if unspecified);
--pipeline restricts to one, --no-optimize disables the optimizer.
| Pipeline | Standard-json settings |
|---|---|
evmasm |
"viaIR": false — EVM assembly codegen |
ir |
"viaIR": true — IR-based codegen |
ir-ssacfg |
"viaIR": true, "viaSSACFG": true — SSA-CFG experimental codegen |
ir-ethdebug |
"viaIR": true, optimizer disabled — unoptimized IR codegen with ETHDebug outputs |
All metrics are collected when applicable, except deployment_gas and
method_gas, which are opt-in per benchmark (see Gas benchmarks),
and gas_used, which needs run --evmone (see Mainnet gas fixtures).
| Metric | Description | Unit | Source |
|---|---|---|---|
cpu_time |
CPU time (user + system) | seconds | os.wait4() rusage |
wall_time |
Wall clock time | seconds | time.monotonic() |
peak_rss |
Peak resident set size | MiB | rusage.ru_maxrss |
cache_miss_rate |
cache_misses / cache_references |
% | perf stat |
creation_size |
Total creation bytecode size | bytes | solc output |
runtime_size |
Total runtime bytecode size | bytes | solc output |
ethdebug_size |
Serialized ETHDebug JSON output size | bytes | solc output |
deployment_gas |
Total deployment gas | gas | forge test --gas-report |
method_gas |
Total method-call gas (mean * calls) |
gas | forge test --gas-report |
gas_used |
Total gas used replaying mainnet fixtures | gas | evmone |
Some perf stat counters are recorded into the result JSON but are not
reported by default. Pass --show-hidden to see them:
| Metric | Description | Unit | Source |
|---|---|---|---|
instructions |
Hardware instruction count | count | perf stat |
cycles |
CPU cycle count | count | perf stat |
cache_references |
Cache references | count | perf stat |
cache_misses |
Cache misses | count | perf stat |
Benchmarks a suite in --benchmark-dir or a single sol/json file without
the --benchmark-dir flag. Results land in bench-results.json in
--output-dir, or in a file with -o file.json.
| Flag | Default | Description |
|---|---|---|
--solc PATH |
required | Path to solc binary |
--benchmark-dir DIR |
required for suites | Suite dir (benchmarks.toml + JSONs) |
--only NAMES |
(all) | Comma-separated benchmark names |
--tags TAGS |
(none) | Comma-separated tags |
--iterations N |
3 |
Number of iterations |
--output-dir DIR |
current dir | Where to write results + logs |
-o, --output-file FILE |
(none) | Write result JSON to a specific file |
--stdout |
off | Also print results to stdout |
--pipeline P |
(all) | evmasm/ir/ir-ssacfg/ir-ethdebug |
--no-optimize |
off | Disable the optimizer |
--yul-optimizations STEPS |
solc's default | Yul optimizer step sequence for every pipeline (STEPS or STEPS:CLEANUP_STEPS). Recorded in the result file; skips forge gas |
--evmone PATH |
(none) | Replay mainnet gas fixtures against the compiled bytecode |
solc-bench run --solc ./solc --benchmark-dir ./my-suite --only openzeppelin-5.6.1
solc-bench run --solc ./solc contract.sol --pipeline ir # single file
solc-bench run --solc ./solc --benchmark-dir ./benchmark_data --evmone ./evmone # + gas-fixture replayTo measure a Yul optimizer step sequence, run the same binary twice and compare the result files:
solc-bench run --solc ./solc --benchmark-dir ./benchmark_data --pipeline ir -o default.json
solc-bench run --solc ./solc --benchmark-dir ./benchmark_data --pipeline ir -o sequence.json \
--yul-optimizations 'dhfoDgvulfnTUtnIf [xa[r]EscLMVcul] jmul:fDnTOcmu'
solc-bench compare default.json sequence.jsonCompares two result files, the baseline first. FILE:PIPELINE reads only that pipeline.
~noise in the winner column means the difference isn't statistically significant or is under 0.10%.
| Flag | Default | Description |
|---|---|---|
--output FILE |
(none) | Write comparison JSON to file |
--per-function [STAT] |
off | Per-function gas deltas |
--summary |
off | Print the summary even with fewer than 10 benchmarks |
--plot FILE |
(none) | Write a boxplot, requires [plot] |
--plot-metric METRIC[,...] |
cpu_time |
Metric(s) to plot |
solc-bench compare baseline/bench-results.json target/bench-results.json
solc-bench compare bench-results.json:evmasm bench-results.json:ir --plot diff.pngDownloads a static Linux solc binary for the host architecture (x86_64 or
aarch64). A release tag (v0.8.35) comes from the matching
argotorg/solidity release;
a branch (develop) from the latest successful CircleCI b_ubu_static
(b_ubu_static_arm on aarch64) artifact. CIRCLECI_TOKEN / GITHUB_TOKEN
raise rate limits.
| Flag | Default | Description |
|---|---|---|
--output FILE |
./solc-{ref} |
Destination path |
--force |
off | Overwrite destination if it exists |
solc-bench fetch v0.8.35
solc-bench fetch develop --output ./solc --forceProduces one standard-json .json per Forge project (sources + base
settings); pipeline and optimizer settings are applied at runtime by run.
| Flag | Default | Description |
|---|---|---|
--solc PATH |
required | Path to solc binary |
--project DIR |
required | Forge project directory |
--output-dir DIR |
project parent | Where to write the standard-json |
Turns real mainnet calls to <address> into replayable EEST state tests.
It picks the most-called selectors among recent successful transactions (via Etherscan),
captures one example transaction each, and checks evmone's replay against the real receipt status, logs and state diff.
Writes <name>-<selector>.json per call plus a targets.toml.
Needs a trace-capable RPC endpoint (debug_traceTransaction with prestateTracer).
| Flag | Default | Description |
|---|---|---|
--output-dir DIR |
required | Where to write fixtures and targets.toml |
--evmone PATH |
required | Path to evmone binary |
--rpc-url URL |
$ETH_RPC_URL |
Trace-capable JSON-RPC endpoint |
--etherscan-api-key KEY |
$ETHERSCAN_API_KEY |
Etherscan API key |
--limit N |
500 | Recent transactions to scan |
--max-selectors N |
5 | Max distinct selectors to capture |
--min-calls N |
1 | Min calls for a selector to qualify |
--end-block N |
latest | Only scan transactions up to this block |
--target-address ADDR |
<address> |
Contract whose bytecode gets swapped, if <address> is a proxy |
--force |
off | Overwrite existing fixtures and targets.toml |
For a contract behind a proxy, pass the proxy as <address> (recorded as discovery_address in benchmarks.toml) and the implementation as --target-address:
solc-bench capture-contract 0x308861a430be4cce5502d0a12724771fc6daf216 \
--target-address 0x17a16747d03006c9754548ac0d0aff48783a4a45 \
--evmone ./evmone --output-dir benchmark_data/gas/etherfi-liquidity-poolLists configured benchmarks, or with --tags/--metrics the tags or
metrics instead.
| Flag | Default | Description |
|---|---|---|
--benchmark-dir DIR |
required unless --metrics |
Suite directory with benchmarks.toml |
--tags |
off | List all tags across benchmarks |
--metrics |
off | List available metrics |
A suite is a directory with a benchmarks.toml and one <key>.json
standard-json input per entry. The repo's default suite is benchmark_data/.
A top-level include = ["subsets"] pulls in subsets/benchmarks.toml; its
entries are named subsets/<key> (e.g. --only subsets/aave-pool-3.6.0).
benchmark_data/subsets/*.json are generated from the full project JSONs by
scripts/regenerate_subsets.sh. Don't edit them by hand; add the subset to
that script instead. It calls scripts/subset.py, which keeps only the import
closure of the given root sources and requests codegen for just those roots:
python scripts/subset.py benchmark_data/openzeppelin-5.6.1.json \
benchmark_data/subsets/openzeppelin-timelock-5.6.1.json \
contracts/governance/TimelockController.solextract writes <project-dir-name>.json, so clone the project into a
directory named after the TOML key:
solc-bench extract --solc ./solc --project /tmp/openzeppelin-5.6.1 --output-dir ./benchmark_dataThen add the TOML entry. extract skips existing JSONs and never touches
benchmarks.toml.
Upstream code rarely compiles with solc 0.9.0 as is, so migrate the new input.
scripts/migrate_0_9.py rewrites it in place to compile with both 0.8.x and
0.9.0: ^0.8.x and <0.9.0 version pragmas become >=, and
pragma experimental ABIEncoderV2; and virtual on modifiers are dropped.
A modifier that is overridden needs a hand patch in the script's PATCHES.
If the input has subsets, run scripts/regenerate_subsets.sh afterwards.
python scripts/migrate_0_9.py benchmark_data/openzeppelin-5.6.1.jsongas = true also collects deployment_gas and method_gas (requires
forge). The first run clones the project at the version git tag into
<benchmark-dir>/<key>/ and runs forge test --gas-report --json; later runs
reuse the clone. Bumping version errors out — delete the stale clone and
re-run.
benchmark_data/gas/<key>/ holds EEST fixtures replaying
mainnet transactions to benchmark <key>, captured with capture-contract.
With --evmone, run swaps each pipeline's freshly compiled bytecode into the fixtures, replays them, and reports the summed gas_used plus a per-fixture breakdown under functions.
A targets.toml next to the fixtures says which contract to swap in at which address:
[[target]]
address = "0x7a603b734ea48cd02ef38671b6cd3e06573f7450"
contract_name = "SpokeInstance"
source_name = "src/spoke/instances/SpokeInstance.sol"
[target.libraries]
LiquidationLogic = "0x88df535473c5adf1f57789734a05e555f7deb8db"
[target.immutables]
ORACLE = "0x000000000000000000000000da1266a7b8620819dae3f8bd6b546da36e505bb8"
[target.discovery]
address = "0x973a023a77420ba610f06b3858ad991df6d85a08"
end_block = 25996062
limit = 500capture-contract writes address and [target.discovery] (the query that found the calls, reproducible via <address>/--end-block/--limit).
The rest is filled in by hand:
contract_name, plussource_nameif that name is declared in more than one file.[target.libraries]: the deployed address of every library the contract links against.[target.immutables]: the deployed value of each immutable, by variable name. Unlisted ones stay zero.
capture-contract --force rewrites targets.toml from scratch, dropping the hand-filled fields, and leaves fixtures
that fall out of the new selection in place.
ir-ethdebug is unoptimized ir plus the ETHDebug outputs, so it requires
--no-optimize (gas is skipped). It adds the ethdebug_size metric. Measure
the overhead against plain unoptimized ir in the same run:
solc-bench run --pipelines ir,ir-ethdebug --no-optimize --solc ./solc --benchmark-dir ./benchmark_data -o ethdebug.json
solc-bench compare ethdebug.json:ir ethdebug.json:ir-ethdebug