Benchmarks

Linux Benchmark: 3n + 1 Problem

The Collatz Conjecture, also known as 3n + 1, is a mathematical problem that has puzzled mathematicians for years. The conjecture states that if you take any positive integer n, and if n is even, divide it by 2, and if n is odd, multiply it by 3 and add 1, and repeat this process, you will eventually reach the number 1. This benchmark tests the performance of the 3n + 1 problem on the number “837,799” which takes 524 steps to reach 1.

number math algorithm

All-Time Rankings

Rank Language Average Time Best Time Worst Time
1 D 1.896µs 1.600µs 2.000µs
2 GraalVM 3.029µs 2.755µs 3.186µs
3 Go 3.251µs 2.896µs 3.837µs
4 C++ (G++) 3.400µs 3.076µs 3.737µs
5 C (GCC) 3.448µs 3.166µs 4.929µs
6 C++ (Clang++) 3.480µs 3.156µs 3.797µs
7 C (Clang) 3.660µs 3.356µs 3.998µs
8 Rust 4.162µs 3.767µs 4.569µs
9 Zig 4.405µs 3.948µs 4.789µs
10 Kotlin (Native) 11.979µs 11.402µs 12.793µs
11 JavaScript (Node) 104.128µs 90.420µs 148.940µs
12 Python 446.423µs 117.851µs 7,483.615µs
13 Ruby 2,401.631µs 46.156µs 51,960.969µs
14 JavaScript (Bun) 2,499.020µs 646.073µs 44,624.995µs
15 Java 3,511.594µs 45.015µs 44,847.536µs
16 JavaScript (Deno) 3,788.157µs 182.082µs 40,430.980µs
17 PHP 9,208.309µs 353.143µs 71,456.626µs
18 Kotlin (JVM) 23,323.764µs 582.914µs 89,975.430µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times