This is an experimental project that benchmarks the performance of several programming languages I've been actively using and studying lately. It also includes some rather interesting supersets, such as Cython (a "C-like" superset of Python).
Not only can you compare the performance of these languages, but you’re also encouraged to explore their syntax, composition, building and other aspects. Feel free to take a look at the source code! 😊
I've been trying to maintain a similar structure for each code while still taking advantage of their unique features, and also ensuring that they will deliver optimal performance in each specific scenario.
- CPU: AMD Ryzen 5 3600
- RAM: 2x16GB DDR4 ~2666MHz
Test by getting 20,000 primes in 10 runs, using the same code structure and algorithm ("trial division").
Language | Average time (s) | Notes |
---|---|---|
C | 0.825s | gcc -O2 |
C++ | 0.826s | g++ -O2 |
Cython | 0.827s | MSVC /O2 |
Python | 10.790s | CPython 3.11.3 |
You will need:
- C/C++ compiler (MSVC is recommended, or MinGW)
- Python 3.11
Don't forget to set your PATH environment variables accordingly (if needed).
These commands will clone the project repository, install the required Python dependencies and build/run the project.
git clone https://github.com/Artprozew/BenchSyntaxLab.git
cd BenchSyntaxLab
python -m pip install -r requirements.txt
make
The make
command defaults to build and run every language on the project. You can change this behavior by using make <language/target>
. For example: make python
would only run the Python code.
If you want to contribute to this project, please fork the repository and use a feature branch to make your changes on. When you are finished, you're welcome to open a pull request! 🤝
This project generally follows these style guidelines:
However, we are currently flexible with minor details (e.g., tabs are still 4 spaces wide instead of 8).
This project is licensed under MIT license; Refer to: LICENSE