s/BenchmarkResult.st
changeset 6 25b264cec44e
parent 5 8669edf62d9b
child 12 3a7ebd3da52f
--- a/s/BenchmarkResult.st	Fri May 31 12:13:11 2013 +0100
+++ b/s/BenchmarkResult.st	Wed Jun 05 10:45:29 2013 +0100
@@ -1,7 +1,7 @@
 "{ Package: 'jv:calipel/s' }"
 
 Object subclass:#BenchmarkResult
-	instanceVariableNames:'outcomes'
+	instanceVariableNames:'outcomes runs'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'CalipeL/S-Core'
@@ -20,6 +20,22 @@
 
 outcomes
     ^ outcomes
+!
+
+runs
+    "Return how many times each benchmark is run." 
+
+    ^ runs
+
+    "Modified (format): / 04-06-2013 / 22:25:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+runs:anInteger
+     "Sets how many times each benchmark is run." 
+
+    runs := anInteger.
+
+    "Modified (comment): / 04-06-2013 / 22:25:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BenchmarkResult methodsFor:'initialization'!
@@ -28,9 +44,9 @@
     "Invoked when a new instance is created."
 
     outcomes := Set new.
+    runs := 1.
 
-    "Modified: / 27-05-2013 / 18:57:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (comment): / 31-05-2013 / 00:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-06-2013 / 22:23:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BenchmarkResult methodsFor:'printing & storing'!
@@ -46,23 +62,18 @@
 
 !BenchmarkResult methodsFor:'running-private'!
 
-performBenchmark:aBenchmarkInstance withParameters:aDictionary
-    ^aBenchmarkInstance runBenchmarkWithParameters:aDictionary
+runBenchmark:aBenchmarkInstance withParameters: aDictionary
+    | times |
 
-    "Created: / 27-05-2013 / 22:24:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-runBenchmark:aBenchmarkInstance withParameters: aDictionary
-    | time |
-
-    time := self performBenchmark: aBenchmarkInstance withParameters:aDictionary.
+    times := (1 to: runs) collect: [:i | aBenchmarkInstance runBenchmarkWithParameters: aDictionary].
     outcomes add:
         (BenchmarkOutcome 
             instance: aBenchmarkInstance
-            time: time
+            times: times
             parameters: aBenchmarkInstance)
 
     "Created: / 27-05-2013 / 22:20:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-06-2013 / 10:29:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !BenchmarkResult class methodsFor:'documentation'!