Skip to content

Instantly share code, notes, and snippets.

@catwell
Last active April 10, 2021 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catwell/8189169 to your computer and use it in GitHub Desktop.
Save catwell/8189169 to your computer and use it in GitHub Desktop.

Interpreters you can use for CLI tools

$ time for i in {1..1000}; do perl -e ""; done # perl 5.18

real    0m1.319s
user    0m0.020s
sys     0m0.123s

$ time for i in {1..1000}; do lua -e ""; done # lua 5.2

real    0m0.870s
user    0m0.027s
sys     0m0.103s

$ time for i in {1..1000}; do luajit -e ""; done # luajit 2.0

real    0m0.705s
user    0m0.037s
sys     0m0.097s

$ time for i in {1..1000}; do bash -c ""; done # GNU Bash 4.2.45

real    0m2.771s
user    0m0.040s
sys     0m0.130s

Interpreters you shouldn't use for CLI tools if you value time

$ time for i in {1..1000}; do ruby -e ""; done # Ruby 2.0.0

real    0m24.624s
user    0m20.987s
sys     0m2.857s

$ time for i in {1..1000}; do python -c ""; done # Python 3.3.3

real    0m27.074s
user    0m22.947s
sys     0m1.727s

$ time for i in {1..1000}; do python2 -c ""; done # Python 2.7.6

real    0m11.001s
user    0m8.120s
sys     0m1.737s
@pfalcon
Copy link

pfalcon commented Apr 9, 2021

Cute test!

For my https://github.com/pfalcon/pycopy, whose purpose is exactly to unsuck Python for things like that:

$ time for i in {1..1000}; do pycopy -c ""; done

real	0m0.869s
user	0m0.662s
sys	0m0.261s

That's native Pycopy (again, purposely de-bloated comparing to CPython). Now with more CPython compatibility (imports stuff on startup):

$ time for i in {1..1000}; do pycopy-dev -c ""; done

real	0m2.164s
user	0m1.715s
sys	0m0.519s

@catwell
Copy link
Author

catwell commented Apr 10, 2021

@pfalcon That's nice. And yes this gist is from 2013, today things like micropython are viable as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment