From f1c1efe1dc2ea97e0302cd7608445356026d5b48 Mon Sep 17 00:00:00 2001 From: zhangzepeng Date: Mon, 31 Jul 2023 19:45:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=80=99Feat:Perf=EF=BC=9Abottom-up?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzepeng --- ide/src/trace/bean/PerfBottomUpStruct.ts | 49 +++ .../component/trace/base/TraceSheetConfig.ts | 6 + .../trace/sheet/hiperf/TabPerfBottomUp.ts | 308 ++++++++++++++++++ .../component/trace/timer-shaft/RangeRuler.ts | 6 +- .../logic-worker/ProcedureLogicWorkerPerf.ts | 218 +++++++++++-- 5 files changed, 548 insertions(+), 39 deletions(-) create mode 100644 ide/src/trace/bean/PerfBottomUpStruct.ts create mode 100644 ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts diff --git a/ide/src/trace/bean/PerfBottomUpStruct.ts b/ide/src/trace/bean/PerfBottomUpStruct.ts new file mode 100644 index 000000000..59f8fdde1 --- /dev/null +++ b/ide/src/trace/bean/PerfBottomUpStruct.ts @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ + +export class PerfBottomUpStruct { + parentNode: PerfBottomUpStruct | undefined; + symbolName: string; + selfTime: number = 0; + selfTimeStr?: string; + selfTimePercent: string = ''; + totalTime: number = 0; + totalTimeStr?: string; + totalTimePercent: string = ''; + children: Array; + frameChildren?: Array; + isSearch: boolean = false; + isSelected: boolean = false; + constructor( + symbolName: string, + ) { + this.symbolName = symbolName; + this.children = []; + } + + addChildren(child: PerfBottomUpStruct): void { + child.parentNode = this; + this.children.push(child); + } + + notifyParentUpdateSelfTime(): void { + this.parentNode?.calculateSelfTime(); + } + + calculateSelfTime(): void { + const sum = this.children.reduce((total, obj) => total + obj.totalTime, 0); + this.selfTime = this.totalTime - sum; + } +} diff --git a/ide/src/trace/component/trace/base/TraceSheetConfig.ts b/ide/src/trace/component/trace/base/TraceSheetConfig.ts index 0fd7bbbf9..6165c7602 100644 --- a/ide/src/trace/component/trace/base/TraceSheetConfig.ts +++ b/ide/src/trace/component/trace/base/TraceSheetConfig.ts @@ -101,6 +101,7 @@ import { TabPaneGpuMemoryVmTracker } from '../sheet/vmtracker/TabPaneGpuMemoryVm import { TabPaneGpuMemorySelectAbility } from '../sheet/ability/TabPaneGpuMemorySelectAbility.js'; import { TabPaneGpuMemorySelectVmTracker } from '../sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.js'; import { TabPaneDmaSelectVmTracker } from '../sheet/vmtracker/TabPaneDmaSelectVmTracker.js'; +import { TabpanePerfBottomUp } from '../sheet/hiperf/TabPerfBottomUp.js'; export let tabConfig: any = { 'tabpane-current': { @@ -237,6 +238,11 @@ export let tabConfig: any = { type: TabPanePerfAnalysis, require: (param: SelectionParam) => param.perfSampleIds.length > 0, }, + 'box-perf-bottom-up': { + title: 'Bottom Up', + type: TabpanePerfBottomUp, + require: (param: SelectionParam) => param.perfSampleIds.length > 0, + }, 'box-perf-profile': { title: 'Perf Profile', type: TabpanePerfProfile, diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts new file mode 100644 index 000000000..ff2419e2f --- /dev/null +++ b/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts @@ -0,0 +1,308 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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 { BaseElement, element } from '../../../../../base-ui/BaseElement.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import '../TabPaneFilter.js'; +import { FilterData, TabPaneFilter } from '../TabPaneFilter.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import '../../../chart/FrameChart.js'; +import '../../../DisassemblingWindow.js'; +import '../../../../../base-ui/slicer/lit-slicer.js'; +import '../../../../../base-ui/progress-bar/LitProgressBar.js'; +import { procedurePool } from '../../../../database/Procedure.js'; +import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar.js'; +import { PerfBottomUpStruct } from '../../../../bean/PerfBottomUpStruct.js'; + +@element('tabpane-perf-bottom-up') +export class TabpanePerfBottomUp extends BaseElement { + private treeTable: HTMLDivElement | undefined | null; + private bottomUpTable: LitTable | null | undefined; + private stackTable: LitTable | null | undefined; + private sortKey = ''; + private sortType = 0; + private bottomUpSource: Array = []; + private bottomUpFilter: TabPaneFilter | undefined | null; + private progressEL: LitProgressBar | null | undefined; + private searchValue: string = ''; + public initElements(): void { + this.bottomUpTable = this.shadowRoot?.querySelector('#callTreeTable') as LitTable; + this.stackTable = this.shadowRoot?.querySelector('#stackTable') as LitTable; + this.treeTable = this.bottomUpTable!.shadowRoot?.querySelector('.thead') as HTMLDivElement; + this.progressEL = this.shadowRoot?.querySelector('.progress') as LitProgressBar; + this.bottomUpFilter = this.shadowRoot?.querySelector('#filter') as TabPaneFilter; + this.bottomUpTable!.addEventListener('row-click', (evt) => this.bottomUpTableRowClickHandler(evt)); + this.stackTable!.addEventListener('row-click', (evt) => this.stackTableRowClick(evt)); + this.bottomUpTable!.addEventListener('column-click', (evt) => this.bottomUpTableColumnClickHandler(evt)); + this.bottomUpFilter!.getFilterData((data: FilterData) => { + if (this.searchValue !== this.bottomUpFilter!.filterValue) { + this.searchValue = this.bottomUpFilter!.filterValue; + this.findSearchNode(this.bottomUpSource, this.searchValue); + this.setBottomUpTableData(this.bottomUpSource); + } + }); + } + + private getDataByWorker(val: SelectionParam, handler: (results: Array) => void): void { + this.progressEL!.loading = true; + const args = [ + { + funcName: 'setPerfBottomUp', + funcArgs: [''], + }, + { + funcName: 'setSearchValue', + funcArgs: [''], + }, + { + funcName: 'getCurrentDataFromDb', + funcArgs: [val], + }, + ]; + procedurePool.submitWithName('logic0', 'perf-action', args, undefined, (results: Array) => { + handler(results); + this.progressEL!.loading = false; + }); + } + + set data(data: SelectionParam) { + if (data instanceof SelectionParam) { + this.sortKey = ''; + this.sortType = 0; + this.bottomUpFilter!.filterValue = ''; + this.getDataByWorker(data, (results: Array) => { + this.setBottomUpTableData(results); + }); + } + } + + private setBottomUpTableData(results: Array): void { + const percentageDenominator = 100; + const percentFraction = 1; + const timeFractionDigits = 2; + this.stackTable!.recycleDataSource = []; + this.bottomUpTable!.recycleDataSource = []; + let totalTime = results.reduce((sum, struct) => sum + struct.selfTime, 0); + const setTabData = (array: Array): void => { + array.forEach((data) => { + data.totalTimePercent = `${ ((data.totalTime / totalTime) * percentageDenominator).toFixed(percentFraction) }%`; + data.selfTimePercent = `${ ((data.selfTime / totalTime) * percentageDenominator).toFixed(percentFraction) }%`; + data.selfTimeStr = `${ data.selfTime.toFixed(timeFractionDigits) }ms`; + data.totalTimeStr = `${ data.totalTime.toFixed(timeFractionDigits) }ms`; + setTabData(data.children); + }); + }; + setTabData(results); + this.bottomUpSource = this.sortTree(results); + this.bottomUpTable!.recycleDataSource = this.bottomUpSource; + } + + private bottomUpTableRowClickHandler(evt: Event): void { + const callStack: Array = []; + const getCallStackChildren = (children: Array): void => { + if (children.length === 0) { + return; + } + const heaviestChild = children.reduce((max, struct) => + Math.max(max.totalTime, struct.totalTime) === max.totalTime ? max : struct + ); + callStack?.push(heaviestChild); + getCallStackChildren(heaviestChild.children); + }; + const getParent = (list: PerfBottomUpStruct): void => { + if (list.parentNode && list.parentNode!.symbolName !== 'root') { + callStack.push(list.parentNode!); + getParent(list.parentNode!); + } + }; + + //@ts-ignore + const data = evt.detail.data as PerfBottomUpStruct; + callStack!.push(data); + if (data.parentNode && data.parentNode!.symbolName !== 'root') { + callStack.push(data.parentNode!); + getParent(data.parentNode!); + } + callStack.reverse(); + getCallStackChildren(data.children); + this.stackTable!.recycleDataSource = callStack; + data.isSelected = true; + this.stackTable?.clearAllSelection(data); + this.stackTable?.setCurrentSelection(data); + // @ts-ignore + if (evt.detail.callBack) { + // @ts-ignore + evt.detail.callBack(true); + } + } + + private bottomUpTableColumnClickHandler(evt: Event): void { + // @ts-ignore + this.sortKey = evt.detail.key; + // @ts-ignore + this.sortType = evt.detail.sort; + this.setBottomUpTableData(this.bottomUpSource); + } + private stackTableRowClick(evt: Event): void { + //@ts-ignore + const data = evt.detail.data as PerfBottomUpStruct; + data.isSelected = true; + this.bottomUpTable!.clearAllSelection(data); + this.bottomUpTable!.scrollToData(data); + // @ts-ignore + if (evt.detail.callBack) { + // @ts-ignore + evt.detail.callBack(true); + } + } + private findSearchNode(sampleArray: PerfBottomUpStruct[], search: string): void { + search = search.toLocaleLowerCase(); + sampleArray.forEach((sample) => { + if (sample.symbolName && sample.symbolName.toLocaleLowerCase().includes(search)) { + sample.isSearch = sample.symbolName !== undefined && sample.symbolName.toLocaleLowerCase().includes(search); + } else { + sample.isSearch = false; + } + if (search === '') { + sample.isSearch = false; + } + if (sample.children.length > 0) { + this.findSearchNode(sample.children, search); + } + }); + } + + + public connectedCallback(): void { + const tableOffsetHeight = 32; + const spanHeight = 22; + super.connectedCallback(); + new ResizeObserver(() => { + // @ts-ignore + this.bottomUpTable?.shadowRoot.querySelector('.table').style.height = `${ + this.parentElement!.clientHeight - tableOffsetHeight + }px`; + this.bottomUpTable?.reMeauseHeight(); + // @ts-ignore + this.stackTable?.shadowRoot.querySelector('.table').style.height = `${ + this.parentElement!.clientHeight - tableOffsetHeight - spanHeight + }px`; + this.stackTable?.reMeauseHeight(); + }).observe(this.parentElement!); + } + + private sortTree(arr: Array): Array { + const defaultSortType = 0; + function defaultSort(callTreeLeftData: PerfBottomUpStruct, callTreeRightData: PerfBottomUpStruct): number { + return callTreeRightData.totalTime - callTreeLeftData.totalTime; + } + const CallTreeSortArr = arr.sort((callTreeLeftData, callTreeRightData) => { + if (this.sortKey === 'selfTimeStr' || this.sortKey === 'selfTimePercent') { + if (this.sortType === defaultSortType) { + return defaultSort(callTreeLeftData, callTreeRightData); + } else if (this.sortType === 1) { + return callTreeLeftData.selfTime - callTreeRightData.selfTime; + } else { + return callTreeRightData.selfTime - callTreeLeftData.selfTime; + } + } else if (this.sortKey === 'symbolName') { + if (this.sortType === defaultSortType) { + return defaultSort(callTreeLeftData, callTreeRightData); + } else if (this.sortType === 1) { + return `${ callTreeLeftData.symbolName }`.localeCompare(`${ callTreeRightData.symbolName }`); + } else { + return `${ callTreeRightData.symbolName }`.localeCompare(`${ callTreeLeftData.symbolName }`); + } + } else { + if (this.sortType === defaultSortType) { + return defaultSort(callTreeLeftData, callTreeRightData); + } else if (this.sortType === 1) { + return callTreeLeftData.totalTime - callTreeRightData.totalTime; + } else { + return callTreeRightData.totalTime - callTreeLeftData.totalTime; + } + } + }); + + CallTreeSortArr.map((call) => { + call.children = this.sortTree(call.children); + }); + return CallTreeSortArr; + } + + private initHtmlStyle(): string { + return ` + + `; + } + public initHtml(): string { + return ` + ${ this.initHtmlStyle() } +
+ + +
+ + + + + + + +
+ +
+
+ Call Stack + + + + + +
+
+
+
+ + +
+ `; + } +} diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts index eb00a1cc6..c25b22a8f 100644 --- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts @@ -951,10 +951,10 @@ export class RangeRuler extends Graph { count2++; } } - if (count2 >= 10) { - return; - } if (totalX <= FIT_TOTALX_MIN) { + if (count2 >= 10) { + return; + } this.pressFrameIdW = requestAnimationFrame(animW); this.fillX(); this.range.refresh = true; diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts index 2c6ad1841..054c6f57e 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts @@ -14,6 +14,8 @@ */ import { LogicHandler, ChartStruct, convertJSON, DataCache, PerfCall } from './ProcedureLogicWorkerCommon.js'; +import { PerfBottomUpStruct } from '../../bean/PerfBottomUpStruct.js'; + const systemRuleName = '/system/'; const numRuleName = '/max/min/'; @@ -32,6 +34,8 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { isActualQuery: boolean = false; currentEventId: string = ''; isAnalysis: boolean = false; + isPerfBottomUp: boolean = false; + private dataCache = DataCache.getInstance(); handle(data: any): void { @@ -60,7 +64,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { break; case 'perf-queryPerfCalls': let perfCalls = convertJSON(data.params.list) || []; - if (perfCalls.length != 0) { + if (perfCalls.length !== 0) { perfCalls.forEach((perfCall: any) => { this.dataCache.perfCallChainMap.set(perfCall.sampleId, perfCall); }); @@ -79,7 +83,6 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { break; case 'perf-queryCallchainsGroupSample': this.samplesData = convertJSON(data.params.list) || []; - let result; if (this.isAnalysis) { result = this.resolvingAction([ @@ -88,6 +91,13 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { funcArgs: [true], }, ]); + } else if (this.isPerfBottomUp) { + result = this.resolvingAction([ + { + funcName: 'getBottomUp', + funcArgs: [true], + }, + ]); } else { result = this.resolvingAction([ { @@ -126,7 +136,8 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { this.queryData( this.currentEventId, 'perf-queryPerfFiles', - `select file_id as fileId,symbol,path from perf_files`, + `select file_id as fileId, symbol, path + from perf_files`, {} ); } @@ -135,7 +146,9 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { this.queryData( this.currentEventId, 'perf-queryPerfThread', - `select a.thread_id as tid,a.thread_name as threadName,a.process_id as pid,b.thread_name as processName from perf_thread a left join (select * from perf_thread where thread_id = process_id) b on a.process_id = b.thread_id`, + `select a.thread_id as tid, a.thread_name as threadName, a.process_id as pid, b.thread_name as processName + from perf_thread a + left join (select * from perf_thread where thread_id = process_id) b on a.process_id = b.thread_id`, {} ); } @@ -144,10 +157,10 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { this.queryData( this.currentEventId, 'perf-queryPerfCalls', - `select count(callchain_id) as depth,callchain_id as sampleId,name -from perf_callchain -where callchain_id != -1 -group by callchain_id`, + `select count(callchain_id) as depth, callchain_id as sampleId, name + from perf_callchain + where callchain_id != -1 + group by callchain_id`, {} ); } @@ -156,9 +169,13 @@ group by callchain_id`, this.queryData( this.currentEventId, 'perf-queryPerfCallchains', - `select c.name,c.callchain_id as sampleId,c.vaddr_in_file as vaddrInFile,c.file_id as fileId,c.symbol_id as symbolId -from perf_callchain c -where callchain_id != -1;`, + `select c.name, + c.callchain_id as sampleId, + c.vaddr_in_file as vaddrInFile, + c.file_id as fileId, + c.symbol_id as symbolId + from perf_callchain c + where callchain_id != -1;`, {} ); } @@ -169,26 +186,31 @@ where callchain_id != -1;`, let threads = selectionParam.perfAll ? [] : selectionParam.perfThread; let sql = ''; if (cpus.length != 0 || processes.length != 0 || threads.length != 0) { - let arg1 = cpus.length > 0 ? `or s.cpu_id in (${cpus.join(',')}) ` : ''; - let arg2 = processes.length > 0 ? `or thread.process_id in (${processes.join(',')}) ` : ''; - let arg3 = threads.length > 0 ? `or s.thread_id in (${threads.join(',')})` : ''; - let arg = `${arg1}${arg2}${arg3}`.substring(3); - sql = ` and (${arg})`; + let arg1 = cpus.length > 0 ? `or s.cpu_id in (${ cpus.join(',') }) ` : ''; + let arg2 = processes.length > 0 ? `or thread.process_id in (${ processes.join(',') }) ` : ''; + let arg3 = threads.length > 0 ? `or s.thread_id in (${ threads.join(',') })` : ''; + let arg = `${ arg1 }${ arg2 }${ arg3 }`.substring(3); + sql = ` and (${ arg })`; } this.queryData( this.currentEventId, 'perf-queryCallchainsGroupSample', ` -select p.callchain_id as sampleId, p.thread_state as threadState, p.thread_id as tid, p.count, p.process_id as pid,p.event_count as eventCount -from (select callchain_id, s.thread_id, thread_state, process_id, count(callchain_id) as count,event_count - from perf_sample s, - trace_range t - left join perf_thread thread on s.thread_id = thread.thread_id - where timestamp_trace between $startTime + t.start_ts and $endTime + t.start_ts - and callchain_id != -1 - and s.thread_id != 0 - ${sql} - group by callchain_id, s.thread_id, thread_state, process_id) p`, + select p.callchain_id as sampleId, + p.thread_state as threadState, + p.thread_id as tid, + p.count, + p.process_id as pid, + p.event_count as eventCount + from (select callchain_id, s.thread_id, thread_state, process_id, count(callchain_id) as count,event_count + from perf_sample s, trace_range t + left join perf_thread thread + on s.thread_id = thread.thread_id + where timestamp_trace between $startTime + t.start_ts + and $endTime + t.start_ts + and callchain_id != -1 + and s.thread_id != 0 ${ sql } + group by callchain_id, s.thread_id, thread_state, process_id) p`, { $startTime: selectionParam.leftNs, $endTime: selectionParam.rightNs, @@ -337,7 +359,7 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai if (rootMerageMap[merageData.pid] == undefined) { let processMerageData = new PerfCallChainMerageData(); //新增进程的节点数据 processMerageData.canCharge = false; - processMerageData.symbolName = this.threadData[merageData.tid].processName || `Process(${merageData.pid})`; + processMerageData.symbolName = this.threadData[merageData.tid].processName || `Process(${ merageData.pid })`; processMerageData.symbol = processMerageData.symbolName; processMerageData.tid = merageData.tid; processMerageData.children.push(merageData); @@ -407,7 +429,7 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai groupNewTreeNoId(sampleIds: string[], isTopDown: boolean): any[] { this.currentTreeMapData = {}; this.currentTreeList = []; - for (let i = 0; i < sampleIds.length; i++) { + for (let i = 0 ; i < sampleIds.length ; i++) { let callChains = this.callChainData[sampleIds[i]]; if (callChains == undefined) continue; let topIndex = isTopDown ? 0 : callChains.length - 1; @@ -428,7 +450,7 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai if (rootMerageMap[merageData.pid] == undefined) { let processMerageData = new PerfCallChainMerageData(); //新增进程的节点数据 processMerageData.canCharge = false; - processMerageData.symbolName = this.threadData[merageData.tid].processName || `Process(${merageData.pid})`; + processMerageData.symbolName = this.threadData[merageData.tid].processName || `Process(${ merageData.pid })`; processMerageData.symbol = processMerageData.symbolName; processMerageData.tid = merageData.tid; processMerageData.children.push(merageData); @@ -530,7 +552,7 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai recursionPruneTree(sample: PerfCallChainMerageData, symbolName: string, isSymbol: boolean) { if ((isSymbol && sample.symbolName == symbolName) || (!isSymbol && sample.libName == symbolName)) { sample.currentTreeParentNode && - sample.currentTreeParentNode.children.splice(sample.currentTreeParentNode.children.indexOf(sample), 1); + sample.currentTreeParentNode.children.splice(sample.currentTreeParentNode.children.indexOf(sample), 1); } else { sample.children.forEach((child) => { this.recursionPruneTree(child, symbolName, isSymbol); @@ -716,8 +738,13 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai case 'setCombineCallChain': this.isAnalysis = true; break; + case 'setPerfBottomUp': + this.isPerfBottomUp = true; + break; case 'combineAnalysisCallChain': return this.combineCallChainForAnalysis(); + case 'getBottomUp': + return this.getBottomUp(); } } } @@ -755,6 +782,125 @@ from (select callchain_id, s.thread_id, thread_state, process_id, count(callchai } return sampleCallChainList; } + + getBottomUp() { + const topUp = new PerfBottomUpStruct('topUp'); + let perfTime = this.dataCache.perfCountToMs; + for (let sample of this.samplesData) { + let currentNode = topUp; + let callChains = this.callChainData[sample.sampleId]; + for (let i = 0 ; i < callChains.length ; i++) { + if (i === 0) { + currentNode = topUp; + } + let item = callChains[i]; + const existingNode = currentNode.children.find(child => child.symbolName === item.name + '(' + item.fileName + ')'); + if (existingNode) { + currentNode = existingNode; + existingNode.totalTime += perfTime * sample.count; + existingNode.calculateSelfTime(); + existingNode.notifyParentUpdateSelfTime(); + } else { + let newNode = new PerfBottomUpStruct(item.name + '(' + item.fileName + ')'); + newNode.totalTime = perfTime * sample.count; + currentNode.addChildren(newNode); + newNode.calculateSelfTime(); + newNode.notifyParentUpdateSelfTime(); + currentNode = newNode; + } + } + } + topUp.children.forEach(child => { + child.parentNode = undefined; + }); + + let date = this.topUpDataToBottomUpData(topUp.children); + if (this.isPerfBottomUp) { + this.isPerfBottomUp = false; + } + return date; + } + + private topUpDataToBottomUpData(perfPositiveArray: Array): Array { + let reverseTreeArray: Array = []; + const recursionTree = (perfBottomUpStruct: PerfBottomUpStruct) => { + if (perfBottomUpStruct.selfTime > 0) { + const clonePerfBottomUpStruct = new PerfBottomUpStruct( + perfBottomUpStruct.symbolName, + ); + clonePerfBottomUpStruct.selfTime = perfBottomUpStruct.selfTime; + clonePerfBottomUpStruct.totalTime = perfBottomUpStruct.totalTime; + reverseTreeArray.push(clonePerfBottomUpStruct); + this.copyParentNode(clonePerfBottomUpStruct, perfBottomUpStruct); + } + if (perfBottomUpStruct.children.length > 0) { + for (const children of perfBottomUpStruct.children) { + children.parentNode = perfBottomUpStruct; + recursionTree(children); + } + } + }; + for (const perfBottomUpStruct of perfPositiveArray) { + recursionTree(perfBottomUpStruct); + } + return this.mergeTreeBifurcation(reverseTreeArray, null); + } + + private mergeTreeBifurcation( + reverseTreeArray: Array | null, + parent: PerfBottomUpStruct | null + ): Array { + const sameSymbolMap = new Map(); + const currentLevelData = new Array(); + const dataArray = reverseTreeArray || parent?.frameChildren; + if (!dataArray) { + return []; + } + for (const perfBottomUpStruct of dataArray) { + let symbolKey = perfBottomUpStruct.symbolName; + let bottomUpStruct: PerfBottomUpStruct; + if (sameSymbolMap.has(symbolKey)) { + bottomUpStruct = sameSymbolMap.get(symbolKey)!; + bottomUpStruct.totalTime += perfBottomUpStruct.totalTime; + bottomUpStruct.selfTime += perfBottomUpStruct.selfTime; + } else { + bottomUpStruct = perfBottomUpStruct; + sameSymbolMap.set(symbolKey, bottomUpStruct); + currentLevelData.push(bottomUpStruct); + if (parent) { + parent.addChildren(bottomUpStruct); + } + } + bottomUpStruct.frameChildren?.push(...perfBottomUpStruct.children); + } + + for (const data of currentLevelData) { + this.mergeTreeBifurcation(null, data); + data.frameChildren = []; + } + if (reverseTreeArray) { + return currentLevelData; + } else { + return []; + } + } + + + /** + * copy整体调用链,从栈顶函数一直copy到栈底函数, + * 给Parent设置selfTime,totalTime设置为children的selfTime,totalTime + * */ + private copyParentNode(perfBottomUpStruct: PerfBottomUpStruct, bottomUpStruct: PerfBottomUpStruct): void { + if (bottomUpStruct.parentNode) { + const copyParent = new PerfBottomUpStruct( + bottomUpStruct.parentNode.symbolName, + ); + copyParent.selfTime = perfBottomUpStruct.selfTime; + copyParent.totalTime = perfBottomUpStruct.totalTime; + perfBottomUpStruct.addChildren(copyParent); + this.copyParentNode(copyParent, bottomUpStruct.parentNode); + } + } } export class PerfFile { @@ -876,8 +1022,8 @@ export class PerfCallChainMerageData extends ChartStruct { set total(data: number) { this.#total = data; - this.weight = `${timeMsFormat2p(this.dur * (DataCache.getInstance().perfCountToMs || 1))}`; - this.weightPercent = `${((this.dur / data) * 100).toFixed(1)}%`; + this.weight = `${ timeMsFormat2p(this.dur * (DataCache.getInstance().perfCountToMs || 1)) }`; + this.weightPercent = `${ ((this.dur / data) * 100).toFixed(1) }%`; } get total() { @@ -886,13 +1032,13 @@ export class PerfCallChainMerageData extends ChartStruct { static merageCallChain(currentNode: PerfCallChainMerageData, callChain: PerfCallChain, isTopDown: boolean) { if (currentNode.symbolName == '') { - currentNode.symbol = `${callChain.name} ${callChain.fileName ? `(${callChain.fileName})` : ''}`; + currentNode.symbol = `${ callChain.name } ${ callChain.fileName ? `(${ callChain.fileName })` : '' }`; currentNode.symbolName = callChain.name; currentNode.pid = callChain.pid; currentNode.tid = callChain.tid; currentNode.libName = callChain.fileName; currentNode.vaddrInFile = callChain.vaddrInFile; - currentNode.addr = `${'0x'}${callChain.vaddrInFile.toString(16)}`; + currentNode.addr = `${ '0x' }${ callChain.vaddrInFile.toString(16) }`; currentNode.lib = currentNode.libName; currentNode.canCharge = callChain.canCharge; if (callChain.path) { @@ -914,14 +1060,14 @@ export class PerfCallChainMerageData extends ChartStruct { isEnd: boolean ) { if (currentNode.symbolName == '') { - currentNode.symbol = `${callChain.name} ${callChain.fileName ? `(${callChain.fileName})` : ''}`; + currentNode.symbol = `${ callChain.name } ${ callChain.fileName ? `(${ callChain.fileName })` : '' }`; currentNode.symbolName = callChain.name; currentNode.pid = sample.pid; currentNode.tid = sample.tid; currentNode.libName = callChain.fileName; currentNode.vaddrInFile = callChain.vaddrInFile; currentNode.lib = callChain.fileName; - currentNode.addr = `${'0x'}${callChain.vaddrInFile.toString(16)}`; + currentNode.addr = `${ '0x' }${ callChain.vaddrInFile.toString(16) }`; currentNode.canCharge = callChain.canCharge; if (callChain.path) { currentNode.path = callChain.path; -- Gitee From 69af67d93129aade697bcbceef6a94e0d4aa7cb4 Mon Sep 17 00:00:00 2001 From: zhangzepeng Date: Mon, 31 Jul 2023 19:49:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E2=80=99Fix:=E4=BF=AE=E5=A4=8D=E5=8A=A8?= =?UTF-8?q?=E6=95=88=E6=A8=A1=E6=9D=BF=E6=A1=86=E9=80=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E5=92=8C=E5=B8=A7=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzepeng --- ide/src/base-ui/checkbox/LitCheckBox.ts | 1 + ide/src/base-ui/tabs/lit-tabs.ts | 1 + ide/src/trace/component/SpSystemTrace.ts | 219 ++++-------------- ide/src/trace/component/Utils.ts | 13 +- .../trace/component/chart/SpFrameTimeChart.ts | 3 +- .../component/trace/base/TraceSheetConfig.ts | 1 + .../trace/sheet/smaps/TabPaneSmapsRecord.ts | 1 + .../sheet/smaps/TabPaneSmapsStatistics.ts | 1 + .../trace/sheet/task/TabPaneTaskFrames.ts | 25 +- 9 files changed, 80 insertions(+), 185 deletions(-) diff --git a/ide/src/base-ui/checkbox/LitCheckBox.ts b/ide/src/base-ui/checkbox/LitCheckBox.ts index 590cb6bdd..757e56427 100644 --- a/ide/src/base-ui/checkbox/LitCheckBox.ts +++ b/ide/src/base-ui/checkbox/LitCheckBox.ts @@ -77,6 +77,7 @@ export class LitCheckBox extends BaseElement { cursor:pointer; display:flex; align-items:center; + gap: 12px; } .chekebox{ position:relative; diff --git a/ide/src/base-ui/tabs/lit-tabs.ts b/ide/src/base-ui/tabs/lit-tabs.ts index aa2958fbb..2bb7e198b 100644 --- a/ide/src/base-ui/tabs/lit-tabs.ts +++ b/ide/src/base-ui/tabs/lit-tabs.ts @@ -41,6 +41,7 @@ export class LitTabs extends HTMLElement { width:100%; height:100%; flex-shrink:0; + overflow: auto; } .nav-item{ display: inline-flex; diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts index 9041dbc67..faeec1e51 100644 --- a/ide/src/trace/component/SpSystemTrace.ts +++ b/ide/src/trace/component/SpSystemTrace.ts @@ -93,7 +93,7 @@ import { TabPaneSummary } from './trace/sheet/ark-ts/TabPaneSummary.js'; import { JsCpuProfilerChartFrame } from '../bean/JsStruct.js'; import { FileInfo } from '../../js-heap/model/UiStruct.js'; import { SnapshotStruct } from '../database/ui-worker/ProcedureWorkerSnapshot.js'; -import { setSelectState } from './Utils.js'; +import { setSelectState, intersectData } from './Utils.js'; function dpr() { return window.devicePixelRatio || 1; @@ -183,20 +183,20 @@ export class SpSystemTrace extends BaseElement { this.snapshotFiles = data; } - addPointPair(a: PairPoint, b: PairPoint) { - if (a.rowEL.collect) { - a.rowEL.translateY = a.rowEL.getBoundingClientRect().top - 195; + addPointPair(startPoint: PairPoint, endPoint: PairPoint) { + if (startPoint.rowEL.collect) { + startPoint.rowEL.translateY = startPoint.rowEL.getBoundingClientRect().top - 195; } else { - a.rowEL.translateY = a.rowEL.offsetTop - this.rowsPaneEL!.scrollTop; + startPoint.rowEL.translateY = startPoint.rowEL.offsetTop - this.rowsPaneEL!.scrollTop; } - if (b.rowEL.collect) { - b.rowEL.translateY = b.rowEL.getBoundingClientRect().top - 195; + if (endPoint.rowEL.collect) { + endPoint.rowEL.translateY = endPoint.rowEL.getBoundingClientRect().top - 195; } else { - b.rowEL.translateY = b.rowEL.offsetTop - this.rowsPaneEL!.scrollTop; + endPoint.rowEL.translateY = endPoint.rowEL.offsetTop - this.rowsPaneEL!.scrollTop; } - a.y = a.rowEL!.translateY! + a.offsetY; - b.y = b.rowEL!.translateY! + b.offsetY; - this.linkNodes.push([a, b]); + startPoint.y = startPoint.rowEL!.translateY! + startPoint.offsetY; + endPoint.y = endPoint.rowEL!.translateY! + endPoint.offsetY; + this.linkNodes.push([startPoint, endPoint]); } clearPointPair() { @@ -657,9 +657,9 @@ export class SpSystemTrace extends BaseElement { selection.funTids.push(parseInt(it.rowId!)); } - let isIntersect = (a: FuncStruct, b: RangeSelectStruct) => - Math.max(a.startTs! + a.dur!, b!.endNS || 0) - Math.min(a.startTs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0) && a.funName!.indexOf('H:Task ') >= 0; + let isIntersect = (filterFunc: FuncStruct, rangeData: RangeSelectStruct) => + Math.max(filterFunc.startTs! + filterFunc.dur!, rangeData!.endNS || 0) - Math.min(filterFunc.startTs!, rangeData!.startNS || 0) < + filterFunc.dur! + (rangeData!.endNS || 0) - (rangeData!.startNS || 0) && filterFunc.funName!.indexOf('H:Task ') >= 0; let taskData = it.dataList.filter((taskData: FuncStruct) => { taskData!.tid = parseInt(it.rowId!); return isIntersect(taskData, TraceRow.rangeSelectObject!); @@ -704,37 +704,13 @@ export class SpSystemTrace extends BaseElement { } else if (th.rowType == TraceRow.ROW_TYPE_NETWORK_ABILITY) { selection.networkAbilityIds.push(th.rowId!); } else if (th.rowType == TraceRow.ROW_TYPE_DMA_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let dmaAbilityData = th.dataList.filter((dmaAbilityData: SnapshotStruct) => { - return isSelect(dmaAbilityData, TraceRow.rangeSelectObject!); - }); - selection.dmaAbilityData.push(...dmaAbilityData!); + selection.dmaAbilityData.push(...intersectData(th)!); } else if (th.rowType == TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let gpuMemoryAbilityData = th.dataList.filter((gpuMemoryAbilityData: SnapshotStruct) => { - return isSelect(gpuMemoryAbilityData, TraceRow.rangeSelectObject!); - }); - selection.gpuMemoryAbilityData.push(...gpuMemoryAbilityData!); + selection.gpuMemoryAbilityData.push(...intersectData(th)!); } else if (th.rowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeableTotalDatas = th.dataList.filter((PurgeableTotalData: SnapshotStruct) => { - return isSelect(PurgeableTotalData, TraceRow.rangeSelectObject!); - }); - selection.purgeableTotalAbility.push(...PurgeableTotalDatas); + selection.purgeableTotalAbility.push(...intersectData(th)); } else if (th.rowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeablePinDatas = th.dataList.filter((PurgeablePinData: SnapshotStruct) => { - return isSelect(PurgeablePinData, TraceRow.rangeSelectObject!); - }); - selection.purgeablePinAbility.push(...PurgeablePinDatas); + selection.purgeablePinAbility.push(...intersectData(th)); } }); } else if (it.rowType == TraceRow.ROW_TYPE_CPU_ABILITY) { @@ -750,21 +726,9 @@ export class SpSystemTrace extends BaseElement { selection.networkAbilityIds.push(it.rowId!); info('load Network Ability traceRow id is : ', it.rowId); } else if (it.rowType == TraceRow.ROW_TYPE_DMA_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let dmaAbilityData = it.dataList.filter((dmaAbilityData: SnapshotStruct) => { - return isSelect(dmaAbilityData, TraceRow.rangeSelectObject!); - }); - selection.dmaAbilityData.push(...dmaAbilityData!); + selection.dmaAbilityData.push(...intersectData(it)!); } else if (it.rowType == TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let gpuMemoryAbilityData = it.dataList.filter((gpuMemoryAbilityData: SnapshotStruct) => { - return isSelect(gpuMemoryAbilityData, TraceRow.rangeSelectObject!); - }); - selection.gpuMemoryAbilityData.push(...gpuMemoryAbilityData!); + selection.gpuMemoryAbilityData.push(...intersectData(it)!); } else if (it.rowType?.startsWith(TraceRow.ROW_TYPE_SDK)) { if (it.rowType == TraceRow.ROW_TYPE_SDK) { let sdkRows: Array> = [ @@ -857,13 +821,7 @@ export class SpSystemTrace extends BaseElement { } else if (it.rowType == TraceRow.ROW_TYPE_SYSTEM_ENERGY) { info('load anomaly Energy traceRow id is : ', it.rowId); } else if (it.rowType == TraceRow.ROW_TYPE_VM_TRACKER_SMAPS) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let smapsData = it.dataList.filter((smapsData: SnapshotStruct) => { - return isSelect(smapsData, TraceRow.rangeSelectObject!); - }); - selection.smapsType.push(...smapsData!); + selection.smapsType.push(...intersectData(it)!); let sMapsChildRows: Array> = [ ...this.shadowRoot!.querySelectorAll>(`trace-row[row-parent-id='${it.rowId}']`), ]; @@ -873,23 +831,11 @@ export class SpSystemTrace extends BaseElement { sMapsChildRows.forEach((item) => { item.rangeSelect = true; if (item.rowType == TraceRow.ROW_TYPE_VM_TRACKER_SMAPS) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let smapsData = item.dataList.filter((smapsData: SnapshotStruct) => { - return isSelect(smapsData, TraceRow.rangeSelectObject!); - }); - selection.smapsType.push(...smapsData!); + selection.smapsType.push(...intersectData(item)!); } }); } else if (it.rowType == TraceRow.ROW_TYPE_VMTRACKER_SHM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let vmTrackerShmData = it.dataList.filter((vmTrackerShmData: SnapshotStruct) => { - return isSelect(vmTrackerShmData, TraceRow.rangeSelectObject!); - }); - selection.vmtrackershm.push(...vmTrackerShmData!); + selection.vmtrackershm.push(...intersectData(it)!); } else if (it.rowType == TraceRow.ROW_TYPE_CLOCK) { selection.clockMapData.set( it.rowId || '', @@ -929,13 +875,7 @@ export class SpSystemTrace extends BaseElement { vMTrackerChildRows.forEach((th) => { th.rangeSelect = true; if (th.rowType === TraceRow.ROW_TYPE_DMA_VMTRACKER) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let dmaVmTrackerData = th.dataList.filter((dmaVmTrackerData: SnapshotStruct) => { - return isSelect(dmaVmTrackerData, TraceRow.rangeSelectObject!); - }); - selection.dmaVmTrackerData.push(...dmaVmTrackerData!); + selection.dmaVmTrackerData.push(...intersectData(th)!); } else if (th.rowType === TraceRow.ROW_TYPE_SYS_MEMORY_GPU) { let vMTrackerGpuChildRows: Array> = [ ...this.shadowRoot!.querySelectorAll>(`trace-row[row-parent-id='${th.rowId}']`), @@ -946,13 +886,7 @@ export class SpSystemTrace extends BaseElement { vMTrackerGpuChildRows.forEach((item) => { item.rangeSelect = true; if (item.rowType == TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let gpuMemoryTrackerData = item.dataList.filter((gpuMemoryTrackerData: SnapshotStruct) => { - return isSelect(gpuMemoryTrackerData, TraceRow.rangeSelectObject!); - }); - selection.gpuMemoryTrackerData.push(...gpuMemoryTrackerData!); + selection.gpuMemoryTrackerData.push(...intersectData(item)!); } else if (item.rowType == TraceRow.ROW_TYPE_SYS_MEMORY_GPU_GL) { selection.gpu.gl = item.dataList.filter( @@ -977,21 +911,9 @@ export class SpSystemTrace extends BaseElement { } }); } else if (th.rowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_VM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let purgeableTotalDatas = th.dataList.filter((purgeableTotalData: SnapshotStruct) => { - return isSelect(purgeableTotalData, TraceRow.rangeSelectObject!); - }); - selection.purgeableTotalVM.push(...purgeableTotalDatas); + selection.purgeableTotalVM.push(...intersectData(th)); } else if (th.rowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_VM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let purgeablePinDatas = th.dataList.filter((purgeablePinData: SnapshotStruct) => { - return isSelect(purgeablePinData, TraceRow.rangeSelectObject!); - }); - selection.purgeablePinVM.push(...purgeablePinDatas); + selection.purgeablePinVM.push(...intersectData(th)); } else if (th.rowType === TraceRow.ROW_TYPE_VM_TRACKER_SMAPS) { let sMapsChildRows: Array> = [ ...this.shadowRoot!.querySelectorAll>(`trace-row[row-parent-id='${th.rowId}']`), @@ -1002,23 +924,11 @@ export class SpSystemTrace extends BaseElement { sMapsChildRows.forEach((item) => { item.rangeSelect = true; if (item.rowType == TraceRow.ROW_TYPE_VM_TRACKER_SMAPS) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let smapsData = item.dataList.filter((smapsData: SnapshotStruct) => { - return isSelect(smapsData, TraceRow.rangeSelectObject!); - }); - selection.smapsType.push(...smapsData!); + selection.smapsType.push(...intersectData(item)!); } }); } else if (th.rowType == TraceRow.ROW_TYPE_VMTRACKER_SHM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let vmTrackerShmData = th.dataList.filter((vmTrackerShmData: SnapshotStruct) => { - return isSelect(vmTrackerShmData, TraceRow.rangeSelectObject!); - }); - selection.vmtrackershm.push(...vmTrackerShmData!); + selection.vmtrackershm.push(...intersectData(th)!); } }); } else if (it.rowType == TraceRow.ROW_TYPE_SYS_MEMORY_GPU) { @@ -1031,13 +941,7 @@ export class SpSystemTrace extends BaseElement { vMTrackerGpuChildRows.forEach((th) => { th.rangeSelect = true; if (th.rowType == TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let gpuMemoryTrackerData = th.dataList.filter((gpuMemoryTrackerData: SnapshotStruct) => { - return isSelect(gpuMemoryTrackerData, TraceRow.rangeSelectObject!); - }); - selection.gpuMemoryTrackerData.push(...gpuMemoryTrackerData!); + selection.gpuMemoryTrackerData.push(...intersectData(th)!); } else if (th.rowType == TraceRow.ROW_TYPE_SYS_MEMORY_GPU_GL) { selection.gpu.gl = th.dataList.filter( @@ -1062,21 +966,9 @@ export class SpSystemTrace extends BaseElement { } }); } else if (it.rowType == TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let gpuMemoryTrackerData = it.dataList.filter((gpuMemoryTrackerData: SnapshotStruct) => { - return isSelect(gpuMemoryTrackerData, TraceRow.rangeSelectObject!); - }); - selection.gpuMemoryTrackerData.push(...gpuMemoryTrackerData!); + selection.gpuMemoryTrackerData.push(...intersectData(it)!); } else if (it.rowType == TraceRow.ROW_TYPE_DMA_VMTRACKER) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let dmaVmTrackerData = it.dataList.filter((dmaVmTrackerData: SnapshotStruct) => { - return isSelect(dmaVmTrackerData, TraceRow.rangeSelectObject!); - }); - selection.dmaVmTrackerData.push(...dmaVmTrackerData!); + selection.dmaVmTrackerData.push(...intersectData(it)!); } else if (it.rowType == TraceRow.ROW_TYPE_SYS_MEMORY_GPU_GL) { selection.gpu.gl = it.dataList.filter( @@ -1099,9 +991,9 @@ export class SpSystemTrace extends BaseElement { (it.endNs >= selection.leftNs && it.endNs <= selection.rightNs) ).length > 0; } else if (it.rowType == TraceRow.ROW_TYPE_JANK) { - let isIntersect = (a: JanksStruct, b: RangeSelectStruct) => - Math.max(a.ts! + a.dur!, b!.endNS || 0) - Math.min(a.ts!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); + let isIntersect = (filterJank: JanksStruct, rangeData: RangeSelectStruct) => + Math.max(filterJank.ts! + filterJank.dur!, rangeData!.endNS || 0) - Math.min(filterJank.ts!, rangeData!.startNS || 0) < + filterJank.dur! + (rangeData!.endNS || 0) - (rangeData!.startNS || 0); if (it.name == 'Actual Timeline') { selection.jankFramesData = []; let jankDatas = it.dataList.filter((jankData: any) => { @@ -1185,56 +1077,37 @@ export class SpSystemTrace extends BaseElement { }); selection.frameAnimation.push(...frameAnimationList); } else if (it.rowType == TraceRow.ROW_TYPE_FRAME_DYNAMIC) { + let appName = it.getAttribute('model-name'); let isSelect = (dynamicStruct: FrameDynamicStruct, b: RangeSelectStruct) => dynamicStruct.ts >= b.startNS! && dynamicStruct.ts <= b.endNS!; let frameDynamicList = it.dataList.filter( (frameAnimationBean: FrameDynamicStruct) => - isSelect(frameAnimationBean, TraceRow.rangeSelectObject!) && frameAnimationBean.groupId !== -1 + isSelect(frameAnimationBean, TraceRow.rangeSelectObject!) && + frameAnimationBean.groupId !== -1 && + frameAnimationBean.appName === appName ); selection.frameDynamic.push(...frameDynamicList); } else if (it.rowType == TraceRow.ROW_TYPE_FRAME_SPACING) { + let appName = it.getAttribute('model-name'); let isSelect = (a: FrameSpacingStruct, b: RangeSelectStruct) => a.currentTs >= b.startNS! && a.currentTs <= b.endNS!; let frameDatas = it.dataList.filter((frameData: FrameSpacingStruct) => { return ( isSelect(frameData, TraceRow.rangeSelectObject!) && frameData.groupId !== -1 && - frameData.frameSpacingResult !== -1 + frameData.frameSpacingResult !== -1 && + frameData.nameId === appName ); }); selection.frameSpacing.push(...frameDatas); } else if (it.rowType == TraceRow.ROW_TYPE_PURGEABLE_TOTAL_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeableTotalDatas = it.dataList.filter((PurgeableTotalData: SnapshotStruct) => { - return isSelect(PurgeableTotalData, TraceRow.rangeSelectObject!); - }); - selection.purgeableTotalAbility.push(...PurgeableTotalDatas); + selection.purgeableTotalAbility.push(...intersectData(it)); } else if (it.rowType == TraceRow.ROW_TYPE_PURGEABLE_PIN_ABILITY) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeablePinDatas = it.dataList.filter((PurgeablePinData: SnapshotStruct) => { - return isSelect(PurgeablePinData, TraceRow.rangeSelectObject!); - }); - selection.purgeablePinAbility.push(...PurgeablePinDatas); + selection.purgeablePinAbility.push(...intersectData(it)); } else if (it.rowType == TraceRow.ROW_TYPE_PURGEABLE_TOTAL_VM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeableTotalDatas = it.dataList.filter((PurgeableTotalData: SnapshotStruct) => { - return isSelect(PurgeableTotalData, TraceRow.rangeSelectObject!); - }); - selection.purgeableTotalVM.push(...PurgeableTotalDatas); + selection.purgeableTotalVM.push(...intersectData(it)); } else if (it.rowType == TraceRow.ROW_TYPE_PURGEABLE_PIN_VM) { - let isSelect = (a: SnapshotStruct, b: RangeSelectStruct) => - Math.max(a.startNs! + a.dur!, b!.endNS || 0) - Math.min(a.startNs!, b!.startNS || 0) < - a.dur! + (b!.endNS || 0) - (b!.startNS || 0); - let PurgeablePinDatas = it.dataList.filter((PurgeablePinData: SnapshotStruct) => { - return isSelect(PurgeablePinData, TraceRow.rangeSelectObject!); - }); - selection.purgeablePinVM.push(...PurgeablePinDatas); + selection.purgeablePinVM.push(...intersectData(it)); } if (this.rangeTraceRow!.length !== rows.length) { let event = this.createPointEvent(it); diff --git a/ide/src/trace/component/Utils.ts b/ide/src/trace/component/Utils.ts index 47b0f41d0..bd5854ea3 100644 --- a/ide/src/trace/component/Utils.ts +++ b/ide/src/trace/component/Utils.ts @@ -13,7 +13,8 @@ * limitations under the License. */ import { JsCpuProfilerChartFrame } from '../bean/JsStruct.js'; -import { TraceRow } from './trace/base/TraceRow.js'; +import { SnapshotStruct } from '../database/ui-worker/ProcedureWorkerSnapshot.js'; +import { RangeSelectStruct, TraceRow } from './trace/base/TraceRow.js'; export function setSelectState( data: JsCpuProfilerChartFrame, @@ -49,3 +50,13 @@ export function setSelectState( } } } + +export function intersectData(row:TraceRow) { + let isIntersect = (snapshotStruct: SnapshotStruct, rangeSelectStruct: RangeSelectStruct) => + Math.max(snapshotStruct.startNs! + snapshotStruct.dur!, rangeSelectStruct!.endNS || 0) - Math.min(snapshotStruct.startNs!, rangeSelectStruct!.startNS || 0) < + snapshotStruct.dur! + (rangeSelectStruct!.endNS || 0) - (rangeSelectStruct!.startNS || 0); + let intersectData = row.dataList.filter((struct: SnapshotStruct) => { + return isIntersect(struct, TraceRow.rangeSelectObject!); + }); + return intersectData; +} diff --git a/ide/src/trace/component/chart/SpFrameTimeChart.ts b/ide/src/trace/component/chart/SpFrameTimeChart.ts index 8c8d0dc43..bd00198c1 100644 --- a/ide/src/trace/component/chart/SpFrameTimeChart.ts +++ b/ide/src/trace/component/chart/SpFrameTimeChart.ts @@ -222,6 +222,7 @@ export class SpFrameTimeChart { systemPopover.blur(); TraceRow.range!.refresh = true; this.trace.refreshCanvas(true); + this.trace.clickEmptyArea(); } }); }); @@ -446,7 +447,7 @@ export class SpFrameTimeChart { let yDifference = frameData[index].y! - frameData[index - unitIndex].y!; let frameWidth = Math.abs(widthDifference / FrameSpacingStruct.physicalWidth / intervalTime); let frameHeight = Math.abs(heightDifference / FrameSpacingStruct.physicalHeight / intervalTime); - let frameX = Math.abs(xDifference / FrameSpacingStruct.physicalHeight / intervalTime); + let frameX = Math.abs(xDifference / FrameSpacingStruct.physicalWidth / intervalTime); let frameY = Math.abs(yDifference / FrameSpacingStruct.physicalHeight / intervalTime); let result = Math.max(frameWidth, frameHeight, frameX, frameY); frameData[index].frameSpacingResult = Number(result.toFixed(unitIndex)); diff --git a/ide/src/trace/component/trace/base/TraceSheetConfig.ts b/ide/src/trace/component/trace/base/TraceSheetConfig.ts index 6165c7602..89adbd86b 100644 --- a/ide/src/trace/component/trace/base/TraceSheetConfig.ts +++ b/ide/src/trace/component/trace/base/TraceSheetConfig.ts @@ -253,6 +253,7 @@ export let tabConfig: any = { type: TabPanePerfSample, require: (param: SelectionParam) => param.perfSampleIds.length > 0, }, + 'box-live-processes-child': { title: 'Live Processes', type: TabPaneLiveProcesses, diff --git a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts index f25c712ed..4aabeb885 100644 --- a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts +++ b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts @@ -30,6 +30,7 @@ export class TabPaneSmapsRecord extends BaseElement { private isClick = false; private tabTitle: HTMLDivElement | undefined | null; set data(valSmapsRecord: SelectionParam) { + this.parentElement!.style.overflow = 'unset'; this.isClick = valSmapsRecord.smapsType.length === 0; this.init(); this.tblSmapsRecord!.loading = true; diff --git a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts index 55b62461f..baea37e09 100644 --- a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts +++ b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts @@ -38,6 +38,7 @@ export class TabPaneSmapsStatistics extends BaseElement { private totalTree: Array = []; private tabTitle: HTMLDivElement | undefined | null; set data(valSmapsStatistics: SelectionParam) { + this.parentElement!.style.overflow = 'unset'; this.currentSelection = valSmapsStatistics; this.isClick = valSmapsStatistics.smapsType.length === 0; this.init(); diff --git a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts index 218080d4b..22fba8c2c 100644 --- a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts +++ b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts @@ -27,6 +27,11 @@ import { BaseStruct } from '../../../../database/ui-worker/ProcedureWorkerCommon import { SpSystemTrace } from '../../../SpSystemTrace.js'; import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar.js'; +const ALLOCATION_TASK = 'H:Task Allocation:'; +const PERFORM_TASK = 'H:Task Perform:'; +const END_TASK = 'H:Task PerformTask End:'; +const TABLE_CURRENCY = 'Task Concurrency'; + @element('tabpane-task-frames') export class TabPaneTaskFrames extends BaseElement { private taskFramesTbl: LitTable | null | undefined; @@ -74,15 +79,15 @@ export class TabPaneTaskFrames extends BaseElement { let executeId = ''; let executeStruct: FuncStruct | undefined = undefined; taskArray.forEach((item) => { - if (item.funName!.indexOf('H:Task Allocation:') >= 0) { + if (item.funName!.indexOf(ALLOCATION_TASK) >= 0) { allocationStartTime = item.startTs!; priorityId = TabPaneTaskFrames.getPriorityId(item.funName!); executeId = TabPaneTaskFrames.getExecuteId(item.funName!); - } else if (item.funName!.indexOf('H:Task Perform:') >= 0) { + } else if (item.funName!.indexOf(PERFORM_TASK) >= 0) { executeStruct = item; executeStartTime = item.startTs!; executeTime = item.dur!; - } else if (item.funName!.indexOf('H:Task PerformTask End:') >= 0) { + } else if (item.funName!.indexOf(END_TASK) >= 0) { returnEndTime = item.startTs! + item.dur!; } }); @@ -101,7 +106,7 @@ export class TabPaneTaskFrames extends BaseElement { tableList: TaskTabStruct[], framesParam: SelectionParam, isClick: boolean): void { this.countConcurrency(executeStruct, tableList, framesParam, isClick).then((result) => { let concurrencyColumn: TaskTabStruct = new TaskTabStruct(); - concurrencyColumn.executeId = 'Task Concurrency'; + concurrencyColumn.executeId = TABLE_CURRENCY; concurrencyColumn.taskPriority = `${ result }`; tableList.push(concurrencyColumn); let filterList = []; @@ -150,7 +155,7 @@ export class TabPaneTaskFrames extends BaseElement { for (let index = 0 ; index < groupsValue.length ; index++) { let data = groupsValue[index]; let executeId = TabPaneTaskFrames.getExecuteId(data.funName!); - if (data.funName!.indexOf('H:Task Perform:') >= 0) { + if (data.funName!.indexOf(PERFORM_TASK) >= 0) { tempExecuteTaskList.push(data); } tempExecuteTaskIds.push(parseInt(executeId)); @@ -232,7 +237,7 @@ export class TabPaneTaskFrames extends BaseElement { // @ts-ignore let compare = function (property, sort, type) { return function (taskFramesLeftData: TaskTabStruct, taskFramesRightData: TaskTabStruct): number { - if (taskFramesLeftData.executeId === 'Task Concurrency') { + if (taskFramesLeftData.executeId === TABLE_CURRENCY) { return 1; } if (type === 'number') { @@ -276,9 +281,9 @@ export class TabPaneTaskFrames extends BaseElement { let endStr = ''; if (strArray.length >= 2) { executeStr = strArray[1]; - if (funName.indexOf('H:Task Allocation:') >= 0 || funName.indexOf('H:Task Perform:') >= 0) { + if (funName.indexOf(ALLOCATION_TASK) >= 0 || funName.indexOf(PERFORM_TASK) >= 0) { executeId = executeStr.split(':')[1].trim(); - } else if (funName.indexOf('H:Task PerformTask End:') >= 0) { + } else if (funName.indexOf(END_TASK) >= 0) { endStr = executeStr.split(':')[1].trim(); if (endStr.indexOf('[') >= 0) { executeId = endStr.substring(0, endStr.indexOf('[')); @@ -295,7 +300,7 @@ export class TabPaneTaskFrames extends BaseElement { let priorityId = ''; if (strArray.length >= 2) { let executeStr = strArray[2]; - if (funName.indexOf('H:Task Allocation:') >= 0) { + if (funName.indexOf(ALLOCATION_TASK) >= 0) { priorityId = executeStr.split(':')[1].trim(); } } @@ -356,7 +361,7 @@ export class TabPaneTaskFrames extends BaseElement { let countConcurrencyPromise = await this.countConcurrency(executeTaskList[0], tableList, framesParam, isClick); maxNumConcurrency = countConcurrencyPromise; let concurrencyColumn: TaskTabStruct = new TaskTabStruct(); - concurrencyColumn.executeId = 'Task Concurrency'; + concurrencyColumn.executeId = TABLE_CURRENCY; concurrencyColumn.taskPriority = `${ maxNumConcurrency }`; tableList.push(concurrencyColumn); //去重 -- Gitee From 1a669de5f3febc64b62bae0b1388b6304c957f7e Mon Sep 17 00:00:00 2001 From: zhangzepeng Date: Mon, 31 Jul 2023 19:54:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E2=80=99Feat:=E6=96=B0=E5=A2=9EUT=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzepeng --- ide/test/base-ui/checkbox/LitCheckBox.test.ts | 2 +- ide/test/trace/SpApplication.test.ts | 2 + .../component/chart/SpVmTrackerChart.test.ts | 46 ++++++- .../component/setting/SpAllocations.test.ts | 7 +- .../component/trace/base/TraceRow.test.ts | 23 +++- .../sheet/TabPaneCurrentSelection.test.ts | 16 +-- .../sheet/ability/TabPaneCpuAbility.test.ts | 28 +++- .../sheet/ability/TabPaneDiskAbility.test.ts | 32 +++++ .../sheet/ability/TabPaneDmaAbility.test.ts | 14 +- .../ability/TabPaneDmaSelectAbility.test.ts | 99 +++++++++++++ .../ability/TabPaneGpuMemoryAbility.test.ts | 13 +- .../TabPaneGpuMemorySelectAbility.test.ts | 70 ++++++++++ .../ability/TabPaneHistoryProcesses.test.ts | 26 ++++ .../ability/TabPaneLiveProcesses.test.ts | 32 ++++- .../sheet/ability/TabPanePurgPin.test.ts | 29 ++-- .../ability/TabPanePurgPinSelection.test.ts | 123 +++++++++++++++++ .../ability/TabPanePurgTotalSelection.test.ts | 123 +++++++++++++++++ .../ark-ts/TabPaneJsCpuStatistics.test.ts | 91 ++++++++++++ .../TabPaneFileSystemCalltree.test.ts | 7 + .../sheet/freq/TabPaneCpuFreqLimits.test.ts | 51 +++++++ .../sheet/gpu/TabPaneGpuClickSelect.test.ts | 29 +++- .../trace/sheet/gpu/TabPaneGpuGL.test.ts | 53 +++++++ .../gpu/TabPaneGpuTotalBoxSelect.test.ts | 72 ++++++++++ .../gpu/TabPaneGpuWindowBoxSelect.test.ts | 79 +++++++++++ .../sheet/hiperf/TabPanePerfAnalysis.test.ts | 90 ++++++++++++ .../sheet/smaps/TabPaneSmapsRecord.test.ts | 3 +- .../vmtracker/TabPaneDmaVmTracker.test.ts | 9 -- .../TabPaneGpuMemoryVmTracker.test.ts | 5 +- .../TabPaneVmTrackerShmSelection.test.ts | 59 +++++++- .../trace/timer-shaft/RangeRuler.test.ts | 6 + .../ProcedureLogicWorkerPerf.test.ts | 53 +++++++ .../ProcedureWorkerAppStartup.test.ts | 62 +++++++++ .../ui-worker/ProcedureWorkerFPS.test.ts | 4 + .../ui-worker/ProcedureWorkerHeap.test.ts | 32 ++++- .../ProcedureWorkerHiPerfEvent.test.ts | 14 +- .../ProcedureWorkerHiPerfReport.test.ts | 4 +- .../ui-worker/ProcedureWorkerSoInit.test.ts | 130 ++++++++++++++++++ 37 files changed, 1474 insertions(+), 64 deletions(-) create mode 100644 ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts create mode 100644 ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts create mode 100644 ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts create mode 100644 ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts create mode 100644 ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts create mode 100644 ide/test/trace/component/trace/sheet/freq/TabPaneCpuFreqLimits.test.ts create mode 100644 ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts create mode 100644 ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts create mode 100644 ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts create mode 100644 ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts create mode 100644 ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts diff --git a/ide/test/base-ui/checkbox/LitCheckBox.test.ts b/ide/test/base-ui/checkbox/LitCheckBox.test.ts index 49183bbfd..b7f6b3dc1 100644 --- a/ide/test/base-ui/checkbox/LitCheckBox.test.ts +++ b/ide/test/base-ui/checkbox/LitCheckBox.test.ts @@ -92,13 +92,13 @@ describe('checkBox Test', () => { cursor:pointer; display:flex; align-items:center; + gap: 12px; } .chekebox{ position:relative; display:flex; justify-content: center; align-items: center; - margin-right:12px; width: 16px; height:16px; border: 1px solid var(--dark-color1,#4D4D4D); diff --git a/ide/test/trace/SpApplication.test.ts b/ide/test/trace/SpApplication.test.ts index 1bb3c36b8..6ab32f8b5 100644 --- a/ide/test/trace/SpApplication.test.ts +++ b/ide/test/trace/SpApplication.test.ts @@ -314,6 +314,8 @@ describe('spApplication Test', () => { :host([chart_filter]) .chart-filter { display: grid; + grid-template-rows: min-content min-content min-content max-content auto; + overflow-y: clip; height: 99%; visibility: visible; position: absolute; diff --git a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts index 14dc276e5..ad5cc8e94 100644 --- a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts +++ b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts @@ -23,8 +23,8 @@ jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => return {}; }); -window.ResizeObserver = - window.ResizeObserver || +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), observe: jest.fn(), @@ -105,6 +105,15 @@ describe('SpVmTrackerChart Test', () => { gpuWindowType.mockResolvedValue(windowsType); let manager = new SpChartManager(); let spVmTrackerChart = new VmTrackerChart(manager); + let memoryData = [{ + startNs:0, + endNs: 0, + dur:0, + name: '', + textWidth: 0, + value: 0, + type: '', + }] it('SpVmTrackerChart01', function () { spVmTrackerChart.initVmTrackerFolder(); expect(spVmTrackerChart).toBeDefined(); @@ -112,6 +121,12 @@ describe('SpVmTrackerChart Test', () => { it('SpVmTrackerChart02', function () { expect(spVmTrackerChart.getSmapsKeyName('USS')).toBeDefined(); }); + it('SpVmTrackerChart07', function () { + expect(spVmTrackerChart.getSmapsKeyName('RSS')).toBeDefined(); + }); + it('SpVmTrackerChart08', function () { + expect(spVmTrackerChart.getSmapsKeyName('')).toBeDefined(); + }); it('SpVmTrackerChart03', function () { expect(spVmTrackerChart.initTraceRow('dirty','smaps','VmTracker')).toBeDefined(); }); @@ -124,4 +139,31 @@ describe('SpVmTrackerChart Test', () => { it('SpVmTrackerChart06', function () { expect(spVmTrackerChart.showTip).toBeDefined(); }); + it('SpVmTrackerChart09', function () { + expect(spVmTrackerChart.initGpuFolder()).toBeDefined(); + }); + it('SpVmTrackerChart09', function () { + expect(spVmTrackerChart.initSMapsFolder()).toBeDefined(); + }); + it('SpVmTrackerChart10', function () { + expect(spVmTrackerChart.initVmTrackerFolder()).toBeDefined(); + }); + it('SpVmTrackerChart11', function () { + expect(spVmTrackerChart.initDmaRow()).toBeDefined(); + }); + it('SpVmTrackerChart12', function () { + expect(spVmTrackerChart.initSmapsRows('Swapped')).toBeDefined(); + }); + it('SpVmTrackerChart13', function () { + expect(spVmTrackerChart.initShmRows()).toBeDefined(); + }); + it('SpVmTrackerChart14', function () { + expect(spVmTrackerChart.initGpuMemoryRow(memoryData)).toBeDefined(); + }); + it('SpVmTrackerChart15', function () { + expect(spVmTrackerChart.addGpuGLRow(memoryData)).toBeDefined(); + }); + it('SpVmTrackerChart16', function () { + expect(spVmTrackerChart.addGpuTotalRow()).toBeDefined(); + }); }); \ No newline at end of file diff --git a/ide/test/trace/component/setting/SpAllocations.test.ts b/ide/test/trace/component/setting/SpAllocations.test.ts index 2360d539a..42a00a54f 100644 --- a/ide/test/trace/component/setting/SpAllocations.test.ts +++ b/ide/test/trace/component/setting/SpAllocations.test.ts @@ -292,9 +292,12 @@ describe('SpAllocations Test', () => {
Use Offline Symbolization (Available on recent OpenHarmony 4.0) - +
- +
+ Use Startup Mode (Available on recent OpenHarmony 4.0) + +
Use Record Statistics (Available on recent OpenHarmony 4.0) diff --git a/ide/test/trace/component/trace/base/TraceRow.test.ts b/ide/test/trace/component/trace/base/TraceRow.test.ts index 404ba1b62..2c7f2e023 100644 --- a/ide/test/trace/component/trace/base/TraceRow.test.ts +++ b/ide/test/trace/component/trace/base/TraceRow.test.ts @@ -811,12 +811,6 @@ describe('TraceRow Test', () => { :host(:not([folder])) .describe:hover .collect{ display: block; } - :host([row-setting='enable']) #rowSetting{ - display: flex; - } - :host([row-setting='enable']) .collect{ - margin-right: 20px; - } .popover{ color: var(--dark-color1,#4b5766); display: none; @@ -852,6 +846,21 @@ describe('TraceRow Test', () => { border-radius: 6px; background-color: var(--dark-background7,#e7c9c9); } + .lit-check-box{ + margin-right: 15px; + } + :host([row-setting='enable'][check-type]) .lit-check-box{ + margin-right: 25px; + } + :host([row-setting='enable'][check-type='-1']) .collect{ + margin-right: 20px; + } + :host([row-setting='enable']) #rowSetting{ + display: flex; + } + :host([row-setting='enable']:not([check-type='-1'])) .collect{ + margin-right: 5px; + }
@@ -869,7 +878,7 @@ describe('TraceRow Test', () => {
- +
" diff --git a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts index 9f17f1a6c..d224ddad1 100644 --- a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts @@ -15,14 +15,6 @@ // @ts-ignore import { getTimeString, TabPaneCurrentSelection } from '../../../../../dist/trace/component/trace/sheet/TabPaneCurrentSelection.js'; - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); const sqlite = require('../../../../../dist/trace/database/SqlLite.js'); jest.mock('../../../../../dist/trace/database/SqlLite.js'); @@ -469,6 +461,13 @@ describe('TabPaneCurrentSelection Test', () => { #rightButton{ padding-top:12px; } + .right{ + display: flex; + } + #right-star{ + padding-top: 10px; + visibility: hidden; + } .scroll-area{ display: flex; flex-direction: row; @@ -492,6 +491,7 @@ describe('TabPaneCurrentSelection Test', () => {
GetWakeupList +
diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts index 29d7aac93..723df48e1 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts @@ -14,6 +14,8 @@ */ // @ts-ignore import { TabPaneCpuAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneCpuAbility.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); window.ResizeObserver = window.ResizeObserver || @@ -25,7 +27,25 @@ window.ResizeObserver = describe('TabPaneCpuAbility Test', () => { let tabPaneCpuAbility = new TabPaneCpuAbility(); - + let val = [ + { + startNs: 0, + rightNs: 1000, + leftNs:0, + } + ]; + let getTabCpuData = sqlite.getTabCpuAbilityData; + let cpuData = [ + { + startTime: 0, + duration: 1000, + totalLoad:2, + userLoad:2, + systemLoad:3, + threads:1, + } + ]; + getTabCpuData.mockResolvedValue(cpuData); it('TabPaneCpuAbilityTest01', function () { tabPaneCpuAbility.queryCpuResult.length = 2; expect(tabPaneCpuAbility.filterData()).toBeUndefined(); @@ -90,4 +110,10 @@ describe('TabPaneCpuAbility Test', () => { }) ).toBeUndefined(); }); + it('TabPaneCpuAbilityTest09 ', function () { + expect( + tabPaneCpuAbility.queryDataByDB({val + }) + ).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts index 21841df71..6e3ddee21 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts @@ -14,6 +14,8 @@ */ //@ts-ignore import { TabPaneDiskAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneDiskAbility.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -24,6 +26,29 @@ window.ResizeObserver = describe('TabPaneDiskAbility Test', () => { let tabPaneDiskAbility = new TabPaneDiskAbility(); + let val = [ + { + startNs: 0, + rightNs: 1000, + leftNs:0, + } + ]; + let getTabDiskAbilityData = sqlite.getTabDiskAbilityData; + let diskAbilityData = [ + { + startTime: 0, + duration: 1000, + dataRead:2, + dataReadSec:2, + dataWrite:3, + dataWriteSec:1, + readsIn:2, + readsInSec:4, + writeOut:2, + writeOutSec:5 + } + ]; + getTabDiskAbilityData.mockResolvedValue(diskAbilityData); it('TabPaneDiskAbilityTest01', () => { tabPaneDiskAbility.queryDiskResult.length = 1; expect(tabPaneDiskAbility.filterData()).toBeUndefined(); @@ -131,4 +156,11 @@ describe('TabPaneDiskAbility Test', () => { }) ).toBeUndefined(); }); + it('TabPaneDiskAbilityTest14', function () { + expect( + tabPaneDiskAbility.queryDataByDB({ + val + }) + ).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts index 4be217619..1ce828f66 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts @@ -116,7 +116,13 @@ describe('TabPaneDmaAbility Test', () => { statisticsSelectData:undefined, }; - + let val = [ + { + leftNs: 0, + rightNs: 1000, + } + ]; + tabPaneDmaAbility.init = jest.fn(() => true); it('TabPaneDmaAbilityTest01', function () { expect(tabPaneDmaAbility.sortDmaByColumn('process',1)).toBeUndefined(); }); @@ -135,4 +141,10 @@ describe('TabPaneDmaAbility Test', () => { it('TabPaneDmaAbilityTest06', function () { expect(tabPaneDmaAbility.sortDmaByColumn('maxSize',1)).toBeUndefined(); }); + it('TabPaneDmaAbilityTest07', function () { + expect(tabPaneDmaAbility.queryDataByDB(val)).toBeUndefined(); + }); + it('TabPaneDmaAbilityTest08', function () { + expect(tabPaneDmaAbility.sortDmaByColumn('',0)).toBeUndefined(); + }); }) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts new file mode 100644 index 000000000..d2a6e42bf --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TabPaneDmaSelectAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneDmaSelectAbility Test', () => { + let tabPaneDmaSelectAbility = new TabPaneDmaSelectAbility(); + let getTabDmaSelectionData = sqlite.getTabDmaAbilityClickData; + let dmaSelectionData = [ + { + startNs: 0, + fd: 1, + size: 1000, + ino: 10, + expPid: 0, + bufName: 'aa', + expName: 'bb', + expTaskComm: 'cc', + processId:2, + processName:'dd', + flag:0, + } + ]; + let val = [ + { + startNs: 0, + rightNs: 1000, + } + ]; + tabPaneDmaSelectAbility.init = jest.fn(() => true); + getTabDmaSelectionData.mockResolvedValue(dmaSelectionData); + it('TabPaneDmaSelectAbility01', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('',0)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility02', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('process',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility03', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('startNs',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility04', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('expTaskComm',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility05', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('fd',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility05', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('size',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility06', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('ino',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility07', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('expPid',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility08', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('flag',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility09', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('bufName',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility10', function () { + expect(tabPaneDmaSelectAbility.sortDmaByColumn('expName',1)).toBeUndefined(); + }); + it('TabPaneDmaSelectAbility11', function () { + expect(tabPaneDmaSelectAbility.queryDmaClickDataByDB(val)).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts index 537a88cc2..95ad8ecf5 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts @@ -105,7 +105,12 @@ describe('TabPaneGpuMemoryAbility Test', () => { staticInit:false, statisticsSelectData:undefined, }; - + let val = [ + { + leftNs: 0, + rightNs: 1000, + } + ]; it('TabPaneGpuMemoryAbilityTest01', function () { expect(tabPaneGpuMemoryAbility.sortGpuMemoryByColumn('process',1)).toBeUndefined(); }); @@ -127,4 +132,10 @@ describe('TabPaneGpuMemoryAbility Test', () => { it('TabPaneGpuMemoryAbilityTest06', function () { expect(tabPaneGpuMemoryAbility.sortGpuMemoryByColumn('maxSize',1)).toBeUndefined(); }); + it('TabPaneGpuMemoryAbilityTest07', function () { + expect(tabPaneGpuMemoryAbility.queryDataByDB(val)).toBeUndefined(); + }); + it('TabPaneGpuMemoryAbilityTest08', function () { + expect(tabPaneGpuMemoryAbility.sortGpuMemoryByColumn('',0)).toBeUndefined(); + }); }) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts new file mode 100644 index 000000000..4452f3a3f --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TabPaneGpuMemorySelectAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneGpuMemorySelectAbility Test', () => { + let tabPaneGpuMemorySelectAbility = new TabPaneGpuMemorySelectAbility(); + let getTabGpuSelectionData = sqlite.getTabGpuMemoryAbilityClickData; + let gpuSelectionData = [ + { + startNs: 0, + size: 1000, + processId:2, + processName:'dd', + gpuName:'bb', + } + ]; + let val = [ + { + startNs: 0, + rightNs: 1000, + } + ]; + getTabGpuSelectionData.mockResolvedValue(gpuSelectionData); + it('TabPaneGpuMemorySelectAbility01', function () { + expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('',0)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectAbility02', function () { + expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('process',1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectAbility03', function () { + expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('startNs',1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectAbility04', function () { + expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('gpuName',1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectAbility05', function () { + expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('size',1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectAbility06', function () { + expect(tabPaneGpuMemorySelectAbility.queryDataByDB(val)).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts index 25ff9d5f7..7e55e7919 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts @@ -14,6 +14,8 @@ */ //@ts-ignore import { TabPaneHistoryProcesses } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -24,6 +26,27 @@ window.ResizeObserver = describe('TabPaneHistoryProcesses Test', function () { let tabPaneHistoryProcesses = new TabPaneHistoryProcesses(); + let val = [ + { + startNs: 0, + rightNs: 1000, + leftNs:0, + } + ]; + let getTabProcessHistoryData = sqlite.getTabProcessHistoryData; + let processHistoryData = [ + { + processId: 0, + alive: 1000, + firstSeen:2, + lastSeen:2, + processName:'aa', + responsibleProcess:1, + userName:2, + cpuTime:4, + } + ]; + getTabProcessHistoryData.mockResolvedValue(processHistoryData); it('TabPaneHistoryProcessesTest01 ', function () { tabPaneHistoryProcesses.queryHistoryResult.length = 1; expect(tabPaneHistoryProcesses.filterData()).toBeUndefined(); @@ -94,4 +117,7 @@ describe('TabPaneHistoryProcesses Test', function () { it('TabPaneHistoryProcessesTest10', function () { expect(tabPaneHistoryProcesses.timeFormat(0)).toBe('0 ms '); }); + it('TabPaneHistoryProcessesTest11', function () { + expect(tabPaneHistoryProcesses.queryDataByDB(val)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts index 4a757b202..eda5cab24 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts @@ -14,6 +14,11 @@ */ //@ts-ignore import { TabPaneLiveProcesses } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneLiveProcesses.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -24,7 +29,29 @@ window.ResizeObserver = describe('TabPaneLiveProcesses Test', function () { let tabPaneLiveProcesses = new TabPaneLiveProcesses(); - + let val = [ + { + startNs: 0, + rightNs: 1000, + leftNs:0, + } + ]; + let getTabLiveProcessData = sqlite.getTabLiveProcessData; + let liveProcessData = [ + { + processId: 0, + cpu: 1000, + threads:2, + memory:2, + processName:'aa', + responsibleProcess:1, + userName:2, + cpuTime:4, + diskReads:20, + diskWrite:10, + } + ]; + getTabLiveProcessData.mockResolvedValue(liveProcessData); it('TabPaneLiveProcessesTest01 ', function () { tabPaneLiveProcesses.queryLiveResult.length = 1; expect(tabPaneLiveProcesses.filterData()).toBeUndefined(); @@ -92,4 +119,7 @@ describe('TabPaneLiveProcesses Test', function () { it('TabPaneLiveProcessesTest08', function () { expect(tabPaneLiveProcesses.timeFormat(10)).toBe('10 ms '); }); + it('TabPaneLiveProcessesTest09', function () { + expect(tabPaneLiveProcesses.queryDataByDB(val)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts index f05301d45..0485af9e7 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts @@ -57,6 +57,24 @@ describe('TabPanePurgPin Test', () => { minSizes: "24.00MB", }, ]); + let data = [{ + avgSize: 25165824, + avgSizes: "24.00MB", + type: "allocator_host", + maxSize: 25165822, + maxSizes: "24.00MB", + minSize: 25165824, + minSizes: "24.00MB", + }, + { + avgSize: 25165824, + avgSizes: "24.00MB", + type: "11allocator_host", + maxSize: 25165824, + maxSizes: "24.00MB", + minSize: 25165824, + minSizes: "24.00MB", + }] tabPanePurgPin.init = jest.fn(() => true); tabPanePurgPin.data = { anomalyEnergy: [], @@ -99,9 +117,9 @@ describe('TabPanePurgPin Test', () => { processIds: [], processTrackIds: [], promiseList: [], - purgeablePinAbility: [], + purgeablePinAbility: data, purgeablePinSelection: [], - purgeablePinVM: [], + purgeablePinVM: data, purgeableTotalAbility: [], purgeableTotalSelection: [], purgeableTotalVM: [], @@ -122,11 +140,4 @@ describe('TabPanePurgPin Test', () => { }) ).toBeUndefined(); }); - it('TabPanePurgPinTest02', function () { - expect( - tabPanePurgPin.sortByColumn({ - key: 'type', - }) - ).toBeUndefined(); - }); }) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts new file mode 100644 index 000000000..ea9bb62d8 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TabPanePurgPinSelection } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgPinSelection.js'; + +const sqlit = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPanePurgPin Test', () => { + let tabPanePurgPinSelection = new TabPanePurgPinSelection(); + let querySysPurgeableSelectionTab = sqlit.querySysPurgeableSelectionTab; + querySysPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + ]); + let queryProcessPurgeableSelectionTab = sqlit.queryProcessPurgeableSelectionTab; + queryProcessPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + ]); + tabPanePurgPinSelection.data = { + anomalyEnergy: [], + clockMapData:{size: 0}, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [], + diskIOWriteIds: [], + diskIOipids: [], + dmaAbilityData: [], + dmaVmTrackerData: [], + fsCount: 0, + funAsync: [], + funTids: [], + gpu: {gl: false, gpuWindow: false, gpuTotal: false}, + gpuMemoryAbilityData: [], + gpuMemoryTrackerData: [], + hasFps: false, + irqMapData:{size: 0}, + isCurrentPane: false, + jankFramesData: [], + jsCpuProfilerData: [], + jsMemory: [], + leftNs: 5050699973, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processIds: [], + processTrackIds: [], + promiseList: [], + purgeablePinAbility: [], + purgeablePinSelection: [], + purgeablePinVM: [], + purgeableTotalAbility: [], + purgeableTotalSelection: [], + purgeableTotalVM: [], + recordStartNs: 333185936669149, + rightNs: 20081096280, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + startup: false, + staticInit: false, + statisticsSelectData: undefined, + }; + + it('tabPanePurgPinSelectionTest01', function () { + expect(tabPanePurgPinSelection.data).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts new file mode 100644 index 000000000..e847d1542 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TabPanePurgTotalSelection } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.js'; + +const sqlit = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPanePurgTotalSelection Test', () => { + let tabPanePurgTotalSelection = new TabPanePurgTotalSelection(); + let querySysPurgeableSelectionTab = sqlit.querySysPurgeableSelectionTab; + querySysPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + ]); + let queryProcessPurgeableSelectionTab = sqlit.queryProcessPurgeableSelectionTab; + queryProcessPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + { + value: 25165824, + name: "24.00MB", + }, + ]); + tabPanePurgTotalSelection.data = { + anomalyEnergy: [], + clockMapData:{size: 0}, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [], + diskIOWriteIds: [], + diskIOipids: [], + dmaAbilityData: [], + dmaVmTrackerData: [], + fsCount: 0, + funAsync: [], + funTids: [], + gpu: {gl: false, gpuWindow: false, gpuTotal: false}, + gpuMemoryAbilityData: [], + gpuMemoryTrackerData: [], + hasFps: false, + irqMapData:{size: 0}, + isCurrentPane: false, + jankFramesData: [], + jsCpuProfilerData: [], + jsMemory: [], + leftNs: 5050699973, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processIds: [], + processTrackIds: [], + promiseList: [], + purgeablePinAbility: [], + purgeablePinSelection: [], + purgeablePinVM: [], + purgeableTotalAbility: [], + purgeableTotalSelection: [], + purgeableTotalVM: [], + recordStartNs: 333185936669149, + rightNs: 20081096280, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + startup: false, + staticInit: false, + statisticsSelectData: undefined, + }; + + it('TabPanePurgTotalSelectionTest01', function () { + expect(tabPanePurgTotalSelection.data).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts b/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts new file mode 100644 index 000000000..0e99c128c --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +//@ts-ignore +import { TabPaneJsCpuStatistics } from '../../../../../../dist/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.js'; +import '../../../../../../dist/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.js'; +import { JsCpuProfilerStatisticsStruct } from '../../../../../../dist/trace/bean/JsStruct.js'; + +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {} +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + recycleDataSource: () => {}, + removeAttribute: () => {}, + reMeauseHeight: () => {}, + addEventListener: () => {}, + }; +}); + +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneJsCpuCallTree Test', () => { + document.body.innerHTML = ``; + let tabPaneJsCpuStatistics = document.querySelector('#statistics'); + let res = [ + { + type: 'a', + time: 0, + timeStr:'st', + percentage:'s', + }, + { + type: 'a', + time: 345, + timeStr:'st', + percentage:'s', + } + ] + it('TabPaneJsCpuStatisticsTest01', () => { + tabPaneJsCpuStatistics.init = jest.fn(()=>true) + tabPaneJsCpuStatistics.data = { + rightNs: 5, + leftNs: 1, + } + expect(tabPaneJsCpuStatistics.data).toBeUndefined(); + }); + it('TabPaneJsCpuStatisticsTest02', () => { + tabPaneJsCpuStatistics.statisticsTable = jest.fn(()=>true) + tabPaneJsCpuStatistics.statisticsTable.addEventListener = jest.fn(()=>true) + tabPaneJsCpuStatistics.statisticsTable.reMeauseHeight = jest.fn(()=>true) + expect(tabPaneJsCpuStatistics.queryPieChartDataByType(res)).toBeUndefined(); + }); + it('TabPaneJsCpuStatisticsTest03', () => { + expect(tabPaneJsCpuStatistics.totalData(res)).toEqual( + {"percentage": "100.0", "time": 345, "timeStr": "345.0 ns", "type": ""} + ); + }); + it('TabPaneJsCpuStatisticsTest04', () => { + tabPaneJsCpuStatistics.toStatisticsStruct = jest.fn(()=>true) + expect(tabPaneJsCpuStatistics.setStatisticsData([''],res)).toStrictEqual([true]); + }); + it('TabPaneJsCpuStatisticsTest05', () => { + expect( + tabPaneJsCpuStatistics.sortByColumn({ + key: 'time', + sort:0, + type: 'number', + }) + ).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.test.ts index cd9c15b26..f7f155a17 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.test.ts @@ -22,6 +22,13 @@ import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/shee import { FrameChart } from '../../../../../../dist/trace/component/chart/FrameChart.js'; // @ts-ignore import { NativeHookStatisticsTableData } from '../../../../../../dist/trace/database/ui-worker/ProcedureWorkerCPU.js'; + +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorkerCPU.js', () => { return { cpuCount: 1, diff --git a/ide/test/trace/component/trace/sheet/freq/TabPaneCpuFreqLimits.test.ts b/ide/test/trace/component/trace/sheet/freq/TabPaneCpuFreqLimits.test.ts new file mode 100644 index 000000000..d1f12c13c --- /dev/null +++ b/ide/test/trace/component/trace/sheet/freq/TabPaneCpuFreqLimits.test.ts @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TabPaneCpuFreqLimits } from '../../../../../../dist/trace/component/trace/sheet/freq/TabPaneCpuFreqLimits.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); + +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('TabPaneCpuFreqLimits Test', () => { + let tabPaneCpuFreqLimits = new TabPaneCpuFreqLimits(); + it('TabPaneCpuFreqLimits01', function () { + expect(tabPaneCpuFreqLimits.sortCpuFreqLimitTable('timeStr',1)).toBeUndefined(); + }); + it('TabPaneCpuFreqLimits02', function () { + expect(tabPaneCpuFreqLimits.sortCpuFreqLimitTable('valueStr',1)).toBeUndefined(); + }); + it('TabPaneCpuFreqLimits03', function () { + expect(tabPaneCpuFreqLimits.sortCpuFreqLimitTable('cpu',1)).toBeUndefined(); + }); + it('TabPaneCpuFreqLimits04', function () { + expect(tabPaneCpuFreqLimits.sortCpuFreqLimitTable('type',1)).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts index d0a40e9d2..b34cd3dfe 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts @@ -18,10 +18,11 @@ import { TabPaneGpuClickSelect } from '../../../../../../dist/trace/component/tr jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); // @ts-ignore -window.ResizeObserver = - window.ResizeObserver || +window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), observe: jest.fn(), @@ -31,11 +32,33 @@ window.ResizeObserver = describe('TabPaneGpuClickSelect Test', () => { document.body.innerHTML = `
`; let tabPaneGpuClickSelect = document.querySelector('#tree'); + let queryGpuDataByTs = sqlite.queryGpuDataByTs; + queryGpuDataByTs.mockResolvedValue([ + { + windowId:1, + moduleId:2, + categoryId:0, + size:123 + }, + { + windowId:7, + moduleId:8, + categoryId:2, + size:1213 + } + ]) it('TabPaneGpuClickSelectTest01', () => { tabPaneGpuClickSelect.data = { type: '', startTs: 1, }; - expect(tabPaneGpuClickSelect.data).not.toBeUndefined(); + expect(tabPaneGpuClickSelect.data).toBeUndefined(); }); + it('TabPaneGpuClickSelectTest02', () => { + let tabPaneGpuClickSelects = new TabPaneGpuClickSelect(); + tabPaneGpuClickSelects.gpuTbl = jest.fn(()=>true) + expect(tabPaneGpuClickSelects.sortByColumn({ + sort:0 + })).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts new file mode 100644 index 000000000..e799ac811 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +//@ts-ignore +import { TabPaneGpuGL } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuGL.js'; + +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); + +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneGpuGL Test', () => { + document.body.innerHTML = `
`; + let tabPaneGpuGL = document.querySelector('#tree'); + let queryGpuGLDataByRange = sqlite.queryGpuGLDataByRange; + queryGpuGLDataByRange.mockResolvedValue([ + { + startTs: 23, + size:10, + }, + { + startTs: 213, + size:110, + } + ]) + it('TabPaneGpuGLTest01', () => { + tabPaneGpuGL.data = { + leftNs: 0, + rightNs:1, + }; + expect(tabPaneGpuGL.data).toStrictEqual({"leftNs": 0, "rightNs": 1}); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts new file mode 100644 index 000000000..66f964ae0 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +//@ts-ignore +import { TabPaneGpuTotalBoxSelect } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.js'; + +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); + +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneGpuTotalBoxSelect Test', () => { + document.body.innerHTML = `
`; + let tabPaneGpuTotalBoxSelect = document.querySelector('#tree'); + let queryGpuDataByRange = sqlite.queryGpuDataByRange; + queryGpuDataByRange.mockResolvedValue([ + { + startTs: 23, + windowId:1, + moduleId:2, + categoryId:0, + sumSize:10, + avgSize:1, + maxSize:1, + minSize:0 + }, + { + startTs: 23, + windowId:1, + moduleId:2, + categoryId:0, + sumSize:10, + avgSize:1, + maxSize:1, + minSize:0 + } + ]) + it('TabPaneGpuTotalBoxSelectTest01', () => { + tabPaneGpuTotalBoxSelect.data = { + type: '', + startTs: 1, + }; + expect(tabPaneGpuTotalBoxSelect.data).toBeUndefined(); + }); + it('TabPaneGpuTotalBoxSelectTest02', () => { + let tabPaneGpuTotalBoxSelects = new TabPaneGpuTotalBoxSelect(); + tabPaneGpuTotalBoxSelects.gpuBoxTbl = jest.fn(()=>true) + expect(tabPaneGpuTotalBoxSelects.sortByColumn({ + sort:0 + })).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts new file mode 100644 index 000000000..9e1922ff0 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +//@ts-ignore +import { TabPaneGpuWindowBoxSelect } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.js'; + +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); + +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneGpuWindowBoxSelect Test', () => { + document.body.innerHTML = `
`; + let tabPaneGpuWindowBoxSelect = document.querySelector('#tree'); + let queryGpuDataByRange = sqlite.queryGpuDataByRange; + queryGpuDataByRange.mockResolvedValue([ + { + startTs: 23, + windowId:1, + moduleId:2, + categoryId:0, + sumSize:10, + avgSize:1, + maxSize:1, + minSize:0 + }, + { + startTs: 23, + windowId:1, + moduleId:2, + categoryId:0, + sumSize:10, + avgSize:1, + maxSize:1, + minSize:0 + } + ]) + it('TabPaneGpuWindowBoxSelectTest01', () => { + tabPaneGpuWindowBoxSelect.data = { + type: '', + startTs:1, + }; + expect(tabPaneGpuWindowBoxSelect.data).toBeUndefined(); + }); + it('TabPaneGpuWindowBoxSelectTest02', () => { + let tabPaneGpuWindowBoxSelects = new TabPaneGpuWindowBoxSelect(); + tabPaneGpuWindowBoxSelects.gpuBoxTbl = jest.fn(()=>true) + expect(tabPaneGpuWindowBoxSelects.sortByColumn({ + sort:0 + })).toBeUndefined(); + }); + it('TabPaneGpuWindowBoxSelectTest03', () => { + let tabPaneGpuWindowBoxSelects = new TabPaneGpuWindowBoxSelect(); + tabPaneGpuWindowBoxSelects.gpuBoxTbl = jest.fn(()=>true) + expect(tabPaneGpuWindowBoxSelects.sortByColumn({ + sort:1 + })).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts b/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts index 09c5bea36..5d782d8de 100644 --- a/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts +++ b/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts @@ -439,4 +439,94 @@ describe('TabPanePerfAnalysis Test', () => { tabPanePerfAnalysis.getHiperfThread(item, val); expect(tabPanePerfAnalysis).toBeTruthy(); }); + it('TabPanePerfAnalysisTest12', function () { + document.body.innerHTML = ` + `; + let tabPanePerfAnalysis = document.getElementById('slc') as TabPanePerfAnalysis; + let item = { + "tableName": "hiperf(28917)", + "pid": 28917, + "percent": "43.53", + "countFormat": "8.00s", + "count": 8460, + "isHover": true + }; + let val = { + perfThread: [], + perfProcess: [], + } + tabPanePerfAnalysis.processData = [ + { + "sampleId": 0, + "tid": 12, + "count": 1, + "threadState": "Running", + "pid": 12, + "eventCount": 14, + "threadName": "rcu_sched", + "processName": "rcu_sched", + "libId": 106, + "libName": "[kernel.kallsyms]", + "symbolId": 148, + "symbolName": "perf_trace_sched_wakeup_template" + }, + { + "sampleId": 0, + "tid": 193, + "count": 1, + "threadState": "Running", + "pid": 193, + "eventCount": 14, + "threadName": "irq/31-rga", + "processName": "irq/31-rga", + "libId": 106, + "libName": "[kernel.kallsyms]", + "symbolId": 148, + "symbolName": "perf_trace_sched_wakeup_template" + }]; + tabPanePerfAnalysis.tableSo.reMeauseHeight = jest.fn(() => true); + tabPanePerfAnalysis.getHiperfSo(item, val); + expect(tabPanePerfAnalysis).toBeTruthy(); + }); + it('TabPanePerfAnalysisTest13', function () { + document.body.innerHTML = ` + `; + let tabPanePerfAnalysis = document.getElementById('slc') as TabPanePerfAnalysis; + let val = { + perfThread: [], + perfProcess: [], + } + tabPanePerfAnalysis.processData = [ + { + "sampleId": 0, + "tid": 12, + "count": 1, + "threadState": "Running", + "pid": 12, + "eventCount": 14, + "threadName": "rcu_sched", + "processName": "rcu_sched", + "libId": 106, + "libName": "[kernel.kallsyms]", + "symbolId": 148, + "symbolName": "perf_trace_sched_wakeup_template" + }, + { + "sampleId": 0, + "tid": 193, + "count": 1, + "threadState": "Running", + "pid": 193, + "eventCount": 14, + "threadName": "irq/31-rga", + "processName": "irq/31-rga", + "libId": 106, + "libName": "[kernel.kallsyms]", + "symbolId": 148, + "symbolName": "perf_trace_sched_wakeup_template" + }]; + tabPanePerfAnalysis.tableSo.reMeauseHeight = jest.fn(() => true); + tabPanePerfAnalysis.data = jest.fn(() => true); + expect(tabPanePerfAnalysis).toBeTruthy(); + }); }) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts index 646308b4a..4a39ed6f5 100644 --- a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts @@ -62,7 +62,7 @@ describe('TabPaneSmapsRecord Test', () => { swap_pss: 2, }, ]); - // + let tabPaneSmapsRecord = new TabPaneSmapsRecord(); tabPaneSmapsRecord.init = jest.fn(() => true); let smaps = new Smaps(); @@ -104,7 +104,6 @@ describe('TabPaneSmapsRecord Test', () => { }) ).toBeUndefined(); }); - it('tabPaneSmapsRecord02', () => { expect(tabPaneSmapsRecord.initElements()).toBeUndefined(); }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts index 2d149062e..5185d8ec2 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts @@ -66,15 +66,6 @@ describe('TabPaneDmaSelectVmTracker Test', () => { it('TabPaneDmaSelectVmTracker01', () => { expect(dmaVmTracker.sortDmaByColumn('', 0)).toBeUndefined(); }); - it('TabPaneDmaSelectVmTracker02', () => { - expect(dmaVmTracker.sortDmaByColumn('startNs', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker03', () => { - expect(dmaVmTracker.sortDmaByColumn('expTaskComm', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker04', () => { - expect(dmaVmTracker.sortDmaByColumn('sumSizes', 1)).toBeUndefined(); - }); it('TabPaneDmaSelectVmTracker05', () => { expect(dmaVmTracker.sortDmaByColumn('avgSize', 1)).toBeUndefined(); }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts index f558b05b1..5b6104cdf 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts @@ -61,14 +61,11 @@ describe('TabPaneGpuMemoryVmTracker Test', () => { ]; gpuMemoryData.mockResolvedValue(gpuData); it('TabPaneGpuMemoryVmTracker01', () => { - expect(gpuMemoryVmTracker.sortGpuMemoryByColumn('expTaskComm', 1)).toBeUndefined(); + expect(gpuMemoryVmTracker.sortGpuMemoryByColumn('gpuName', 1)).toBeUndefined(); }); it('TabPaneGpuMemoryVmTracker02', () => { expect(gpuMemoryVmTracker.sortGpuMemoryByColumn('', 0)).toBeUndefined(); }); - it('TabPaneGpuMemoryVmTracker03', () => { - expect(gpuMemoryVmTracker.sortGpuMemoryByColumn('sumSizes', 1)).toBeUndefined(); - }); it('TabPaneGpuMemoryVmTracker04', () => { expect(gpuMemoryVmTracker.sortGpuMemoryByColumn('avgSize', 1)).toBeUndefined(); }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts index 77d09cb2c..76848fb68 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts @@ -35,10 +35,11 @@ jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { return {}; }); +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); // @ts-ignore -window.ResizeObserver = - window.ResizeObserver || +window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), observe: jest.fn(), @@ -48,6 +49,51 @@ window.ResizeObserver = describe('TabPaneVmTrackerShmSelection Test', () => { document.body.innerHTML = ` `; let tabPaneVmTrackerShmSelection = new TabPaneVmTrackerShmSelection(); + let queryVmTrackerShmSelectionData = sqlite.queryVmTrackerShmSelectionData; + queryVmTrackerShmSelectionData.mockResolvedValue([ + { + startNs: 0, + ipid:1, + fd:123, + size:12, + adj: 3, + name:'NAME', + id:1, + time:12333, + purged:6, + count:3, + flag:0 + } + ]) + let data = { + startNs: 0, + endNs: 0, + dur:0, + name:'', + textWidth: 0, + value: 0, + type: '', + } + let dataList = [ + { + startNs: 0, + endNs: 0, + dur:0, + name:'', + textWidth: 0, + value: 0, + type: '', + }, + { + startNs: 1, + endNs: 2, + dur:1, + name:'a', + textWidth: 0, + value: 0, + type: 'a', + } + ] it('TabPaneVmTrackerShmSelection01', () => { expect(tabPaneVmTrackerShmSelection.sortByColumn('ts', 1)).toBeUndefined(); }); @@ -84,4 +130,13 @@ describe('TabPaneVmTrackerShmSelection Test', () => { it('TabPaneVmTrackerShmSelection12', () => { expect(tabPaneVmTrackerShmSelection.clear()).toBeUndefined(); }); + it('TabPaneVmTrackerShmSelection13', () => { + tabPaneVmTrackerShmSelection.init = jest.fn(() => true); + tabPaneVmTrackerShmSelection.clear = jest.fn(() => true); + tabPaneVmTrackerShmSelection.queryDataByDB = jest.fn(() => true); + expect(tabPaneVmTrackerShmSelection.setShmData(data,dataList)).toBeUndefined(); + }); + it('TabPaneVmTrackerShmSelection14', () => { + expect(tabPaneVmTrackerShmSelection.queryDataByDB(data)).toBe(true); + }); }); diff --git a/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts b/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts index 68ce3eba9..7e2d9f20d 100644 --- a/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts @@ -279,4 +279,10 @@ describe('RangeRuler Test', () => { it('RangeRulerTest25', function () { expect(rangeRuler.delayDraw()).toBeUndefined(); }); + it('RangeRulerTest26', function () { + expect(rangeRuler.keyPressF()).toBeUndefined(); + }); + it('RangeRulerTest27', function () { + expect(rangeRuler.zoomFit('100','200')).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts index 20d5a5784..bc6de14a1 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts @@ -530,4 +530,57 @@ describe('ProcedureLogicWorkerPerf Test', () => { let procedureLogicWorkerPerf = new ProcedureLogicWorkerPerf(); expect(procedureLogicWorkerPerf.splitAllProcess([])).toBeUndefined(); }); + it('ProcedureLogicWorkerPerfTest57', function () { + let procedureLogicWorkerPerf = new ProcedureLogicWorkerPerf(); + let callChains = [{ + tid:1, + sampleId:20, + }, + { + tid:2, + sampleId:30, + } + ] + expect(procedureLogicWorkerPerf.initPerfCallChainBottomUp(callChains)).toBeUndefined(); + }); + it('ProcedureLogicWorkerPerfTest58', function () { + let procedureLogicWorkerPerf = new ProcedureLogicWorkerPerf(); + let callChains = [{ + tid:1, + sampleId:20, + symbolId:-1, + fileName:'a' + }, + { + tid:2, + sampleId:30, + symbolId:0, + fileName:'a' + } + ] + expect(procedureLogicWorkerPerf.setPerfCallChainFrameName(callChains)).toBeUndefined(); + }); + it('ProcedureLogicWorkerPerfTest59', function () { + let procedureLogicWorkerPerf = new ProcedureLogicWorkerPerf(); + let callChains = [{ + sampleId: '', + depth: 0, + canCharge: false, + name: '', + tid: '', + fileName: '', + threadName: '', + }, + { + sampleId: '', + depth: 0, + canCharge: false, + name: '', + tid: '', + fileName: '', + threadName: '', + } + ] + expect(procedureLogicWorkerPerf.addPerfGroupData(callChains)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts new file mode 100644 index 000000000..cb7163a33 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +// @ts-ignore +import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; +// @ts-ignore +import { AppStartupRender, AppStartupStruct} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerAppStartup.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); + +describe('ProcedureWorkerAppStartup Test', () => { + it('AppStartupStructTest01', () => { + const data = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + dur: 1, + value: 'aa', + startTs: 12, + pid: 1, + process: 'null', + itid: 12, + endItid: 13, + tid: 1, + startName: '23', + stepName: 'st' + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(AppStartupStruct.draw(ctx, data)).toBeUndefined(); + }); + + it('AppStartupStructTest02', () => { + expect(AppStartupStruct.getStartupName(12)).toBe("Unknown Start Step"); + }); + it('AppStartupStructTest03', () => { + expect(AppStartupStruct).not.toBeUndefined(); + }); +}); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts index 03b20c15b..2ae7209b1 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts @@ -24,6 +24,10 @@ import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js describe(' FPSTest', () => { it('FpsTest01', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); let dataList = new Array(); dataList.push({ startTime: 0, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts index 9d6cc4102..521b22945 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts @@ -88,7 +88,7 @@ describe(' Test', () => { startNS: 200, value: 50, }; - expect(HeapStruct.draw(ctx, data)).toBeUndefined(); + expect(HeapStruct.drawHeap(ctx, data, 0)).toBeUndefined(); }); it('HeapTest04', () => { const canvas = document.createElement('canvas'); @@ -106,7 +106,7 @@ describe(' Test', () => { maxHeapSize: 200, value: 50, }; - expect(HeapStruct.draw(ctx, data)).toBeUndefined(); + expect(HeapStruct.drawHeap(ctx, data, 1)).toBeUndefined(); }); it('HeapTest05', function () { @@ -150,4 +150,32 @@ describe(' Test', () => { window.postMessage = jest.fn(() => true); expect(nativeMemoryRender.render(req, [], [])).toBeUndefined(); }); + it('HeapTest04', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + + const data = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startNS: 200, + value: 50, + }; + const node = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startNS: 200, + value: 50, + }; + expect(HeapStruct.setFrame(node, 2, 1, 5, 4, data)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts index 1b9aca00e..6b884347b 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts @@ -12,11 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; -}); - // @ts-ignore import { HiPerfEventStruct, @@ -24,6 +19,11 @@ import { } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.js'; // @ts-ignore import { Rect } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCommon'; +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); describe('ProcedureWorkerHiPerfEvent Test', () => { it('ProcedureWorkerHiPerfEventTest03', () => { @@ -92,8 +92,8 @@ describe('ProcedureWorkerHiPerfEvent Test', () => { }); it('ProcedureWorkerHiPerfEventTest06', function () { - expect(HiPerfEventStruct.groupBy10MS([{ ps: 1 }, { coX: '1' }], 10, '')).toEqual([ - { dur: 10000000, height: Infinity, startNS: NaN}, + expect(HiPerfEventStruct.eventGroupBy10MS([{ ps: 1 }, { coX: '1' }], 10, '')).toEqual([ + { dur: 10000000, height: NaN, startNS: NaN,max: 0,sum:NaN}, ]); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts index f9a68d6b8..981048d35 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts @@ -177,8 +177,8 @@ describe('ProcedureWorkerHiPerfReport Test', () => { }); it('ProcedureWorkerHiPerfReportTest06', function () { - expect(HiPerfReportStruct.groupBy10MS([{ ps: 1 }, { coX: '1' }], 10, '')).toEqual([ - { dur: 10000000, height: Infinity, startNS: NaN}, + expect(HiPerfReportStruct.reportGroupBy10MS([{ ps: 1 }, { coX: '1' }], 10)).toEqual([ + { dur: 10000000, height: NaN, startNS: NaN, sum:NaN}, ]); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts new file mode 100644 index 000000000..9f03cb183 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * 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. + */ +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +// @ts-ignore +import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; +// @ts-ignore +import { soDataFilter, SoRender, SoStruct} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerSoInit.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); + +describe('ProcedureWorkerSoInit Test', () => { + it('soDataFilterTest', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + let rect = new Rect(0, 10, 10, 10); + let filter = [ + { + startTs: 50, + dur: 1520000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 0, + itid: 2, + textMetricsWidth: 50.5810546875, + process: '' + }, + ]; + let list = [ + { + startTs: 50, + dur: 1520000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 0, + itid: 2, + textMetricsWidth: 50.5810546875, + process: '' + }, + ]; + soDataFilter(list, filter, 100254, 100254, rect, { height: 40, width: 1407, x: 0, y: 0 },true); + }); + + it('SoStructTest01', () => { + const data = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startTs: 50, + dur: 1520000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 0, + itid: 2, + textMetricsWidth: 50.5810546875, + process: '' + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(SoStruct.draw(ctx, data)).toBeUndefined(); + }); + + it('SoStructTest02', () => { + const data = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startTs: 50, + dur: 1520000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 0, + itid: 2, + textMetricsWidth: 50.5810546875, + process: '' + }; + let node = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startTs: 50, + dur: 1520000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 0, + itid: 2, + textMetricsWidth: 50.5810546875, + process: '' + }; + expect(SoStruct.setSoFrame(node, 2, 0, 1, 2, data)).toBeUndefined(); + }); + it('SoStructTest03', () => { + expect(SoStruct).not.toBeUndefined(); + }); +}); -- Gitee From 158a8095767f1da9cc1a4b386a3e5ea90cbe30bd Mon Sep 17 00:00:00 2001 From: zhangzepeng Date: Mon, 31 Jul 2023 20:01:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E2=80=99=E9=A6=96=E9=A1=B5=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzepeng --- ide/src/trace/component/SpWelcomePage.ts | 12 ++++++++++++ .../trace/component/trace/timer-shaft/RangeRuler.ts | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ide/src/trace/component/SpWelcomePage.ts b/ide/src/trace/component/SpWelcomePage.ts index 59d9e29a3..ecb418c6d 100644 --- a/ide/src/trace/component/SpWelcomePage.ts +++ b/ide/src/trace/component/SpWelcomePage.ts @@ -30,11 +30,23 @@ export class SpWelcomePage extends BaseElement { align-content: center; background: var(--dark-background5,#F6F6F6); } + .home-page{ + margin-top: -100px; + } .lit-icon{ + margin-top: 50px; + margin-left: 50px; content: var(--dark-img,url('img/pic.png')); }
+
+

黄区域名: https://smartperf.rnd.huawei.com/smartperf/

+

绿区域名: https://devecotesting.rnd.huawei.com/smartperf/

+

3ms社区: http://3ms.huawei.com/km/groups/3956611/home?|=zh-cn

+

welink讨论群: 群1: 473395703, 群2: 485625665

+

welink讨论群: 群1: 473395703(已满), 群2: 485625665(已满), 群3: 593524364461277889

+
`; diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts index c25b22a8f..eb00a1cc6 100644 --- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts @@ -951,10 +951,10 @@ export class RangeRuler extends Graph { count2++; } } + if (count2 >= 10) { + return; + } if (totalX <= FIT_TOTALX_MIN) { - if (count2 >= 10) { - return; - } this.pressFrameIdW = requestAnimationFrame(animW); this.fillX(); this.range.refresh = true; -- Gitee