Odd performance question

danielv at netvision.net.il danielv at netvision.net.il
Sat Aug 4 13:20:52 UTC 2001


Calculating 1000 factorial requires 1000 operations of type
multiply-often-large-numbers.
Calculating the printString for the previous expressions result requires
~2568 (Tim's number) operations of type
get-enough-bits-from-the-binary-representation-and-convert-them-to-a-tar
get-base-digit-also-using-the-remainder-from-previous-bunch-of-bits.

Not so surprising the second takes much longer...

BTW, if you want more details than millisecondsToRun: gives you, you can
use-
TimeProfileBrowser onBlock: [Transcript show: (1000 factorial)]

It's a great way to learn about the system and it's bottlenecks.

Ned Konz <ned at bike-nomad.com> wrote:
> 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