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 D 1.184µs 1.100µs 1.600µs
2 GraalVM 1.845µs 1.629µs 2.830µs
3 Go 2.360µs 2.000µs 3.000µs
4 C (GCC) 2.754µs 2.558µs 3.361µs
5 Zig 3.120µs 3.000µs 4.000µs
6 Rust 3.320µs 3.000µs 4.000µs
7 C++ (Clang++) 3.454µs 2.919µs 11.903µs
8 C (Clang) 3.581µs 2.887µs 10.625µs
9 C++ (G++) 4.000µs 2.000µs 34.000µs
10 Kotlin (Native) 15.445µs 14.122µs 20.012µs
11 Java 63.037µs 53.008µs 105.268µs
12 PHP 91.067µs 78.797µs 191.000µs
13 JavaScript (Node) 127.226µs 110.515µs 290.673µs
14 Python 148.640µs 122.000µs 207.000µs
15 Ruby 191.880µs 53.000µs 3,395.000µs
16 JavaScript (Deno) 275.309µs 209.343µs 511.841µs
17 JavaScript (Bun) 23,444.554µs 236.123µs 514,454.536µs
18 Kotlin (JVM) 90,067.378µs 483.198µs 1,196,351.159µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times