Skip to content

Commit

Permalink
Fix profile_tree tests (elastic#24158) (elastic#24238)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb authored Oct 18, 2018
1 parent 6d1b5cd commit 86706e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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).' }
];
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 86706e8

Please sign in to comment.