Fix profile_tree tests (#24158)

This commit is contained in:
Josh Dover 2018-10-17 14:55:27 -05:00 committed by GitHub
parent 2f99cf896d
commit 29b1839c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View file

@ -63,14 +63,14 @@ export const normalized = [ { key: 'next_doc',
relative: 0,
color: '#f5f5f5',
tip: '' },
{ key: 'match',
time: 0,
relative: '0.0',
color: '#f5f5f5',
tip: 'The time taken to execute a secondary, more precise scoring phase (used by phrase queries).' },
{ key: 'match_count',
time: 0,
relative: 0,
color: '#f5f5f5',
tip: '' },
{ key: 'match',
time: 0,
relative: '0.0',
color: '#f5f5f5',
tip: 'The time taken to execute a secondary, more precise scoring phase (used by phrase queries).' }
];

View file

@ -84,7 +84,7 @@ export function normalizeBreakdown(breakdown) {
}
return partialTotal;
}, 0);
Object.keys(breakdown).forEach(key => {
Object.keys(breakdown).sort().forEach(key => {
let relative = 0;
if (key.indexOf('_count') === -1) {
relative = ((breakdown[key] / total) * 100).toFixed(1);
@ -97,8 +97,15 @@ export function normalizeBreakdown(breakdown) {
tip: getToolTip(key)
});
});
final.sort((a, b) => comparator(a.time, b.time));
return final;
// Sort by time descending and then key ascending
return final.sort((a, b) => {
if (comparator(a.time, b.time) !== 0) {
return comparator(a.time, b.time);
}
return -1 * comparator(a.key, b.key);
});
}
export function normalizeTimes(data, totalTime, depth) {