• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { SampleType } from '../database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.js';
17const ROW_TYPE = 'cpu-profiler';
18export class JsCpuProfilerUIStruct {
19  name: string;
20  depth: number;
21  selfTime: number;
22  totalTime: number;
23  url: string;
24  line: number;
25  column: number;
26  scriptName: string;
27  id: number;
28  parentId: number;
29
30  constructor(
31    id: number,
32    name: string,
33    depth: number,
34    selfTime: number,
35    totalTime: number,
36    url: string,
37    line: number,
38    column: number
39  ) {
40    this.id = id;
41    this.parentId = -1;
42    this.name = name;
43    this.depth = depth;
44    this.selfTime = selfTime;
45    this.totalTime = totalTime;
46    this.url = url;
47    this.line = line;
48    this.column = column;
49    this.scriptName = '';
50    if (url) {
51      let dirs = url.split('/');
52      this.scriptName = dirs.pop() || '';
53    }
54  }
55}
56
57export class JsCpuProfilerChartFrame extends JsCpuProfilerUIStruct {
58  startTime: number;
59  endTime: number;
60  children: Array<JsCpuProfilerChartFrame>;
61  samplesIds: Array<number>;
62  isSelect: boolean = false;
63  parent?: JsCpuProfilerChartFrame;
64
65  constructor(
66    id: number,
67    name: string,
68    startTime: number,
69    endTime: number,
70    totalTime: number,
71    depth: number,
72    url: string,
73    line: number,
74    column: number
75  ) {
76    super(id, name, depth, 0, totalTime, url, line, column);
77    this.id = id;
78    this.startTime = startTime;
79    this.endTime = endTime;
80    this.children = new Array<JsCpuProfilerChartFrame>();
81    this.samplesIds = new Array<number>();
82  }
83}
84
85export class JsCpuProfilerTabStruct extends JsCpuProfilerUIStruct {
86  rowName = ROW_TYPE;
87  parent?: JsCpuProfilerTabStruct | null | undefined;
88  children: Array<JsCpuProfilerTabStruct>;
89  chartFrameChildren?: Array<JsCpuProfilerChartFrame>;
90  isSelected: boolean = false; //select data line
91  totalTimePercent: string = '';
92  selfTimePercent: string = '';
93  symbolName: string = ''; // function name + scriptName
94  selfTimeStr: string = ''; //selfTime unit conversion
95  totalTimeStr: string = ''; //totalTime unit conversion
96  isSearch: boolean = false; //filter data bold
97
98  constructor(
99    name: string,
100    selfTime: number,
101    totalTime: number,
102    depth: number,
103    url: string,
104    line: number,
105    column: number,
106    id: number
107  ) {
108    super(id, name, depth, selfTime, totalTime, url, line, column);
109    this.chartFrameChildren = new Array<JsCpuProfilerChartFrame>();
110    this.children = new Array<JsCpuProfilerTabStruct>();
111  }
112}
113
114export class JsCpuProfilerStatisticsStruct {
115  type: SampleType | string;
116  time: number = 0;
117  timeStr: string = '';
118  percentage: string = '';
119  constructor(type: SampleType | string, time: number, timeStr: string, percentage: string) {
120    this.type = type;
121    this.time = time;
122    this.timeStr = timeStr;
123    this.percentage = percentage;
124  }
125}
126