Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Ramon Ribó <ramsan@xxxxxxxxxxxxx>
- Date: Wed, 9 Nov 2011 23:48:48 -0800 (PST)
snit is a very nice OO system but it is VERY slow when creating the
initial objects. It can slow down
the creation of the initial GUI of a complex app for even a few
seconds.
It would benefit greatly, in my opinion, on being based in some way
on tclOO
On 2 nov, 15:46, Will Duquette <w...@xxxxxxxxxxxxxx> wrote:
On Nov 2, 6:44 am, Jeremy Cowgar <jer...@xxxxxxxxxx> wrote:
On 11/1/2011 6:00 PM, Will Duquette wrote:
I've not benchmarked it myself; but Snit method dispatch uses the
[namespace ensemble] mechanism, and so is just as fast as that is.
Presuming that [namespace ensemble] and TclOO have comparable method
dispatch speeds, the only place for a speedup is variable resolution.
Snit methods automatically call [namespace upvar] to pull in all of
the type and instance variables; TclOO methods can make their
variables available without that, and so are probably a bit faster.
The place where Snit is really slow is creating objects--but that is
mostly the option processing, I think, which TclOO doesn't help with.
(If anyone can prove me wrong about where the slowdown is, please do!
And if you have ideas for how to fix it, even better!)
I am no benchmarking guru but after this thread, I decided to give it a
try. I know there are a million places you can go wrong. With this
benchmark, I tried to hit at least 99% of those million places :-), but
here are the results anyway:
TclOO
=============================================================
Create : 5119 microseconds per iteration
Calls : 400469 microseconds per iteration
Destroy: 3427 microseconds per iteration
Overall: 409071 microseconds per iteration
Snit
=============================================================
Create : 54186 microseconds per iteration
Calls : 464022 microseconds per iteration
Destroy: 49968 microseconds per iteration
Overall: 568343 microseconds per iteration
Benchmark code:
====
package require snit
set callCount 100000
set objectCount 1000
oo::class create TclOoBear {
constructor {name} {
variable MyName $name
}
method growl {} {
variable MyName
set msg "$MyName growl"
}
method changeName {name} {
variable MyName $name
}
method getName {} {
variable MyName
return $MyName
}
}
snit::type SnitBear {
variable MyName
constructor {name} {
set MyName $name
}
method growl {} {
set msg "$MyName growl"
}
method changeName {name} {
set MyName $name
}
method getName {} {
return $MyName
}
}
set overallT [time {
set createT [time {
for {set x 0} { $x < $objectCount } { incr x } {
TclOoBear create b$x John
}
}]
set destroyT [time {
for {set x 0} { $x < $objectCount } { incr x } {
b$x destroy
}
}]
TclOoBear create b John
set callsT [time {
for {set x 0} { $x < $callCount } { incr x } {
b growl
b changeName Jed$x
set name [b getName]
}
}]
b destroy
}]
puts "TclOO"
puts "============================================================="
puts "Create : $createT"
puts "Calls : $callsT"
puts "Destroy: $destroyT"
puts "Overall: $overallT"
puts ""
set overallT [time {
set createT [time {
for {set x 0} { $x < $objectCount } { incr x } {
SnitBear b$x John
}
}]
set destroyT [time {
for {set x 0} { $x < $objectCount } { incr x } {
b$x destroy
}
}]
SnitBear b John
set callsT [time {
for {set x 0} { $x < $callCount } { incr x } {
b growl
b changeName Jed$x
set name [b getName]
}
}]
b destroy
}]
puts "Snit"
puts "============================================================="
puts "Create : $createT"
puts "Calls : $callsT"
puts "Destroy: $destroyT"
puts "Overall: $overallT"
puts ""
====
Jeremy
Which bears out my claim: method calls are a little slower in Snit
than in TclOO, and when it comes to creation and destruction, Snit's
really slow. :-)
.
- Follow-Ups:
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Eric Boudaillier
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- References:
- Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Jeremy Cowgar
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Will Duquette
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Jeremy Cowgar
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Will Duquette
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Jeremy Cowgar
- Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- From: Will Duquette
- Any plans to make a 8.6 snit? i.e. based on TclOO?
- Prev by Date: Re: Unable to create Makefile using configure (building extension)
- Next by Date: Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- Previous by thread: Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- Next by thread: Re: Any plans to make a 8.6 snit? i.e. based on TclOO?
- Index(es):
Relevant Pages
|