Skip to content

Commit

Permalink
Merge pull request #500 from jmaher/nits
Browse files Browse the repository at this point in the history
Bug 1142680 - Write a compare-talos equivalent, items 5,6,9
  • Loading branch information
jmaher committed May 1, 2015
2 parents 24be865 + 5294a66 commit ed4f759
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 119 deletions.
222 changes: 116 additions & 106 deletions ui/js/compareperf.js
Expand Up @@ -31,7 +31,7 @@ perf.controller('CompareResultsCtrl', [
thServiceDomain, $http, $q,
$timeout, PhSeries, math,
isReverseTest, PhCompare) {
function displayComparision() {
function displayComparison() {
$scope.testList = [];
$scope.platformList = [];

Expand All @@ -46,8 +46,7 @@ perf.controller('CompareResultsCtrl', [
PhSeries.getSeriesSummaries($scope.originalProject,
timeRange,
optionCollectionMap,
{e10s: $scope.e10s,
pgo: $scope.pgo}).then(
{e10s: $scope.e10s}).then(
function(originalSeriesData) {
$scope.platformList = originalSeriesData.platformList;
$scope.testList = originalSeriesData.testList;
Expand All @@ -69,8 +68,7 @@ perf.controller('CompareResultsCtrl', [
PhSeries.getSeriesSummaries($scope.newProject,
timeRange,
optionCollectionMap,
{e10s: $scope.e10s,
pgo: $scope.pgo}).then(
{e10s: $scope.e10s}).then(
function(newSeriesData) {
$scope.platformList = _.union($scope.platformList,
newSeriesData.platformList).sort();
Expand All @@ -91,11 +89,10 @@ perf.controller('CompareResultsCtrl', [
function displayResults(rawResultsMap, newRawResultsMap) {
$scope.compareResults = {};
$scope.titles = {};
window.document.title = "Perfherder Compare Revisions";

$scope.testList.forEach(function(testName) {
$scope.titles[testName] = testName.replace('summary ', '');
$scope.compareResults[testName] = [];

$scope.platformList.forEach(function(platform) {
var oldSig = _.find(Object.keys(rawResultsMap), function (sig) {
return (rawResultsMap[sig].name == testName && rawResultsMap[sig].platform == platform)});
Expand All @@ -118,9 +115,16 @@ perf.controller('CompareResultsCtrl', [
cmap.detailsLink = detailsLink;
cmap.name = platform;
cmap.hideMinorChanges = $scope.hideMinorChanges;
if (Object.keys($scope.compareResults).indexOf(testName) < 0)
$scope.compareResults[testName] = [];
$scope.compareResults[testName].push(cmap);
});
});

// Remove the tests with no data, report them as well; not needed for subtests
$scope.testNoResults = _.difference($scope.testList, Object.keys($scope.compareResults))
.map(function(name) { return ' ' + name.replace(' summary', '') }).join();
$scope.testList = Object.keys($scope.compareResults).sort();
}

//TODO: duplicated in comparesubtestctrl
Expand All @@ -132,7 +136,6 @@ perf.controller('CompareResultsCtrl', [
return $http.get(uri).then(function(response) {
var results = response.data.results;
if (results.length > 0) {

//TODO: this is a bit hacky to pass in 'original' as a text string
if (rsid == 'original') {
$scope.originalResultSetID = results[0].id;
Expand All @@ -141,6 +144,8 @@ perf.controller('CompareResultsCtrl', [
$scope.newResultSetID = results[0].id;
$scope.newTimestamp = results[0].push_timestamp;
}
} else {
$scope.errors.push("No results found for revision " + revision + " on branch " + project);
}
});
}
Expand All @@ -157,29 +162,28 @@ perf.controller('CompareResultsCtrl', [
return option.name; }).join(" ");
});
}).then(function() {
$stateParams.pgo = Boolean($stateParams.pgo);
$scope.errors = PhCompare.validateInput($stateParams.originalProject, $stateParams.newProject,
$stateParams.originalRevision, $stateParams.originalProject);

if ($scope.errors.length > 0) {
$scope.dataLoading = false;
return;
}

$stateParams.e10s = Boolean($stateParams.e10s);
$scope.hideMinorChanges = Boolean($stateParams.hideMinorChanges);

// TODO: validate projects and revisions
$scope.originalProject = $stateParams.originalProject;
$scope.newProject = $stateParams.newProject;
$scope.newRevision = $stateParams.newRevision;
$scope.originalRevision = $stateParams.originalRevision;
if (!$scope.originalProject ||
!$scope.newProject ||
!$scope.originalRevision ||
!$scope.newRevision) {
//TODO: get an error to the UI
return;
}

verifyRevision($scope.originalProject, $scope.originalRevision, "original").then(function () {
verifyRevision($scope.newProject, $scope.newRevision, "new").then(function () {
$http.get(thServiceDomain + '/api/repository/').then(function(response) {
$scope.projects = response.data;
displayComparision();
});
if ($scope.errors.length > 0) {
$scope.dataLoading = false;
return;
}
displayComparison();
});
});
});
Expand Down Expand Up @@ -212,6 +216,8 @@ perf.controller('CompareSubtestResultsCtrl', [
$scope.newResultSetID = results[0].id;
$scope.newTimestamp = results[0].push_timestamp;
}
} else {
$scope.errors.push("No results found for revision " + revision + " on branch " + project);
}
});
}
Expand All @@ -220,6 +226,10 @@ perf.controller('CompareSubtestResultsCtrl', [
$scope.compareResults = {};
$scope.titles = {};

var subtestTitle = $scope.platformList[0].split(' ')[0];
subtestTitle += " " + $scope.testList[0].split(' ')[0];
window.document.title = subtestTitle + " subtest comparison";

$scope.testList.forEach(function(testName) {
$scope.titles[testName] = testName.replace('summary ', '');
$scope.compareResults[testName] = [];
Expand Down Expand Up @@ -283,101 +293,101 @@ perf.controller('CompareSubtestResultsCtrl', [
return option.name; }).join(" ");
});
}).then(function() {
// TODO: validate projects and revisions
$scope.errors = PhCompare.validateInput($stateParams.originalProject, $stateParams.newProject,
$stateParams.originalRevision, $stateParams.newRevision,
$stateParams.originalSignature, $stateParams.newSignature);

if ($scope.errors.length > 0) {
$scope.dataLoading = false;
return;
}

$scope.hideMinorChanges = Boolean($stateParams.hideMinorChanges);
$scope.originalProject = $stateParams.originalProject;
$scope.newProject = $stateParams.newProject;
$scope.newRevision = $stateParams.newRevision;
$scope.originalRevision = $stateParams.originalRevision;
$scope.originalSignature = $stateParams.originalSignature;
$scope.newSignature = $stateParams.newSignature;
$scope.hideMinorChanges = Boolean($stateParams.hideMinorChanges);
if (!$scope.originalProject ||
!$scope.newProject ||
!$scope.originalRevision ||
!$scope.newRevision ||
!$scope.originalSignature ||
!$scope.newSignature) {
//TODO: get an error to the UI
return;
}


verifyRevision($scope.originalProject, $scope.originalRevision, "original").then(function () {
verifyRevision($scope.newProject, $scope.newRevision, "new").then(function () {
$http.get(thServiceDomain + '/api/repository/').then(function(response) {
$scope.projects = response.data;
$scope.pageList = [];

var timeRange = PhCompare.getInterval($scope.originalTimestamp, $scope.newTimestamp);
var resultSetIds = [$scope.originalResultSetID];

// Optimization - if old/new branches are the same collect data in one pass
if ($scope.originalProject == $scope.newProject) {
resultSetIds = [$scope.originalResultSetID, $scope.newResultSetID];
}

PhSeries.getSubtestSummaries($scope.originalProject,
timeRange,
optionCollectionMap,
$scope.originalSignature).then(
function (originalSeriesData) {
$scope.testList = originalSeriesData.testList;
$scope.platformList = originalSeriesData.platformList;
return PhCompare.getResultsMap($scope.originalProject,
originalSeriesData.seriesList,
timeRange,
resultSetIds);
}).then(function(seriesMaps) {
var originalSeriesMap = seriesMaps[$scope.originalResultSetID];
var newSeriesMap = seriesMaps[$scope.newResultSetID];
[originalSeriesMap, newSeriesMap].forEach(function (seriesMap) {
// If there is no data for a given signature, handle it gracefully
if (seriesMap) {
Object.keys(seriesMap).forEach(function(series) {
if (!_.contains($scope.pageList, seriesMap[series].name)) {
$scope.pageList.push(seriesMap[series].name);
}
});
}
});

// Optimization- collect all data in a single pass
$scope.pageList = [];

if ($scope.errors.length > 0) {
$scope.dataLoading = false;
return;
}

var timeRange = PhCompare.getInterval($scope.originalTimestamp, $scope.newTimestamp);
var resultSetIds = [$scope.originalResultSetID];

// Optimization - if old/new branches are the same collect data in one pass
if ($scope.originalProject == $scope.newProject) {
resultSetIds = [$scope.originalResultSetID, $scope.newResultSetID];
}

PhSeries.getSubtestSummaries($scope.originalProject,
timeRange,
optionCollectionMap,
$scope.originalSignature).then(
function (originalSeriesData) {
$scope.testList = originalSeriesData.testList;
$scope.platformList = originalSeriesData.platformList;
return PhCompare.getResultsMap($scope.originalProject,
originalSeriesData.seriesList,
timeRange,
resultSetIds);
}).then(function(seriesMaps) {
var originalSeriesMap = seriesMaps[$scope.originalResultSetID];
var newSeriesMap = seriesMaps[$scope.newResultSetID];
[originalSeriesMap, newSeriesMap].forEach(function (seriesMap) {
// If there is no data for a given signature, handle it gracefully
if (seriesMap) {
Object.keys(seriesMap).forEach(function(series) {
if (!_.contains($scope.pageList, seriesMap[series].name)) {
$scope.pageList.push(seriesMap[series].name);
}
});
}
});

// Optimization- collect all data in a single pass
if (newSeriesMap) {
$scope.dataLoading = false;
displayResults(originalSeriesMap, newSeriesMap, timeRange);
return;
}

PhSeries.getSubtestSummaries($scope.newProject,
timeRange,
optionCollectionMap,
$scope.newSignature).then(
function (newSeriesData) {
$scope.platformList = _.union($scope.platformList,
newSeriesData.platformList).sort();
$scope.testList = _.union($scope.testList,
newSeriesData.testList).sort();

return PhCompare.getResultsMap($scope.newProject,
newSeriesData.seriesList,
timeRange,
[$scope.newResultSetID]);
}).then(function(newSeriesMaps) {
var newSeriesMap = newSeriesMaps[$scope.newResultSetID];
// There is a chance that we haven't received data for the given signature/resultSet yet
if (newSeriesMap) {
$scope.dataLoading = false;
displayResults(originalSeriesMap, newSeriesMap, timeRange);
return;
Object.keys(newSeriesMap).forEach(function(series) {
if (!_.contains($scope.pageList, newSeriesMap[series].name)) {
$scope.pageList.push(newSeriesMap[series].name);
}
});
} else {
newSeriesMap = {};
}

PhSeries.getSubtestSummaries($scope.newProject,
timeRange,
optionCollectionMap,
$scope.newSignature).then(
function (newSeriesData) {
$scope.platformList = _.union($scope.platformList,
newSeriesData.platformList).sort();
$scope.testList = _.union($scope.testList,
newSeriesData.testList).sort();

return PhCompare.getResultsMap($scope.newProject,
newSeriesData.seriesList,
timeRange,
[$scope.newResultSetID]);
}).then(function(newSeriesMaps) {
var newSeriesMap = newSeriesMaps[$scope.newResultSetID];
// There is a chance that we haven't received data for the given signature/resultSet yet
if (newSeriesMap) {
Object.keys(newSeriesMap).forEach(function(series) {
if (!_.contains($scope.pageList, newSeriesMap[series].name)) {
$scope.pageList.push(newSeriesMap[series].name);
}
});
} else {
newSeriesMap = {};
}
$scope.dataLoading = false;
displayResults(originalSeriesMap, newSeriesMap, timeRange);
});
});
$scope.dataLoading = false;
displayResults(originalSeriesMap, newSeriesMap, timeRange);
});
});
});
});
Expand Down

0 comments on commit ed4f759

Please sign in to comment.