You can do things like:

MessageTally spyOn: [ 1 to: 1000 do: [ :i | i primeFactors logCr ] ].

or

AndreasSystemProfiler spyOn: [ 1 to: 1000 do: [ :i | i primeFactors logCr ]
].

See https://www.youtube.com/watch?v=aiA8GblEw00

or

[ 1000 primeFactors ] benchFor: 5 seconds

--> "a BenchmarkResult(11,386,117 iterations in 5 seconds. 2,277,223 per
second)"

or

[ 1000000 timesRepeat: [  1000 primeFactors ] ] timeToRun

--> "0:00:00:01.055"

etc.

http://www.smalltalkhub.com/#!/~StefanMarr/SMark is also interesting and
more like a framework.

ZnBase64EncoderTests class side has a few bench methods:


bench10kEncode
"self bench10kEncode"
| bytes |
bytes := ByteArray new: 10240 streamContents: [ :out |
10240 timesRepeat: [ out nextPut: 256 atRandom - 1 ] ].
^ [ ZnBase64Encoder new encode: bytes ] bench

There is also this chapter:
http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/Profiling.pdf

HTH

Phil






On Thu, May 25, 2017 at 12:51 PM, Steven Costiou <[email protected]>
wrote:

> Hi,
>
> is there any benchmark library for Pharo ? that would provide tools to
> choose metrics to measure between two versions of the same code and maybe
> display a comparison or something (whatever the form of the report) ?
>
> I've found BenchmarkResult in Pharo but it seems very basic, at least
> there are no detailed examples of how it could be used.
>
> I'm specifically looking for a way to measure the speed of method calls
> (if that is possible) or the memory usage, but i'm also curious in general
> about what is measureable and try different benchmarks to see the results.
> So if there were a tool already doing all this work... ?
>
> Steven.
>
>
>
>
>

Reply via email to