Skip to content

Latest commit

History

93 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Performance Test

This repository contains an implementation of the is_prime function in multiple programming languages using the same algorithm. The goal is to compare the performance of different languages and runtimes.

Usage

To run code in various programming languages, use the run.sh script:

./run.sh [LANGUAGE]

If no argument is provided, the script will run code in all supported languages. Otherwise, provide a language name to run the corresponding code.

Supported Languages

  • assembly
  • c
  • cpp
  • rust
  • go
  • java
  • nodejs
  • csharp_mono
  • dart
  • python_codon
  • pascal
  • python
  • php
  • r
  • chap
  • lua

Examples

# Run code in all supported languages
./run.sh
# Run specific language
./run.sh cpp

To display usage instructions and a list of supported languages, use the --help or -h flag:

./run.sh --help

If you want to add your own test results, simply run the run.sh script with your CPU model name and redirect the output to a file in the result directory.

See the result directory for the output of running the tests on different CPUs.

My Laptop (Intel(R) Core(TM) i7-8550U)

Note: times are 5% more or less on different runs, so C and C++ can win sometimes.

RankingLanguageRuntime/CompilerTimen% Slower than Winner
#1AssemblyNASM3.10sWinner
#2CGCC3.12s0.64%
#3C++G++3.15s1.6%
#4JavaOpenJDK 173.62s16%
#5GoGo 1.20.33.81s22%
#6JuliaJulia 1.8.53.87s24%
#7RustNative 1.67.13.97s28%
#8C#Mono 6.85.32s71%
#9JsNodejs 205.80s87%
#10DartDart 2.19.07.11s129%
#11PythonCodon 0.16.010.89s251%
#12PascalFPC 3.2.213.68s341%
#13PHPPHP 8.2.526.32s749%
#14LuaLua 5.2.434.00s996%
#15PythonPython 3.11.382.31s2545%
#16RubyRuby 3.2.285.55s2641%
#17RRscript 4.0.4240.0s7641%
#18ChapChap 2.2.2602s19319%

The n% Slower than Winner column shows the percent difference between the time taken by each language and the fastest language (Assembly).

Formula: ((LanguageTime - WinnerTime) * 100) / WinnerTime

Contribute

You can contribute to this repository in one of the following ways:

  1. Optimize your favorite programming language without changing the algorithm and without using concurrency.
  2. Add a new language by using the same algorithm.
  3. Add a new runtime.

About

language speed test of running is_prime function

Topics

Resources

Stars

41 stars

Watchers

2 watching

Forks

Contributors

Languages