From bce395675a65df212ae3ea8533041f3d1db79a89 Mon Sep 17 00:00:00 2001 From: marianrai Date: Tue, 11 Jun 2019 18:57:41 +0300 Subject: [PATCH] Injected js code to get the metrics for Raptor. Modified the JetStreamDriver.js file to get the metrics in milliseconds and grouped by testName-subTest:[value]. --- benchmarks/JetStream2/JetStreamDriver.js | 45 +++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/benchmarks/JetStream2/JetStreamDriver.js b/benchmarks/JetStream2/JetStreamDriver.js index 221d200d..c1d2ab73 100644 --- a/benchmarks/JetStream2/JetStreamDriver.js +++ b/benchmarks/JetStream2/JetStreamDriver.js @@ -360,15 +360,14 @@ class Driver { if (!isInBrowser) return; - if (window.location.search !== '?report=true') - return; - let results = {}; for (let benchmark of this.benchmarks) { const subResults = {} const subTimes = benchmark.subTimes(); for (const name in subTimes) { - subResults[name] = {"metrics": {"Time": {"current": [toTimeValue(subTimes[name])]}}}; + // i removed the function toTimeValue() that was applied to subTimes[name] + // because the metrics were transformed in "timestamps" instead of ms + subResults[name] = {"metrics": {"Time": {"current": [subTimes[name]]}}}; } results[benchmark.name] = { "metrics" : { @@ -379,6 +378,44 @@ class Driver { }; } + + //================================================================================= + // Start code injection + // @author: marian + //================================================================================= + var allTests = results; + var measured = {}; + var nameSeparator = '-'; + + // testName is a string and equal to something like "WSL", "Babylon", etc. + for (var testName in allTests) { + // testScoreName = WSL-Geometric + var testScoreName = testName + nameSeparator + allTests[testName]['metrics']['Time'][0]; + // testScoreValue = [23.14077876392941] + var testScoreValue = allTests[testName]['metrics']['Score']['current']; + // measured['WSL-Geometric'] = 23.14077876392941 + measured[testScoreName] = testScoreValue; + + // subTestName has a value from [First, Worst, Average, Stdlib, MainRun, Startup, Runtime, etc] + for (var subTestName in allTests[testName]['tests']) { + // subTestValue = allTests['WSL']['tests']['Stdlib']['metrics']['Time']['current'] = 0.243 + var subTestValue = allTests[testName]['tests'][subTestName]['metrics']['Time']['current']; + // let's add the testName as a prefix: WSL-Stdlib, etc. + var subTestName = testName + nameSeparator + subTestName; + // insert the values in the measurements object + measured[subTestName] = subTestValue; + } + } + + if (location.search === '?raptor') { + // the data that will be sent to raptor + var _data = ['raptor-benchmark', 'jetstream2', measured]; + console.log('jetstream2 is about to post results to the raptor webext'); + window.postMessage(_data, '*'); + } + //================================================================================= + + results = {"JetStream2.0": {"metrics" : {"Score" : ["Geometric"]}, "tests" : results}}; const content = JSON.stringify(results);