Perl:
$ cat test.pl
for ($i = 0 ; $i < 10000 ; $i++) {
unshift(@f, $i) ;
}
$ /bin/time perl test.pl
real 4.6
user 4.4
sys 0.0
VSCM:
$ cat test.scm
cat test.scm
(do ((i 0 (+ i 1))
(l '() (cons i l)))
((>= i 10000) l))
(quit)
$ /bin/time scheme test.scm
[SLIB available]
Loading "test.scm" ...
real 0.3
user 0.2
sys 0.0
$
Hey, if we're having fun with times:
On an Amiga 2500/30 (25Mhz 68030)
scheme (compiled, code is same as above):
Total time 1.28, of which 0.82 for garbage collection (64.1%)
(the times are very variable depending on GC, from 0.52 to 1.74 seconds.
The compiler has too many bugs, and I've effectively abandoned it)
mudlle (the scheme-like language I mentioned in a previous posting):
interpreted (code similar to the scheme version, though more
imperative): 4.0 seconds
compiled: 0.17 seconds
perl (4.0, pl 35):
same as above:
~65 seconds
as above, but replacing unshift with push (as suggested in various messages):
~8 seconds
(these are with the perl interpreter loading time subtracted)
The mudlle and scheme compilers are home-grown, and don't produce very good
code. So why hasn't anybody written a perl compiler yet ? ;-) Of course such
examples overestimate the gains compilers bring, as typical scripts use more
complex operations, which reduces the interpreter overhead (for example, on
more realistic examples, the mudlle compiler is only 4-5x faster, not 20x).
Still, if an aging Amiga can appear as fast as a modern DEC Alpha ...
David Gay
dgay@di.epfl.ch