gota・滴
Educational · Polyglot · Copy, don't depend

gota・滴

Cross-language throughput benchmarks, drop by drop.

The same operation, implemented in ten languages, measured the same way so the numbers actually compare. gota is a measurement protocol, a generic Python orchestrator, a runner template per language, and a self-contained HTML report. Copy it into your project; the protocol is the product, the code is small enough to re-type.

Ten languages · one JSON line per benchmark · no fabricated numbers

What a micro-benchmark is

A micro-benchmark isolates one small operation — a hash, a parse, a buffer copy — and runs it in a tight loop to measure how fast that single code path goes. It deliberately leaves out everything around it: no network, no disk, no real workload. That isolation is the whole point. It is what makes one operation's speed a clean, comparable number — here, the same operation across ten languages.

Approach What it measuresThe question it answers
Micro-benchmark One small operation, in isolation, loopedHow fast is this specific code path?
Macro / application A whole program under a realistic workloadHow fast is the system, end to end?
Profiling A real run, sampled to find hot spotsWhere is the time actually spent?

These answer different questions and are complements, not rivals: a micro-benchmark tells you which implementation of an operation is faster, a macro benchmark tells you whether the whole system is fast enough, and a profiler tells you where to look. gota lives in the first row.

gota lives in the first row, with one distinguishing property: the same operation is measured the same way in ten languages, so the results land in one table and compare across languages. What you copy is a ~20-line protocol rather than a package you install, which is what lets every runner stay native to its own language.

One more axis: throughput, not latency. Even within micro-benchmarking, gota measures throughput — the peak rate (MB/s) a loop sustains, the unimpeded speed, which is what you want for comparing implementations. Per-call latency and its distribution (mean, p99, outlier rejection) is a different measurement, and batching deliberately discards the per-call overhead it would need. gota answers a narrower question on purpose, and the protocol below is how it keeps that one answer honest and comparable.

Three layers, one contract

A runner is usable on its own; the orchestrator is just the conductor that runs them together; the report is a pure consumer of the JSON. You can stop at any layer. Between the first two sits the protocol every runner obeys.

Measure. One native runner per language. Copy gota.<lang> as-is; it runs the peak-of-batches timing loop and prints one JSON line, {"impl","bench","mbps","mbps_median","iters","protocol"}, per benchmark. The line names the protocol version it implements, so a copy that has fallen behind says so.
Orchestrate. Python, once, across every language. harness.py builds and runs each runner under identical parameters, collects their JSON, records machine, date, git, and toolchain-version provenance, and writes results.json + a Markdown table.
Report. Optional and generic over the format. report.py turns any results.json into a standalone, sortable HTML viewer with a file picker, metric-aware units (MB/s or ops/sec), and baseline comparison.

Ten languages, one protocol

Two files per language: gota.* is the harness you copy untouched; runner.* is your code, where one seam (run(impl, register) then bench(name, op)) plugs an operation into the timing loop. Each runner is independently runnable.

Python

The orchestrator's own language and the simplest runner. No build step; run it straight.

gota.py · runner.py

Rust

A single-file rustc build, no Cargo project. Closures plug the op straight in.

gota.rs · runner.rs

C

The harness is a header plus one translation unit; the op is a function pointer with a void* ctx.

gota.h · gota.c · runner.c

C++

Header-only: lambdas mean the op inlines into the timing loop, so no function-pointer indirection is needed. C++20, std::span buffer.

gota.hpp · runner.cpp

Go

A tiny module with the harness in its own package. go build, then run.

go.mod · gota/gota.go · runner.go

Java

The op is a functional interface; javac the two files and run Runner.

Gota.java · Runner.java

Swift

The op is a non-escaping closure over an inout [UInt8]. An @main struct, because swiftc reserves top-level code for main.swift.

Gota.swift · runner.swift

Zig

Targets Zig 0.16 (std.process.Init, std.Io.Clock). Built ReleaseFast.

gota.zig · runner.zig

TypeScript

Runs under Node's type stripping (--experimental-strip-types), no transpile step.

gota.ts · runner.ts

Haskell

Lazy and pure; the op threads a forced accumulator so the work can't be deferred or shared. GHC, stdlib only.

Gota.hs · runner.hs

Language Harness (copy as-is)Your op (one seam)Build & run
Python gota.pyrunner.pypython3 runner.py 65536 0.2 0.4
Rust gota.rsrunner.rsrustc -O runner.rs -o runner
C gota.h + gota.crunner.ccc -std=c17 -O2 runner.c gota.c -o runner
C++ gota.hpprunner.cppc++ -std=c++20 -O2 runner.cpp -o runner
Go gota/gota.gorunner.gogo build -o runner .
Java Gota.javaRunner.javajavac *.java && java Runner ...
Swift Gota.swiftrunner.swiftswiftc -O Gota.swift runner.swift -o runner
Zig gota.zigrunner.zigzig build-exe runner.zig -O ReleaseFast
TypeScript gota.tsrunner.tsnode --experimental-strip-types runner.ts ...
Haskell Gota.hsrunner.hsghc -O2 runner.hs -o runner

Python is tinted because it also hosts the orchestrator (harness.py + your run.py). Every other row is just a runner. Full build notes live in each templates/<lang>/README.md.

See a live report

The bundled example — FNV-1a across all ten languages — rendered by report.py into a standalone, sortable HTML viewer. One toggle in the report flips the same measurement between byte throughput (MB/s) and operations per second (one op = hashing the whole 64 KiB buffer): same numbers, same ranking, two units.

A self-contained page with a file picker, so you can drop any other results.json in and re-render. Generated from the committed example data, never hand-edited.

What you can do with the output

Nothing here is a closed pipeline. Each layer hands you a plain artifact, so you can stop at the one you need and route the rest into your own systems.

  • Just the numbers. run_all() returns a plain list of dicts, one per benchmark, with a per-runner timeout= so a hung runner is killed and skipped instead of stalling the whole run.
  • Compare against a baseline. Point the report at two or more results.json files for a per-cell delta table. A change inside the noise band (±2% by default) is not flagged, and comparing across different machines or parameters is called out as a warning rather than shown as a meaningful delta.
  • Gate CI on it. --fail-on-regression PCT exits non-zero when any cell drops more than PCT% below baseline; --markdown emits the same comparison as a table for a PR comment.
  • Send it anywhere. Outputs accept a path or any writable stream, so results can go to a file, to stdout, into memory, or straight to an HTTP body without touching disk.
  • Measure something other than bytes. A run records the kind of quantity it measured — byte throughput, operation throughput, latency — apart from the free-text unit label, so the report headlines the right number and a comparison refuses to pit different kinds against each other.

The protocol is the product

Every runner obeys the same recipe, so numbers compare even though each runner is native to its language. This is the same discipline a multi-port project uses to keep ports in sync; here the ports are the timing harnesses.

  • Same three CLI args — buffer bytes, warmup seconds, measure seconds — passed identically to every runner.
  • Peak of batches, with a stability check. Warm up the JIT, grow a batch until it runs ≥ 100ms, then report the fastest batch's MB/s next to the median of all batches — a close gap means a clean run, a wide one means the peak is noisy. The clock is read only at batch boundaries, never around one tiny op.
  • One JSON line per benchmark on stdout ({"impl","bench","mbps","mbps_median","iters","protocol"}) — the entire wire format between a runner and the orchestrator.
  • Kept equivalent across all ten templates. Change the loop in one and you change it in all of them, and in PROTOCOL.md, or they stop being comparable.

The contract carries its own version — currently protocol 1.2.0 — so a project that copied its runners can say which version they implement, and a copy that has fallen behind is a fact you can check rather than a guess.

The easiest way to measure nothing

The classic micro-benchmark trap: if nothing observes your operation's result, an optimizing compiler is free to delete the whole computation — and you measure nanoseconds of nothing, a confident wrong number. gota's templates guard against it in every language.

Compiled languages — dead-code elimination. In any optimizing compiler a result that is never read can be deleted outright, so the loop measures an empty loop at full speed. Every runner consumes its op's result through a one-byte sink, so the work has to survive.
Haskell — laziness. The sharpest case: in a lazy language an unforced computation is a thunk that never runs, and an invariant one is computed once and shared. The harness threads each result into the next call and forces it, so the work can be neither deferred nor shared. Same hazard, made a language requirement.
Why it matters here. Peak-of-batches is only honest if the batches did real work. The sink discipline is what keeps the number a measurement instead of a fiction — the same reason every runner.* carries a sink and Haskell's seam is shaped the way it is.

Honest by design

gota reports peak (unimpeded) throughput on a normal machine, which is right for comparing implementations and optimistic for real-world latency. It says so, and it never invents a number.

What the numbers mean. Peak-of-batches is the unimpeded rate, not a latency figure, and naive code shows language/runtime overhead, not how fast tuned or SIMD code can go. Every figure comes from a real run on a stated machine; RESULTS.md, results.json, and report.html are generated, never hand-edited, and CI numbers (whose hardware varies) are never committed.

And it is deliberately narrow: it reports sustained throughput, not nanosecond latency distributions, and not lab-grade absolute numbers — those would want pinned cores and a locked clock on a dedicated box. What it gives you is a comparable picture, drop by drop.

Copy and run

Copy harness.py and the templates/<lang> for each language you benchmark, swap your operation into each runner.*, write a small run.py, and run it. The bundled example ties all ten languages together end to end.

# run one language's runner standalone (prints one JSON line)
python3 templates/python/runner.py 65536 0.2 0.4

# run the full example: build + run every runner, then tabulate
python3 examples/run.py            # writes results.json + RESULTS.md
python3 report.py examples/results.json -o examples/report.html