Skip to content

Commit

Permalink
Injected js code to get the metrics for Raptor.
Browse files Browse the repository at this point in the history
Modified the JetStreamDriver.js file to get the metrics in milliseconds
and grouped by testName-subTest:[value].

Added a small snippet to autostart the tests if location has ?raptor in it.
  • Loading branch information
marianrai committed Jun 12, 2019
1 parent c641aab commit 5d75a80
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions benchmarks/JetStream2/JetStreamDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,25 @@ class Driver {
JetStream.start();
return false;
}

if (location.search === '?raptor') {
statusElement.click();
}
}

async reportScoreToRunBenchmarkRunner()
{
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" : {
Expand All @@ -379,6 +382,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);
Expand Down

0 comments on commit 5d75a80

Please sign in to comment.