Awesome Open Source
Awesome Open Source

Comparison of languages for speed by calculation of factorial in different languages

Hardware:

2.4 GHz Intel Core i5 (haswell)

Report:

versions:

  • C: Apple clang version 12.0.5 (clang-1205.0.22.9)
  • CoffeeScript: 1.10.0
  • D: 2.098.1
  • Dart: 2.15.1
  • Erlang: 12.2
  • Go: 1.18beta1
  • Haskell: 8.10.7
  • Java: 18-ea
  • JavascriptCore: 15.2
  • Kotlin: 1.4.10
  • OCaml: 4.12.0
  • Pascal: 3.2.2
  • PyPy: 7.3.6
  • Rust: 1.58.1
  • Swift: 5.4
  • awk: 20200816
  • gawk: 5.1.1
  • lua: 5.4.3
  • luajit: 2.0.5
  • nim: 1.6.2
  • node.js: 17.4.0
  • perl: 5.30.2
  • perl6: Welcome to Rakudo(tm) v2021.04.
  • php: 7.3.29
  • python: 2.7.16
  • python3: 3.8.2
  • ruby: 2.6.3

raw data:

C: 7.660 sec for 100000000 = 13054503 rps
C gcc -O1: 16.503 sec for 500000000 = 30297896 rps
C gcc -O2: 0.407 sec for 9000000000 = 22091641529 rps
CoffeeScript: 5.770 sec for 50000000 = 8665196 rps
D: 5.441 sec for 100000000 = 18379185 rps
Dart: 6.959 sec for 200000000 = 28739658 rps
Erlang: 3.685 sec for 7000000 = 1899451 rps
Go: 5.433 sec for 150000000 = 27608714 rps
Go-cgo: 4.059 sec for 50000000 = 12316995 rps
Go-mt: 2.114 sec for 150000000 = 70965380 rps
Haskell: 10.412 sec for 10000000 = 960450 rps
Java: 7.222 sec for 300000000 = 41540572 rps
JavascriptCore: 3.513 sec for 50000000 = 14233863 rps
Kotlin: 5.317 sec for 200000000 = 37617803 rps
OCaml: 7.656 sec for 150000000 = 19591915 rps
Pascal: 4.578 sec for 100000000 = 21844709 rps
PyPy: 5.961 sec for 10000000 = 1677571 rps
Rust: 2.909 sec for 20000000 = 6875770 rps
Swift: 7.223 sec for 200000000 = 27691041 rps
awk: 3.083 sec for 1000000 = 324411 rps
gawk: 4.223 sec for 1000000 = 236809 rps
lua: 1.958 sec for 3000000 = 1531888 rps
luajit: 3.585 sec for 50000000 = 13947174 rps
nim: 1.146 sec for 30000000 = 26167064 rps
node.js: 6.761 sec for 50000000 = 7395713 rps
perl: 3.556 sec for 1000000 = 281198 rps
perl6: 6.108 sec for 300000 = 49115 rps
php: 4.967 sec for 7000000 = 1409200 rps
python: 4.630 sec for 2000000 = 431987 rps
python3: 7.042 sec for 2000000 = 284013 rps
ruby: 3.592 sec for 5000000 = 1392016 rps

report all:

Chart for all

report fast:

Chart for fast

report other:

Chart for other

See also

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,059,387
Python (806,773
Java (388,359
Php (285,915
Ruby (221,829
Golang (158,174
Swift (65,199
Rust (57,501
Dart (52,579
Kotlin (46,431
Lua (33,856
Perl (30,539
Perl6 (30,539
Language (30,057
Haskell (20,366
Coffeescript (17,291
Benchmark (11,649
Erlang (9,064
Ocaml (6,703
Pascal (6,441
Clang (3,786
Awk (1,155
Javascriptcore (222