[DISCUSSION] Is Squeak/Smalltalk able to do this?

Ned Konz ned at bike-nomad.com
Sat Feb 8 16:38:41 UTC 2003


On Friday 07 February 2003 07:59 pm, Doug Clapp wrote:
> Given that Squeak is "reflective," would it be possible
> to write code such that...
>
> -- the system was "watched" as it was exercised, and...
>
> -- attention was paid to which "cases"  (ifTrue/ifFalse)
> were triggered more often, and...
>
> -- the methods were then re-written to have the "most
> likely (often)"if" be placed first in the method, to speed
> up the execution of "most often done things"?

But if you look at the code that is executed for ifTrue:ifFalse, it's 
no faster to have it swapped around.

((1 to: 100) collect: [ :n | Time millisecondsToRun: [ 1000000 
timesRepeat: [ true ifTrue: [ ] ifFalse: [ ] ]]]) average asFloat 
250.48

((1 to: 100) collect: [ :n | Time millisecondsToRun: [ 1000000 
timesRepeat: [ false ifTrue: [ ] ifFalse: [ ] ]]]) average asFloat  
248.53

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list