https://github.com/msoap/factorial-multi-language
Calc factorial in any languages
https://github.com/msoap/factorial-multi-language
awk benchmark coffeescript dart erlang golang haskell java javascript kotlin languages lua ocaml pascal perl php python ruby rust swift
Last synced: 10 months ago
JSON representation
Calc factorial in any languages
- Host: GitHub
- URL: https://github.com/msoap/factorial-multi-language
- Owner: msoap
- Created: 2012-03-18T11:13:46.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2025-02-16T22:05:41.000Z (12 months ago)
- Last Synced: 2025-03-27T04:33:22.924Z (10 months ago)
- Topics: awk, benchmark, coffeescript, dart, erlang, golang, haskell, java, javascript, kotlin, languages, lua, ocaml, pascal, perl, php, python, ruby, rust, swift
- Language: Perl
- Homepage:
- Size: 314 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Comparison of languages for speed by calculation of factorial in different languages
====================================================================================
Hardware:
---------
Apple M1 Pro / 3.2 GHz / 8 Cores
Report:
-------
### statistic with versions:
| Language | Version | Time, sec | Iterations | RPS |
|------------|----------------|-----------|------------|-----------|
| Go-mt | 1.24.0 | 2.72 | 1000000000 | 368312242 |
| C gcc -O1 | 16.0.0 | 3.29 | 500000000 | 152010059 |
| Java | 22.0.1 | 3.08 | 300000000 | 97328163 |
| Swift | 6.0.3 | 3.31 | 200000000 | 60458121 |
| Go | 1.24.0 | 2.48 | 150000000 | 60363878 |
| OCaml | 5.2.1 | 3.16 | 150000000 | 47487954 |
| C | 16.0.0 | 2.29 | 100000000 | 43649629 |
| Pascal | 3.2.2 | 2.93 | 100000000 | 34123098 |
| luajit | 2.1.1736781742 | 1.50 | 50000000 | 33335445 |
| Dart | 3.7.0 | 6.13 | 200000000 | 32639633 |
| Rust | 1.84.1 | 0.63 | 20000000 | 31685658 |
| Go-cgo | 1.24.0 | 1.71 | 50000000 | 29217052 |
| nim | 2.2.2 | 1.21 | 30000000 | 24852630 |
| JSCore | 18.3 | 3.18 | 50000000 | 15718209 |
| Kotlin | 1.4.10 | 17.59 | 200000000 | 11370540 |
| node.js | 23.7.0 | 5.52 | 50000000 | 9057589 |
| PyPy | 7.3.18 | 2.29 | 10000000 | 4368677 |
| Erlang | 15.2.2 | 1.72 | 7000000 | 4065669 |
| lua | 5.4.7 | 1.21 | 3000000 | 2473240 |
| php | 8.4.4 | 2.90 | 7000000 | 2411103 |
| Haskell | 9.12.1 | 6.03 | 10000000 | 1658778 |
| python3 | 3.13.2 | 1.56 | 2000000 | 1283701 |
| ruby | 2.6.10 | 3.95 | 5000000 | 1264967 |
| gawk | 5.3.1 | 1.29 | 1000000 | 774202 |
| perl | 5.34.1 | 1.67 | 1000000 | 599218 |
| awk | 20200816 | 2.39 | 1000000 | 417936 |
| perl6 | ta | 1.07 | 300000 | 280319 |
## Chart
### report for all:
Go-mt - 368312242 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
C gcc -O1 - 152010059 rps: ■■■■■■■■■■■■■■■■■■■■■■■■
Java - 97328163 rps: ■■■■■■■■■■■■■■■
Swift - 60458121 rps: ■■■■■■■■■
Go - 60363878 rps: ■■■■■■■■■
OCaml - 47487954 rps: ■■■■■■■
C - 43649629 rps: ■■■■■■■
Pascal - 34123098 rps: ■■■■■
luajit - 33335445 rps: ■■■■■
Dart - 32639633 rps: ■■■■■
Rust - 31685658 rps: ■■■■■
Go-cgo - 29217052 rps: ■■■■
nim - 24852630 rps: ■■■■
JSCore - 15718209 rps: ■■
Kotlin - 11370540 rps: ■
node.js - 9057589 rps: ■
PyPy - 4368677 rps:
Erlang - 4065669 rps:
lua - 2473240 rps:
php - 2411103 rps:
Haskell - 1658778 rps:
python3 - 1283701 rps:
ruby - 1264967 rps:
gawk - 774202 rps:
perl - 599218 rps:
awk - 417936 rps:
perl6 - 280319 rps:
### report for fast languages:
Go-mt - 368312242 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
C gcc -O1 - 152010059 rps: ■■■■■■■■■■■■■■■■■■■■■■■■
Java - 97328163 rps: ■■■■■■■■■■■■■■■
Swift - 60458121 rps: ■■■■■■■■■
Go - 60363878 rps: ■■■■■■■■■
OCaml - 47487954 rps: ■■■■■■■
C - 43649629 rps: ■■■■■■■
Pascal - 34123098 rps: ■■■■■
luajit - 33335445 rps: ■■■■■
Dart - 32639633 rps: ■■■■■
Rust - 31685658 rps: ■■■■■
Go-cgo - 29217052 rps: ■■■■
nim - 24852630 rps: ■■■■
JSCore - 15718209 rps: ■■
Kotlin - 11370540 rps: ■
node.js - 9057589 rps: ■
### report for slow languages:
PyPy - 4368677 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
Erlang - 4065669 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
lua - 2473240 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
php - 2411103 rps: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
Haskell - 1658778 rps: ■■■■■■■■■■■■■■■■■■■■■■
python3 - 1283701 rps: ■■■■■■■■■■■■■■■■■
ruby - 1264967 rps: ■■■■■■■■■■■■■■■■■
gawk - 774202 rps: ■■■■■■■■■■
perl - 599218 rps: ■■■■■■■■
awk - 417936 rps: ■■■■■
perl6 - 280319 rps: ■■■
See also
--------
* [Wikipedia](http://en.wikipedia.org/wiki/Factorial)
* [Rosettacode](http://rosettacode.org/wiki/Factorial)
* [Stackoverflow](http://stackoverflow.com/questions/23930/factorial-algorithms-in-different-languages)
* [The Computer Language Benchmarks Game](https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html)
* [Recursive Fibonacci Benchmark using top languages on Github](https://github.com/drujensen/fib)