From 035ff1b01e74802eda6793c9312ebb7cc5da3807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Tue, 14 Feb 2023 12:52:48 +0100 Subject: [PATCH] Sort power tracks, and show them right after the other counter tracks. --- src/profile-logic/tracks.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/profile-logic/tracks.js b/src/profile-logic/tracks.js index 70540bbf98..2011711158 100644 --- a/src/profile-logic/tracks.js +++ b/src/profile-logic/tracks.js @@ -62,15 +62,15 @@ const LOCAL_TRACK_INDEX_ORDER = { const LOCAL_TRACK_DISPLAY_ORDER = { network: 0, memory: 1, + power: 2, // IPC tracks that belong to the global track will appear right after network - // and memory tracks. But we want to show the IPC tracks that belong to the + // and counter tracks. But we want to show the IPC tracks that belong to the // local threads right after their track. This special handling happens inside // the sort function. - ipc: 2, - thread: 3, - 'event-delay': 4, - 'process-cpu': 5, - power: 6, + ipc: 3, + thread: 4, + 'event-delay': 5, + 'process-cpu': 6, }; const GLOBAL_TRACK_INDEX_ORDER = { @@ -113,6 +113,17 @@ function _getDefaultLocalTrackOrder(tracks: LocalTrack[], profile: ?Profile) { return 1; } + if ( + profile && + profile.counters && + tracks[a].type === 'power' && + tracks[b].type === 'power' + ) { + const nameA = profile.counters[tracks[a].counterIndex].name; + const nameB = profile.counters[tracks[b].counterIndex].name; + return naturalSort.compare(nameA, nameB); + } + // If the tracks are both threads, sort them by thread name, and then by // creation time if they have the same name. if (tracks[a].type === 'thread' && tracks[b].type === 'thread' && profile) {