Programming benchmarks
This repository contains various benchmarks on different programming languages for different algorithms. The primary goal of this repository is to provide a comparison between different programming languages and their speeds.
You can navigate to the website here, or by clicking the linked website on the repository.
This repository also features the ability to benchmark all the algorithms locally.
Benchmarks offers two gradle tasks: compileBenchmark and runBenchmark, to run specific benchmarks.
./gradlew compileBenchmark runBenchmark -Planguage={language} -Pfile={file}For example, to run count-1M for c using Clang, you would run:
./gradlew compileBenchmark runBenchmark -Planguage=c-llvm -Pfile=count-1M/main.cNote
compileBenchmark is only required to be passed for compiled languages. Gradle will automatically skip interpreted languages passed,
like python and ruby.
./gradlew runBenchmark -Planguage=ruby -Pfile=count-1M/main.rbAny language with a compile command in the config.yml file needs to be compiled first before it can run with the run commmand.
To compile the code, you can run the compileBenchmark task in the root directory for the repository:
./gradlew compileBenchmark -Planguage={language} -Pfile={file}The task accepts two parameters:
language - ID of the language in the config.yml file
file - File to compile relative to the benchmarks directory
For example, to compile the HTTP GET benchmark for Kotlin/Native, you would run:
./gradlew compileBenchmark -Planguage=kotlin-native -Pfile=http-get/main.ktAfter compiling the benchmarks, you can run them using the runBenchmark task:
./gradlew runBenchmark -Planguage={language} -Pfile={file}Note
compileBenchmark is only required to be passed for compiled languages. You can use runBenchmark for interpreted languages:
./gradlew runBenchmark -Planguage=ruby -Pfile=count-1M/main.rbThe task accepts the same parameters as the compileBenchmark task.
For example, to run the HTTP GET benchmark for Kotlin/Native, you do:
./gradlew compileBenchmark runBenchmark -Planguage=kotlin-native -Pfile=http-get/main.kthttp-get measures in ms according to its benchmark config.yml, so the output will be in milliseconds.
All command line tools present in config.yml must be installed. You can determine if you meet them by running
the version, compile, and/or run commands in the terminal.
Here are some notable examples:
pythonfor Pythonjavafor Java- Using the JDK for Gradle requires Java 21 or higher.
- Using the
javacommand on the command line requires Java 8 or higher.
kotlincfor Kotlin JVM- This requires the
KOTLIN_HOMEenvironment variable to be set to the Kotlin compiler directory (not the bin directory).
- This requires the
kotlinc-nativefor Kotlin Native- This requires the
KOTLIN_NATIVE_HOMEenvironment variable to be set to the Kotlin Native compiler directory (not the bin directory).
- This requires the
rubyfor Rubynative-imagefor GraalVM- This requires the
GRAALVM_HOMEenvironment variable to be set to the GraalVM directory (not the bin directory).
- This requires the
gcc/g++andclang/clang++for C/C++rustcfor Rustgofor Gonode,denoandbunfor JavaScriptrubyfor Rubyphpfor PHPzigfor Zig
You can test if you have the necessary tools and setup by running the validate gradle task:
./gradlew validateThe repository comes with two IntelliJ IDEA run configuration that allows you to run benchmarks directly from the IDE:
benchmark- Runs and graphs the benchmarksall- Runs and graphs the benchmarks, then prepares and serves the website
To both run and graph the benchmarks, you can use the following command:
./gradlew benchmarkBenchmarks will be generated in JSON format in the benchmarks/output directory.
Interactive HTML graphs are available in the benchmarks/output/graphs directory.
After that, you can prepare and serve the website by running:
./gradlew previewYou can navigate to the website by visiting http://localhost:4000.
The preview output only creates benchmarks for your hosting operating system.
For example, if you're benchmarking your computer on a Windows machine, clicking on macOS or Linux will report a 404 error.
Otherwise, you can navigate through the website as if it were live.
Contributors are always welcome.
If you would like to contribute to this repository, please read the CONTRIBUTING.md file.
This repository is licensed under the Apache License 2.0.
As per outlined in the license, you are free to use, modify, distribute, and sublicense this repository for personal or commercial use. However, you must include the original copyright and license in any copy of the software.
By using the software, locally or on its website, you agree to the terms and conditions outlined in the license.
