Perl Go C Python JavaScript Awk Other
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Makefile
README.md
create-report.pl
fact-O1.c
fact-O2.c
fact-cgo.go
fact-jit.lua
fact-jsc.js
fact-mt.go
fact-perl6.pl
fact-pypy.py
fact-python3.py
fact.awk
fact.c
fact.coffee
fact.d
fact.dart
fact.erl
fact.gawk
fact.go
fact.hs
fact.java
fact.js
fact.kt
fact.lua
fact.ml
fact.nim
fact.pas
fact.php
fact.pl
fact.py
fact.rb
fact.rs
fact.swift

README.md

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

Hardware:

2.4 GHz Intel Core i5 (haswell)

Report:

versions:

  • C: Apple LLVM version 9.1.0 (clang-902.0.39.1)
  • CoffeeScript: 1.10.0
  • D: 2.079.0
  • Dart: 1.24.3
  • Erlang: 9.3
  • Go: 1.10.1
  • Haskell: 8.4.1
  • Java: 10+46-Debian-2
  • JavascriptCore: 11.1
  • Kotlin: 1.2.31
  • OCaml: 4.06.1
  • Pascal: 3.0.4
  • PyPy: 5.10.0
  • Rust: 1.25.0
  • Swift: 4.1
  • awk: 20070501
  • gawk: 4.2.1
  • lua: 5.3.4
  • luajit: 2.0.5
  • nim: 0.18.0
  • node.js: 9.10.1
  • perl: 5.18.2
  • perl6: 2018.01 built on MoarVM version 2018.01
  • php: 7.1.14
  • python: 2.7.10
  • python3: 3.6.5
  • ruby: 2.3.3

raw data:

C: 7.576 sec for 100000000 = 13199466 rps
C gcc -O1: 6.265 sec for 500000000 = 79806813 rps
C gcc -O2: 0.436 sec for 9000000000 = 20633479930 rps
CoffeeScript: 5.770 sec for 50000000 = 8665196 rps
D: 4.529 sec for 100000000 = 22078155 rps
Dart: 6.751 sec for 200000000 = 29626034 rps
Erlang: 5.677 sec for 7000000 = 1233030 rps
Go: 10.085 sec for 150000000 = 14873600 rps
Go-cgo: 3.782 sec for 50000000 = 13219572 rps
Go-mt: 3.461 sec for 150000000 = 43340976 rps
Haskell: 10.658 sec for 10000000 = 938243 rps
Java: 6.992 sec for 300000000 = 42907190 rps
JavascriptCore: 3.452 sec for 50000000 = 14483549 rps
Kotlin: 5.047 sec for 200000000 = 39624877 rps
OCaml: 7.376 sec for 150000000 = 20337449 rps
Pascal: 4.619 sec for 100000000 = 21650808 rps
PyPy: 5.834 sec for 10000000 = 1714205 rps
Rust: 3.191 sec for 20000000 = 6268512 rps
Swift: 7.382 sec for 200000000 = 27093186 rps
awk: 3.201 sec for 1000000 = 312420 rps
gawk: 4.223 sec for 1000000 = 236810 rps
lua: 3.330 sec for 3000000 = 900888 rps
luajit: 3.585 sec for 50000000 = 13947174 rps
nim: 4.038 sec for 10000000 = 2476447 rps
node.js: 6.106 sec for 50000000 = 8188929 rps
perl: 4.300 sec for 1000000 = 232557 rps
perl6: 7.974 sec for 300000 = 37624 rps
php: 5.266 sec for 7000000 = 1329193 rps
python: 4.850 sec for 2000000 = 412402 rps
python3: 7.395 sec for 2000000 = 270462 rps
ruby: 5.067 sec for 5000000 = 986851 rps

report all:

Chart for all

report fast:

Chart for fast

report other:

Chart for other

See also