Added parameter to BenchmarkResult to run each benchmark multiple times.
The BenchmarkOutcome keeps all times. Also, BenchmarkInstance>>benchmark
renamed to selector.
"{ Package: 'jv:calipel/s' }"
Object subclass:#BenchmarkSuite
instanceVariableNames:'benchmarks'
classVariableNames:''
poolDictionaries:''
category:'CalipeL/S-Core'
!
!BenchmarkSuite class methodsFor:'instance creation'!
class: class
| suite current |
suite := self new.
current := class.
[ current notNil ] whileTrue:[
current selectorsAndMethodsDo:[:selector :method|
(method pragmaAt:#benchmark) notNil ifTrue:[
suite addBenchmark: (BenchmarkInstance class:class selector:selector)
].
].
current := current superclass.
].
^suite
"Created: / 28-05-2013 / 19:49:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
class:class selector:benchmark
^ BenchmarkInstance class:class selector:benchmark
"Created: / 28-05-2013 / 19:46:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
new
"return an initialized instance"
^ self basicNew initialize.
! !
!BenchmarkSuite methodsFor:'adding & removing'!
addBenchmark: aBenchmarkInstanceOrBenchmarkSuite
benchmarks add: aBenchmarkInstanceOrBenchmarkSuite
"Created: / 28-05-2013 / 19:48:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkSuite methodsFor:'initialization'!
initialize
"Invoked when a new instance is created."
benchmarks := Set new.
"Modified: / 27-05-2013 / 18:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (comment): / 31-05-2013 / 00:31:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkSuite methodsFor:'running'!
run
^self run: BenchmarkResult new.
"Created: / 27-05-2013 / 19:10:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
run: aBenchmarkResult
^self run: aBenchmarkResult with: Dictionary new
"Created: / 27-05-2013 / 19:10:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-05-2013 / 00:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
run: aBenchmarkResult with: aDictionary
benchmarks do:[:each|
each run: aBenchmarkResult with: aDictionary
].
^aBenchmarkResult
"Created: / 27-05-2013 / 22:18:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
runWith: aDictionary
^self run: BenchmarkResult new with: aDictionary
"Created: / 27-05-2013 / 22:18:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!BenchmarkSuite class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
!
version_MC
^ 'CalipeL_S-Core-JanVrany.7 5c300a20-c9d7-11e2-a959-606720e43e2c 2013-05-31T10:49:17 JanVrany'
! !