[BangPypers] cgi help

Noufal Ibrahim noufal at gmail.com
Wed Oct 6 13:27:15 CEST 2010


> Even for Perl, you will have to load the interpretor. So, it is a
> heavy weight operation if you involve any scripting language.

"Loading the interpreter" is a general term. Interpreters do various
things when they start which can significantly affect performance
(searching module include paths is one example).

I tried some rudimentary comparisons and found this.

noufal at sanitarium% time ~/perl.sh
~/perl.sh  1.11s user 0.84s system 98% cpu 1.976 total

noufal at sanitarium% time ~/python.sh
~/python.sh  8.53s user 3.08s system 98% cpu 11.792 total

The programs are shown below (let me know if the program semantics are
significantly different).

for i in $(seq 1 1000)
 perl -e ';'

for i in $(seq 1 1000)
 python -c 'pass' # Similar results with python -c ''

Also, changing the invocation to 

python -EsS -c 'pass' 

(i.e. no PYTHON* envars, no user site-packages directory and no "import site")
speeds it up a significantly.

noufal at sanitarium% time ~/python.sh
~/python.sh  3.55s user 1.85s system 99% cpu 5.428 total

Even with this, perl has a better startup time so if that is a concern,
and you *must* use CGI, that'd be the way to go. I'm quite sure that if
you're going that route, PHP will be even faster given it's integration
into apache.

The takeaway, I think, is use the right tool for the job. 



More information about the BangPypers mailing list