s/BenchmarkExecutor.st
changeset 262 8d2849dd3227
parent 216 be26cc6e8795
child 267 5c032df036a4
--- a/s/BenchmarkExecutor.st	Sun Nov 09 18:04:29 2014 +0100
+++ b/s/BenchmarkExecutor.st	Wed Dec 03 23:53:25 2014 +0000
@@ -1,7 +1,7 @@
 "{ Package: 'jv:calipel/s' }"
 
 Object subclass:#BenchmarkExecutor
-	instanceVariableNames:''
+	instanceVariableNames:'instruments'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'CalipeL-S-Core'
@@ -27,6 +27,14 @@
 "
 ! !
 
+!BenchmarkExecutor class methodsFor:'instance creation'!
+
+new
+    "return an initialized instance"
+
+    ^ self basicNew initialize.
+! !
+
 !BenchmarkExecutor class methodsFor:'execution'!
 
 execute:aBenchmarkInstance
@@ -41,6 +49,20 @@
     ^ self new execute:aBenchmarkInstance result:aBenchmarkResult defines:aDictionary
 ! !
 
+!BenchmarkExecutor methodsFor:'accessing'!
+
+instruments
+    ^ instruments
+!
+
+instruments:aCollection
+    "Set a list of user-defined mersurement instruments"
+
+    instruments := aCollection.
+
+    "Modified (comment): / 27-11-2014 / 13:43:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !BenchmarkExecutor methodsFor:'executing'!
 
 execute: aBenchmarkInstance
@@ -216,6 +238,19 @@
 
 !BenchmarkExecutor methodsFor:'executing-private'!
 
+benchmark: aBenchmarkInstance
+    | measurements |
+    [
+        measurements := aBenchmarkInstance benchmarkUsingInstruments: (BenchmarkPlatform current instruments) , instruments.
+    ] on: Error do:[:ex|
+        BenchmarkExecutionError new signal:'Error during measurement: ', ex description.      
+    ].
+    ^measurements
+
+    "Created: / 24-11-2014 / 00:18:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-11-2014 / 13:43:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 execute: aBenchmarkInstance result: aBenchmarkResult parameters: aCollection
     "
     Takes a benchmark instance and a set of parameter defines,
@@ -224,7 +259,7 @@
 
     This is where real execution happens"
 
-    | times outcome |
+    | measurements outcome |
 
     "First, warm it up"
     [ 
@@ -234,10 +269,10 @@
         self tearDown: aBenchmarkInstance
     ].
 
-    times := (1 to: aBenchmarkResult runs) collect:[:i | 
+    measurements := (1 to: aBenchmarkResult runs) collect:[:i | 
         [
             self setUp:aBenchmarkInstance parameters: aCollection.  
-            self timeIt: aBenchmarkInstance 
+            self benchmark: aBenchmarkInstance 
         ] ensure:[
             self tearDown: aBenchmarkInstance
         ].
@@ -246,13 +281,13 @@
     aBenchmarkResult addOutcome:
         (outcome := BenchmarkOutcome 
             benchmark: aBenchmarkInstance
-            times: times
-            parameters: aCollection).
+            parameters: aCollection
+            measurements: measurements).     
 
     ^ outcome
 
     "Created: / 27-07-2013 / 12:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 10-03-2014 / 09:36:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 24-11-2014 / 06:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 setUp:aBenchmarkInstance parameters: aCollection
@@ -297,19 +332,6 @@
     "Modified: / 31-07-2013 / 01:03:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-timeIt: aBenchmarkInstance
-    | t |
-    [
-        t := aBenchmarkInstance timeIt.
-    ] on: Error do:[:ex|
-        BenchmarkExecutionError new signal:'Error during measurement: ', ex description.      
-    ].
-    ^t
-
-    "Created: / 24-06-2013 / 01:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 31-07-2013 / 01:03:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 warmUp: aBenchmarkInstance
     [
         aBenchmarkInstance warmUp.
@@ -321,6 +343,16 @@
     "Modified: / 31-07-2013 / 01:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!BenchmarkExecutor methodsFor:'initialization'!
+
+initialize
+    "Invoked when a new instance is created."
+
+    instruments := #()
+
+    "Modified: / 27-11-2014 / 13:42:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !BenchmarkExecutor methodsFor:'profiling-private'!
 
 spy: aBenchmarkInstance result: aBenchmarkResult parameters: aCollection