Re: Tcl/Lisp/Python: A "User" point of view

Tim Bunce (Tim.Bunce@ig.co.uk)
Fri, 30 Sep 1994 11:01:02 +0000

In article <36cafa$5ue@btree.brooktree.com> mdimeo@brooktree.com (Matt DiMeo) writes:
>
>The users will care about O(1) vs. O(n) as soon as they notice how long it
>takes for tcl to build up a ten thousand element list.
>
>tst.tcl------------------
>set l ""
>for { set i 0 } { $i < 10000 } { incr i } {
> lvarpush l $i
>}
>-------------------------
>
>tst.perl-----------------
>for ($i = 0 ; $i < 10000 ; $i++) {
> unshift(@f, $i) ;
>}
>-------------------------

Why are you using unshift? I hardly know tcl at all so I don't know
what lvarpush does. Perl unshift adds items to the beginning of a
list, push add items to the end.

>{/home/mdimeo}% /bin/time /cad/bin/perl tst.perl
> 4.8 real 4.6 user 0.0 sys
>{/home/mdimeo}% /bin/time tcl tst.tcl
>^CCommand terminated abnormally.
> 334.2 real 326.7 user 0.2 sys
>
I'll just offer this perl 5 timing:

$ time perl -e 'for ($i = 0 ; $i < 10000 ; $i++){ push(@f,$i)}'

real 0.5
user 0.3
sys 0.1

Most of that time is process startup.

>-Matt

Regards,
Tim Bunce.