Merge "ui: Sort by tid when available"
diff --git a/ui/src/common/actions.ts b/ui/src/common/actions.ts
index 25bca46..e982bc9 100644
--- a/ui/src/common/actions.ts
+++ b/ui/src/common/actions.ts
@@ -115,8 +115,8 @@
function rankIndex<T>(element: T, array: T[]): number {
const index = array.indexOf(element);
- if (index === -1) return 0;
- return array.length - index;
+ if (index === -1) return array.length;
+ return index;
}
export const StateActions = {
@@ -280,7 +280,7 @@
const aRank = rank(state.tracks[a]);
const bRank = rank(state.tracks[b]);
for (let i = 0; i < aRank.length; i++) {
- if (aRank[i] !== bRank[i]) return bRank[i] - aRank[i];
+ if (aRank[i] !== bRank[i]) return aRank[i] - bRank[i];
}
const aName = state.tracks[a].name.toLocaleLowerCase();
diff --git a/ui/src/common/actions_unittest.ts b/ui/src/common/actions_unittest.ts
index 87bf309..8cf6acf 100644
--- a/ui/src/common/actions_unittest.ts
+++ b/ui/src/common/actions_unittest.ts
@@ -19,6 +19,7 @@
import {
PROCESS_SCHEDULING_TRACK_KIND
} from '../tracks/process_scheduling/common';
+import {THREAD_STATE_TRACK_KIND} from '../tracks/thread_state/common';
import {StateActions} from './actions';
import {
@@ -34,7 +35,8 @@
kind?: string,
trackGroup?: string,
trackKindPriority?: TrackKindPriority,
- name?: string
+ name?: string,
+ tid?: string
}): State {
return produce(state, draft => {
StateActions.addTrack(draft, {
@@ -46,7 +48,7 @@
TrackKindPriority.ORDINARY :
args.trackKindPriority,
trackGroup: args.trackGroup || SCROLLING_TRACK_GROUP,
- config: {}
+ config: {tid: args.tid || '0'}
});
});
}
@@ -392,3 +394,35 @@
expect(after.trackGroups['g'].tracks)
.toEqual(['a', 'b', 'b', 'c', 'd', 'e', 'f', 'g']);
});
+
+test('sortTracksByTidThenName', () => {
+ let state = createEmptyState();
+ state = fakeTrackGroup(state, {id: 'g', summaryTrackId: 'a'});
+ state = fakeTrack(state, {
+ id: 'a',
+ kind: SLICE_TRACK_KIND,
+ trackGroup: 'g',
+ name: 'aaa',
+ tid: '1'
+ });
+ state = fakeTrack(state, {
+ id: 'b',
+ kind: SLICE_TRACK_KIND,
+ trackGroup: 'g',
+ name: 'bbb',
+ tid: '2'
+ });
+ state = fakeTrack(state, {
+ id: 'c',
+ kind: THREAD_STATE_TRACK_KIND,
+ trackGroup: 'g',
+ name: 'ccc',
+ tid: '1'
+ });
+
+ const after = produce(state, draft => {
+ StateActions.sortThreadTracks(draft, {});
+ });
+
+ expect(after.trackGroups['g'].tracks).toEqual(['a', 'a', 'c', 'b']);
+});
diff --git a/ui/src/common/state.ts b/ui/src/common/state.ts
index a194042..71c3f2f 100644
--- a/ui/src/common/state.ts
+++ b/ui/src/common/state.ts
@@ -60,10 +60,10 @@
export type NewEngineMode = 'USE_HTTP_RPC_IF_AVAILABLE'|'FORCE_BUILTIN_WASM';
export enum TrackKindPriority {
- 'MAIN_THREAD' = 3,
- 'RENDER_THREAD' = 2,
- 'GPU_COMPLETION' = 1,
- 'ORDINARY' = 0
+ 'MAIN_THREAD' = 0,
+ 'RENDER_THREAD' = 1,
+ 'GPU_COMPLETION' = 2,
+ 'ORDINARY' = 3
}
export type HeapProfileFlamegraphViewingOption =
diff --git a/ui/src/controller/track_decider.ts b/ui/src/controller/track_decider.ts
index 8768949..d4eb474 100644
--- a/ui/src/controller/track_decider.ts
+++ b/ui/src/controller/track_decider.ts
@@ -412,7 +412,7 @@
trackGroup: uuid,
trackKindPriority:
TrackDecider.inferTrackKindPriority(threadName, tid, pid),
- config: {utid}
+ config: {utid, tid}
});
}
}
@@ -508,12 +508,7 @@
name,
trackKindPriority: TrackDecider.inferTrackKindPriority(threadName),
trackGroup: uuid,
- config: {
- name,
- trackId,
- startTs,
- endTs,
- }
+ config: {name, trackId, startTs, endTs, tid}
});
}
}
@@ -762,11 +757,7 @@
name,
trackGroup: uuid,
trackKindPriority,
- config: {
- trackId,
- maxDepth,
- tid,
- }
+ config: {trackId, maxDepth, tid}
});
}
}
@@ -976,7 +967,7 @@
kind,
trackKindPriority: TrackDecider.inferTrackKindPriority(threadName),
name: `${upid === null ? tid : pid} summary`,
- config: {pidForColor, upid, utid},
+ config: {pidForColor, upid, utid, tid},
});
const name = TrackDecider.getTrackName(