Benchmarks

Twenty-five small programs, each written with the same algorithm and the same input in Tomato and in Go, Rust, C, C++, Java, C#, Swift, JavaScript, TypeScript, PHP and Python. Tick the languages to show below. Every version prints the same checksum, so none of the work can be skipped.

Loading the results…

These numbers were measured on a MacBook Pro with an Apple M3 Pro chip (arm64, macOS). The earlier numbers on this page (v0.51, ten benchmarks) came from an Apple M1 Mac, and the Linux x86-64 run of the same suite (a 64-core Threadripper) is in the repository under benchmarks/results/linux-x86_64/; the three sets are not comparable.

Summary

Time per benchmark

Median wall-clock seconds of the runs; bars are drawn on one scale per benchmark, so a shorter bar is faster. The number is the median time in seconds.

Table

Tomato's time ÷ each language's time

Tomato's median time divided by the other language's median time, per benchmark: below 1.0 Tomato is faster (highlighted), above 1.0 it is slower.

Build time, binary size and memory

Method

Caveats

What the numbers suggest for Tomato

The list is in docs/performance.md.

  1. Investigate numeric loops, including spectral_norm and nbody, with profiling and less-loaded runs before drawing conclusions.
  2. Investigate allocations in text code: split still makes one string per piece. Profiling and less-loaded runs can help identify the costs.
  3. Investigate allocation-heavy code: binary_trees (2.4× Rust, 3.9× Go) and kmers (2.8× Rust) are the largest gaps in this run.

Since v0.48 release mode links the program and the runtime with link-time optimisation and the cycle collector skips objects that cannot form cycles; since v0.49 the compiler no longer counts references for reads of a variable that keeps its value alive, sorted is a native introsort and big integers are freed; since v0.50 small objects come from a size-class allocator, string paths work in place, range(a, b, step) loops are counted loops and sorted takes key= and cmp= functions.

Source

Everything is in the benchmarks/ folder: one folder per benchmark with its programs, sizes.txt (the inputs), run.sh (the runner), measure.c (the timing helper) and results/ (the numbers on this page). Run benchmarks/run.sh yourself; it needs clang and skips every other language whose tools are missing. The other languages' programs exist only as a comparison; Tomato's own tooling uses no Python.