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