wx257osn2 / speed-comparison

A repo which compares the speed of different programming languages.

Home Page:https://niklas-heer.github.io/speed-comparison

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plot


Speed comparison of programming languages

This projects tries to compare the speed of different programming languages. In this project we don't really care about getting a precise calculation of pi. We only want to see how fast are the programming languages doing.
It uses an implementation of the Leibniz formula for π to do the comparison.
Here is a video which explains how it works: Calculating π by hand

You can find the results here: https://niklas-heer.github.io/speed-comparison/

Disclaimer

I'm no expert in all these languages, so take my results with a grain of salt.
Also the findings just show how good the languages can handle floating point operations, which is only one aspect of a programming language.

You are also welcome to contribute and help me fix my possible horrible code in some languages. 😄

Run it yourself

Everything is run by a Docker container and a bash script which envokes the programs.

To measure the execution time a python package is used.

Requirements

Run everything

Earthly allows to run everything with a single command:

earthly --config earthly-config.yml +all

This will run all tasks to collect all measurements and then run the analysis.

Collect data

To collect data for all languages run:

earthly --config earthly-config.yml +collect-data

To collect data for a single languages run:

earthly --config earthly-config.yml +<replace me with language name>

Analyse results

To generate the combined CSV out of all results use this command:

earthly --config earthly-config.yml +analysis

FAQ

Why do you also count reading a file and printing the output?

Because I think this is a more realistic scenario to compare speeds.

Are the compile times included in the measurements?

No they are not included, because when running the program in the real world this would also be done before.

TODO

  • Add C++
  • Add run pypy for Python
  • Produce graphic with results
  • Add Java
  • Add Swift
  • Add R
  • Add Elixir
  • Add Smalltalk
  • Add C#
  • Add Perl
  • Add Kotlin
  • Add Haskell
  • Add Lisp
  • Add Ada
  • Add COBOL

Thanks

The list of Contributors is automatically generated.

Contributors

Niklas
Niklas Heer
Francesco
Francesco Alemanno
Jerry
Jerry Ling
0xB00B/
0xB00B
Jonathan
Jonathan Carroll
Gaute
Gaute Hope
Gabriel
Gabriel Baraldi
mattn/
mattn
LazyKernel/
LazyKernel
Michael
Michael Abbott
Oscar
Oscar Smith
DirkieDurky/
DirkieDurky
RDPatrickTheDev/
RDPatrickTheDev
Sergey
Sergey Trofimov
Thomas
Thomas A Caswell
yinheli/
yinheli

Special thanks

sharkdp

For creating hyperfine which is used for the fundamental benchmarking.

Thomas

This projects takes inspiration from Thomas who did a similar comparison on his blog.

Languages used in this comparison

About

A repo which compares the speed of different programming languages.

https://niklas-heer.github.io/speed-comparison

License:MIT License


Languages

Language:Earthly 34.9%Language:Python 17.8%Language:Crystal 17.3%Language:Java 3.3%Language:C++ 2.9%Language:C 2.7%Language:Julia 2.5%Language:Rust 2.1%Language:Zig 2.0%Language:Fortran 1.9%Language:Elixir 1.7%Language:C# 1.5%Language:Clojure 1.4%Language:Go 1.4%Language:Lua 1.1%Language:PHP 1.0%Language:Swift 0.9%Language:Nim 0.9%Language:Perl 0.8%Language:JavaScript 0.8%Language:Ruby 0.5%Language:R 0.5%