Benchmarks

Windows 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 Go 0.000µs 0.000µs 0.000µs
2 C++ (Clang++) 2.864µs 2.500µs 3.200µs
3 C (Clang) 3.212µs 3.000µs 3.500µs
4 C (GCC) 3.584µs 3.300µs 4.000µs
5 C++ (G++) 3.604µs 3.300µs 4.000µs
6 Zig 4.304µs 3.600µs 15.400µs
7 Rust 4.376µs 3.300µs 24.600µs
8 GraalVM 4.400µs 2.900µs 35.800µs
9 Kotlin (Native) 19.796µs 18.600µs 23.600µs
10 PHP 72.480µs 59.100µs 104.800µs
11 Ruby 72.984µs 64.600µs 146.200µs
12 JavaScript (Node) 101.656µs 85.800µs 126.800µs
13 Python 149.064µs 133.500µs 173.100µs
14 JavaScript (Deno) 424.216µs 251.600µs 926.000µs
15 Kotlin (JVM) 957.096µs 707.300µs 2,031.000µs
16 Java 5,093.800µs 44.700µs 96,850.100µs
17 JavaScript (Bun) 141,947.432µs 46,896.100µs 312,654.400µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times