Re: TclX loop slow in the default case



ed@aleph> tclsh8.5 run-tests.tcl 10000
8.4.18  8.5.3   ratio   proc
1960    1699      0.87  tcl_for
5481    16175     2.95  loop_default
9020    11777     1.31  loop_eval  <-- naive implemenation

And here is the result if I use a fixed increment (what is the default
case). i.e.

proc my_loop {index init bound inc script} {
upvar 1 $index i
for {set i $init} {$i < $bound} {incr i} { ;# we dont use incr i
$inc
uplevel 1 $script
}
}

ed@aleph> tclsh8.5 run-tests.tcl 10000
8.4.18 8.5.3 ratio proc
1965 1705 0.87 tcl_for
5400 17278 3.20 loop_default
8620 10818 1.25 loop_eval_fixed_increment

The last line removes the cost of a single variable access
i.e. 8620 vs 9020
.



Relevant Pages

  • Re: upvar doubt
    ... procedure P1 which is called from a script which has a var "a". ... but should be able to access var "a" in it. ... Can you tell us why you don't want to pass anything to P1, and why P1 must access a variable in the caller via upvar? ... Eventually someone may try to use P1 in another manner, or refacter the parent proc to not include this variable, and they will be surprised at their lack of success. ...
    (comp.lang.tcl)
  • Re: Gracefully stopping an infinite loop after a particular keyboard input
    ... But by "ctrl+c" the script stops at that very ... fconfigure stdin -buffering no -blocking no ... proc do_stuff { ... set service ...
    (comp.lang.tcl)
  • RE: stored procedure names
    ... I have a Perl script that can address both your questions. ... my $server = 'YourServerName'; ... sub getMSProcNames { ... push @procs, $proc; ...
    (microsoft.public.sqlserver.programming)
  • Re: How to use proc with Expect
    ... I need help to understand how proc works in expect. ... leads to trouble and alot of grief as your script will envariably ... You should always cover the timeout and eof cases when doing expect ...
    (comp.lang.tcl)
  • RE: [Info-ingres] Check if Proc exists
    ... I dont think you can alter a procedure like MSSQL. ... copydb -with_proc will give you a script with procedures and perms only. ... Which checks for the existence of the Proc, if it does not exist it ...
    (comp.databases.ingres)