Re: TclX loop slow in the default case



On Aug 27, 5:23 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
On Aug 26, 11:02 pm, Evil Son <ewilsonm...@xxxxxxxxx> wrote:

proc loop_explicit {lim} {
  loop i 0 1 $lim {}

Afraid you swapped two arguments here:

Aargh! Thanks! I had fun writing the test harness though, albeit all
screwed up.

   loop var start end ?increment? command
In general, an O(N) algorithm suddenly switching to O(1) in constant
space is suspect ;-)

Indeed. Here are the new results:

ed@aleph> tclsh8.5 run-tests.tcl 10
8.4.18 8.5.3 ratio proc
6 6 1.00 tcl_for
12 25 2.08 loop_default
12 25 2.08 loop_explicit
ed@aleph> tclsh8.5 run-tests.tcl 100
8.4.18 8.5.3 ratio proc
23 21 0.91 tcl_for
58 176 3.03 loop_default
59 171 2.90 loop_explicit
ed@aleph> tclsh8.5 run-tests.tcl 1000
8.4.18 8.5.3 ratio proc
199 174 0.87 tcl_for
522 1703 3.26 loop_default
531 1718 3.24 loop_explicit
ed@aleph> tclsh8.5 run-tests.tcl 10000
8.4.18 8.5.3 ratio proc
1966 1699 0.86 tcl_for
5466 16827 3.08 loop_default
5481 16433 3.00 loop_explicit

As always, I remain obliged.
.