Benchmarks

Mac 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 1.883µs 1.791µs 2.832µs
2 Go 2.640µs 2.000µs 3.000µs
3 C (GCC) 2.851µs 2.710µs 3.030µs
4 C++ (G++) 2.920µs 2.000µs 4.000µs
5 Zig 3.200µs 3.000µs 4.000µs
6 C (Clang) 3.249µs 3.113µs 3.706µs
7 C++ (Clang++) 3.342µs 3.193µs 3.692µs
8 Rust 3.440µs 3.000µs 4.000µs
9 Kotlin (Native) 15.567µs 15.052µs 16.984µs
10 Ruby 57.560µs 54.000µs 69.000µs
11 Java 62.282µs 55.519µs 111.884µs
12 PHP 90.738µs 84.838µs 128.243µs
13 JavaScript (Node) 128.160µs 116.316µs 230.045µs
14 Python 144.800µs 127.000µs 292.000µs
15 JavaScript (Deno) 269.958µs 228.219µs 467.586µs
16 JavaScript (Bun) 24,620.650µs 249.384µs 578,378.670µs
17 Kotlin (JVM) 25,117.519µs 492.385µs 581,542.449µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times