diff options
author | antirez <antirez> | 2005-03-06 22:42:33 +0000 |
---|---|---|
committer | antirez <antirez> | 2005-03-06 22:42:33 +0000 |
commit | d455df785b1c4f6037260e8d3575e346da9a360e (patch) | |
tree | 76cf3d91f547ea66ad71c47c115796765e54014a /bench.tcl | |
parent | 553e1e1b13041aee95a1732224cda7d7bdc56b60 (diff) | |
download | jimtcl-d455df785b1c4f6037260e8d3575e346da9a360e.zip jimtcl-d455df785b1c4f6037260e8d3575e346da9a360e.tar.gz jimtcl-d455df785b1c4f6037260e8d3575e346da9a360e.tar.bz2 |
A specializing version of [for] that appears able to match the
performaces of Tcl8.4 for the specialized forms. The implementation
is a bit complex so may contain bugs... to handle with care.
Also a [for] bug about [continue] was fixed and the regression test added.
Diffstat (limited to 'bench.tcl')
-rw-r--r-- | bench.tcl | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -9,7 +9,7 @@ proc bench {title script} { ### BUSY LOOP ################################################################## -proc x {} { +proc busyloop {} { set i 0 while {$i < 1850000} { incr i @@ -97,16 +97,16 @@ proc sieve {num} { while {$num > 0} { incr num -1 set count 0 - for {set i 2} {$i <= 8192} {incr i 1} { + for {set i 2} {$i <= 8192} {incr i} { set flags($i) 1 } - for {set i 2} {$i <= 8192} {incr i 1} { + for {set i 2} {$i <= 8192} {incr i} { if {$flags($i) == 1} { # remove all multiples of prime: i for {set k [expr {$i+$i}]} {$k <= 8192} {incr k $i} { set flags($k) 0 } - incr count 1 + incr count } } } @@ -254,9 +254,22 @@ proc expand {} { } } +### MINLOOPS ################################################################### + +proc miniloops {} { + for {set i 0} {$i < 100000} {incr i} { + set sum 0 + for {set j 0} {$j < 10} {incr j} { + # something of more or less real + incr sum $j + } + } +} + ### RUN ALL #################################################################### -bench {busy loop} {x} +bench {busy loop} {busyloop} +bench {mini loops} {miniloops} bench {fibonacci(25)} {fibonacci 25} bench {heapsort} {heapsort_main} bench {sieve} {sieve 10} |