[Newbies] How to profile a bunch of code
David Shaffer
cdshaffer at acm.org
Mon May 8 13:10:25 UTC 2006
cdrick wrote:
> Hi
>
> Is it possible to compare methods time execution...
>
> I know the possiblity to use
> Time millisecondsToRun: aBlock
> but it's not really useful...
> I've seen a profiler but not really sure...
>
> My aim is just to compare for instance the access to an existing
> dictionary, or creating it with several methods...
>
I use the "TimeProfileBrowser":
TimeProfileBrowser spyOn: ["your code goes here"]
The code in the block should take at least 1 second to get a reasonable
number of samples. If you need to you can always do something like:
TimeProfileBrowser spyOn: [100 timesRepeat: ["your code goes here"]]
Keep in mind that spyOn: does its work by sampling the stack at fixed
intervals...have a look at the class docs for MessageTally for more
details and alternatives.
David
More information about the Beginners
mailing list