On Thu, Feb 20, 2020 at 12:22:53PM -0500, Greg Reagle wrote: > Hello. I am amazed at how fast Lua is to start up and shut down. Is my > benchmark defective in any way? Lua seems to start up and exit faster > than bash, python, rc, and ksh. Dash and mksh are faster. These > interpreters are all packages from Debian Stable 10 "Buster".
One problem I see with these benchmarks is that it's not an entirely fair comparison. For example, in Python, you're only printing some text, but you aren't importing any modules. Just about every non-trivial Python script will import at least one module which will in turn import others, and imports affect how long it takes before the core of your script runs: $ time for _ in {1..10}; do python -c 'print("Hello world")'; done ... [0.376s (98.63% CPU; User: 0.322, Sys: 0.049)] $ time for _ in {1..10}; do python -c 'import subprocess; import os; print("Hello world")'; done ... [0.502s (99.91% CPU; User: 0.402, Sys: 0.099)] I've used "os" and "subprocess" in my examples since those are among the most likely to be used if you're replacing a shell script with a Python script. Also, you didn't include AWK interpreters. On my system MAWK and the typically slower GAWK take around the same time to print "Hello world" as dash does on my machines: $ time for _ in {1..10}; do mawk 'BEGIN { print "Hello world" }'; done > /dev/null [0.112s (100.60% CPU; User: 0.107, Sys: 0.005)] $ time for _ in {1..10}; do gawk 'BEGIN { print "Hello world" }'; done > /dev/null [0.152s (99.90% CPU; User: 0.150, Sys: 0.002)] $ time for _ in {1..10}; do sh -c 'echo Hello world'; done > /dev/null [0.115s (100.53% CPU; User: 0.104, Sys: 0.012)] Eric