Performance Comparison of Multiple Programming Languages on a 1 Billion Nested Loop
This article benchmarks dozens of programming languages by measuring the time to execute a one‑billion‑iteration nested loop on an M3 MacBook Pro, revealing that compiled languages like C, Rust and Java finish in about half a second while interpreted languages such as Python and Ruby take tens of seconds, and provides detailed version information, test commands, and additional results for many other languages.
The article presents a benchmark comparing the execution time of a 1 billion‑iteration nested loop across dozens of programming languages on an M3 MacBook Pro (16 GB RAM), using /usr/bin/time and hyperfine.
Results show compiled languages such as C, Rust and Java achieve the best performance (~0.5 s), while interpreted languages like Python and Ruby are much slower (Python 74.42 s, Ruby 68.96 s). The Fibonacci calculation also ranks C and Rust fastest (0.40 s and 0.41 s), with Python and R at the bottom.
Additional tests with more languages (Zig, Swift, Fortran, etc.) confirm that Zig, Rust and C remain the fastest, all around 0.5 s, and that Python 3.13 improves to 31.589 s. R remains the slowest at 72.643 s.
The testing environment details the compiler and interpreter versions for each language (e.g., Apple clang 16.0.0, Rust cargo 1.82.0, Python 3.13, etc.).
Instructions are provided to clone the benchmark repository, compile, run, and clean the tests:
<code>git clone https://github.com/bddicken/languages</code> <code>cd loops</code> <code>../compile.sh</code> <code>../run.sh</code> <code>../clean.sh</code>Sample output demonstrates the timing format for Zig, C, and Rust benchmarks.
The article also includes promotional material encouraging readers to follow the public account and scan a QR code to receive free Python learning resources.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.