How Fast is Fast Enough?

Posted on June 5, 2007 
Filed Under Programming

I mentioned that I don’t believe that Java has any true scripting languages because none of its languages are useful for System Administration. One of specific flaws that all Java scripting languages share is general sluggishness. This begs the question: How fast is fast enough?

tortoise-hare

To answer the question “How fast is fast enough” the question must be put into some context. In this discussion the context is system administration. Complex language tests like mandelbrot are not suitable when speaking in terms of system administration because by their very nature shell scripts are supposed to start-up, perform a simple task, and shutdown. A more appropriate test is measuring how quickly the language can perform an extremely simple task like adding 1+2. For this type of test my threshold for “fast enough” is visually noticing a lag from the time I hit enter on the keyboard to the time the script returns. For me, this equates to about 60ms. By this measure none of the Java scripting languages are fast enough.

Taking the question from the subjective to the objective it is important to understand just how far Java’s scripting languages are from its contemporaries. So, I benchmarked start-up time for the following languages on my Thinkpad T60p with an Intel T2600 processor: BASH, python, perl, jython, jruby, and groovy. The results are listed below.

Language Start-up Time (ms)
BASH 8
python 27
perl 7
ruby 10
jython 900
jruby 1900
groovy 1200


The number speak for themselves, Java’s scripting languages are at least an order of magnitude slower than its non Java counterpart.

Comments

2 Responses to “How Fast is Fast Enough?”

  1. Patrick Mueller on June 5th, 2007 4:30 pm

    Startup time certainly factors in here; if I run a script, I usually want it to start Real Soon Now.

    And to take an example of the assumption of fast startup times, consider the TextMate editor on the mac, which primarily uses shell scripts to implement macro functionality. You decide which language to implement your function in; whatever you happen to have on your system. If you had to wait a second to start an editor macro, you couldn’t get away with this sort of scheme.

    A couple of notes on your benches.

    It would be nice if a fully configured bench wad were provided, with the jars and everything for jython et al.

    Ruby itself isn’t in your list, but there’s a ruby script in your wad.

    the jruby and jpython scripts are the same (you’re measuring jpython instead of jruby)

    you should probably launch each script with /usr/bin/env or none of them

    You are claiming “startup time”, however, it looks like you’re measuring elapsed time; which means you’re also measuring shutdown time. Might be better to actually do that thang where you have the script print the current time in milli’s, and the launch also calculate the time it launched in milli’s, and the calculate the diff, to get the ‘time just past startup time, and after a call to get the system time’. I may have some python code to do this …

  2. Tom on June 5th, 2007 5:04 pm

    Good catch on not including ruby in the table and the jruby script. Will add that now. Regarding the env stuff, this is recommended way to run the Java scripts, so just following the docs ;). See http://groovy.codehaus.org/Running as an example

Leave a Reply