Skip to content

Commit cc362ba

Browse files
committed
Replace 4 counter track components with a single generic TrackCounter
Collapse the separate Memory, Power, ProcessCPU, and Bandwidth track implementations into a single TrackCounter component that renders any counter type using CounterDisplayConfig from PR #5912. The LocalTrack union type is simplified from 8 variants to 5 by replacing 'memory', 'power', 'process-cpu', and 'bandwidth' with a single 'counter' type. The component branches on display.graphType for canvas drawing (accumulated vs rate) and on display.unit for tooltip rendering (bytes, pWh, percent, etc.). Track index ordering (for URL backward compatibility) is handled by a category-based mapping function. Display ordering uses the new display.sortWeight field. Part of #5752.
1 parent 21adfa0 commit cc362ba

31 files changed

Lines changed: 1243 additions & 2972 deletions

src/actions/profile-view.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,7 @@ function getInformationFromTrackReference(
347347
relatedThreadIndex: localTrack.threadIndex,
348348
relatedTab: null,
349349
};
350-
case 'memory':
351-
case 'bandwidth':
352-
case 'process-cpu':
353-
case 'power': {
350+
case 'counter': {
354351
const counterSelectors = getCounterSelectors(localTrack.counterIndex);
355352
const counter = counterSelectors.getCounter(state);
356353
return {

src/app-logic/constants.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,10 @@ export const TRACK_NETWORK_ROW_REPEAT = 7;
2929
export const TRACK_NETWORK_HEIGHT =
3030
TRACK_NETWORK_ROW_HEIGHT * TRACK_NETWORK_ROW_REPEAT;
3131

32-
// The following values are for memory track.
33-
export const TRACK_MEMORY_GRAPH_HEIGHT = 25;
34-
export const TRACK_MEMORY_MARKERS_HEIGHT = 15;
35-
export const TRACK_MEMORY_HEIGHT =
36-
TRACK_MEMORY_GRAPH_HEIGHT + TRACK_MEMORY_MARKERS_HEIGHT;
37-
export const TRACK_MEMORY_LINE_WIDTH = 2;
38-
export const TRACK_MEMORY_DEFAULT_COLOR = 'orange';
39-
40-
// The following values are for the bandwidth track.
41-
export const TRACK_BANDWIDTH_HEIGHT = 25;
42-
export const TRACK_BANDWIDTH_LINE_WIDTH = 2;
43-
export const TRACK_BANDWIDTH_DEFAULT_COLOR = 'blue';
32+
// The following values are for counter tracks (Memory, Power, Bandwidth, etc.).
33+
export const TRACK_COUNTER_GRAPH_HEIGHT = 25;
34+
export const TRACK_COUNTER_MARKERS_HEIGHT = 15;
35+
export const TRACK_COUNTER_LINE_WIDTH = 2;
4436

4537
// The following values are for experimental event delay track.
4638
export const TRACK_EVENT_DELAY_HEIGHT = 40;
@@ -61,15 +53,6 @@ export const TRACK_PROCESS_BLANK_HEIGHT = 30;
6153
// Height of timeline ruler.
6254
export const TIMELINE_RULER_HEIGHT = 20;
6355

64-
// Height of the power track.
65-
export const TRACK_POWER_HEIGHT = 25;
66-
export const TRACK_POWER_LINE_WIDTH = 2;
67-
export const TRACK_POWER_DEFAULT_COLOR = 'grey';
68-
69-
// Height of the process cpu track.
70-
export const TRACK_PROCESS_CPU_HEIGHT = 25;
71-
export const TRACK_PROCESS_CPU_LINE_WIDTH = 2;
72-
7356
// JS Tracer has very high fidelity information, and needs a more fine-grained zoom.
7457
export const JS_TRACER_MAXIMUM_CHART_ZOOM = 0.001;
7558

src/components/timeline/LocalTrack.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ import { getThreadSelectors } from 'firefox-profiler/selectors/per-thread';
2626
import { TimelineTrackThread } from './TrackThread';
2727
import { TrackEventDelay } from './TrackEventDelay';
2828
import { TrackNetwork } from './TrackNetwork';
29-
import { TrackMemory } from './TrackMemory';
30-
import { TrackBandwidth } from './TrackBandwidth';
29+
import { TrackCounter } from './TrackCounter';
3130
import { TrackIPC } from './TrackIPC';
32-
import { TrackProcessCPU } from './TrackProcessCPU';
33-
import { TrackPower } from './TrackPower';
3431
import { getTrackSelectionModifiers } from 'firefox-profiler/utils';
3532
import type {
3633
TrackReference,
@@ -106,18 +103,12 @@ class LocalTrackComponent extends PureComponent<Props> {
106103
);
107104
case 'network':
108105
return <TrackNetwork threadIndex={localTrack.threadIndex} />;
109-
case 'memory':
110-
return <TrackMemory counterIndex={localTrack.counterIndex} />;
111-
case 'bandwidth':
112-
return <TrackBandwidth counterIndex={localTrack.counterIndex} />;
106+
case 'counter':
107+
return <TrackCounter counterIndex={localTrack.counterIndex} />;
113108
case 'ipc':
114109
return <TrackIPC threadIndex={localTrack.threadIndex} />;
115110
case 'event-delay':
116111
return <TrackEventDelay threadIndex={localTrack.threadIndex} />;
117-
case 'process-cpu':
118-
return <TrackProcessCPU counterIndex={localTrack.counterIndex} />;
119-
case 'power':
120-
return <TrackPower counterIndex={localTrack.counterIndex} />;
121112
case 'marker':
122113
return (
123114
<TrackCustomMarker
@@ -241,10 +232,7 @@ export const TimelineLocalTrack = explicitConnect<
241232
'Event Delay of ' + selectors.getThreadProcessDetails(state);
242233
break;
243234
}
244-
case 'memory':
245-
case 'bandwidth':
246-
case 'process-cpu':
247-
case 'power': {
235+
case 'counter': {
248236
titleText = getCounterSelectors(localTrack.counterIndex).getDescription(
249237
state
250238
);

src/components/timeline/TrackBandwidth.css

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/components/timeline/TrackBandwidth.tsx

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)