Odd performance question

Tim Rowledge tim at sumeru.stanford.edu
Fri Aug 3 02:42:39 UTC 2001


Timothy Reaves <treaves at silverfields.com> is widely believed to have written:

> 	Hello all.
> 
> 	Here's a question.  I take the code '1000 factorial' and do it.  It takes 35 milliseconds (using Time MillisecondsToRun).  When I take the same code and 'print it', it takes about 9500 milliseconds.  This is two orders of magnatude slower!
> 
> 	Why?  Are not the same objects created, with the printing version just printing an ASCII representation of the final end product Object?
Nope. To print it, you have to generate the string representation (take
a look at the codefor Integer> printString) then insert it into the
current text view's selection. This involves formatting it to wrap
properly etc, then actually displaying it and then updating the screen.
1000 factorial has 2568 characters, which takes some work to wrap
neatly.

tim

-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
You can swear at the keyboard and it won't be offended.,It was going to
treat you badly anyway





More information about the Squeak-dev mailing list