--- a/s/BenchmarkExecutor.st Fri Jul 26 00:32:44 2013 +0100
+++ b/s/BenchmarkExecutor.st Sat Jul 27 13:26:01 2013 +0100
@@ -37,10 +37,75 @@
This is where real execution happens"
+ | parameters combinator |
+
+ parameters := aBenchmarkInstance parameters collect:[:parameter|
+ | key1 key2 valuesString values defined |
+
+ key1 := aBenchmarkInstance instance class name , '#' , parameter name.
+ key2 := parameter name.
+ defined := true.
+ valuesString := aDictionary at: key1 ifAbsent:[aDictionary at: key2 ifAbsent:[defined := false]].
+ defined ifTrue:[
+ (parameter type includesBehavior: CharacterArray) ifTrue:[
+ values := Array with:valuesString
+ ] ifFalse:[
+ values := (valuesString tokensBasedOn: $,) collect:[:each|
+ | s v |
+
+ s := each readStream.
+ v := parameter type readFrom: s onError:[
+ "JV: Note for Smalltalk/X: #signal: is actually an ANSI 1.9 protocol!!"
+ BenchmarkParameterError new signal: 'Cannot read parameter value for ' , parameter name , ' (parse error)'
+ ].
+ s atEnd ifFalse:[
+ "JV: Note for Smalltalk/X: #signal: is actually an ANSI 1.9 protocol!!"
+ BenchmarkParameterError new signal: 'Cannot read parameter value for ' , parameter name , ' (parse error)'
+ ].
+ v.
+ ]
+ ].
+ ] ifFalse:[
+ values := Array with: parameter default.
+ ].
+ parameter -> values
+ ].
+
+ parameters := parameters asOrderedCollection sort:[:a :b | a key name < b key name ].
+
+ combinator := [:parametersAndValues |
+ parametersAndValues size = parameters size ifTrue:[
+ self execute: aBenchmarkInstance result: aBenchmarkResult parameters: parametersAndValues.
+ ] ifFalse:[
+ | parameter |
+
+ parameter := parameters at: parametersAndValues size + 1.
+ parameter value do:[:value |
+ combinator value: (parametersAndValues copyWith: (parameter key -> value)).
+ ]
+ ]
+ ].
+
+ combinator value: #().
+
+ "Created: / 25-07-2013 / 23:51:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 27-07-2013 / 13:09:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BenchmarkExecutor methodsFor:'executing-private'!
+
+execute: aBenchmarkInstance result: aBenchmarkResult parameters: aCollection
+ "
+ Takes a benchmark instance and a set of parameter defines,
+ executes the benchmark and one or more outcomes into given
+ result.
+
+ This is where real execution happens"
+
| times |
[
- self setUp: aBenchmarkInstance parameters: aDictionary.
+ self setUp:aBenchmarkInstance parameters: aCollection .
self warmUp: aBenchmarkInstance.
times := (1 to: aBenchmarkResult runs) collect:[:i | self timeIt: aBenchmarkInstance ].
aBenchmarkResult addOutcome:
@@ -52,16 +117,16 @@
self tearDown: aBenchmarkInstance
]
- "Created: / 25-07-2013 / 23:51:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
+ "Created: / 27-07-2013 / 12:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
-!BenchmarkExecutor methodsFor:'executing-private'!
-
-setUp: aBenchmarkInstance parameters: aDictionary
- aBenchmarkInstance setUpParameters: aDictionary.
+setUp:aBenchmarkInstance parameters: aCollection
+ aCollection do:[:each|
+ aBenchmarkInstance setUpParameter: each key value: each value
+ ].
aBenchmarkInstance setUp.
- "Created: / 24-06-2013 / 01:11:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 27-07-2013 / 12:31:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
tearDown: aBenchmarkInstance