Benchmark every
runtime.
Write benchmarks once in a simple DSL. Run them across Go, TypeScript, and Rust. Get unified, statistically sound results.
use std::charting
suite keccakBench { description: "Keccak256 benchmark - Rust should win here" warmup: 100ms baseline: "go" mode: "auto" targetTime: 3000ms
after { charting.drawSpeedupChart( title: "Keccak256 Performance", xlabel: "Time (ns)" ) }
setup go { import "golang.org/x/crypto/sha3"
helpers { func keccak256Go(data []byte) []byte { h := sha3.NewLegacyKeccak256() h.Write(data) return h.Sum(nil) } } }
setup ts { import { import { keccak256 } from 'viem'; }
helpers { function keccak256Ts(data: Uint8Array): Uint8Array { return keccak256(data, 'bytes') } } }
setup rust { import { use tiny_keccak::{Hasher, Keccak}; }
helpers { fn keccak256_rust(data: &[u8]) -> [u8; 32] { let mut hasher = Keccak::v256(); let mut output = [0u8; 32]; hasher.update(data); hasher.finalize(&mut output); output } } }
fixture data { hex: "68656c6c6f20776f726c64" }
bench keccak256Bench { go: keccak256Go(data) ts: keccak256Ts(data) rust: keccak256_rust(&data) }}$ curl -L https://install.evm-tooling.tools | bashWhy Poly Bench?
A multi-language benchmarking framework for fair cross-language comparisons.
No unified cross-language benchmarking — separate harnesses, different APIs, different methodologies
Fair comparisons are hard — different iteration counts, warmup strategies, and data inputs
Results are scattered — each language's output looks different, side-by-side comparisons are tedious
One run.
Every language.
Compared.
Run poly-bench run and get a statistical comparison across all three languages. Includes mean, standard deviation, ops/sec, and speedup ratios.
Summary: keccak256Bench
─────────────────────────────────────────────
│ Lang │ Mean (ns/op) │ Std Dev │ Ops/s │
├──────┼──────────────┼─────────┼───────────┤
│ rust │ 993 │ ± 1.8% │ 1,006,752 │
│ go │ 1,216 │ ± 2.1% │ 822,714 │
│ ts │ 15,667 │ ± 3.1% │ 63,839 │
Comparison (baseline: go):
rust: 1.22x faster
ts: 12.88x slowerHow benchmarks flow
From .bench file to results — every benchmark follows the same five-stage pipeline.
Parse
Your .bench file → Lexer → AST → Semantic validation
Lower to IR
Resolve fixtures, merge config defaults, normalize imports
Generate
Emit native Go, TypeScript, and Rust benchmark code
Execute
Isolated subprocesses — no FFI, full native speed per language
Report
Console tables, markdown docs, JSON, SVG charts
Each language runs at full native speed
No interpretation, no FFI — isolated subprocesses with per-language memory tracking.
Go
- Runtime
- Plugin-based execution or subprocess
- Memory
- runtime.ReadMemStats
TypeScript
- Runtime
- Node.js subprocess
- Memory
- process.memoryUsage()
Rust
- Runtime
- Cargo build + subprocess
- Memory
- Custom allocator tracking
Everything you need for rigorous benchmarking
poly-bench provides a complete toolkit — from DSL parsing to chart generation — built in Rust for speed and reliability.
Custom DSL
Clean, declarative syntax with language-specific setup blocks
Auto-calibration
Automatically adjusts iteration counts to reach target execution time
Memory Profiling
Track allocations across Go, TypeScript, and Rust
Portable Fixtures
Share hex-encoded test data across all language implementations
Chart Generation
SVG speedup charts and tables from results
LSP Support
Full editor integration with diagnostics, completions, and formatting
Rust workspace, 8 crates
Each crate handles a specific responsibility. Use them individually or together.
poly-bench-dslLexer, parser, AST, formatter, validator
poly-bench-irIntermediate representation — normalized benchmark structures
poly-bench-runtimeLanguage-specific code generation and execution
poly-bench-executorOrchestrates runs, calibration, measurements
poly-bench-reporterConsole, markdown, JSON, SVG output
poly-bench-lsp-v2Language Server Protocol for editor support (v2)
poly-bench-stdlibStandard library — anvil, charting, constants
poly-bench-projectProject init, dependency management, manifests
No shortcuts on
measurement.
poly-bench includes proper statistical methodology so you can trust the numbers.
Warmup Removal
Discard initial iterations before timing
Multi-run
Run benchmarks N times for reliable stats
Outlier Detection
IQR-based outlier removal
Auto-calibration
Hit target execution time automatically
Ready to benchmark?
Install poly-bench and write your first .bench file in under a minute.
Get involved
poly-bench is open source and actively developed. Contributions welcome.


