diff --git a/ui/src/plugins/dev.perfetto.TraceProcessorTrack/index.ts b/ui/src/plugins/dev.perfetto.TraceProcessorTrack/index.ts index 6702adb837..7666caa32c 100644 --- a/ui/src/plugins/dev.perfetto.TraceProcessorTrack/index.ts +++ b/ui/src/plugins/dev.perfetto.TraceProcessorTrack/index.ts @@ -50,7 +50,6 @@ import ProcessThreadGroupsPlugin from '../dev.perfetto.ProcessThreadGroups'; import StandardGroupsPlugin from '../dev.perfetto.StandardGroups'; import {CounterSelectionAggregator} from './counter_selection_aggregator'; import {COUNTER_TRACK_SCHEMAS} from './counter_tracks'; -import {PivotTableTab} from './pivot_table_tab'; import {ThreadSliceAggregator} from './thread_slice_aggregator'; import {SLICE_TRACK_SCHEMAS} from './slice_tracks'; import {STATE_TRACK_SCHEMAS} from './state_tracks'; @@ -599,7 +598,6 @@ export default class TraceProcessorTrackPlugin implements PerfettoPlugin { ctx.selection.registerAreaSelectionTab( createAggregationTab(ctx, new ThreadSliceAggregator(ctx)), ); - ctx.selection.registerAreaSelectionTab(new PivotTableTab(ctx)); ctx.selection.registerAreaSelectionTab( this.createSliceFlameGraphPanel(ctx), ); diff --git a/ui/src/plugins/dev.perfetto.TraceProcessorTrack/pivot_table_tab.ts b/ui/src/plugins/dev.perfetto.TraceProcessorTrack/pivot_table_tab.ts deleted file mode 100644 index 44ebb7a85b..0000000000 --- a/ui/src/plugins/dev.perfetto.TraceProcessorTrack/pivot_table_tab.ts +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2025 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import m from 'mithril'; -import {ensureExists} from '../../base/assert'; -import {Icons} from '../../base/semantic_icons'; -import {PivotTable} from '../../components/widgets/sql/pivot_table/pivot_table'; -import {PivotTableState} from '../../components/widgets/sql/pivot_table/pivot_table_state'; -import { - type AreaSelection, - areaSelectionsEqual, - type AreaSelectionTab, -} from '../../public/selection'; -import {SLICE_TRACK_KIND} from '../../public/track_kinds'; -import {Button} from '../../widgets/button'; -import type {Trace} from '../../public/trace'; -import {extensions} from '../../components/extensions'; -import {SLICE_TABLE} from '../../components/widgets/sql/table_definitions'; -import {resolveTableDefinition} from '../../components/widgets/sql/table/columns'; - -export class PivotTableTab implements AreaSelectionTab { - readonly id = 'pivot_table'; - readonly name = 'Pivot Table'; - - private state?: PivotTableState; - private previousSelection?: AreaSelection; - private trackIds: number[] = []; - - constructor(private readonly trace: Trace) {} - - render(selection: AreaSelection) { - if ( - this.previousSelection === undefined || - !areaSelectionsEqual(this.previousSelection, selection) - ) { - this.previousSelection = selection; - this.trackIds = selection.tracks - .filter((track) => track.tags?.kinds?.includes(SLICE_TRACK_KIND)) - .flatMap((track) => track.tags?.trackIds ?? []); - this.getOrCreateState().filters.setFilters([ - { - op: (cols) => `${cols[0]} + ${cols[1]} > ${selection.start}`, - columns: ['ts', 'dur'], - }, - {op: (cols) => `${cols[0]} < ${selection.end}`, columns: ['ts']}, - { - op: (cols) => `${cols[0]} in (${this.trackIds.join(', ')})`, - columns: ['track_id'], - }, - ]); - } - if (this.trackIds.length === 0) return undefined; - const state = this.getOrCreateState(); - - return { - isLoading: state?.getData() === undefined, - content: m(PivotTable, { - state, - getSelectableColumns: () => state.table.columns, - extraRowButton: (node) => - m(Button, { - icon: Icons.GoTo, - onclick: () => { - extensions.addLegacySqlTableTab(this.trace, { - table: SLICE_TABLE, - filters: [ - ...(state?.filters.get() ?? []), - ...node.getFilters(), - ], - }); - }, - }), - }), - }; - } - - private getOrCreateState(): PivotTableState { - if (this.state !== undefined) return this.state; - const sliceTable = resolveTableDefinition(this.trace, SLICE_TABLE); - const name = ensureExists( - sliceTable.columns.find((c) => c.column === 'name'), - ); - const dur = ensureExists( - sliceTable.columns.find((c) => c.column === 'dur'), - ); - this.state = new PivotTableState({ - trace: this.trace, - table: sliceTable, - pivots: [name], - aggregations: [ - { - column: dur, - op: 'sum', - }, - ], - }); - return this.state; - } -}