However, Python is *slow* starting up - a problem in CGI world. I still use it but wish it'll load faster.
Here are some number for comparison (all programs just print "Hello there" and exit):
hw real: 0.001 user: 0.001 sys: 0.000
hwcc real: 0.002 user: 0.001 sys: 0.001
hw.lua real: 0.004 user: 0.001 sys: 0.004
hw.pl real: 0.004 user: 0.002 sys: 0.001
hw.rb real: 0.006 user: 0.004 sys: 0.002
hw.php real: 0.017 user: 0.013 sys: 0.005
hw.py real: 0.019 user: 0.011 sys: 0.008
hw.lsp real: 0.023 user: 0.011 sys: 0.011
hw.scm real: 0.027 user: 0.019 sys: 0.008
hwcs.exe real: 0.036 user: 0.029 sys: 0.007
HT.class real: 0.084 user: 0.027 sys: 0.01
See the makefile below for which is each program.
As you can see Python is somewhere in the middle, not as bad as Java and C#, but about 5 times slower than Perl.
Makefile:
SCRIPTS = hw.py hw.rb hw.pl hw.lsp hw.scm hw.lua hw.php
GENERATED = hw hwcc hwcs.exe
JAVA = HT.class
PROGRAMS = $(SCRIPTS) $(GENERATED) $(JAVA)
all: $(PROGRAMS) times
@echo DONE
hw: hw.c
gcc -o $@ -O3 $<
hwcc: hw.cc
g++ -o $@ -O3 $<
HT.class: hw.java
javac $<
and timeit is:
#!/bin/bash
TIMEFORMAT='real: %3R user: %3U sys: %3S'
SPACES=" "
MAXLEN=10
for program in $*;
do
name=${program/.class/}
if [ ${program/.exe/} != $program ]; then
timestr=`(time mono $program > /dev/null) 2>&1`
elif [ $name == $program ]; then
timestr=`(time ./$program > /dev/null) 2>&1`
else
timestr=`(time java -client $name > /dev/null) 2>&1`
fi
padlen=$(($MAXLEN - ${#program}))
echo "${program}${SPACES:0:$padlen}${timestr}"
done
1 comment:
Good post.
Post a Comment