Home Blog CV Projects Patterns Notes Book Colophon Search

How Fast are Node and Python to start and exit?

1 Dec, 2016

Well, simple hacky test:

cat << EOF > timer.sh 
time \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()' && \
python3 -c 'exit()'

time \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()" && \
node -e "process.exit()"
EOF

sh timer.sh

Gives:

real	0m0.034s
user	0m0.023s
sys	0m0.004s

real	0m0.060s
user	0m0.049s
sys	0m0.007s

This means for twenty invocations and exits, Python is about twice as fast as node. Not significant enough to make me choose one rather than the other in shell scripts.

Copyright James Gardner 1996-2020 All Rights Reserved. Admin.