• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2/*
3 * Copyright (C) 2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { type SpSystemTrace } from '../SpSystemTrace';
17import { TraceRow } from '../trace/base/TraceRow';
18import { renders } from '../../database/ui-worker/ProcedureWorker';
19import { type EmptyRender } from '../../database/ui-worker/cpu/ProcedureWorkerCPU';
20import { type FreqExtendRender, CpuFreqExtendStruct } from '../../database/ui-worker/ProcedureWorkerFreqExtend';
21import { type BinderRender, BinderStruct } from '../../database/ui-worker/procedureWorkerBinder';
22import { type BaseStruct } from '../../bean/BaseStruct';
23import { type AllStatesRender, AllstatesStruct } from '../../database/ui-worker/ProcedureWorkerAllStates';
24import { StateGroup } from '../../bean/StateModle';
25import { queryAllFuncNames } from '../../database/sql/Func.sql';
26import { Utils } from '../trace/base/Utils';
27const UNIT_HEIGHT: number = 20;
28const MS_TO_US: number = 1000000;
29const MIN_HEIGHT: number = 2;
30export class SpSegmentationChart {
31  static trace: SpSystemTrace;
32  static cpuRow: TraceRow<CpuFreqExtendStruct> | undefined;
33  static GpuRow: TraceRow<CpuFreqExtendStruct> | undefined;
34  static binderRow: TraceRow<BinderStruct> | undefined;
35  static schedRow: TraceRow<CpuFreqExtendStruct> | undefined;
36  static freqInfoMapData = new Map<number, Map<number, number>>();
37  static hoverLine: Array<HeightLine> = [];
38  static tabHoverObj: { key: string, cycle: number };
39  private rowFolder!: TraceRow<BaseStruct>;
40  static chartData: Array<Object> = [];
41  static statesRow: TraceRow<AllstatesStruct> | undefined;
42  // 数据切割联动
43  static setChartData(type: string, data: Array<FreqChartDataStruct>): void {
44    SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 };
45    SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined;
46    if (type === 'CPU-FREQ') {
47      setCpuData(data);
48    } else if (type === 'GPU-FREQ') {
49      setGpuData(data);
50    } else {
51      setSchedData(data);
52    }
53    SpSegmentationChart.trace.refreshCanvas(false);
54  }
55
56  // state泳道联动
57  static setStateChartData(data: Array<StateGroup>) {
58    SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 };
59    SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined;
60    let stateChartData = new Array();
61    stateChartData = data.map(v => {
62      return {
63        dur: v.dur,
64        chartDur: v.chartDur,
65        pid: v.pid,
66        tid: v.tid,
67        end_ts: v.startTs! + v.chartDur!,
68        id: v.id,
69        name: 'all-state',
70        startTime: v.startTs,
71        start_ts: v.startTs,
72        state: v.state,
73        type: v.type,
74        cycle: v.cycle,
75      };
76    });
77    SpSegmentationChart.statesRow!.dataList = [];
78    SpSegmentationChart.statesRow!.dataListCache = [];
79    SpSegmentationChart.statesRow!.isComplete = false;
80    // @ts-ignore
81    SpSegmentationChart.statesRow!.supplier = (): Promise<Array<ThreadStruct>> =>
82      new Promise<Array<AllstatesStruct>>((resolve) => resolve(stateChartData));
83    SpSegmentationChart.trace.refreshCanvas(false);
84  };
85
86  // binder联动调用
87  static setBinderChartData(data: Array<Array<FreqChartDataStruct>>): void {
88    SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 };
89    SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined;
90    BinderStruct.maxHeight = 0;
91    SpSegmentationChart.binderRow!.dataList = [];
92    SpSegmentationChart.binderRow!.dataListCache = [];
93    SpSegmentationChart.binderRow!.isComplete = false;
94    if (data.length === 0) {
95      SpSegmentationChart.binderRow!.style.height = `40px`;
96      SpSegmentationChart.binderRow!.funcMaxHeight = 40;
97      // @ts-ignore
98      SpSegmentationChart.binderRow!.supplier = (): Promise<Array<FreqChartDataStruct>> =>
99        new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([]));
100    } else {
101      let binderList: Array<FreqChartDataStruct> = [];
102      let chartData: Array<FreqChartDataStruct> = [];
103      setBinderData(data, binderList);
104      chartData = binderList.map((v: FreqChartDataStruct) => {
105        return {
106          cpu:
107            v.name === 'binder transaction'
108              ? 0
109              : v.name === 'binder transaction async'
110                ? 1
111                : v.name === 'binder reply'
112                  ? MS_TO_US
113                  : 3,
114          startNS: v.startNS,
115          dur: v.dur,
116          name: `${v.name}`,
117          value: v.value,
118          depth: v.depth,
119          cycle: v.cycle,
120        };
121      });
122      // @ts-ignore
123      SpSegmentationChart.binderRow!.supplier = (): Promise<Array<FreqChartDataStruct>> =>
124        new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(chartData));
125      SpSegmentationChart.binderRow!.style.height = `${BinderStruct.maxHeight > MIN_HEIGHT ? BinderStruct.maxHeight * UNIT_HEIGHT + UNIT_HEIGHT : 40}px`;
126      SpSegmentationChart.binderRow!.funcMaxHeight = BinderStruct.maxHeight > MIN_HEIGHT ? BinderStruct.maxHeight * UNIT_HEIGHT + UNIT_HEIGHT : 40;
127    }
128    TraceRow.range!.refresh = true;
129    SpSegmentationChart.binderRow!.needRefresh = true;
130    SpSegmentationChart.binderRow!.draw(false);
131    if (SpSegmentationChart.binderRow!.collect) {
132      window.publish(window.SmartEvent.UI.RowHeightChange, {
133        expand: SpSegmentationChart.binderRow!.funcExpand,
134        value: SpSegmentationChart.binderRow!.funcMaxHeight - 40,
135      });
136    }
137    SpSegmentationChart.trace.favoriteChartListEL?.scrollTo(0, 0);
138    SpSegmentationChart.trace.refreshCanvas(false);
139  }
140  // 悬浮联动
141  static tabHover(type: string, tableIsHover: boolean = false, cycle: number = -1): void {
142    if (tableIsHover) {
143      if (SpSegmentationChart.tabHoverObj.cycle === cycle && SpSegmentationChart.tabHoverObj.key === type) {
144        SpSegmentationChart.tabHoverObj = { cycle: -1, key: '' };
145      } else {
146        SpSegmentationChart.tabHoverObj = { cycle, key: type };
147      }
148    } else {
149      SpSegmentationChart.tabHoverObj = { cycle: -1, key: '' };
150    }
151
152    SpSegmentationChart.trace.refreshCanvas(false);
153  }
154  constructor(trace: SpSystemTrace) {
155    SpSegmentationChart.trace = trace;
156  }
157  async init() {
158    if (Utils.getInstance().getCallStatckMap().size > 0) {
159      await this.initFolder();
160      await this.initCpuFreq();
161      await this.initGpuTrace();
162      await this.initSchedTrace();
163      await this.initBinderTrace();
164      await this.initAllStates();
165    } else {
166      return;
167    }
168  }
169  async initFolder() {
170    let row = TraceRow.skeleton();
171    row.rowId = 'segmentation';
172    row.index = 0;
173    row.rowType = TraceRow.ROW_TYPE_SPSEGNENTATION;
174    row.rowParentId = '';
175    row.folder = true;
176    row.style.height = '40px';
177    row.name = 'Segmentation';
178    row.supplier = (): Promise<Array<BaseStruct>> => new Promise<Array<BaseStruct>>((resolve) => resolve([]));
179    row.onThreadHandler = (useCache): void => {
180      row.canvasSave(SpSegmentationChart.trace.canvasPanelCtx!);
181      if (row.expansion) {
182        SpSegmentationChart.trace.canvasPanelCtx?.clearRect(0, 0, row.frame.width, row.frame.height);
183      } else {
184        (renders['empty'] as EmptyRender).renderMainThread(
185          {
186            context: SpSegmentationChart.trace.canvasPanelCtx,
187            useCache: useCache,
188            type: '',
189          },
190          row
191        );
192      }
193      row.canvasRestore(SpSegmentationChart.trace.canvasPanelCtx!);
194    };
195    this.rowFolder = row;
196    SpSegmentationChart.trace.rowsEL?.appendChild(row);
197  }
198  async initCpuFreq() {
199    // json文件泳道
200    SpSegmentationChart.cpuRow = TraceRow.skeleton<CpuFreqExtendStruct>();
201    SpSegmentationChart.cpuRow.rowId = 'cpu-freq';
202    SpSegmentationChart.cpuRow.rowType = TraceRow.ROW_TYPE_CPU_COMPUTILITY;
203    SpSegmentationChart.cpuRow.rowParentId = '';
204    SpSegmentationChart.cpuRow.style.height = '40px';
205    SpSegmentationChart.cpuRow.name = 'Cpu Computility';
206    SpSegmentationChart.cpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler;
207    SpSegmentationChart.cpuRow.addRowCheckFilePop();
208    SpSegmentationChart.cpuRow.rowSetting = 'checkFile';
209    // 拿到了用户传递的数据
210    SpSegmentationChart.cpuRow.onRowCheckFileChangeHandler = (): void => {
211      SpSegmentationChart.freqInfoMapData = new Map<number, Map<number, number>>();
212      if (sessionStorage.getItem('freqInfoData')) {
213        // @ts-ignore
214        let chartData = JSON.parse(JSON.parse(sessionStorage.getItem('freqInfoData')));
215        let mapData = new Map<number, number>();
216        // @ts-ignore
217        chartData.map((v) => {
218          for (let key in v.freqInfo) {
219            mapData.set(Number(key), Number(v.freqInfo[key]));
220          }
221          SpSegmentationChart.freqInfoMapData.set(v.cpuId, mapData);
222          mapData = new Map();
223        });
224      }
225    };
226    SpSegmentationChart.cpuRow.focusHandler = (ev): void => {
227      SpSegmentationChart.trace?.displayTip(
228        SpSegmentationChart.cpuRow!,
229        CpuFreqExtendStruct.hoverStruct,
230        `<span>${CpuFreqExtendStruct.hoverStruct === undefined ? 0 : CpuFreqExtendStruct.hoverStruct.value!
231        }</span>`
232      );
233    };
234    SpSegmentationChart.cpuRow.findHoverStruct = (): void => {
235      CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.cpuRow!.getHoverStruct();
236    };
237    // @ts-ignore
238    SpSegmentationChart.cpuRow.supplier = (): Promise<Array<freqChartDataStruct>> =>
239      new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([]));
240    SpSegmentationChart.cpuRow.onThreadHandler = (useCache): void => {
241      let context: CanvasRenderingContext2D;
242      if (SpSegmentationChart.cpuRow!.currentContext) {
243        context = SpSegmentationChart.cpuRow!.currentContext;
244      } else {
245        context = SpSegmentationChart.cpuRow!.collect
246          ? SpSegmentationChart.trace.canvasFavoritePanelCtx!
247          : SpSegmentationChart.trace.canvasPanelCtx!;
248      }
249      SpSegmentationChart.cpuRow!.canvasSave(context);
250      (renders['freq-extend'] as FreqExtendRender).renderMainThread(
251        {
252          context: context,
253          useCache: useCache,
254          type: 'CPU-FREQ',
255        },
256        SpSegmentationChart.cpuRow!
257      );
258      SpSegmentationChart.cpuRow!.canvasRestore(context);
259    };
260    SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.cpuRow);
261    this.rowFolder!.addChildTraceRow(SpSegmentationChart.cpuRow);
262  }
263  async initGpuTrace() {
264    SpSegmentationChart.GpuRow = TraceRow.skeleton<CpuFreqExtendStruct>();
265    SpSegmentationChart.GpuRow.rowId = 'gpurow';
266    SpSegmentationChart.GpuRow.rowType = TraceRow.ROW_TYPE_GPU_COMPUTILITY;
267    SpSegmentationChart.GpuRow.rowParentId = '';
268    SpSegmentationChart.GpuRow.style.height = '40px';
269    SpSegmentationChart.GpuRow.name = 'Gpu Computility';
270    SpSegmentationChart.GpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler;
271    SpSegmentationChart.GpuRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler;
272    // @ts-ignore
273    SpSegmentationChart.GpuRow.supplier = (): Promise<Array<freqChartDataStruct>> =>
274      new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([]));
275    SpSegmentationChart.GpuRow.focusHandler = (ev): void => {
276      SpSegmentationChart.trace?.displayTip(
277        SpSegmentationChart.GpuRow!,
278        CpuFreqExtendStruct.hoverStruct,
279        `<span>${CpuFreqExtendStruct.hoverStruct === undefined ? 0 : CpuFreqExtendStruct.hoverStruct.value!
280        }</span>`
281      );
282    };
283    SpSegmentationChart.GpuRow.findHoverStruct = (): void => {
284      CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.GpuRow!.getHoverStruct();
285    };
286    SpSegmentationChart.GpuRow.onThreadHandler = (useCache): void => {
287      let context: CanvasRenderingContext2D;
288      if (SpSegmentationChart.GpuRow!.currentContext) {
289        context = SpSegmentationChart.GpuRow!.currentContext;
290      } else {
291        context = SpSegmentationChart.GpuRow!.collect
292          ? SpSegmentationChart.trace.canvasFavoritePanelCtx!
293          : SpSegmentationChart.trace.canvasPanelCtx!;
294      }
295      SpSegmentationChart.GpuRow!.canvasSave(context);
296      (renders['freq-extend'] as FreqExtendRender).renderMainThread(
297        {
298          context: context,
299          useCache: useCache,
300          type: 'GPU-FREQ',
301        },
302        SpSegmentationChart.GpuRow!
303      );
304      SpSegmentationChart.GpuRow!.canvasRestore(context);
305    };
306    SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.GpuRow);
307    this.rowFolder!.addChildTraceRow(SpSegmentationChart.GpuRow);
308  }
309  async initSchedTrace() {
310    SpSegmentationChart.schedRow = TraceRow.skeleton<CpuFreqExtendStruct>();
311    SpSegmentationChart.schedRow.rowId = 'sched_switch Count';
312    SpSegmentationChart.schedRow.rowType = TraceRow.ROW_TYPE_SCHED_SWITCH;
313    SpSegmentationChart.schedRow.rowParentId = '';
314    SpSegmentationChart.schedRow.style.height = '40px';
315    SpSegmentationChart.schedRow.name = 'Sched_switch Count';
316    SpSegmentationChart.schedRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler;
317    SpSegmentationChart.schedRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler;
318    SpSegmentationChart.schedRow.focusHandler = (ev): void => {
319      SpSegmentationChart.trace?.displayTip(
320        SpSegmentationChart.schedRow!,
321        CpuFreqExtendStruct.hoverStruct,
322        `<span>${CpuFreqExtendStruct.hoverStruct?.value!}</span>`
323      );
324    };
325    SpSegmentationChart.schedRow.findHoverStruct = (): void => {
326      CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.schedRow!.getHoverStruct();
327    };
328    // @ts-ignore
329    SpSegmentationChart.schedRow.supplier = (): Promise<Array<freqChartDataStruct>> =>
330      new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([]));
331    SpSegmentationChart.schedRow.onThreadHandler = (useCache): void => {
332      let context: CanvasRenderingContext2D;
333      if (SpSegmentationChart.schedRow!.currentContext) {
334        context = SpSegmentationChart.schedRow!.currentContext;
335      } else {
336        context = SpSegmentationChart.schedRow!.collect
337          ? SpSegmentationChart.trace.canvasFavoritePanelCtx!
338          : SpSegmentationChart.trace.canvasPanelCtx!;
339      }
340      SpSegmentationChart.schedRow!.canvasSave(context);
341      (renders['freq-extend'] as FreqExtendRender).renderMainThread(
342        {
343          context: context,
344          useCache: useCache,
345          type: 'SCHED-SWITCH',
346        },
347        SpSegmentationChart.schedRow!
348      );
349      SpSegmentationChart.schedRow!.canvasRestore(context);
350    };
351    SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.schedRow);
352    this.rowFolder!.addChildTraceRow(SpSegmentationChart.schedRow);
353  }
354
355  async initAllStates() {
356    SpSegmentationChart.statesRow = TraceRow.skeleton<AllstatesStruct>();
357    SpSegmentationChart.statesRow.rowId = `statesrow`;
358    SpSegmentationChart.statesRow.rowType = TraceRow.ROW_TYPE_THREAD;
359    SpSegmentationChart.statesRow.rowParentId = '';
360    SpSegmentationChart.statesRow.style.height = '30px';
361    SpSegmentationChart.statesRow.name = `All States`;
362    SpSegmentationChart.statesRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler;
363    SpSegmentationChart.statesRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler;
364    // @ts-ignore
365    SpSegmentationChart.statesRow.supplier = (): Promise<Array<freqChartDataStruct>> =>
366      new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([]));
367    SpSegmentationChart.statesRow.onThreadHandler = (useCache) => {
368      let context: CanvasRenderingContext2D;
369      if (SpSegmentationChart.statesRow!.currentContext) {
370        context = SpSegmentationChart.statesRow!.currentContext;
371      } else {
372        context = SpSegmentationChart.statesRow!.collect ? SpSegmentationChart.trace.canvasFavoritePanelCtx! : SpSegmentationChart.trace.canvasPanelCtx!;
373      }
374      SpSegmentationChart.statesRow!.canvasSave(context);
375      (renders.stateCut as AllStatesRender).renderMainThread(
376        {
377          context: context,
378          useCache: useCache,
379          type: ``,
380          translateY: SpSegmentationChart.statesRow!.translateY,
381        },
382        SpSegmentationChart.statesRow!
383      );
384      SpSegmentationChart.statesRow!.canvasRestore(context);
385    };
386    SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.statesRow);
387    this.rowFolder!.addChildTraceRow(SpSegmentationChart.statesRow);
388  }
389
390  async initBinderTrace() {
391    SpSegmentationChart.binderRow = TraceRow.skeleton<BinderStruct>();
392    SpSegmentationChart.binderRow.rowId = 'binderrow';
393    SpSegmentationChart.binderRow.rowType = TraceRow.ROW_TYPE_BINDER_COUNT;
394    SpSegmentationChart.binderRow.enableCollapseChart(40, SpSegmentationChart.trace);
395    SpSegmentationChart.binderRow.rowParentId = '';
396    SpSegmentationChart.binderRow.name = 'Binder Count';
397    SpSegmentationChart.binderRow.style.height = '40px';
398    SpSegmentationChart.binderRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler;
399    SpSegmentationChart.binderRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler;
400    SpSegmentationChart.binderRow.findHoverStruct = () => {
401      BinderStruct.hoverCpuFreqStruct = SpSegmentationChart.binderRow!.dataListCache.find((v: BinderStruct) => {
402        if (SpSegmentationChart.binderRow!.isHover) {
403          if (v.frame!.x < SpSegmentationChart.binderRow!.hoverX + 1 &&
404            v.frame!.x + v.frame!.width > SpSegmentationChart.binderRow!.hoverX - 1 &&
405            (BinderStruct.maxHeight * 20 - v.depth * 20 + 20) < SpSegmentationChart.binderRow!.hoverY &&
406            BinderStruct.maxHeight * 20 - v.depth * 20 + v.value * 20 + 20 > SpSegmentationChart.binderRow!.hoverY) {
407            return v;
408          }
409        }
410      })
411    };
412    SpSegmentationChart.binderRow.focusHandler = (ev): void => {
413      SpSegmentationChart.trace!.displayTip(
414        SpSegmentationChart.binderRow!,
415        BinderStruct.hoverCpuFreqStruct,
416        `<span style='font-weight: bold;'>Cycle: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.cycle : 0
417        }</span><br>
418                <span style='font-weight: bold;'>Name: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.name : ''
419        }</span><br>
420                <span style='font-weight: bold;'>Count: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.value : 0
421        }</span>`
422      );
423    };
424
425    SpSegmentationChart.binderRow.supplier = (): Promise<Array<BinderStruct>> =>
426      new Promise<Array<BinderStruct>>((resolve) => resolve([]));
427    SpSegmentationChart.binderRow.onThreadHandler = (useCache): void => {
428      let context: CanvasRenderingContext2D;
429      if (SpSegmentationChart.binderRow!.currentContext) {
430        context = SpSegmentationChart.binderRow!.currentContext;
431      } else {
432        context = SpSegmentationChart.binderRow!.collect
433          ? SpSegmentationChart.trace.canvasFavoritePanelCtx!
434          : SpSegmentationChart.trace.canvasPanelCtx!;
435      }
436      SpSegmentationChart.binderRow!.canvasSave(context);
437      (renders.binder as BinderRender).renderMainThread(
438        {
439          context: context,
440          useCache: useCache,
441          type: 'BINDER',
442        },
443        SpSegmentationChart.binderRow!
444      );
445      SpSegmentationChart.binderRow!.canvasRestore(context);
446    };
447    SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.binderRow);
448    this.rowFolder!.addChildTraceRow(SpSegmentationChart.binderRow);
449  }
450}
451class FreqChartDataStruct {
452  colorIndex?: number = 0;
453  dur: number = 0;
454  value: number = 0;
455  startNS: number = 0;
456  cycle: number = 0;
457  depth?: number = 1;
458  name?: string = '';
459}
460
461function setCpuData(data: Array<FreqChartDataStruct>) {
462  let currentMaxValue = 0;
463  data.map((v: FreqChartDataStruct) => {
464    if (v.value > currentMaxValue) {
465      currentMaxValue = v.value;
466    }
467  });
468  CpuFreqExtendStruct.hoverType = 'CPU-FREQ';
469  CpuFreqExtendStruct.cpuMaxValue = currentMaxValue;
470  SpSegmentationChart.cpuRow!.dataList = [];
471  SpSegmentationChart.cpuRow!.dataListCache = [];
472  SpSegmentationChart.cpuRow!.isComplete = false;
473  // @ts-ignore
474  SpSegmentationChart.cpuRow!.supplier = (): Promise<Array<FreqChartDataStruct>> =>
475    new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data));
476}
477function setGpuData(data: Array<FreqChartDataStruct>): void {
478  let currentMaxValue = 0;
479  data.map((v: FreqChartDataStruct) => {
480    if (v.value && v.value > currentMaxValue!) {
481      currentMaxValue = v.value;
482    }
483  });
484  CpuFreqExtendStruct.hoverType = 'GPU-FREQ';
485  CpuFreqExtendStruct.gpuMaxValue = currentMaxValue;
486  SpSegmentationChart.GpuRow!.dataList = [];
487  SpSegmentationChart.GpuRow!.dataListCache = [];
488  SpSegmentationChart.GpuRow!.isComplete = false;
489  // @ts-ignore
490  SpSegmentationChart.GpuRow!.supplier = (): Promise<Array<FreqChartDataStruct>> =>
491    new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data));
492}
493function setSchedData(data: Array<FreqChartDataStruct>): void {
494  let currentMaxValue = 0;
495  data.map((v: FreqChartDataStruct) => {
496    if (v.value && v.value > currentMaxValue!) {
497      currentMaxValue = v.value;
498    }
499  });
500  CpuFreqExtendStruct.hoverType = 'SCHED-SWITCH';
501  CpuFreqExtendStruct.schedMaxValue = currentMaxValue!;
502  SpSegmentationChart.schedRow!.dataList = [];
503  SpSegmentationChart.schedRow!.dataListCache = [];
504  SpSegmentationChart.schedRow!.isComplete = false;
505  // @ts-ignore
506  SpSegmentationChart.schedRow!.supplier = (): Promise<Array<FreqChartDataStruct>> =>
507    new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data));
508}
509function setBinderData(data: Array<Array<FreqChartDataStruct>>, binderList: Array<FreqChartDataStruct>): void {
510  data.map((v: Array<FreqChartDataStruct>) => {
511    // 统计每一竖列的最大count
512    let listCount = 0;
513    v.map((t: FreqChartDataStruct) => {
514      listCount += t.value;
515      if (t.name === 'binder transaction') {
516        t.depth = t.value;
517      }
518      if (t.name === 'binder transaction async') {
519        t.depth =
520          t.value +
521          (v.filter((i: FreqChartDataStruct) => {
522            return i.name === 'binder transaction';
523          }).length > 0
524            ? v.filter((i: FreqChartDataStruct) => {
525              return i.name === 'binder transaction';
526            })[0].value
527            : 0);
528      }
529      if (t.name === 'binder reply') {
530        t.depth =
531          t.value +
532          (v.filter((i: FreqChartDataStruct) => {
533            return i.name === 'binder transaction';
534          }).length > 0
535            ? v.filter((i: FreqChartDataStruct) => {
536              return i.name === 'binder transaction';
537            })[0].value
538            : 0) +
539          (v.filter((i: FreqChartDataStruct) => {
540            return i.name === 'binder transaction async';
541          }).length > 0
542            ? v.filter((i: FreqChartDataStruct) => {
543              return i.name === 'binder transaction async';
544            })[0].value
545            : 0);
546      }
547      if (t.name === 'binder async rcv') {
548        t.depth =
549          t.value +
550          (v.filter((i: FreqChartDataStruct) => {
551            return i.name === 'binder transaction';
552          }).length > 0
553            ? v.filter((i: FreqChartDataStruct) => {
554              return i.name === 'binder transaction';
555            })[0].value
556            : 0) +
557          (v.filter((i: FreqChartDataStruct) => {
558            return i.name === 'binder transaction async';
559          }).length > 0
560            ? v.filter((i: FreqChartDataStruct) => {
561              return i.name === 'binder transaction async';
562            })[0].value
563            : 0) +
564          (v.filter((i: FreqChartDataStruct) => {
565            return i.name === 'binder reply';
566          }).length > 0
567            ? v.filter((i: FreqChartDataStruct) => {
568              return i.name === 'binder reply';
569            })[0].value
570            : 0);
571      }
572      binderList.push(t);
573    });
574    BinderStruct.maxHeight =
575      BinderStruct.maxHeight > listCount ? BinderStruct.maxHeight : JSON.parse(JSON.stringify(listCount));
576    listCount = 0;
577  });
578}
579
580class HeightLine {
581  key: string = '';
582  cycle: number = -1;
583}
584