/benchmarks

Benchmarks of different languages achieving the same simple task.

Primary LanguageJavaScriptMIT LicenseMIT

Benchmarks

The goal of each language is to execute the pseudo code of

answer = 0
for (a = 1; a <= 65535; a++) {
   for (b = 1; b <= 65535; b++) {
     if (a % b == 0) answer++
   }
}

and return the answer and time in seconds it took to calculate.

Results

Benchmark results of GitHub Actions runner. Smaller is better.

# Name Time Answer
1 Lua (LuaJIT) 8.028954s 736957
2 C# 14.804897s 736957
3 Rust 15.295s 736957
4 C (GCC) 17.105967s 736957
5 C++ (G++) 18.281353s 736957
6 Java 21.172s 736957
7 Node.js 24.391247141999994s 736957
8 Go 44.890678447s 736957
9 Python (PyPy) 61.0546090603s 736957

Dependencies

Each program needs to be added to PATH if the associated installer or package doesn't do so automatically.

*You should select x86_64 architecture, POSIX threads, and SEH exceptions for your MinGW installation.

Running

Simply run the bench script (bench.bat on Windows) and wait for all the results. You may notice some new files as languages like C, C++, C#, Java, and Rust need to be compiled and leave build artefacts. If there is an error, ensure that the program that errored is installed and on the PATH environment variable. If it is and it keeps erroring or crashing, then open an issue.