[tcltk-perl] Re: [Activetcl] why simple Tcl script have very different execution time...
Brought to you by:
hobbs
From: Jeff H. <je...@Ac...> - 2004-10-19 04:24:22
|
Konovalov, Vadim wrote: > why simple Tcl script have very different execution time when invoked from file > and from tclsh? > > Give following simple script: > > for {set i 0} {$i < 1000000} {incr i} {} > > If invoked from file: tclsh a.tcl > finishes execution in about 6 seconds on my PC. > When I input same string from within "tclsh" shell it finishes in 3 seconds. In general, Tcl does not compile toplevel code, since it is expected this code runs once. Not great for large loops. If you have a large loop, put it in a proc if you want it to run fast: proc test {} { for {set i 0} {$i < 1000000} {incr i} {} } test -- Jeff Hobbs, The Tcl Guy http://www.ActiveState.com/, a division of Sophos |