Blue Mountain
Resident Skeptical Hobbit
It may be fashionable to rag on Perl, but it does have excellent performance.
A while ago I was testing database scaling with GNU dbm and Berkeley dbm. I needed a large dataset and hit on the idea of using a number as the key (e.g. "123456789") and the number's words in English as the data (e.g. "one hundred twenty-three million, four hundred fifty-six thousand, seven hundred eighty-nine".) Such a dataset is by its very nature infinitely scalable. The algorithm I developed is pretty straightforward, and out of curiosity I ended up implementing it in several languages.
Here are the results from tests I ran on my laptop (Intel Pentium 3825U, 1.90GHz), in thousands of records generated per second:
Compiled C program (gcc -O3): 2,840
PHP 7: 403
mawk (a fast version of awk): 311
Perl: 287
Lua: 164
Ruby: 158
Java: 137
Python: 116
TCL: 68
Bash script: 6.4
The Perl program ran at more than twice the speed of the equivalent Python and Java programs.
On more powerful hardware such as a Ryzen CPU, Java and Python fared better when compared with Perl, running at 79% and 68% (respectively) the speed of the Perl program.
A while ago I was testing database scaling with GNU dbm and Berkeley dbm. I needed a large dataset and hit on the idea of using a number as the key (e.g. "123456789") and the number's words in English as the data (e.g. "one hundred twenty-three million, four hundred fifty-six thousand, seven hundred eighty-nine".) Such a dataset is by its very nature infinitely scalable. The algorithm I developed is pretty straightforward, and out of curiosity I ended up implementing it in several languages.
Here are the results from tests I ran on my laptop (Intel Pentium 3825U, 1.90GHz), in thousands of records generated per second:
Compiled C program (gcc -O3): 2,840
PHP 7: 403
mawk (a fast version of awk): 311
Perl: 287
Lua: 164
Ruby: 158
Java: 137
Python: 116
TCL: 68
Bash script: 6.4
The Perl program ran at more than twice the speed of the equivalent Python and Java programs.
On more powerful hardware such as a Ryzen CPU, Java and Python fared better when compared with Perl, running at 79% and 68% (respectively) the speed of the Perl program.