Odd performance question
Ned Konz
ned at bike-nomad.com
Fri Aug 3 02:54:09 UTC 2001
On Thursday 02 August 2001 07:25 pm, you wrote:
> 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?
Well, kinda. There's four things going on here (with timings on my machine):
* computing the number (43 msec)
* changing this LargeInteger into a string (via printString) (7922 msec)
99.8% of that time is spent in LargePositiveInteger>>printOn:base:
* sending it to the Transcript (3 msec)
* displaying it (flushing) the transcript (100 msec)
As you see, the bulk of the work is computing the printString.
--
Ned Konz
currently: Stanwood, WA
email: ned at bike-nomad.com
homepage: http://bike-nomad.com
More information about the Squeak-dev
mailing list
|