This is an experiment to compare performance of some programming languages.
The program will read the following from standard input
- A long
text
of lengthtextLength
from the first line. - An integer
wordsCount
from the second line. wordsCount
words from the nextwordsCount
lines. Then print how manywords
are included in thetext
.
{
"textLength": 1000000,
"wordsCount": 10000,
"wordLength": 7
}
PHP7: 6.151s
Python3: 7.015s
Nodejs: 8.053s
C++: 11.121s
The program will read the following from standard input
- An integer
count
from the first line. count
integers betweenmin
andmax
from the nextcount
lines. Then print how many integer is a prime number.
{
"count": 1000000,
"min": 100000,
"max": 900000
}
C++: 1.699s
Nodejs: 2.961s
Python3: 7.254s
PHP7: 13.062s
- You should have a Unix system with
g++
,python3
,PHP
andnode
installed. - Run
./run-all
script.
- run
npm i
to install dependencies if you want to regenerate the random inputs. - edit the
config.json
file. - run
./generate-all
to generate new inputs. - run
./run-all
.