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 GraalVM 3.009µs 2.705µs 3.246µs
2 Go 3.258µs 2.955µs 3.557µs
3 C (GCC) 3.386µs 3.036µs 3.697µs
4 C++ (G++) 3.428µs 3.246µs 3.657µs
5 C (Clang) 3.677µs 3.467µs 4.048µs
6 Zig 3.682µs 3.307µs 4.067µs
7 C++ (Clang++) 3.714µs 3.266µs 6.633µs
8 Rust 3.771µs 3.406µs 4.268µs
9 Kotlin (Native) 11.792µs 11.262µs 13.044µs
10 JavaScript (Bun) 1,724.264µs 632.958µs 26,250.427µs
11 Python 3,497.826µs 128.854µs 45,363.344µs
12 Ruby 3,681.406µs 44.215µs 69,748.266µs
13 JavaScript (Node) 5,092.145µs 91.634µs 80,527.289µs
14 Java 8,819.238µs 45.446µs 65,135.137µs
15 JavaScript (Deno) 10,098.854µs 155.856µs 64,180.081µs
16 PHP 11,376.231µs 383.946µs 63,689.447µs
17 Kotlin (JVM) 15,412.315µs 543.109µs 85,864.899µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times