s/BenchmarkReportJSON.st
changeset 262 8d2849dd3227
parent 195 6bb215884ead
child 285 0cf54ee76de5
--- a/s/BenchmarkReportJSON.st	Sun Nov 09 18:04:29 2014 +0100
+++ b/s/BenchmarkReportJSON.st	Wed Dec 03 23:53:25 2014 +0000
@@ -80,16 +80,62 @@
     "Modified: / 12-06-2013 / 14:14:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+writeMeasurement: measurement
+    measurement value ~~ BenchmarkMeasurementValueNotAvailable instance ifTrue:[  
+        json writeDictionaryWith:[
+            json writeKey: 'instrument' valueWith: [ self writeMeasurementInstrument: measurement instrument ].
+            json writeElementSeparator.
+            json writeKey: 'value' value: measurement value
+        ].
+    ].
+
+    "Created: / 24-11-2014 / 23:41:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-12-2014 / 03:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+writeMeasurementInstrument: instrument
+    json writeDictionaryWith:[
+        json writeKey: 'name' value: instrument name.
+        json writeElementSeparator.
+        json writeKey: 'class' value: instrument class name.
+        json writeElementSeparator.
+        json writeKey: 'unit' value: instrument measurementUnit.        
+    ].
+
+    "Created: / 24-11-2014 / 23:46:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+writeMeasurements: measurements
+    json writeArrayWith:[
+        measurements do:[:run | 
+            json writeArrayWith:[
+                run do:[:measurement |  
+                    self writeMeasurement: measurement
+                ] separatedBy:[  
+                    json writeElementSeparator
+                ].
+            ].
+        ] separatedBy:[ 
+            json writeElementSeparator
+        ].
+    ].
+
+    "Created: / 24-11-2014 / 23:37:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 writeOutcome:outcome
     json writeDictionaryWith:[
         json writeKey: 'benchmark' valueWith: [ self writeBenchmark: outcome benchmark ].
         json writeElementSeparator.
-        json writeKey: 'times' value: outcome times.
+        json writeKey: 'measurements' valueWith: [ self writeMeasurements: outcome measurements ].
         json writeElementSeparator.        
         json writeKey: 'parameters' valueWith: [ self writeParameters: outcome ].
+        json writeElementSeparator.        
+        "For backward compatibility, will wanish"
+        json writeKey: 'times' value: outcome times.
     ]
 
-    "Modified: / 12-06-2013 / 14:10:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 24-11-2014 / 23:36:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 writeOutcomes