Artifact
84218ff898426b933ec43a8afa0304358526ea2b:
Attachment "test.tcl" to
ticket [2825543fff]
added by
sbabbaro
2009-07-23 03:39:26.
# -- this script print the needed time foreach operation
# to see the 'effect': switch between the expressions commenting/uncommenting
# in section 3; pay attention to the execution time of section 1
#
proc test {s} {
# ---
set t 0
binary scan $s c* r
foreach {n} $r {
# ... section 1
set m [time {set k [expr (int($t) >> 24)]}]
puts "1-[format %40s $m]"
# ... section 2
set m [time {set idx [expr {($k ^ ($n & 0xFF)) & 0xFF}]}]
puts "2-[format %40s $m]"
# ... section 3
# ... without 'time loss'
# set m [time {set t [expr int(($t << 8) ^ 0xA2F33668)]}]
# ... with 'time loss'
set m [time {set t [expr (($t << 8) ^ 0xA2F33668)]}]
puts "3-[format %40s $m]"
}
return [expr {~$t & 0xFFFFFFFF}]
}
set p [string repeat "x" 2000]
test $p