Benchmarking in Pharo
Damien Cassou, Stéphane Ducasse and Luc Fabresse
http://stephane.ducasse.free.fr
Common Wisdom
If you did not profile your code you may have 40-50% speed up waiting for you.
Measuring Execution Speed
We create an expression and use [ expression ] timeToRun
Comparing Two Executions
Is select:
, then collect:
slower than select:thenCollect:
?
timeToRun example
bench
- Returns how many times the code can get executed in 5 seconds
- Answer a string with meaningful description
The higher the better!
[ 1234 factorial ] benchFor: 2 seconds
Time Profiler
TimeProfiler
: a sampling-based code profiler
- At regular interval, take information from the execution stack
Time Profiler
Summary
[ anExpression ] timeToRun
[ anExpression ] bench
TimeProfiler spyOn: [ anExpression ]
- Check Profiling Applications Chapter in Deep into Pharo (at http://books.pharo.org)
/