Skip to content

Commit

Permalink
combine multiple results per target and calc average
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Apr 13, 2020
1 parent 90093c5 commit b844f18
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[haxe]": {
"editor.formatOnSave": true,
"editor.formatOnPaste": true
}
}
46 changes: 45 additions & 1 deletion src/CsvToJson.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,51 @@ class CsvToJson {
});
}

return testRun;
return combineMultipleResults(testRun);
}

static function combineMultipleResults(testRun:TestRun):TestRun {
var combinedResults:TestRun = {
haxeVersion: testRun.haxeVersion,
date: testRun.date,
targets: []
}

var seenNames:Array<String> = [];
for (target in testRun.targets) {
if (seenNames.indexOf(target.name) >= 0) {
continue;
}
combinedResults.targets.push(buildTargetAverage(testRun, target.name));
seenNames.push(target.name);
}
return combinedResults;
}

static function buildTargetAverage(testRun:TestRun, name:String):TargetResult {
var values:Array<Float> = [];
var result:TargetResult = {
name: name,
inputLines: 0,
outputLines: 0,
time: 0
};

var totalTime:Float = 0;
var count:Int = 0;
for (target in testRun.targets) {
if (target.name != name) {
continue;
}
totalTime += target.time;
count++;
}
if (count == 1) {
result.time = totalTime;
} else {
result.time = totalTime / count;
}
return result;
}

static function getHaxeVersion():String {
Expand Down

0 comments on commit b844f18

Please sign in to comment.