Re: Can someone explain this performance issue?
- From: schlenk@xxxxxxxxxxxxxxxx
- Date: Wed, 28 Nov 2007 09:30:10 -0800 (PST)
Twylite wrote:
Hi,
I have a proc to splice together n lists, creating a list that
contains [lindex $list1 0] [lindex $list2 0] ... [lindex $list-n 0]
[lindex $list1 1] ... etc.
I have a fairly decent microbenchmark that constructs around 1000
lists of 10-20 elements each (each element is a different md5 hash in
hex format), and then splices together pairs from this set of lists.
In total I time {} about 25000 splice operations to get the benchmark.
If I run the code below as-is, the second benchmark run gives around
48000 micros per iteration (for pairs of lists).
If I run the code with the "set iterscript" uncommented, I get around
36500 micros per iteration.
proc ::listx::splice2 {args} {
set varcounter 0
set iterscript "lappend list_S"
set eachspec [list]
foreach arg $args {
set v "v[incr varcounter]"
append iterscript " \$$v"
lappend eachspec $v $arg
}
# set iterscript "lappend list_S \$v1 \$v2"
set list_S [list]
foreach {*}$eachspec $iterscript
return $list_S
}
Needless to say I have checked that the iterscript I build and the one
I define are identical - in fact I can add an if { $iterscript_built
ne $iterscript } { error DIE } to that code and it will run happily.
Does anyone have any wisdom on this apparently bizarre situation?
My guess at the situation:
If you set iterscript in the proc, the bytecompiler can bytecompile it
while compiling
the proc, as it is a literal expression while it
does not if you construct it at runtime. Try the new diassamble
command
from the betas to see if I'm right,
Michael
.
- References:
- Can someone explain this performance issue?
- From: Twylite
- Can someone explain this performance issue?
- Prev by Date: Re: Can someone explain this performance issue?
- Next by Date: Re: Czym programowac' TCL
- Previous by thread: Re: Can someone explain this performance issue?
- Index(es):
Relevant Pages
|