diff --git a/ide/src/base-ui/chart/pie/LitChartPie.ts b/ide/src/base-ui/chart/pie/LitChartPie.ts index ed191a2492e55e667c1073d7436c5292478c665c..a70f491bfdcbdc32ab49f5e359857c38c3b36869 100644 --- a/ide/src/base-ui/chart/pie/LitChartPie.ts +++ b/ide/src/base-ui/chart/pie/LitChartPie.ts @@ -135,11 +135,15 @@ export class LitChartPie extends BaseElement { this.data.push(item); startAngle += full * ((pieItem[pieCfg.angleField] / sum) * 360); startDegree += fullDegree + (pieItem[pieCfg.angleField] / sum) * 360; + let colorFieldValue = item.obj[pieCfg.colorField]; + if (this.config?.colorFieldTransferHandler) { + colorFieldValue = this.config.colorFieldTransferHandler(colorFieldValue); + } labelArray.push(``); }); diff --git a/ide/src/base-ui/chart/pie/LitChartPieConfig.ts b/ide/src/base-ui/chart/pie/LitChartPieConfig.ts index 50846a86dc5adee92b0d2de6d6fda115476b36ed..9960f1bbcd86c9ad53b1746686bae7095a24b790 100644 --- a/ide/src/base-ui/chart/pie/LitChartPieConfig.ts +++ b/ide/src/base-ui/chart/pie/LitChartPieConfig.ts @@ -18,6 +18,7 @@ export interface LitChartPieConfig { data: any[]; angleField: string; colorField: string; + colorFieldTransferHandler?: (value: any) => any; radius: number; angleClick?: (it: object) => void; label: { diff --git a/ide/src/base-ui/select/LitSelectOption.ts b/ide/src/base-ui/select/LitSelectOption.ts index cbade4cd0334b41e4ebadc8810299a15c003b1c6..5c7afc8ce8fda677143dd45b06318621d212052a 100644 --- a/ide/src/base-ui/select/LitSelectOption.ts +++ b/ide/src/base-ui/select/LitSelectOption.ts @@ -93,6 +93,7 @@ export class LitSelectOption extends BaseElement { }, }) ); + ev.stopPropagation(); }; } } diff --git a/ide/src/base-ui/table/lit-table.ts b/ide/src/base-ui/table/lit-table.ts index 4931e6dcc804d315bdf68413e24247975271a4be..a7b633855465e0aec6429a0843dd4b1f1507fb28 100644 --- a/ide/src/base-ui/table/lit-table.ts +++ b/ide/src/base-ui/table/lit-table.ts @@ -30,8 +30,9 @@ export class LitTable extends HTMLElement { currentTreeDivList: HTMLDivElement[] = []; public rememberScrollTop = false; public getItemTextColor?: (data: any) => string; + public itemTextHandleMap: Map string> = new Map string>(); private ds: Array = []; - private recycleDs: Array = []; + public recycleDs: Array = []; private normalDs: Array = []; private gridTemplateColumns: any; /*Grid css layout descriptions are obtained according to the clustern[] nested structure*/ @@ -753,7 +754,7 @@ export class LitTable extends HTMLElement { if (tblColumn.hasAttribute('fixed')) { this.fixed(tblDiv, tblColumn.getAttribute('fixed') || '', '#ffffff'); } - tblDiv.innerHTML = this.formatName(rowData[dataIndex]); + tblDiv.innerHTML = this.formatName(dataIndex, rowData[dataIndex]); tblRowElement.append(tblDiv); } }); @@ -868,7 +869,7 @@ export class LitTable extends HTMLElement { this.fixed(treeTblEl, treeTblColumn.getAttribute('fixed') || '', '#ffffff'); } // @ts-ignore - treeTblEl.innerHTML = this.formatName(rowData[dataIndex]); + treeTblEl.innerHTML = this.formatName(dataIndex, rowData[dataIndex]); } treeTblRowElement.append(treeTblEl); } else { @@ -893,7 +894,7 @@ export class LitTable extends HTMLElement { this.fixed(treeTblEl, treeTblColumn.getAttribute('fixed') || '', '#ffffff'); } // @ts-ignore - treeTblEl.innerHTML = this.formatName(rowData[dataIndex]); + treeTblEl.innerHTML = this.formatName(dataIndex, rowData[dataIndex]); } if (rowData.children && rowData.children.length > 0) { let treeTblIcon = document.createElement('lit-icon'); @@ -965,6 +966,8 @@ export class LitTable extends HTMLElement { return 27; } + + meauseAllRowHeight(list: any[]): TableRowObject[] { this.tbodyElement!.innerHTML = ''; this.meauseRowElement = undefined; @@ -974,7 +977,7 @@ export class LitTable extends HTMLElement { let headHeight = 0; let totalHeight = headHeight; let visibleObjects: TableRowObject[] = []; - list.forEach((rowData, index) => { + let itemHandler = (rowData: any, index: number) => { let height = this.meauseElementHeight(rowData); let tableRowObject = new TableRowObject(); tableRowObject.height = height; @@ -989,9 +992,24 @@ export class LitTable extends HTMLElement { newTableElement.style.transform = `translateY(${totalHeight}px)`; this.tbodyElement?.append(newTableElement); this.currentRecycleList.push(newTableElement); + let td = newTableElement?.querySelectorAll('.td'); + if (tableRowObject.data.rowName === 'cpu-profiler') { + this.createTextColor(tableRowObject, td[0]); + } } totalHeight += height; visibleObjects.push(tableRowObject); + } + let realIndex = 0; + list.forEach((item, index) => { + if (Array.isArray(item)) { + item.forEach((rowData, childIndex) => { + itemHandler(rowData, realIndex); + realIndex++; + }); + } else { + itemHandler(item, index); + } }); this.tbodyElement && (this.tbodyElement.style.height = totalHeight + (this.isScrollXOutSide ? 0 : 0) + 'px'); this.tableElement && @@ -1019,6 +1037,11 @@ export class LitTable extends HTMLElement { } for (let i = 0; i < this.currentRecycleList.length; i++) { this.freshCurrentLine(this.currentRecycleList[i], visibleObjects[i + skip]); + if (visibleObjects[i + skip]) { + if (visibleObjects[i + skip].data.rowName === 'cpu-profiler') { + this.createTextColor(visibleObjects[i + skip], this.currentRecycleList[i].childNodes[0]); + } + } } }); return visibleObjects; @@ -1133,7 +1156,7 @@ export class LitTable extends HTMLElement { td.title = rowData.data[dataIndex]; } else { td = document.createElement('div'); - td.innerHTML = this.formatName(rowData.data[dataIndex]); + td.innerHTML = this.formatName(dataIndex, rowData.data[dataIndex]); td.dataIndex = dataIndex; td.title = rowData.data[dataIndex]; } @@ -1189,6 +1212,9 @@ export class LitTable extends HTMLElement { } td.title = rowData.data.objectName; } + if (rowData.data.rowName === 'cpu-profiler') { + this.createTextColor(rowData, td); + } (td as any).data = rowData.data; td.classList.add('tree-first-body'); td.style.position = 'absolute'; @@ -1231,7 +1257,7 @@ export class LitTable extends HTMLElement { td.appendChild(column.template.render(rowData.data).content.cloneNode(true)); td.template = column.template; } else { - td.innerHTML = this.formatName(rowData.data[dataIndex]); + td.innerHTML = this.formatName(dataIndex, rowData.data[dataIndex]); } newTableElement.append(td); } @@ -1403,6 +1429,11 @@ export class LitTable extends HTMLElement { ); } else { this.freshCurrentLine(this.currentRecycleList[i], visibleObjects[i + skip]); + if (visibleObjects[i + skip]) { + if (visibleObjects[i + skip].data.rowName === 'cpu-profiler') { + this.createTextColor(visibleObjects[i + skip], this.currentRecycleList[i].childNodes[0]); + } + } } } } @@ -1427,7 +1458,7 @@ export class LitTable extends HTMLElement { td.appendChild(column.template.render(rowData.data).content.cloneNode(true)); td.template = column.template; } else { - td.innerHTML = this.formatName(rowData.data[dataIndex]); + td.innerHTML = this.formatName(dataIndex, rowData.data[dataIndex]); } newTableElement.append(td); }); @@ -1475,7 +1506,7 @@ export class LitTable extends HTMLElement { .content.cloneNode(true).innerHTML; } else { let dataIndex = this.columns![0].getAttribute('data-index') || '1'; - firstElement.innerHTML = this.formatName(rowObject.data[dataIndex]); + firstElement.innerHTML = this.formatName(dataIndex, rowObject.data[dataIndex]); firstElement.title = rowObject.data[dataIndex]; } if (rowObject.children && rowObject.children.length > 0 && !rowObject.data.hasNext) { @@ -1531,6 +1562,9 @@ export class LitTable extends HTMLElement { } firstElement.title = rowObject.data.objectName; } + if (rowObject.data.rowName === 'cpu-profiler') { + this.createTextColor(rowObject, firstElement); + } firstElement.onclick = () => { this.dispatchRowClickEvent(rowObject, [firstElement, element]); }; @@ -1549,7 +1583,7 @@ export class LitTable extends HTMLElement { ); (child as HTMLElement).title = rowObject.data[dataIndex]; } else { - (child as HTMLElement).innerHTML = this.formatName(rowObject.data[dataIndex]); + (child as HTMLElement).innerHTML = this.formatName(dataIndex, rowObject.data[dataIndex]); (child as HTMLElement).title = rowObject.data[dataIndex]; } }); @@ -1810,9 +1844,13 @@ export class LitTable extends HTMLElement { ); } - formatName(name: any) { - if (name != undefined && name !== null) { - return name.toString().replace(//g, '>'); + formatName(key: string, name: any) { + let content = name; + if (this.itemTextHandleMap.has(key)) { + content = this.itemTextHandleMap.get(key)?.(name) || ''; + } + if (content !== undefined && content !== null) { + return content.toString().replace(//g, '>'); } return ''; } @@ -1824,4 +1862,19 @@ export class LitTable extends HTMLElement { element.removeAttribute('high-light'); } } + + createTextColor(rowData: any, divElement: any) { + let nodeText = document.createElement('text'); + nodeText.classList.add('functionName'); + nodeText.textContent = rowData.data.name; + divElement.append(nodeText); + if (rowData.data.scriptName !== 'unknown') { + let scriptText = document.createElement('text'); + scriptText.classList.add('scriptName'); + scriptText.textContent = rowData.data.scriptName; + divElement.append(scriptText); + scriptText.style.color = '#a1a1a1'; + } + divElement.title = rowData.data.symbolName; + } } diff --git a/ide/src/base-ui/utils/CSVFormater.ts b/ide/src/base-ui/utils/CSVFormater.ts index 71fa3e57d2b946a4e184691f20055f8b9c592253..9feb1fcce796c0f30a1e3fa144eb451e09674296 100644 --- a/ide/src/base-ui/utils/CSVFormater.ts +++ b/ide/src/base-ui/utils/CSVFormater.ts @@ -180,15 +180,29 @@ export class JSONToCSV { static async csvExport(dataSource: { columns: any[]; tables: any[]; fileName: string }): Promise { return new Promise((resolve) => { let data: any = this.columnsData(dataSource.columns); - let resultArr = JSONToCSV.treeToArr(dataSource.tables); - JSONToCSV.setCsvData({ - data: resultArr, - fileName: dataSource.fileName, - columns: { + let columns = { title: data.titleList, key: data.ketList, - }, - }); + }; + if (dataSource.tables.length > 0) { + if (Array.isArray(dataSource.tables[0])) { + dataSource.tables.forEach((childArr, childIndex) => { + let resultArr = JSONToCSV.treeToArr(childArr); + JSONToCSV.setCsvData({ + data: resultArr, + fileName: `${dataSource.fileName}_${childIndex}`, + columns: columns + }); + }) + } else { + let resultArr = JSONToCSV.treeToArr(dataSource.tables); + JSONToCSV.setCsvData({ + data: resultArr, + fileName: dataSource.fileName, + columns: columns, + }); + } + } resolve('ok'); }); } diff --git a/ide/src/trace/bean/AbilityMonitor.ts b/ide/src/trace/bean/AbilityMonitor.ts index 9a638dfadc530102d9b1b742684e1d768db0c248..8134d316c5e7287663dbd6aa05cbce90b5c0b400 100644 --- a/ide/src/trace/bean/AbilityMonitor.ts +++ b/ide/src/trace/bean/AbilityMonitor.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +import { CompareStruct } from '../component/trace/sheet/SheetUtils.js'; + export class SystemCpuSummary { startTime: number = -1; startTimeStr: string = ''; @@ -135,8 +137,8 @@ export class Dma { processId: number = -1; timeStamp: string = ''; startNs: number = -1; - expTaskComm: string| number = ''; - avgSize: number = -1; + expTaskComm: string | number = ''; + avgSize: number = 0; minSize: number = -1; maxSize: number = -1; bufName: string | number = ''; @@ -166,6 +168,7 @@ export class GpuMemory { minSize: number = -1; maxSize: number = -1; gpuName: string = ''; + gpuNameId: number = -1; processName: string = ''; process: string = ''; //processName + processId threadName: string = ''; @@ -178,3 +181,45 @@ export class GpuMemory { sumSize: number = -1; sumSizes: string = ''; } + +export class DmaComparison extends CompareStruct { + processId: number = -1; + processName: string = ''; + process: string = ''; //processName + processId + sizes: string = ''; + thread: string = ''; + + constructor(process: string, value: number) { + super(process, value); + this.process = process; + } + + clone(isBase?: boolean): DmaComparison { + const value = isBase ? this.value : -this.value; + return new DmaComparison(this.process, value); + } +} + +export class GpuMemoryComparison extends CompareStruct { + processId: number = -1; + processName: string = ''; + process: string = ''; //processName + processId + sizes: string = ''; + gpuNameId: number = -1; + gpuName: string = ''; + threadName: string = ''; + threadId: number = -1; + thread: string = ''; + + constructor(process: string, thread: string, gpuName: string, value: number) { + super(process + '' + thread + '' + gpuName, value); + this.process = process; + this.gpuName = gpuName; + this.thread = thread; + } + + clone(isBase?: boolean): GpuMemoryComparison { + const value = isBase ? this.value : -this.value; + return new GpuMemoryComparison(this.process, this.thread, this.gpuName, value); + } +} diff --git a/ide/src/trace/bean/JsStruct.ts b/ide/src/trace/bean/JsStruct.ts index 69746d847c8ed8c84ab24d238b5333108871f9b1..1b0c5500be1188ab7da7d8ea08e67e018149ccc8 100644 --- a/ide/src/trace/bean/JsStruct.ts +++ b/ide/src/trace/bean/JsStruct.ts @@ -14,7 +14,7 @@ */ import { SampleType } from '../database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.js'; - +const ROW_TYPE = 'cpu-profiler'; export class JsCpuProfilerUIStruct { name: string; depth: number; @@ -83,6 +83,7 @@ export class JsCpuProfilerChartFrame extends JsCpuProfilerUIStruct { } export class JsCpuProfilerTabStruct extends JsCpuProfilerUIStruct { + rowName = ROW_TYPE; parent?: JsCpuProfilerTabStruct | null | undefined; children: Array; chartFrameChildren?: Array; diff --git a/ide/src/trace/bean/SmapsStruct.ts b/ide/src/trace/bean/SmapsStruct.ts index 17070f7a4bbb96bc040b7ddaa547ee8e6dc0b4a3..7c9edd3b450e8473bf1fa005a30413d280d01469 100644 --- a/ide/src/trace/bean/SmapsStruct.ts +++ b/ide/src/trace/bean/SmapsStruct.ts @@ -14,33 +14,28 @@ * limitations under the License. */ export class Smaps { - tsNS: number = -1; - start_addr: string = ''; - end_addr: string = ''; + startNs: number = -1; + startAddr: string = ''; + endAddr: string = ''; + address: string = ''; permission: string = ''; + type: SmapsType = 0; + typeName: string = ''; path: string = ''; size: number = 0; + sizeStr: string = ''; + count:number = 0; rss: number = 0; - pss: number = 0; - reside: number = 0; - dirty: number = 0; - swapper: number = 0; - address: string = ''; - type: SmapsType = 0; - typeName: string = ''; - dirtyStr: string = ''; - swapperStr: string = ''; rssStr: string = ''; + pss: number = 0; pssStr: string = ''; - sizeStr: string = ''; - resideStr: string = ''; - shared_clean : number = 0; - shared_dirty:number = 0; - private_clean:number = 0; - private_dirty:number = 0; + sharedClean : number = 0; + sharedDirty:number = 0; + privateClean:number = 0; + privateDirty:number = 0; swap:number = 0; - swap_pss:number = 0; - count:number = 0; + swapPss:number = 0; + resideStr: string = ''; } export class SmapsTreeObj { constructor(id: string, pid: string, type: string) { @@ -50,27 +45,17 @@ export class SmapsTreeObj { } id: string = ''; pid: string = ''; - rsspro: number = 0; - rssproStr: string = ''; typeName: string = ''; - reg: number = 0; - regStr: string = ''; path: any = ''; - rss: number = 0; - rssStr: string = ''; - dirty: number = 0; - dirtyStr: string = ''; - swapper: number = 0; - swapperStr: string = ''; - pss: number = 0; - pssStr: string = ''; size: number = 0; sizeStr: string = ''; - respro: number = 0; - resproStr: string = ''; sizePro:number = 0; sizeProStr :string = ''; count :number = 0 ; + rss: number = 0; + rssStr: string = ''; + pss: number = 0; + pssStr: string = ''; sharedClean : number = 0; sharedCleanStr:string = ''; sharedDirty:number = 0; diff --git a/ide/src/trace/component/SpQuerySQL.ts b/ide/src/trace/component/SpQuerySQL.ts index 627c161ca2146b1c1c15f7431340671198214043..d8d3b9b259d9b0f1a0eb0336215325bf324dd4a6 100644 --- a/ide/src/trace/component/SpQuerySQL.ts +++ b/ide/src/trace/component/SpQuerySQL.ts @@ -126,6 +126,7 @@ export class SpQuerySQL extends BaseElement { }); this.statDataArray = []; this.keyList = []; + this.response!.innerHTML = ''; this.queryTableEl!.innerHTML = ''; if (this.isSupportSql) { this.progressLoad!.loading = true; diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts index faeec1e51cfe1670fc39afd9d9a76b8f7092dabc..15f643d75f000059db6d557a695c2b6d57773f6d 100644 --- a/ide/src/trace/component/SpSystemTrace.ts +++ b/ide/src/trace/component/SpSystemTrace.ts @@ -2198,19 +2198,19 @@ export class SpSystemTrace extends BaseElement { ], [ TraceRow.ROW_TYPE_DMA_ABILITY, - () => SnapshotStruct.selectSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, + () => SnapshotStruct.hoverSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, ], [ TraceRow.ROW_TYPE_DMA_VMTRACKER, - () => SnapshotStruct.selectSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, + () => SnapshotStruct.hoverSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, ], [ TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY, - () => SnapshotStruct.selectSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, + () => SnapshotStruct.hoverSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, ], [ TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER, - () => SnapshotStruct.selectSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, + () => SnapshotStruct.hoverSnapshotStruct !== null && SnapshotStruct.hoverSnapshotStruct !== undefined, ], [ TraceRow.ROW_TYPE_VMTRACKER_SHM, @@ -2513,12 +2513,26 @@ export class SpSystemTrace extends BaseElement { this.traceSheetEL?.displayClockData(ClockStruct.selectClockStruct); this.timerShaftEL?.modifyFlagList(undefined); } else if (clickRowType === TraceRow.ROW_TYPE_SYS_MEMORY_GPU_TOTAL && SnapshotStruct.hoverSnapshotStruct) { + let gpuDumpTotalRow = this.shadowRoot?.querySelector>( + `trace-row[row-id='Skia Gpu Dump Total']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayGpuSelectedData('total', SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayGpuSelectedData( + 'total', + SnapshotStruct.selectSnapshotStruct.startNs, + gpuDumpTotalRow!.dataList + ); this.timerShaftEL?.modifyFlagList(undefined); } else if (clickRowType === TraceRow.ROW_TYPE_SYS_MEMORY_GPU_WINDOW && SnapshotStruct.hoverSnapshotStruct) { + let gpuDumpWindowRow = this.shadowRoot?.querySelector>( + `trace-row[row-id='Skia Gpu Dump Window']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayGpuSelectedData('window', SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayGpuSelectedData( + 'window', + SnapshotStruct.selectSnapshotStruct.startNs, + gpuDumpWindowRow!.dataList + ); this.timerShaftEL?.modifyFlagList(undefined); } else if (clickRowType === TraceRow.ROW_TYPE_IRQ && IrqStruct.hoverIrqStruct) { IrqStruct.selectIrqStruct = IrqStruct.hoverIrqStruct; @@ -2656,29 +2670,55 @@ export class SpSystemTrace extends BaseElement { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; this.traceSheetEL?.displayShmData(SnapshotStruct.selectSnapshotStruct!, shmRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_ABILITY && SnapshotStruct.hoverSnapshotStruct) { + let totalAbilityRow = this.shadowRoot?.querySelector>( + `trace-row[row-id='System Purgeable Total']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayPurgTotalAbilityData(SnapshotStruct.hoverSnapshotStruct); + this.traceSheetEL?.displayPurgTotalAbilityData(SnapshotStruct.hoverSnapshotStruct, totalAbilityRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_ABILITY && SnapshotStruct.hoverSnapshotStruct) { + let pinAbilityRow = this.shadowRoot?.querySelector>( + `trace-row[row-id='System Purgeable Pin']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayPurgPinAbilityData(SnapshotStruct.hoverSnapshotStruct); + this.traceSheetEL?.displayPurgPinAbilityData(SnapshotStruct.hoverSnapshotStruct, pinAbilityRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_VM && SnapshotStruct.hoverSnapshotStruct) { + let totalVMRow = this.shadowRoot?.querySelector>(`trace-row[row-id='Purgeable Total']`); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayPurgTotalVMData(SnapshotStruct.hoverSnapshotStruct); + this.traceSheetEL?.displayPurgTotalVMData(SnapshotStruct.hoverSnapshotStruct, totalVMRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_VM && SnapshotStruct.hoverSnapshotStruct) { + let pinVMRow = this.shadowRoot?.querySelector>(`trace-row[row-id='Purgeable Pin']`); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayPurgPinVMData(SnapshotStruct.hoverSnapshotStruct); + this.traceSheetEL?.displayPurgPinVMData(SnapshotStruct.hoverSnapshotStruct, pinVMRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_DMA_ABILITY && SnapshotStruct.hoverSnapshotStruct) { + let dmaAbilityRow = this.shadowRoot?.querySelector>( + `trace-row[row-id='abilityMonitorDma']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayDmaAbility(SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayDmaAbility(SnapshotStruct.selectSnapshotStruct.startNs, dmaAbilityRow!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_DMA_VMTRACKER && SnapshotStruct.hoverSnapshotStruct) { + let dmaVmTracker = this.shadowRoot?.querySelector>( + `trace-row[row-type='dma-vmTracker']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayDmaVmTracker(SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayDmaVmTracker(SnapshotStruct.selectSnapshotStruct.startNs, dmaVmTracker!.dataList); } else if (clickRowType === TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY && SnapshotStruct.hoverSnapshotStruct) { + let gpuMemoryAbilityMonitor = this.shadowRoot?.querySelector>( + `trace-row[row-id='abilityMonitorGpuMemory']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayGpuMemoryAbility(SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayGpuMemoryAbility( + SnapshotStruct.selectSnapshotStruct.startNs, + gpuMemoryAbilityMonitor!.dataList + ); } else if (clickRowType === TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER && SnapshotStruct.hoverSnapshotStruct) { + let gpuMemoryVmTracker = this.shadowRoot?.querySelector>( + `trace-row[row-id='Skia Gpu Memory']` + ); SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - this.traceSheetEL?.displayGpuMemoryVmTracker(SnapshotStruct.selectSnapshotStruct.startNs); + this.traceSheetEL?.displayGpuMemoryVmTracker( + SnapshotStruct.selectSnapshotStruct.startNs, + gpuMemoryVmTracker!.dataList + ); } else { if (!JankStruct.hoverJankStruct && JankStruct.delJankLineFlag) { this.removeLinkLinesByBusinessType('janks'); diff --git a/ide/src/trace/component/SpWelcomePage.ts b/ide/src/trace/component/SpWelcomePage.ts index ecb418c6d981d789887bc28529563d24ba1d9c7a..ec4ce087b0d1a44d1596cad2bce23739f6094e7d 100644 --- a/ide/src/trace/component/SpWelcomePage.ts +++ b/ide/src/trace/component/SpWelcomePage.ts @@ -44,8 +44,7 @@ export class SpWelcomePage extends BaseElement {

黄区域名: 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

+

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

diff --git a/ide/src/trace/component/chart/SpAbilityMonitorChart.ts b/ide/src/trace/component/chart/SpAbilityMonitorChart.ts index 45bb19bd969234cd3d3cbde8cd8cd253d6f79146..17de2c1783144f9741e48c948ac68bf1841fa849 100644 --- a/ide/src/trace/component/chart/SpAbilityMonitorChart.ts +++ b/ide/src/trace/component/chart/SpAbilityMonitorChart.ts @@ -734,7 +734,7 @@ export class SpAbilityMonitorChart { totalTraceRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; totalTraceRow.selectChangeHandler = this.trace.selectChangeHandler; totalTraceRow.setAttribute('children', ''); - totalTraceRow.name = `System Purgeable Total`; + totalTraceRow.name = `Purgeable Total`; totalTraceRow.supplier = () => new Promise>((resolve) => resolve(purgeableTotalData)); totalTraceRow.focusHandler = (ev) => { this.trace?.displayTip( @@ -774,7 +774,7 @@ export class SpAbilityMonitorChart { pinTraceRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; pinTraceRow.selectChangeHandler = this.trace.selectChangeHandler; pinTraceRow.setAttribute('children', ''); - pinTraceRow.name = `System Purgeable Pin`; + pinTraceRow.name = `Purgeable Pin`; pinTraceRow.supplier = () => new Promise>((resolve) => resolve(purgeablePinData)); pinTraceRow.focusHandler = (ev) => { this.trace?.displayTip( diff --git a/ide/src/trace/component/schedulingAnalysis/Top20FrequencyThread.ts b/ide/src/trace/component/schedulingAnalysis/Top20FrequencyThread.ts index 0f89fab00f7b809325f2b8a2ad775d8326078f6f..a73b6f56e48298f438a9f31e371001e54039bbf3 100644 --- a/ide/src/trace/component/schedulingAnalysis/Top20FrequencyThread.ts +++ b/ide/src/trace/component/schedulingAnalysis/Top20FrequencyThread.ts @@ -82,6 +82,7 @@ export class Top20FrequencyThread extends BaseElement { } this.frequencyThreadPie?.showHover(); }); + this.frequencyThreadTbl!.itemTextHandleMap.set('freq',(value) => value === -1 ? 'unknown' : value); } sortByColumn(detail: any) { @@ -167,13 +168,14 @@ export class Top20FrequencyThread extends BaseElement { data: this.getPieChartData(res), angleField: 'time', colorField: 'freq', + colorFieldTransferHandler: (value) => value === -1 ? 'unknown' : value, radius: 0.8, label: { type: 'outer', }, tip: (obj) => { return `
-
freq:${obj.obj.freq}
+
freq:${obj.obj.freq===-1 ? 'unknown' : obj.obj.freq}
cpu:${obj.obj.cpu}
time:${obj.obj.timeStr}
ratio:${obj.obj.ratio}%
diff --git a/ide/src/trace/component/setting/SpArkTs.ts b/ide/src/trace/component/setting/SpArkTs.ts index f821b529b431492da636717bec205dffc932e7e2..84c007ac3f0d85e5032c0408e9867bc581ff70e8 100644 --- a/ide/src/trace/component/setting/SpArkTs.ts +++ b/ide/src/trace/component/setting/SpArkTs.ts @@ -388,7 +388,7 @@ export class SpArkTs extends BaseElement { Interval(Available on recent OpenHarmony 4.0)
- US + μs
diff --git a/ide/src/trace/component/setting/SpProbesConfig.ts b/ide/src/trace/component/setting/SpProbesConfig.ts index 9681839cca5a1f994794a0843cc23f0027884870..07c0c2971c7101444ef8fb8282d27b4ae8d48b82 100644 --- a/ide/src/trace/component/setting/SpProbesConfig.ts +++ b/ide/src/trace/component/setting/SpProbesConfig.ts @@ -231,6 +231,7 @@ export class SpProbesConfig extends BaseElement { { value: 'sensors', isSelect: false }, { value: 'sync', isSelect: true }, { value: 'usb', isSelect: false }, + { value: 'ufs', isSelect: false }, { value: 'useriam', isSelect: false }, { value: 'window', isSelect: true }, { value: 'workq', isSelect: true }, diff --git a/ide/src/trace/component/setting/SpRecordTemplate.ts b/ide/src/trace/component/setting/SpRecordTemplate.ts index 448b4a344f4e9ce9baa8de018216dbfc0411e927..d0cacc4c2f93c913671124e9ae3cc14fb850dd6e 100644 --- a/ide/src/trace/component/setting/SpRecordTemplate.ts +++ b/ide/src/trace/component/setting/SpRecordTemplate.ts @@ -15,7 +15,7 @@ import { BaseElement, element } from '../../../base-ui/BaseElement.js'; import LitSwitch, { LitSwitchChangeEvent } from '../../../base-ui/switch/lit-switch.js'; -import { ProfilerPluginConfig, TracePluginConfig } from './bean/ProfilerServiceTypes.js'; +import { HiperfPluginConfig, ProfilerPluginConfig, TracePluginConfig } from './bean/ProfilerServiceTypes.js'; import { SpRecordTrace } from '../SpRecordTrace.js'; @element('sp-record-template') @@ -76,6 +76,8 @@ export class SpRecordTemplate extends BaseElement { 'zimage', 'zmedia', ]; + static HIPERF_DEFAULT_RECORD_ARGS = '-f 1000 -a --cpu-limit 100 -e hw-cpu-cycles,sched:sched_waking' + + ' --call-stack dwarf --clockid monotonic --offcpu -m 256'; private frameTimeline: LitSwitch | undefined | null; private schedulingAnalysis: LitSwitch | undefined | null; private appStartup: LitSwitch | undefined | null; @@ -113,8 +115,9 @@ export class SpRecordTemplate extends BaseElement { hitraceCategories.push(categories); } }); - if (this.appStartup?.checked){ + if (this.appStartup?.checked) { hitraceCategories.push('musl'); + config.push(this.createHiperfDefaultConfig()); } SpRecordTemplate.FRAME_TIMELINE_EVENTS.forEach((ev) => { if (traceEventSet.indexOf(ev) == -1) { @@ -161,6 +164,19 @@ export class SpRecordTemplate extends BaseElement { return config; } + private createHiperfDefaultConfig() { + let hiPerf: HiperfPluginConfig = { + isRoot: false, + outfileName: '/data/local/tmp/perf.data', + recordArgs: SpRecordTemplate.HIPERF_DEFAULT_RECORD_ARGS, + }; + let htraceProfilerPluginConfig: ProfilerPluginConfig = { + pluginName: 'hiperf-plugin', + sampleInterval: 5000, + configData: hiPerf, + }; + return htraceProfilerPluginConfig; + } initHtml(): string { return ` Input Filter diff --git a/ide/src/trace/component/trace/sheet/TabPaneJsMemoryFilter.ts b/ide/src/trace/component/trace/sheet/TabPaneJsMemoryFilter.ts index fd1951bfec0bc2e22be81fc9b3b63d38d7f7edb3..f94a8ff32f88fa69ae824d9352c384bf2c22a36b 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneJsMemoryFilter.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneJsMemoryFilter.ts @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { BaseElement, element } from '../../../../base-ui/BaseElement.js'; import '../../../../base-ui/icon/LitIcon.js'; import { LitIcon } from '../../../../base-ui/icon/LitIcon.js'; @@ -21,11 +20,9 @@ import { LitCheckBox } from '../../../../base-ui/checkbox/LitCheckBox.js'; import { LitSelect } from '../../../../base-ui/select/LitSelect.js'; import '../../../../base-ui/select/LitSelect.js'; import { LitSelectOption } from '../../../../base-ui/select/LitSelectOption.js'; - @element('tab-pane-js-memory-filter') export class TabPaneJsMemoryFilter extends BaseElement { initElements(): void {} - initHtml(): string { return ` - Class Filter - +
+ Class Filter + +
- +
`; } -} +} \ No newline at end of file diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbility.ts index c22166678c1f725747c3a417f22984e2cfef2342..04a7a37ddae8e712e3d176e70596382fa4cffaed 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbility.ts @@ -28,6 +28,7 @@ export class TabPaneDmaAbility extends BaseElement { private dmaSource: Array = []; private tableThead: HTMLDivElement | undefined | null; private dmaTimeRange: HTMLLabelElement | null | undefined; + private total: Dma = new Dma(); set data(dmaAbilityValue: SelectionParam | any) { if (dmaAbilityValue.dmaAbilityData.length > 0) { @@ -69,25 +70,39 @@ export class TabPaneDmaAbility extends BaseElement { queryDataByDB(val: SelectionParam | any): void { getTabDmaAbilityData(val.leftNs, val.rightNs, (MemoryConfig.getInstance().interval * 1000000) / 5).then((data) => { + this.dmaSource = data; this.dmaTbl!.loading = false; if (data.length !== null && data.length > 0) { + this.total = new Dma(); + this.total.process = '*All*'; data.forEach((item) => { if (item.processName !== null) { item.process = `${item.processName}(${item.processId})`; } else { item.process = `Process(${item.processId})`; } + + this.total.avgSize += item.avgSize; + if (this.total.minSize < 0) { + this.total.minSize = item.minSize; + } + if (this.total.maxSize < 0) { + this.total.maxSize = item.maxSize; + } + this.total.minSize = Math.min(this.total.minSize, item.minSize); + this.total.maxSize = Math.max(this.total.maxSize, item.maxSize); + item.avgSizes = Utils.getBinaryByteWithUnit(Math.round(item.avgSize)); item.minSizes = Utils.getBinaryByteWithUnit(item.minSize); item.maxSizes = Utils.getBinaryByteWithUnit(item.maxSize); }); - this.dmaSource = data; - this.dmaTbl!.recycleDataSource = this.dmaSource.sort(function ( - dmaAbilityLeftData: Dma, - dmaAbilityRightData: Dma - ) { + this.total.avgSizes = Utils.getBinaryByteWithUnit(Math.round(this.total.avgSize / data.length)); + this.total.minSizes = Utils.getBinaryByteWithUnit(this.total.minSize); + this.total.maxSizes = Utils.getBinaryByteWithUnit(this.total.maxSize); + this.dmaSource.sort(function (dmaAbilityLeftData: Dma, dmaAbilityRightData: Dma) { return dmaAbilityRightData.avgSize - dmaAbilityLeftData.avgSize; }); + this.dmaTbl!.recycleDataSource = [this.total, ...this.dmaSource]; } else { this.dmaTbl!.recycleDataSource = []; this.dmaSource = []; @@ -114,14 +129,14 @@ export class TabPaneDmaAbility extends BaseElement {
- + - - + +
`; @@ -130,40 +145,41 @@ export class TabPaneDmaAbility extends BaseElement { sortDmaByColumn(column: string, sort: number): void { switch (sort) { case 0: - this.dmaTbl!.recycleDataSource = this.dmaSource; + this.dmaTbl!.recycleDataSource = [this.total, ...this.dmaSource]; break; default: let array = [...this.dmaSource]; switch (column) { case 'process': - this.dmaTbl!.recycleDataSource = array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { + array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { return sort === 1 ? `${dmaAbilityLeftData.process}`.localeCompare(`${dmaAbilityRightData.process}`) : `${dmaAbilityRightData.process}`.localeCompare(`${dmaAbilityLeftData.process}`); }); break; case 'avgSize': - this.dmaTbl!.recycleDataSource = array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { + array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { return sort === 1 ? dmaAbilityLeftData.avgSize - dmaAbilityRightData.avgSize : dmaAbilityRightData.avgSize - dmaAbilityLeftData.avgSize; }); break; case 'minSize': - this.dmaTbl!.recycleDataSource = array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { + array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { return sort === 1 ? dmaAbilityLeftData.minSize - dmaAbilityRightData.minSize : dmaAbilityRightData.minSize - dmaAbilityLeftData.minSize; }); break; case 'maxSize': - this.dmaTbl!.recycleDataSource = array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { + array.sort((dmaAbilityLeftData, dmaAbilityRightData) => { return sort === 1 ? dmaAbilityLeftData.maxSize - dmaAbilityRightData.maxSize : dmaAbilityRightData.maxSize - dmaAbilityLeftData.maxSize; }); break; } + this.dmaTbl!.recycleDataSource = [this.total, ...array]; break; } } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b1c1b3b3a9d39fd31d0fe78dbe066952a3e83f8 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.ts @@ -0,0 +1,170 @@ +/* + * 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { DmaComparison } from '../../../../bean/AbilityMonitor.js'; +import { getTabDmaAbilityComparisonData } from '../../../../database/SqlLite.js'; +import { SnapshotStruct } from '../../../../database/ui-worker/ProcedureWorkerSnapshot.js'; +import { Utils } from '../../base/Utils.js'; +import { compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import '../TabPaneJsMemoryFilter.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; + +@element('tabpane-dma-ability-comparison') +export class TabPaneDmaAbilityComparison extends BaseElement { + private damClickTable: LitTable | null | undefined; + private comparisonSelect: TabPaneJsMemoryFilter | null | undefined; + private selectEl: LitSelect | null | undefined; + private selfData: Array = []; + private comparisonSource: Array = []; + + initElements(): void { + this.damClickTable = this.shadowRoot?.querySelector('#damClickTable'); + this.comparisonSelect = this.shadowRoot?.querySelector('#filter') as TabPaneJsMemoryFilter; + this.selectEl = this.comparisonSelect?.shadowRoot?.querySelector('lit-select'); + this.damClickTable!.addEventListener('column-click', (e) => { + // @ts-ignore + this.sortDmaByColumn(e.detail.key, e.detail.sort); + }); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.damClickTable!, this.comparisonSelect!); + } + + async queryDataByDB(startNs: number): Promise { + let timeStampData: Array = []; + await getTabDmaAbilityComparisonData(startNs).then((data) => { + data.forEach((item) => { + if (item.processName !== null) { + item.process = `${item.processName}(${item.processId})`; + } else { + item.process = `Process(${item.processId})`; + } + }); + timeStampData = data; + }); + return timeStampData; + } + + async comparisonDataByDB(startNs: number, dataList: Array): Promise { + this.selfData = []; + const selfData = await this.queryDataByDB(startNs); + const dataArray = []; + for (const item of selfData) { + this.selfData.push(new DmaComparison(item.process, item.value)); + } + for (let item of dataList) { + if (item.startNs !== startNs) { + dataArray.push(item); + } + } + this.selectStamps(dataArray); + this.getComparisonData(dataArray[0].startNs); + } + + selectStamps(dataList: Array): void { + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (dataList[0].name) { + option.setAttribute('value', dataList[0].name); + } + this.selectEl!.defaultValue = dataList[0].name || ''; + this.selectEl!.placeholder = dataList[0].name || ''; + this.selectEl!.dataSource = dataList; + this.selectEl!.querySelectorAll('lit-select-option').forEach((option) => { + option.addEventListener('onSelected', (e) => { + for (let f of dataList) { + if (input.value === f.name) { + this.getComparisonData(f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + + async getComparisonData(targetStartNs: number) { + let comparisonData: DmaComparison[] = []; + let comparison: DmaComparison[] = []; + const data = await this.queryDataByDB(targetStartNs); + for (const item of data) { + comparison.push(new DmaComparison(item.process, item.value)); + } + comparisonData = compare(this.selfData, comparison); + for (const item of comparisonData) { + item.sizes = Utils.getBinaryByteWithUnit(item.value); + } + this.comparisonSource = comparisonData; + this.damClickTable!.recycleDataSource = comparisonData; + } + + sortDmaByColumn(column: string, sort: number): void { + switch (sort) { + case 0: + this.damClickTable!.recycleDataSource = this.comparisonSource; + break; + default: + let array = [...this.comparisonSource]; + switch (column) { + case 'process': + this.damClickTable!.recycleDataSource = array.sort((dmaComparisonLeftData, dmaComparisonRightData) => { + return sort === 1 + ? `${dmaComparisonLeftData.process}`.localeCompare(`${dmaComparisonRightData.process}`) + : `${dmaComparisonRightData.process}`.localeCompare(`${dmaComparisonLeftData.process}`); + }); + break; + case 'sizeDelta': + this.damClickTable!.recycleDataSource = array.sort((dmaComparisonLeftData, dmaComparisonRightData) => { + return sort === 1 + ? dmaComparisonLeftData.value - dmaComparisonRightData.value + : dmaComparisonRightData.value - dmaComparisonLeftData.value; + }); + break; + } + break; + } + } + + initHtml(): string { + return ` + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.ts index 32c051a0e90b1f8685b30bed678168b2eacfceac..5e6138cb8ffa98a765eb6b57461a57db0a3e4965 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.ts @@ -79,9 +79,9 @@ export class TabPaneDmaSelectAbility extends BaseElement { item.timeStamp = ns2s(item.startNs); this.damClickTable!.getItemTextColor = (item: Dma): any => { if (item.flag === 1) { - return '#6b6b6b96'; + return '#d4b550'; } else if (item.flag === 2) { - return '#4a4a4a'; + return '#f86b6b'; } else { return '#000000'; } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.ts index 98abc0001a5862507b188cd7dfe3ef867f95683a..1e1d70a3e1a07c937bf5de53df8e24079a82e296 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.ts @@ -22,6 +22,7 @@ import { getTabGpuMemoryAbilityData } from '../../../../database/SqlLite.js'; import { ns2s } from '../../../../database/ui-worker/ProcedureWorkerCommon.js'; import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; import { Utils } from '../../base/Utils.js'; +import { SpSystemTrace } from '../../../SpSystemTrace.js'; @element('tabpane-gpu-memory-ability') export class TabPaneGpuMemoryAbility extends BaseElement { @@ -29,6 +30,7 @@ export class TabPaneGpuMemoryAbility extends BaseElement { private gpuMemorySource: Array = []; private tableThead: HTMLDivElement | undefined | null; private gpuMemoryTimeRange: HTMLLabelElement | undefined | null; + private total: GpuMemory = new GpuMemory(); set data(gpuMemoryAbilityValue: SelectionParam | any) { if (gpuMemoryAbilityValue.gpuMemoryAbilityData.length > 0) { @@ -75,23 +77,38 @@ export class TabPaneGpuMemoryAbility extends BaseElement { (data) => { this.gpuMemoryTableTbl!.loading = false; if (data.length !== null && data.length > 0) { + this.total = new GpuMemory(); + this.total.process = '*All*'; + this.total.gpuName = '*All*'; data.forEach((item) => { if (item.processName !== null) { item.process = `${item.processName}(${item.processId})`; } else { item.process = `Process(${item.processId})`; } + + this.total.avgSize += item.avgSize; + if (this.total.minSize < 0) { + this.total.minSize = item.minSize; + } + if (this.total.maxSize < 0) { + this.total.maxSize = item.maxSize; + } + this.total.minSize = Math.min(this.total.minSize, item.minSize); + this.total.maxSize = Math.max(this.total.maxSize, item.maxSize); + item.gpuName = SpSystemTrace.DATA_DICT.get(item.gpuNameId) || ''; item.avgSizes = Utils.getBinaryByteWithUnit(Math.round(item.avgSize)); item.minSizes = Utils.getBinaryByteWithUnit(item.minSize); item.maxSizes = Utils.getBinaryByteWithUnit(item.maxSize); }); + this.total.avgSizes = Utils.getBinaryByteWithUnit(Math.round(this.total.avgSize / data.length)); + this.total.minSizes = Utils.getBinaryByteWithUnit(this.total.minSize); + this.total.maxSizes = Utils.getBinaryByteWithUnit(this.total.maxSize); this.gpuMemorySource = data; - this.gpuMemoryTableTbl!.recycleDataSource = this.gpuMemorySource.sort(function ( - gpuMemoryLeftData: GpuMemory, - gpuMemoryRightData: GpuMemory - ) { + this.gpuMemorySource.sort(function (gpuMemoryLeftData: GpuMemory, gpuMemoryRightData: GpuMemory) { return gpuMemoryRightData.avgSize - gpuMemoryLeftData.avgSize; }); + this.gpuMemoryTableTbl!.recycleDataSource = [this.total, ...this.gpuMemorySource]; } else { this.gpuMemoryTableTbl!.recycleDataSource = []; this.gpuMemorySource = []; @@ -129,7 +146,7 @@ export class TabPaneGpuMemoryAbility extends BaseElement { - + @@ -145,47 +162,48 @@ export class TabPaneGpuMemoryAbility extends BaseElement { sortGpuMemoryByColumn(column: string, sort: number): void { switch (sort) { case 0: - this.gpuMemoryTableTbl!.recycleDataSource = this.gpuMemorySource; + this.gpuMemoryTableTbl!.recycleDataSource = [this.total, this.gpuMemorySource]; break; default: let array = [...this.gpuMemorySource]; switch (column) { case 'process': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? `${gpuMemoryLeftData.process}`.localeCompare(`${gpuMemoryRightData.process}`) : `${gpuMemoryRightData.process}`.localeCompare(`${gpuMemoryLeftData.process}`); }); break; case 'gpuName': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 - ? `${gpuMemoryLeftData.gpuName}`.localeCompare(`${gpuMemoryRightData.gpuName}`) - : `${gpuMemoryRightData.gpuName}`.localeCompare(`${gpuMemoryLeftData.gpuName}`); + ? `${gpuMemoryLeftData.gpuName}`.localeCompare(`${gpuMemoryRightData.gpuName}`) + : `${gpuMemoryRightData.gpuName}`.localeCompare(`${gpuMemoryLeftData.gpuName}`); }); break; case 'avgSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.avgSize - gpuMemoryRightData.avgSize : gpuMemoryRightData.avgSize - gpuMemoryLeftData.avgSize; }); break; case 'minSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.minSize - gpuMemoryRightData.minSize : gpuMemoryRightData.minSize - gpuMemoryLeftData.minSize; }); break; case 'maxSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.maxSize - gpuMemoryRightData.maxSize : gpuMemoryRightData.maxSize - gpuMemoryLeftData.maxSize; }); break; } + this.gpuMemoryTableTbl!.recycleDataSource = [this.total, ...array]; break; } } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.ts new file mode 100644 index 0000000000000000000000000000000000000000..4cdb471a9c690d2e462cd6dcea4b81a1ce6d25d8 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.ts @@ -0,0 +1,188 @@ +/* + * 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { GpuMemoryComparison } from '../../../../bean/AbilityMonitor.js'; +import { getTabGpuMemoryComparisonData } from '../../../../database/SqlLite.js'; +import { SnapshotStruct } from '../../../../database/ui-worker/ProcedureWorkerSnapshot.js'; +import { SpSystemTrace } from '../../../SpSystemTrace.js'; +import { Utils } from '../../base/Utils.js'; +import { compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import '../TabPaneJsMemoryFilter.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; + +@element('tabpane-gpu-memory-comparison') +export class TabPaneGpuMemoryComparison extends BaseElement { + private gpuMemoryClickTable: LitTable | null | undefined; + private comparisonSelect: TabPaneJsMemoryFilter | null | undefined; + private selectEl: LitSelect | null | undefined; + private selfData: Array = []; + private comparisonSource: Array = []; + + initElements(): void { + this.gpuMemoryClickTable = this.shadowRoot?.querySelector('#gpuMemoryClickTable'); + this.comparisonSelect = this.shadowRoot?.querySelector('#filter') as TabPaneJsMemoryFilter; + this.selectEl = this.comparisonSelect?.shadowRoot?.querySelector('lit-select'); + this.gpuMemoryClickTable!.addEventListener('column-click', (e) => { + // @ts-ignore + this.sortGpuMemoryByColumn(e.detail.key, e.detail.sort); + }); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.gpuMemoryClickTable!, this.comparisonSelect!); + } + + async queryDataByDB(startNs: number): Promise { + let timeStampData: Array = []; + await getTabGpuMemoryComparisonData(startNs).then((data) => { + data.forEach((item) => { + if (item.processName !== null) { + item.process = `${item.processName}(${item.processId})`; + } else { + item.process = `Process(${item.processId})`; + } + item.gpuName = SpSystemTrace.DATA_DICT.get(item.gpuNameId as number) || '-'; + }); + timeStampData = data; + }); + return timeStampData; + } + + async comparisonDataByDB(startNs: number, dataList: Array): Promise { + this.selfData = []; + let selfData = await this.queryDataByDB(startNs); + const dataArray = []; + for (const item of selfData) { + this.selfData.push(new GpuMemoryComparison(item.process, '', item.gpuName, item.value)); + } + for (let item of dataList) { + if (item.startNs !== startNs) { + dataArray.push(item); + } + } + this.selectStamps(dataArray); + this.getComparisonData(dataArray[0].startNs); + } + + selectStamps(dataList: Array): void { + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (dataList[0].name) { + option.setAttribute('value', dataList[0].name); + } + option.setAttribute('value', dataList[0].name); + this.selectEl!.defaultValue = dataList[0].name || ''; + this.selectEl!.placeholder = dataList[0].name || ''; + this.selectEl!.dataSource = dataList; + this.selectEl!.querySelectorAll('lit-select-option').forEach((option) => { + option.addEventListener('onSelected', async (e) => { + for (let f of dataList) { + if (input.value === f.name) { + this.getComparisonData(f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + + async getComparisonData(targetStartNs: number) { + let comparisonData: GpuMemoryComparison[] = []; + let comparison: GpuMemoryComparison[] = []; + let data = await this.queryDataByDB(targetStartNs); + for (const item of data) { + comparison.push(new GpuMemoryComparison(item.process, '', item.gpuName, item.value)); + } + comparisonData = compare(this.selfData!, comparison); + for (const item of comparisonData) { + item.sizes = Utils.getBinaryByteWithUnit(item.value); + } + this.comparisonSource = comparisonData; + this.gpuMemoryClickTable!.recycleDataSource = comparisonData; + } + + sortGpuMemoryByColumn(column: string, sort: number): void { + switch (sort) { + case 0: + this.gpuMemoryClickTable!.recycleDataSource = this.comparisonSource; + break; + default: + let array = [...this.comparisonSource]; + switch (column) { + case 'process': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? `${gpuMComparisonLeftData.process}`.localeCompare(`${gpuMComparisonRightData.process}`) + : `${gpuMComparisonRightData.process}`.localeCompare(`${gpuMComparisonLeftData.process}`); + } + ); + break; + case 'gpuName': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? `${gpuMComparisonLeftData.gpuName}`.localeCompare(`${gpuMComparisonRightData.gpuName}`) + : `${gpuMComparisonRightData.gpuName}`.localeCompare(`${gpuMComparisonLeftData.gpuName}`); + } + ); + break; + case 'sizeDelta': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? gpuMComparisonLeftData.value - gpuMComparisonRightData.value + : gpuMComparisonRightData.value - gpuMComparisonLeftData.value; + } + ); + break; + } + break; + } + } + + initHtml(): string { + return ` + + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.ts index 26e09f68afb7a49060a9f4256139ef7284de1f51..b4105318cc9f79c605c1ad5e87e62731fd98d4b3 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.ts @@ -66,7 +66,8 @@ export class TabPaneGpuMemorySelectAbility extends BaseElement { } } - queryDataByDB(startNs: number): void { + queryGpuMemoryClickDataByDB(startNs: number): void { + this.init(); getTabGpuMemoryAbilityClickData(startNs).then((data) => { if (data.length !== null && data.length > 0) { data.forEach((item) => { diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..fe1dfd6879812794647ff76bdb9d0d62b6602f2b --- /dev/null +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this data 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import { querySysPurgeableSelectionTab } from '../../../../database/SqlLite.js'; +import { Utils } from '../../base/Utils.js'; +import { CompareStruct, compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +@element('tabpane-purgeable-pin-comparison-ability') +export class TabPanePurgPinComparisonAbility extends BaseElement { + private purgeablePinTable: LitTable | null | undefined; + private purgeablePinSource: Array = []; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private selectEl: LitSelect | undefined | null; + + public initElements(): void { + this.purgeablePinTable = this.shadowRoot?.querySelector('#tb-purgeable-pin'); + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + } + public totalData(data: SelectionParam | any, dataList: any): void { + //@ts-ignore + this.purgeablePinTable?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.purgeablePinSource = []; + let fileArr: any[] = []; + for (let file of dataList) { + if (file.startNs !== data.startNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.initSelect(data.startNs, fileArr); + this.updateComparisonData(data.startNs, fileArr[0].startNs); + } + private initSelect(fileStartNs: number, fileArr: Array): void { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) { + option.setAttribute('value', fileArr[0].name); + } + this.selectEl!.defaultValue = fileArr[0].name; + this.selectEl!.placeholder = fileArr[0].name; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e: any) => { + for (let f of fileArr) { + if (input.value === f.name) { + that.updateComparisonData(fileStartNs, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + private async updateComparisonData(baseTime: number, targetTime: number): Promise { + this.purgeablePinSource = []; + let tableData = await this.queryTableData(baseTime, targetTime); + this.purgeablePinSource.push(tableData); + if (this.purgeablePinSource.length > 0) { + this.purgeablePinTable!.recycleDataSource = this.purgeablePinSource; + } else { + this.purgeablePinTable!.recycleDataSource = []; + } + } + private async queryTableData(baseTime: number, targetTime: number): Promise { + let delta = { + purgPinedDelta: '0Bytes', + shmPurgPinDelta: '0Bytes', + }; + const baseArr: CompareStruct[] = []; + const targetArr: CompareStruct[] = []; + // 点击的 + await querySysPurgeableSelectionTab(baseTime, true).then(async (results) => { + for (let i = 0; i < results.length; i++) { + baseArr.push(new CompareStruct(results[i].name, results[i].value)); + } + // 被比较的 + await querySysPurgeableSelectionTab(targetTime, true).then((results) => { + for (let i = 0; i < results.length; i++) { + targetArr.push(new CompareStruct(results[i].name, results[i].value)); + } + let compareData = compare(baseArr, targetArr); + for (let data of compareData) { + if (data.key === 'PinedPurg') { + delta.purgPinedDelta = Utils.getBinaryByteWithUnit(data.value); + } else { + delta.shmPurgPinDelta = Utils.getBinaryByteWithUnit(data.value); + } + } + }); + }); + return delta; + } + + public connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.purgeablePinTable!, this.filterEl!); + } + public initHtml(): string { + return ` + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinSelection.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinSelection.ts index 24d8f9f57fc02c6790c4d72c9dba27cb8918e0af..642426e701ba946411c4cbf8d938bc303ed5a152 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinSelection.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinSelection.ts @@ -28,8 +28,9 @@ export class TabPanePurgPinSelection extends BaseElement { private purgeableSelectionSource: Array = []; set data(selection: SelectionParam | any) { - this.purgeableSelectionSource = []; - this.queryTableData(selection.type, selection.startNs); + if (selection && selection.type) { + this.queryTableData(selection.type, selection.startNs); + } } async queryTableData(type: string, startNs: number) { diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e7ee6d466ce4526cba4761d1912e5a38ec6b41b --- /dev/null +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this data 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import { querySysPurgeableSelectionTab } from '../../../../database/SqlLite.js'; +import { Utils } from '../../base/Utils.js'; +import { CompareStruct, compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +@element('tabpane-purgeable-total-comparison-ability') +export class TabPanePurgTotalComparisonAbility extends BaseElement { + private purgeableTotalTable: LitTable | null | undefined; + private purgeableTotalSource: Array = []; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private selectEl: LitSelect | undefined | null; + + public initElements(): void { + this.purgeableTotalTable = this.shadowRoot?.querySelector('#tb-purgeable-total'); + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + } + public totalData(data: SelectionParam | any, dataList: any): void { + //@ts-ignore + this.purgeableTotalTable?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.purgeableTotalSource = []; + let fileArr: any[] = []; + for (let file of dataList) { + if (file.startNs !== data.startNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.initSelect(data.startNs, fileArr); + this.updateComparisonData(data.startNs, fileArr[0].startNs); + } + private initSelect(fileStartNs: number, fileArr: Array): void { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) option.setAttribute('value', fileArr[0].name); + this.selectEl!.defaultValue = fileArr[0].name; + this.selectEl!.placeholder = fileArr[0].name; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e: any) => { + for (let f of fileArr) { + if (input.value === f.name) { + that.updateComparisonData(fileStartNs, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + private async updateComparisonData(baseTime: number, targetTime: number): Promise { + this.purgeableTotalSource = []; + let tableData = await this.queryTableData(baseTime, targetTime); + this.purgeableTotalSource.push(tableData); + if (this.purgeableTotalSource.length > 0) { + this.purgeableTotalTable!.recycleDataSource = this.purgeableTotalSource; + } else { + this.purgeableTotalTable!.recycleDataSource = []; + } + } + private async queryTableData(baseTime: number, targetTime: number): Promise { + let delta = { + purgActiveDelta: '0Bytes', + purgInActiveDelta: '0Bytes', + shmPurgTotalDelta: '0Bytes', + }; + const baseArr: CompareStruct[] = []; + const targetArr: CompareStruct[] = []; + // 点击的 + await querySysPurgeableSelectionTab(baseTime).then(async (results) => { + for (let i = 0; i < results.length; i++) { + baseArr.push(new CompareStruct(results[i].name, results[i].value)); + } + // 被比较的 + await querySysPurgeableSelectionTab(targetTime).then((results) => { + for (let i = 0; i < results.length; i++) { + targetArr.push(new CompareStruct(results[i].name, results[i].value)); + } + let compareData = compare(baseArr, targetArr); + for (let data of compareData) { + if (data.key === 'ActivePurg') { + delta.purgActiveDelta = Utils.getBinaryByteWithUnit(data.value); + } else if (data.key === 'InActivePurg') { + delta.purgInActiveDelta = Utils.getBinaryByteWithUnit(data.value); + } else if (data.key === 'ShmPurg') { + delta.shmPurgTotalDelta = Utils.getBinaryByteWithUnit(data.value); + } + } + }); + }); + return delta; + } + + public connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.purgeableTotalTable!, this.filterEl!); + } + public initHtml(): string { + return ` + + + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.ts index fbd0e0a8786441c9838e01127495d1f93feaf682..967adcaa317b818da6c5a78a58782b6ff51a879d 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.ts @@ -28,7 +28,9 @@ export class TabPanePurgTotalSelection extends BaseElement { private purgeableSelectionSource: Array = []; set data(selection: SelectionParam | any) { - this.queryTableData(selection.type, selection.startNs); + if (selection && selection.type) { + this.queryTableData(selection.type, selection.startNs); + } } async queryTableData(type: string, startNs: number) { diff --git a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts index 9aba213a79e5e8cfecf76c658abd47dd71887408..deaee198c7ef25100209a1f00c1bd773aef16a82 100644 --- a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts +++ b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts @@ -284,7 +284,7 @@ export class TabPaneJsCpuCallTree extends BaseElement {
- + @@ -296,7 +296,7 @@ export class TabPaneJsCpuCallTree extends BaseElement {
Heaviest Stack - + diff --git a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts index 7a89714bf268f26958774b617f91e57baeb3c536..4ae657e747411c2f4910ca9a12f736a62e7dcef0 100644 --- a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts +++ b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts @@ -51,6 +51,7 @@ export class TabPaneSummary extends BaseElement { private stack: HTMLLIElement | null | undefined; private retainers: HTMLLIElement | null | undefined; private file: FileInfo | undefined | null; + private leftTable: HTMLDivElement | null | undefined; initElements(): void { this.tblSummary = this.shadowRoot?.querySelector('#left'); @@ -65,9 +66,10 @@ export class TabPaneSummary extends BaseElement { this.tblTable = this.tblSummary!.shadowRoot?.querySelector('.table') as HTMLDivElement; this.rightTheadTable = this.tbs!.shadowRoot?.querySelector('.thead') as HTMLDivElement; this.leftTheadTable = this.tblSummary!.shadowRoot?.querySelector('.thead') as HTMLDivElement; + this.tbsTable = this.tbs!.shadowRoot?.querySelector('.table') as HTMLDivElement; + this.leftTable = this.shadowRoot?.querySelector('#left_table') as HTMLDivElement; this.tblSummary!.addEventListener('row-click', (evt) => { this.rightTheadTable!.removeAttribute('sort'); - this.tbsTable = this.tbs!.shadowRoot?.querySelector('.table') as HTMLDivElement; this.tbsTable!.scrollTop = 0; //@ts-ignore let data = evt.detail.data as ConstructorItem; @@ -647,6 +649,7 @@ export class TabPaneSummary extends BaseElement { connectedCallback() { super.connectedCallback(); let filterHeight = 0; + let parentWidth = this.parentElement!.clientWidth + 'px'; let system = document .querySelector('body > sp-application') ?.shadowRoot?.querySelector('#app-content > sp-system-trace'); @@ -658,13 +661,19 @@ export class TabPaneSummary extends BaseElement { } else { summaryPaneFilter.style.display = 'none'; } + parentWidth = this.parentElement!.clientWidth + 'px'; this.tbs!.style.height = 'calc(100% - 30px)'; + this.tbsTable!.style.width = `calc(${parentWidth} - ${this.leftTable!.style.width} - 5px)`; this.tbs!.reMeauseHeight(); + this.tblSummary!.reMeauseHeight(); }).observe(this.parentElement!); new ResizeObserver(() => { this.parentElement!.style.width = system!.clientWidth + 'px'; this.style.width = system!.clientWidth + 'px'; }).observe(system!); + new ResizeObserver(() => { + this.tbsTable!.style.width = `calc(${parentWidth} - ${this.leftTable!.style.width} - 5px)`; + }).observe(this.leftTable!); } initHtml(): string { diff --git a/ide/src/trace/component/trace/sheet/energy/TabPaneSystemDetails.ts b/ide/src/trace/component/trace/sheet/energy/TabPaneSystemDetails.ts index b8c366d48d14958152aaa65cea86b1c9bfe4b388..204ddd59e01f35013a1eeae57176cae33619ead5 100644 --- a/ide/src/trace/component/trace/sheet/energy/TabPaneSystemDetails.ts +++ b/ide/src/trace/component/trace/sheet/energy/TabPaneSystemDetails.ts @@ -61,7 +61,7 @@ export class TabPaneSystemDetails extends BaseElement { convertData(data: SystemDetailsEnergy) { if (data.eventName === 'Event Name') { this.slicerTrack!.style.visibility = 'hidden'; - this.detailsTbl!.recycleDataSource = []; + this.detailsTbl!.dataSource = []; this.boxDetails!.style.width = '100%'; } else { this.slicerTrack!.style.visibility = 'visible'; @@ -98,7 +98,7 @@ export class TabPaneSystemDetails extends BaseElement { value: data.interval, }); } - this.detailsTbl!.recycleDataSource = this.detailsSource; + this.detailsTbl!.dataSource = this.detailsSource; this.boxDetails!.style.width = '65%'; } this.detailsTbl!.shadowRoot?.querySelectorAll('.td').forEach((td) => { @@ -161,7 +161,7 @@ export class TabPaneSystemDetails extends BaseElement { }); this.tblSystemDetails!.recycleDataSource = this.eventSource.concat(itemList); - this.detailsTbl!.recycleDataSource = []; + this.detailsTbl!.dataSource = []; this.boxDetails!.style.width = '100%'; this.tblSystemDetails?.shadowRoot?.querySelectorAll('.td').forEach((td) => { td.style.fontSize = '14px'; diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts index b773685721fb9fe7c6582ab326cba48f98f6d544..6abc2096b668f8eb52e0e5463c282627eaf2bc1b 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts @@ -12,7 +12,6 @@ * 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 { resizeObserver } from '../SheetUtils.js'; @@ -21,7 +20,6 @@ import { VmTrackerChart } from '../../../chart/SpVmTrackerChart.js'; import { log } from '../../../../../log/Log.js'; import { SpSystemTrace } from '../../../SpSystemTrace.js'; import { Utils } from '../../base/Utils.js'; - interface GpuTreeItem { name: string; id: number; @@ -29,96 +27,98 @@ interface GpuTreeItem { sizeStr: string; children?: GpuTreeItem[] | undefined; } - @element('tabpane-gpu-click-select') export class TabPaneGpuClickSelect extends BaseElement { private gpuTbl: LitTable | null | undefined; private gpuSource: Array = []; - - set data(gpu: { type: string, startTs: number }) { - let label = this.gpuTbl!.shadowRoot!.querySelector('.thead')?.firstChild?.firstChild?.firstChild + gpuClickData(gpu: { type: string; startTs: number }) { + let label = this.gpuTbl!.shadowRoot!.querySelector('.thead')?.firstChild?.firstChild?.firstChild; if (label) { (label as HTMLLabelElement).innerHTML = gpu.type === 'total' ? 'Module / Category' : 'Window / Module / Category'; } //@ts-ignore this.gpuTbl?.shadowRoot?.querySelector('.table')?.style?.height = this.parentElement!.clientHeight - 45 + 'px'; this.gpuTbl!.loading = true; - let window = gpu.type === 'total' ? 0 : VmTrackerChart.gpuWindow; let module = gpu.type === 'total' ? VmTrackerChart.gpuTotalModule : VmTrackerChart.gpuWindowModule; queryGpuDataByTs(gpu.startTs, window || 0, module).then((result) => { - this.gpuTbl!.loading = false; - if (result != null && result.length > 0) { - log('queryGpuDataByTs result size : ' + result.length); - let gpuDataObj = result.reduce((group: any, item) => { - let categoryItem: GpuTreeItem = { - name: SpSystemTrace.DATA_DICT.get(item.categoryId) || 'null', - id: item.categoryId, + this.gpuTbl!.loading = false; + if (result != null && result.length > 0) { + log('queryGpuDataByTs result size : ' + result.length); + let items = this.createTreeData(result); + this.gpuSource = (gpu.type === 'total' ? items[0].children : items) || []; + this.gpuTbl!.recycleDataSource = this.gpuSource; + } else { + this.gpuSource = []; + this.gpuTbl!.recycleDataSource = []; + } + }); + } + protected createTreeData(result: any): Array { + let gpuDataObj = result.reduce( + ( + group: any, + item: { categoryId: number; size: number; windowNameId: number; moduleId: number; windowId: any } + ) => { + let categoryItem: GpuTreeItem = { + name: SpSystemTrace.DATA_DICT.get(item.categoryId) || 'null', + id: item.categoryId, + size: item.size, + sizeStr: Utils.getBinaryByteWithUnit(item.size), + }; + if (group[`${item.windowNameId}(${item.windowId})`]) { + let windowGroup = group[`${item.windowNameId}(${item.windowId})`] as GpuTreeItem; + windowGroup.size += item.size; + windowGroup.sizeStr = Utils.getBinaryByteWithUnit(windowGroup.size); + let moduleGroup = windowGroup.children!.find((it) => it.id === item.moduleId); + if (moduleGroup) { + moduleGroup.size += item.size; + moduleGroup.sizeStr = Utils.getBinaryByteWithUnit(moduleGroup.size); + moduleGroup.children?.push(categoryItem); + } else { + windowGroup.children?.push({ + name: SpSystemTrace.DATA_DICT.get(item.moduleId) || 'null', + id: item.moduleId, size: item.size, - sizeStr: Utils.getBinaryByteWithUnit(item.size) - }; - if (group[`${item.windowId}`]) { - let windowGroup = group[`${item.windowId}`] as GpuTreeItem; - windowGroup.size += item.size; - windowGroup.sizeStr = Utils.getBinaryByteWithUnit(windowGroup.size); - let moduleGroup = windowGroup.children!.find(it => it.id === item.moduleId); - if (moduleGroup) { - moduleGroup.size += item.size; - moduleGroup.sizeStr = Utils.getBinaryByteWithUnit(moduleGroup.size); - moduleGroup.children?.push(categoryItem); - } else { - windowGroup.children?.push( - { - name: SpSystemTrace.DATA_DICT.get(item.moduleId) || 'null', - id: item.moduleId, - size: item.size, - sizeStr: Utils.getBinaryByteWithUnit(item.size), - children: [ categoryItem ] - } - ); - } - } else { - group[`${item.windowId}`] = { - name: SpSystemTrace.DATA_DICT.get(item.windowId), - id: item.windowId, + sizeStr: Utils.getBinaryByteWithUnit(item.size), + children: [categoryItem], + }); + } + } else { + group[`${item.windowNameId}(${item.windowId})`] = { + name: SpSystemTrace.DATA_DICT.get(item.windowNameId) + `(${item.windowId})`, + id: item.windowNameId, + size: item.size, + sizeStr: Utils.getBinaryByteWithUnit(item.size), + children: [ + { + name: SpSystemTrace.DATA_DICT.get(item.moduleId), + id: item.moduleId, size: item.size, sizeStr: Utils.getBinaryByteWithUnit(item.size), - children: [ - { - name: SpSystemTrace.DATA_DICT.get(item.moduleId), - id: item.moduleId, - size: item.size, - sizeStr: Utils.getBinaryByteWithUnit(item.size), - children: [ categoryItem ] - } - ] - }; - } - return group; - }, {}); - let items = Object.values(gpuDataObj) as GpuTreeItem[]; - this.gpuSource = (gpu.type === 'total' ? items[0].children : items) || []; - this.gpuTbl!.recycleDataSource = this.gpuSource; - } else { - this.gpuSource = []; - this.gpuTbl!.recycleDataSource = []; + children: [categoryItem], + }, + ], + }; } - } + return group; + }, + {} ); + let items = Object.values(gpuDataObj) as GpuTreeItem[]; + return items; } - initElements(): void { this.gpuTbl = this.shadowRoot?.querySelector('#tb-gpu'); this.gpuTbl!.addEventListener('column-click', (evt: any) => { this.sortByColumn(evt.detail); }); } - connectedCallback(): void { super.connectedCallback(); - resizeObserver(this.parentElement!, this.gpuTbl!); + this.parentElement!.style.overflow = 'hidden'; + resizeObserver(this.parentElement!, this.gpuTbl!, 18); } - initHtml(): string { return ` + + + + + + + + `; + } +} +export class GpuDumpComparison extends CompareStruct { + windowNameId: number = -1; + windowId: number = -1; + moduleId: number = -1; + categoryId: number = -1; + size: number = -1; + constructor(windowNameId: number, windowId: number, moduleId: number, categoryId: number, value: number) { + super(`${windowNameId}` + '' + `${windowId}` + '' + `${moduleId}` + '' + `${categoryId}`, value); + this.windowNameId = windowNameId; + this.moduleId = moduleId; + this.windowId = windowId; + this.categoryId = categoryId; + } + clone(isBase?: boolean): GpuDumpComparison { + const value = isBase ? this.value : -this.value; + return new GpuDumpComparison(this.windowNameId, this.windowId, this.moduleId, this.categoryId, value); + } +} diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.ts index dfc88177ac66981616fec89006e79e0811a639b1..9d435fe8dfa4027d62ecec0af90832f6e245e194 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.ts @@ -31,8 +31,6 @@ interface GpuTotal { moduleId: number; categoryId: number; gpuName?: string; - sumSize: number; - sumSizeStr?: string; avgSize: number; avgSizeStr?: string; maxSize: number; @@ -69,7 +67,6 @@ export class TabPaneGpuTotalBoxSelect extends BaseElement { it.gpuName = `${moduleName} / ${categoryName}`; it.startTsStr = getProbablyTime(it.startTs); it.avgSizeStr = Utils.getBinaryByteWithUnit(it.avgSize); - it.sumSizeStr = Utils.getBinaryByteWithUnit(it.sumSize); it.minSizeStr = Utils.getBinaryByteWithUnit(it.minSize); it.maxSizeStr = Utils.getBinaryByteWithUnit(it.maxSize); }); @@ -114,7 +111,6 @@ export class TabPaneGpuTotalBoxSelect extends BaseElement {
- diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts index 51a1e0a2095b340b9ae84f70ef9eabc56d02a533..38453b5c37070586e3f25ed932b8bf1f444b3f27 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts @@ -31,8 +31,6 @@ interface Gpu { moduleId: number; categoryId: number; gpuName?: string; - sumSize: number; - sumSizeStr?: string; avgSize: number; avgSizeStr?: string; maxSize: number; @@ -70,7 +68,6 @@ export class TabPaneGpuWindowBoxSelect extends BaseElement { it.gpuName = `${windowName} / ${moduleName} / ${categoryName}`; it.startTsStr = getProbablyTime(it.startTs); it.avgSizeStr = Utils.getBinaryByteWithUnit(it.avgSize); - it.sumSizeStr = Utils.getBinaryByteWithUnit(it.sumSize); it.minSizeStr = Utils.getBinaryByteWithUnit(it.minSize); it.maxSizeStr = Utils.getBinaryByteWithUnit(it.maxSize); }); @@ -115,7 +112,6 @@ export class TabPaneGpuWindowBoxSelect extends BaseElement {
- diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.ts deleted file mode 100644 index 5007beb79149aed5e15a11595f24d02022aa8dbd..0000000000000000000000000000000000000000 --- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.ts +++ /dev/null @@ -1,424 +0,0 @@ -/* - * 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 { SelectionParam } from '../../../../bean/BoxSelection.js'; -import { query, queryNativeHookEventTid } from '../../../../database/SqlLite.js'; -import { NativeHookCallInfo, NativeHookStatistics } from '../../../../bean/NativeHook.js'; -import '../TabPaneFilter.js'; -import { FilterData, TabPaneFilter } from '../TabPaneFilter.js'; -import '../../../chart/FrameChart.js'; -import '../../../../../base-ui/slicer/lit-slicer.js'; -import { FrameChart } from '../../../chart/FrameChart.js'; -import { ChartMode } from '../../../../bean/FrameChartStruct.js'; -import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar.js'; -import { procedurePool } from '../../../../database/Procedure.js'; - -@element('tabpane-native-callinfo') -export class TabPaneNMCallInfo extends BaseElement { - private callInfoTbl: LitTable | null | undefined; - private tblData: LitTable | null | undefined; - private progressEL: LitProgressBar | null | undefined; - private loadingList: number[] = []; - private callInfoLoadingPage: any; - private callInfoSource: Array = []; - private rightSource: Array = []; - private queryResult: Array = []; - private native_type: Array = ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM']; - private filterAllocationType: string = '0'; - private filterNativeType: string = '0'; - private currentSelection: SelectionParam | undefined; - private frameChart: FrameChart | null | undefined; - private isChartShow: boolean = false; - private sortColumn: string = ''; - private sortType: number = 0; - - set data(callInfoParam: SelectionParam | any) { - if (callInfoParam == this.currentSelection) { - return; - } - this.currentSelection = callInfoParam; - this.initFilterTypes(); - let types: Array = []; - if (callInfoParam.nativeMemory.indexOf(this.native_type[0]) != -1) { - types.push("'AllocEvent'"); - types.push("'MmapEvent'"); - } else { - if (callInfoParam.nativeMemory.indexOf(this.native_type[1]) != -1) { - types.push("'AllocEvent'"); - } - if (callInfoParam.nativeMemory.indexOf(this.native_type[2]) != -1) { - types.push("'MmapEvent'"); - } - } - // @ts-ignore - this.callInfoTbl?.shadowRoot?.querySelector('.table').style.height = this.parentElement.clientHeight - 20 - 31 + 'px'; - // @ts-ignore - this.tblData?.shadowRoot?.querySelector('.table').style.height = this.parentElement.clientHeight + 'px'; - // @ts-ignore - this.tblData?.recycleDataSource = []; - // @ts-ignore - this.callInfoTbl?.recycleDataSource = []; - this.progressEL!.loading = true; - this.callInfoLoadingPage.style.visibility = 'visible'; - queryNativeHookEventTid(callInfoParam.leftNs, callInfoParam.rightNs, types).then((result) => { - this.queryResult = result; - this.getDataByNativeMemoryWorker(callInfoParam); - }); - } - - getDataByNativeMemoryWorker(callInfoParam: SelectionParam | any) { - let callInfoArgs = new Map(); - callInfoArgs.set('data', this.queryResult); - callInfoArgs.set('filterAllocType', this.filterAllocationType); - callInfoArgs.set('filterEventType', this.filterNativeType); - callInfoArgs.set('leftNs', callInfoParam.leftNs); - callInfoArgs.set('rightNs', callInfoParam.rightNs); - callInfoArgs.set('actionType', 'call-info'); - this.startWorker(callInfoArgs, (results: any[]) => { - this.tblData!.recycleDataSource = []; - this.progressEL!.loading = false; - if (results.length > 0) { - this.callInfoSource = results; - this.sortTreeByColumn(this.sortColumn, this.sortType); - this.frameChart!.mode = ChartMode.Byte; - this.frameChart!.data = this.callInfoSource; - this.frameChart?.updateCanvas(true, this.clientWidth); - this.frameChart?.calculateChartData(); - } else { - this.callInfoSource = []; - this.callInfoTbl!.recycleDataSource = []; - this.frameChart!.data = []; - this.frameChart!.clearCanvas(); - } - }); - } - - startWorker(callInfoArgs: Map, handler: Function) { - this.loadingList.push(1); - this.progressEL!.loading = true; - this.callInfoLoadingPage.style.visibility = 'visible'; - procedurePool.submitWithName('logic1', 'native-memory-action', callInfoArgs, undefined, (res: any) => { - handler(res); - this.loadingList.splice(0, 1); - if (this.loadingList.length == 0) { - this.progressEL!.loading = false; - this.callInfoLoadingPage.style.visibility = 'hidden'; - } - }); - } - - getParentTree( - src: Array, - target: NativeHookCallInfo, - parents: Array - ): boolean { - for (let hook of src) { - if (hook.id == target.id) { - parents.push(hook); - return true; - } else { - if (this.getParentTree(hook.children as Array, target, parents)) { - parents.push(hook); - return true; - } - } - } - return false; - } - - getChildTree(src: Array, eventId: number, children: Array): boolean { - for (let hook of src) { - if (hook.eventId == eventId && hook.children.length == 0) { - children.push(hook); - return true; - } else { - if (this.getChildTree(hook.children as Array, eventId, children)) { - children.push(hook); - return true; - } - } - } - return false; - } - - setRightTableData(hook: NativeHookCallInfo) { - let parents: Array = []; - let children: Array = []; - this.getParentTree(this.callInfoSource, hook, parents); - let maxEventId = hook.eventId; - let maxHeap = 0; - - function findMaxStack(hook: NativeHookCallInfo) { - if (hook.children.length == 0) { - if (hook.size > maxHeap) { - maxHeap = hook.size; - maxEventId = hook.eventId; - } - } else { - hook.children.map((hookChild) => { - findMaxStack(hookChild); - }); - } - } - - findMaxStack(hook); - this.getChildTree(hook.children as Array, maxEventId, children); - this.rightSource = parents.reverse().concat(children.reverse()); - let len = this.rightSource.length; - // @ts-ignore - this.tblData?.dataSource = len == 0 ? [] : this.rightSource.slice(1, len); - } - - initFilterTypes() { - let filter = this.shadowRoot?.querySelector('#filter'); - this.queryResult = []; - filter!.firstSelect = '0'; - filter!.secondSelect = '0'; - this.filterAllocationType = '0'; - this.filterNativeType = '0'; - } - - sortTreeByColumn(column: string, sort: number) { - this.sortColumn = column; - this.sortType = sort; - this.callInfoTbl!.recycleDataSource = this.sortTree(this.callInfoSource, column, sort); - } - - sortTree(arr: Array, column: string, sort: number): Array { - let sortArr = arr.sort((callInfoLeftData, callInfoRightData) => { - if (column == 'size') { - if (sort == 0) { - return callInfoLeftData.eventId - callInfoRightData.eventId; - } else if (sort == 1) { - return callInfoLeftData.size - callInfoRightData.size; - } else { - return callInfoRightData.size - callInfoLeftData.size; - } - } else { - if (sort == 0) { - return callInfoLeftData.eventId - callInfoRightData.eventId; - } else if (sort == 1) { - return callInfoLeftData.count - callInfoRightData.count; - } else { - return callInfoRightData.count - callInfoLeftData.count; - } - } - }); - sortArr.map((call) => { - call.children = this.sortTree(call.children as Array, column, sort); - }); - return sortArr; - } - - showButtomMenu(isShow: boolean) { - let filter = this.shadowRoot?.querySelector('#filter')!; - if (isShow) { - filter.setAttribute('first', ''); - filter.setAttribute('second', ''); - } else { - filter.removeAttribute('first'); - filter.removeAttribute('second'); - } - } - - initElements(): void { - this.callInfoLoadingPage = this.shadowRoot?.querySelector('.nm-call-info-loading'); - this.progressEL = this.shadowRoot?.querySelector('.nm-call-info-progress') as LitProgressBar; - this.callInfoTbl = this.shadowRoot?.querySelector('#tb-native-callinfo'); - this.tblData = this.shadowRoot?.querySelector('#tb-native-data'); - this.frameChart = this.shadowRoot?.querySelector('#framechart'); - let pageTab = this.shadowRoot?.querySelector('#show_table'); - let pageChart = this.shadowRoot?.querySelector('#show_chart'); - this.frameChart?.addChartClickListener((showMenu: boolean) => { - this.parentElement!.scrollTo(0, 0); - this.showButtomMenu(showMenu); - }); - - this.callInfoTbl!.addEventListener('row-click', (e) => { - // @ts-ignore - let data = e.detail.data as NativeHookCallInfo; - this.setRightTableData(data); - data.isSelected = true; - this.tblData?.clearAllSelection(data); - this.tblData?.setCurrentSelection(data); - // @ts-ignore - if ((e.detail as any).callBack) { - // @ts-ignore - (e.detail as any).callBack(true); - } - }); - this.tblData!.addEventListener('row-click', (e) => { - // @ts-ignore - let detail = e.detail.data as NativeHookCallInfo; - this.callInfoTbl?.clearAllSelection(detail); - detail.isSelected = true; - this.callInfoTbl!.scrollToData(detail); - // @ts-ignore - if ((e.detail as any).callBack) { - // @ts-ignore - (e.detail as any).callBack(true); - } - }); - this.callInfoTbl!.addEventListener('column-click', (evt) => { - this.sortTreeByColumn( - // @ts-ignore - evt.detail.key == 'countValue' || evt.detail.key == 'countPercent' ? 'countValue' : 'size', evt.detail.sort - ); - }); - - this.shadowRoot?.querySelector('#filter')!.getFilterData((data: FilterData) => { - this.filterAllocationType = data.firstSelect || '0'; - this.filterNativeType = data.secondSelect || '0'; - this.getDataByNativeMemoryWorker(this.currentSelection); - if (data.icon == 'block') { - pageChart?.setAttribute('class', 'show'); - pageTab?.setAttribute('class', ''); - this.isChartShow = true; - this.frameChart!.data = this.callInfoSource; - this.frameChart?.calculateChartData(); - } else if (data.icon == 'tree') { - pageChart?.setAttribute('class', ''); - pageTab?.setAttribute('class', 'show'); - this.isChartShow = false; - this.frameChart!.clearCanvas(); - this.callInfoTbl!.reMeauseHeight(); - } - }); - this.initFilterTypes(); - } - - connectedCallback() { - super.connectedCallback(); - this.parentElement!.onscroll = () => { - this.frameChart!.tabPaneScrollTop = this.parentElement!.scrollTop; - }; - let filterHeight = 0; - new ResizeObserver((entries) => { - let nmCallInfoTabFilter = this.shadowRoot!.querySelector('#filter') as HTMLElement; - if (nmCallInfoTabFilter.clientHeight > 0) filterHeight = nmCallInfoTabFilter.clientHeight; - if (this.parentElement!.clientHeight > filterHeight) { - nmCallInfoTabFilter.style.display = 'flex'; - } else { - nmCallInfoTabFilter.style.display = 'none'; - } - if (this.parentElement?.clientHeight != 0) { - if (!this.isChartShow) { - // @ts-ignore - this.callInfoTbl?.shadowRoot.querySelector('.table').style.height = this.parentElement.clientHeight + 'px'; - this.callInfoTbl?.reMeauseHeight(); - } else { - // @ts-ignore - this.frameChart?.updateCanvas(false, entries[0].contentRect.width); - this.frameChart?.calculateChartData(); - } - // @ts-ignore - this.callInfoTbl?.shadowRoot.querySelector('.table').style.height = this.parentElement.clientHeight - 10 - 31 + 'px'; - this.callInfoTbl?.reMeauseHeight(); - // @ts-ignore - this.tblData?.shadowRoot.querySelector('.table').style.height = this.parentElement.clientHeight - 10 - 31 + 'px'; - this.tblData?.reMeauseHeight(); - this.callInfoLoadingPage.style.height = this.parentElement!.clientHeight - 24 + 'px'; - } - }).observe(this.parentElement!); - } - - initHtml(): string { - return ` - -
- - -
- - - - - - - - - - - - - - - -
- - - - - - - - -
-
- - - - - -
-
- `; - } -} diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts index 4f0fee82c86489189a3bf71bb22fab7dbe33f342..fdb2076c273a0eaa0e93caa218760d46164e9a62 100644 --- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts +++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts @@ -54,11 +54,13 @@ export class TabPaneNMStatstics extends BaseElement { this.nativeStatisticsTbl?.shadowRoot.querySelector('.table').style.height = this.parentElement.clientHeight - 20 + 'px'; // @ts-ignore this.nativeStatisticsTbl?.recycleDataSource = []; + this.nativeStatisticsTbl!.loading = true; Promise.all([ queryNativeHookStatistics(nativeStatisticsParam.leftNs, nativeStatisticsParam.rightNs), queryNativeHookStatisticsSubType(nativeStatisticsParam.leftNs, nativeStatisticsParam.rightNs), queryNativeHookStatisticsMalloc(nativeStatisticsParam.leftNs, nativeStatisticsParam.rightNs), ]).then((values) => { + this.nativeStatisticsTbl!.loading = false; let arr: Array = []; let index1 = nativeStatisticsParam.nativeMemory.indexOf(this.native_type[0]); let index2 = nativeStatisticsParam.nativeMemory.indexOf(this.native_type[1]); diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts index ac1e14be9a8d88280f36f50adaba015c3a32fad5..2ef501ae65ea6b0497ee3f99bb15b87cf278128d 100644 --- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts +++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMemory.ts @@ -17,18 +17,25 @@ import { BaseElement, element } from '../../../../../base-ui/BaseElement.js'; import { LitTable } from '../../../../../base-ui/table/lit-table.js'; import '../../../../../base-ui/slicer/lit-slicer.js'; import { SelectionParam } from '../../../../bean/BoxSelection.js'; -import { query, queryNativeHookEventTid } from '../../../../database/SqlLite.js'; -import { NativeHookStatistics, NativeMemory, NativeHookCallInfo } from '../../../../bean/NativeHook.js'; +import { NativeMemory, NativeHookCallInfo } from '../../../../bean/NativeHook.js'; import '../TabPaneFilter.js'; import { FilterData, TabPaneFilter } from '../TabPaneFilter.js'; import { TabPaneNMSampleList } from './TabPaneNMSampleList.js'; import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar.js'; import { procedurePool } from '../../../../database/Procedure.js'; +import { + formatRealDateMs, + getByteWithUnit, + getTimeString +} from '../../../../database/logic-worker/ProcedureLogicWorkerCommon.js'; +import { SpNativeMemoryChart } from '../../../chart/SpNativeMemoryChart.js'; +import { Utils } from '../../base/Utils.js'; @element('tabpane-native-memory') export class TabPaneNMemory extends BaseElement { private defaultNativeTypes = ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM']; private memoryTbl: LitTable | null | undefined; + private filter: TabPaneFilter | null | undefined; private tblData: LitTable | null | undefined; private progressEL: LitProgressBar | null | undefined; private loadingList: number[] = []; @@ -36,7 +43,6 @@ export class TabPaneNMemory extends BaseElement { private memorySource: Array = []; private native_type: Array = [...this.defaultNativeTypes]; private statsticsSelection: Array = []; - private queryResult: Array = []; private filterAllocationType: string = '0'; private filterNativeType: string = '0'; private filterResponseType: number = -1; @@ -45,30 +51,28 @@ export class TabPaneNMemory extends BaseElement { private rowSelectData: any = undefined; private sortColumn: string = ''; private sortType: number = 0; - private leftNs: number = 0; - private rightNs: number = 0; private responseTypes: any[] = []; + private eventTypes: string[] = []; set data(memoryParam: SelectionParam | any) { if (memoryParam == this.currentSelection) { return; } this.currentSelection = memoryParam; - this.initFilterTypes(); this.queryData(memoryParam); } queryData(memoryParam: SelectionParam | any) { - let types: Array = []; + this.eventTypes = []; if (memoryParam.nativeMemory.indexOf(this.defaultNativeTypes[0]) != -1) { - types.push("'AllocEvent'"); - types.push("'MmapEvent'"); + this.eventTypes.push("'AllocEvent'"); + this.eventTypes.push("'MmapEvent'"); } else { if (memoryParam.nativeMemory.indexOf(this.defaultNativeTypes[1]) != -1) { - types.push("'AllocEvent'"); + this.eventTypes.push("'AllocEvent'"); } if (memoryParam.nativeMemory.indexOf(this.defaultNativeTypes[2]) != -1) { - types.push("'MmapEvent'"); + this.eventTypes.push("'MmapEvent'"); } } TabPaneNMSampleList.serSelection(memoryParam); @@ -80,24 +84,19 @@ export class TabPaneNMemory extends BaseElement { this.tblData?.recycleDataSource = []; // @ts-ignore this.memoryTbl?.recycleDataSource = []; - this.leftNs = memoryParam.leftNs; - this.rightNs = memoryParam.rightNs; - this.progressEL!.loading = true; - this.loadingPage.style.visibility = 'visible'; - queryNativeHookEventTid(memoryParam.leftNs, memoryParam.rightNs, types).then((result) => { - this.queryResult = result; - this.getDataByNativeMemoryWorker(memoryParam); - }); + this.resetFilter(); + this.getDataByNativeMemoryWorker(memoryParam, true); } - getDataByNativeMemoryWorker(val: SelectionParam | any) { + getDataByNativeMemoryWorker(val: SelectionParam | any, refresh = false) { let args = new Map(); - args.set('data', this.queryResult); args.set('filterAllocType', this.filterAllocationType); args.set('filterEventType', this.filterNativeType); args.set('filterResponseType', this.filterResponseType); args.set('leftNs', val.leftNs); args.set('rightNs', val.rightNs); + args.set('types', this.eventTypes); + args.set('refresh', refresh); let selections: Array = []; if (this.statsticsSelection.length > 0) { this.statsticsSelection.map((memory) => { @@ -108,13 +107,21 @@ export class TabPaneNMemory extends BaseElement { }); } args.set('statisticsSelection', selections); - args.set('actionType', 'native-memory'); - this.startWorker(args, (results: any[]) => { + args.set('sortColumn', this.sortColumn); + args.set('sortType', this.sortType); + this.memorySource = []; + if (this.memoryTbl!.recycleDs.length > 1_0000) { + this.memoryTbl!.recycleDataSource = []; + } + this.startWorker('native-memory-queryNativeHookEvent', args, (results: any[]) => { this.tblData!.recycleDataSource = []; - this.progressEL!.loading = false; + if (refresh) { + this.setLoading(true); + this.initFilterTypes(() => this.setLoading(false)); + } if (results.length > 0) { this.memorySource = results; - this.sortByColumn(this.sortColumn, this.sortType); + this.memoryTbl!.recycleDataSource = this.memorySource; } else { this.memorySource = []; this.memoryTbl!.recycleDataSource = []; @@ -122,18 +129,34 @@ export class TabPaneNMemory extends BaseElement { }); } - startWorker(args: Map, handler: Function) { - this.loadingList.push(1); - this.progressEL!.loading = true; - this.loadingPage.style.visibility = 'visible'; - procedurePool.submitWithName('logic1', 'native-memory-action', args, undefined, (res: any) => { - handler(res); + startWorker(type: string, args: any, handler: Function) { + this.setLoading(true); + procedurePool.submitWithName('logic1', type, args, undefined, (res: any) => { + if (res.data && res.tag) { + this.memorySource.push(res.data); + if (res.tag == 'end') { + handler(this.memorySource); + this.setLoading(false); + } + } else { + handler(res); + this.setLoading(false) + } + }); + } + + setLoading(loading: boolean) { + if (loading) { + this.loadingList.push(1); + this.progressEL!.loading = true; + this.loadingPage.style.visibility = 'visible'; + } else { this.loadingList.splice(0, 1); if (this.loadingList.length == 0) { this.progressEL!.loading = false; this.loadingPage.style.visibility = 'hidden'; } - }); + } } fromStastics(val: SelectionParam | any) { @@ -188,12 +211,10 @@ export class TabPaneNMemory extends BaseElement { } initFilterTypes(initCallback?: () => void) { - let filter = this.shadowRoot?.querySelector('#filter'); - this.queryResult = []; this.native_type = [...this.defaultNativeTypes]; this.statsticsSelection = []; procedurePool.submitWithName('logic1', 'native-memory-get-responseType', {}, undefined, (res: any) => { - filter!.setSelectList( + this.filter!.setSelectList( null, this.native_type, 'Allocation Lifespan', @@ -202,17 +223,11 @@ export class TabPaneNMemory extends BaseElement { return item.value; }) ); - filter!.setFilterModuleSelect('#first-select', 'width', '150px'); - filter!.setFilterModuleSelect('#second-select', 'width', '150px'); - filter!.setFilterModuleSelect('#third-select', 'width', '150px'); + this.filter!.setFilterModuleSelect('#first-select', 'width', '150px'); + this.filter!.setFilterModuleSelect('#second-select', 'width', '150px'); + this.filter!.setFilterModuleSelect('#third-select', 'width', '150px'); this.responseTypes = res; - filter!.firstSelect = '0'; - filter!.secondSelect = '0'; - filter!.thirdSelect = '0'; - this.filterResponseSelect = '0'; - this.filterAllocationType = '0'; - this.filterNativeType = '0'; - this.filterResponseType = -1; + this.resetFilter(); this.rowSelectData = undefined; if (initCallback) { initCallback(); @@ -220,11 +235,22 @@ export class TabPaneNMemory extends BaseElement { }); } + resetFilter() { + this.filter!.firstSelect = '0'; + this.filter!.secondSelect = '0'; + this.filter!.thirdSelect = '0'; + this.filterResponseSelect = '0'; + this.filterAllocationType = '0'; + this.filterNativeType = '0'; + this.filterResponseType = -1; + } + initElements(): void { this.loadingPage = this.shadowRoot?.querySelector('.loading'); this.progressEL = this.shadowRoot?.querySelector('.progress') as LitProgressBar; this.memoryTbl = this.shadowRoot?.querySelector('#tb-native-memory'); this.tblData = this.shadowRoot?.querySelector('#tb-native-data'); + this.filter = this.shadowRoot?.querySelector('#filter'); this.memoryTbl!.addEventListener('row-click', (e) => { // @ts-ignore let data = e.detail.data as NativeMemory; @@ -236,12 +262,24 @@ export class TabPaneNMemory extends BaseElement { }) ); }); - this.memoryTbl!.addEventListener('column-click', (evt) => { - // @ts-ignore - this.sortByColumn(evt.detail.key, evt.detail.sort); + this.memoryTbl!.addEventListener('column-click', (evt: any) => { + this.sortColumn = evt.detail.key; + this.sortType = evt.detail.sort; + this.getDataByNativeMemoryWorker(this.currentSelection); }); - let filter = this.shadowRoot?.querySelector('#filter'); - + this.memoryTbl!.itemTextHandleMap.set('startTs', (startTs) => { + return SpNativeMemoryChart.REAL_TIME_DIF === 0 ? getTimeString(startTs) : formatRealDateMs(startTs + SpNativeMemoryChart.REAL_TIME_DIF); + }); + this.memoryTbl!.itemTextHandleMap.set('endTs', (endTs) => { + return (endTs > this.currentSelection!.leftNs && + endTs <= this.currentSelection!.rightNs && + endTs !== 0 && + endTs !== null + ) ? 'Freed' : 'Existing'; + }); + this.memoryTbl!.itemTextHandleMap.set('heapSize', (heapSize) => { + return getByteWithUnit(heapSize); + }) this.shadowRoot?.querySelector('#filter')!.getFilterData((data: FilterData) => { if (data.mark) { document.dispatchEvent( @@ -269,12 +307,10 @@ export class TabPaneNMemory extends BaseElement { } if (filterTemp.length > 0) { this.rowSelectData = filterTemp[0]; - let currentSelection = this.queryResult.filter((item) => { - return item.startTs == this.rowSelectData.startTs; - }); - if (currentSelection.length > 0) { - currentSelection[0].isSelected = true; - } + let args = new Map(); + args.set('startTs', this.rowSelectData.startTs); + args.set('actionType', 'native-memory-state-change'); + this.startWorker('native-memory-action', args, (results: any[]) => {}); TabPaneNMSampleList.addSampleData(this.rowSelectData); this.memoryTbl!.scrollToData(this.rowSelectData); } @@ -294,7 +330,7 @@ export class TabPaneNMemory extends BaseElement { this.getDataByNativeMemoryWorker(this.currentSelection); } }); - filter!.firstSelect = '1'; + this.filter!.firstSelect = '1'; } connectedCallback() { @@ -312,103 +348,14 @@ export class TabPaneNMemory extends BaseElement { }).observe(this.parentElement!); } - sortByColumn(nmMemoryColumn: string, nmMemorySort: number) { - this.sortColumn = nmMemoryColumn; - this.sortType = nmMemorySort; - if (nmMemorySort == 0) { - this.memoryTbl!.recycleDataSource = this.memorySource; - } else { - let arr = [...this.memorySource]; - if (nmMemoryColumn == 'index') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - return nmMemorySort == 1 - ? memoryLeftData.index - memoryRightData.index - : memoryRightData.index - memoryLeftData.index; - }); - } else if (nmMemoryColumn == 'addr') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - if (nmMemorySort == 1) { - if (memoryLeftData.addr > memoryRightData.addr) { - return 1; - } else if (memoryLeftData.addr == memoryRightData.addr) { - return 0; - } else { - return -1; - } - } else { - if (memoryRightData.addr > memoryLeftData.addr) { - return 1; - } else if (memoryLeftData.addr == memoryRightData.addr) { - return 0; - } else { - return -1; - } - } - }); - } else if (nmMemoryColumn == 'timestamp') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - return nmMemorySort == 1 - ? memoryLeftData.startTs - memoryRightData.startTs - : memoryRightData.startTs - memoryLeftData.startTs; - }); - } else if (nmMemoryColumn == 'heapSizeUnit') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - return nmMemorySort == 1 - ? memoryLeftData.heapSize - memoryRightData.heapSize - : memoryRightData.heapSize - memoryLeftData.heapSize; - }); - } else if (nmMemoryColumn == 'library') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - if (nmMemorySort == 1) { - if (memoryLeftData.library > memoryRightData.library) { - return 1; - } else if (memoryLeftData.library == memoryRightData.library) { - return 0; - } else { - return -1; - } - } else { - if (memoryRightData.library > memoryLeftData.library) { - return 1; - } else if (memoryLeftData.library == memoryRightData.library) { - return 0; - } else { - return -1; - } - } - }); - } else if (nmMemoryColumn == 'symbol') { - this.memoryTbl!.recycleDataSource = arr.sort((memoryLeftData, memoryRightData) => { - if (nmMemorySort == 1) { - if (memoryLeftData.symbol > memoryRightData.symbol) { - return 1; - } else if (memoryLeftData.symbol == memoryRightData.symbol) { - return 0; - } else { - return -1; - } - } else { - if (memoryRightData.symbol > memoryLeftData.symbol) { - return 1; - } else if (memoryLeftData.symbol == memoryRightData.symbol) { - return 0; - } else { - return -1; - } - } - }); - } - } - } - setRightTableData(nativeMemoryHook: NativeMemory) { let args = new Map(); args.set('eventId', nativeMemoryHook.eventId); args.set('actionType', 'memory-stack'); - this.startWorker(args, (results: any[]) => { + this.startWorker('native-memory-action', args, (results: any[]) => { let thread = new NativeHookCallInfo(); thread.threadId = nativeMemoryHook.threadId; - thread.threadName = nativeMemoryHook.threadName; + thread.threadName = Utils.THREAD_MAP.get(thread.threadId) || 'Thread'; thread.title = `${nativeMemoryHook.threadName ?? ''}【${nativeMemoryHook.threadId}】`; thread.type = -1; let currentSource = []; @@ -462,15 +409,15 @@ export class TabPaneNMemory extends BaseElement { - + - + - + - + - +
diff --git a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.ts b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.ts new file mode 100644 index 0000000000000000000000000000000000000000..863c6a21e64bc4dc82e6b96cfe84556de6e6a5a3 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.ts @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this data 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 { element } from '../../../../../base-ui/BaseElement.js'; +import { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import { getTabSmapsStatisticData } from '../../../../database/SqlLite.js'; +import { resizeObserverFromMemory } from '../SheetUtils.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +import { TabPaneSmapsStatistics } from './TabPaneSmapsStatistics.js'; +import { SmapsType } from '../../../../bean/SmapsStruct.js'; + +@element('tabpane-smaps-comparison') +export class TabPaneSmapsComparison extends TabPaneSmapsStatistics { + private smapsCompariosnTable: LitTable | null | undefined; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private selectEl: LitSelect | undefined | null; + + public initElements(): void { + this.smapsCompariosnTable = this.shadowRoot?.querySelector('#tb-smaps-comparison'); + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + this.tabTitle = this.smapsCompariosnTable!.shadowRoot?.querySelector('.thead') as HTMLDivElement; + this.smapsCompariosnTable!.addEventListener('column-click', (evt) => { + // @ts-ignore + this.sortByColumn(evt.detail.key, evt.detail.sort, this.smapsCompariosnTable); + }); + } + public setData(data: SelectionParam | any, dataList: any): void { + //@ts-ignore + this.smapsCompariosnTable?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.smapsCompariosnTable!.loading = true; + this.init(this.tabTitle!); + let fileArr: any[] = []; + for (let file of dataList) { + if (file.startNs !== data.leftNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.initSelect(data.leftNs, fileArr); + this.querySmapsData(data.leftNs, fileArr[0].startNs); + } + private initSelect(fileStartNs: number, fileArr: Array): void { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) { + option.setAttribute('value', fileArr[0].name); + } + this.selectEl!.defaultValue = fileArr[0].name; + this.selectEl!.placeholder = fileArr[0].name; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e: any) => { + for (let f of fileArr) { + if (input.value === f.name) { + that.querySmapsData(fileStartNs, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + + private async querySmapsData(baseTime: number, targetTime: number): Promise { + const baseArr: SmapsCompareStruct[] = []; + const targetArr: SmapsCompareStruct[] = []; + // 点击的 + await getTabSmapsStatisticData(baseTime).then(async (results) => { + this.smapsCompariosnTable!.loading = false; + for (let i = 0; i < results.length; i++) { + baseArr.push( + new SmapsCompareStruct( + results[i].type, + results[i].path, + results[i].size, + results[i].count, + results[i].rss, + results[i].pss, + results[i].sharedClean, + results[i].sharedDirty, + results[i].privateClean, + results[i].privateDirty, + results[i].swap, + results[i].swapPss + ) + ); + } + // 被比较的 + await getTabSmapsStatisticData(targetTime).then((results) => { + for (let i = 0; i < results.length; i++) { + targetArr.push( + new SmapsCompareStruct( + results[i].type, + results[i].path, + results[i].size, + results[i].count, + results[i].rss, + results[i].pss, + results[i].sharedClean, + results[i].sharedDirty, + results[i].privateClean, + results[i].privateDirty, + results[i].swap, + results[i].swapPss + ) + ); + } + let compareData = this.compare(baseArr, targetArr); + this.filteredData(compareData, this.smapsCompariosnTable!); + }); + }); + } + + private compare(base: Array, target: Array): Array { + const diffMap = new Map(); + + for (const item of base) { + diffMap.set(item.type + ' ' + item.path, item.clone(true)); + } + + for (const item of target) { + if (diffMap.has(item.type + ' ' + item.path)) { + const diffItem = diffMap.get(item.type + ' ' + item.path); + diffItem!.size = diffItem!.size - item.size; + diffItem!.count = diffItem!.count - item.count; + diffItem!.rss = diffItem!.rss - item.rss; + diffItem!.pss = diffItem!.pss - item.pss; + diffItem!.sharedClean = diffItem!.sharedClean - item.sharedClean; + diffItem!.sharedDirty = diffItem!.sharedDirty - item.sharedDirty; + diffItem!.privateClean = diffItem!.privateClean - item.privateClean; + diffItem!.privateDirty = diffItem!.privateDirty - item.privateDirty; + diffItem!.swap = diffItem!.swap - item.swap; + diffItem!.swapPss = diffItem!.swapPss - item.swapPss; + } else { + diffMap.set(item.type + ' ' + item.path, item.clone()); + } + } + return Array.from(diffMap.values()); + } + + public connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.smapsCompariosnTable!, this.filterEl!); + } + public initHtml(): string { + return ` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
`; + } +} + +class SmapsCompareStruct { + type: SmapsType; + path: string; + size: number; + count: number; + rss: number; + pss: number; + sharedClean: number; + sharedDirty: number; + privateClean: number; + privateDirty: number; + swap: number; + swapPss: number; + + constructor( + type: SmapsType, + path: string, + size: number, + count: number, + rss: number, + pss: number, + sharedClean: number, + sharedDirty: number, + privateClean: number, + privateDirty: number, + swap: number, + swapPss: number + ) { + this.type = type; + this.path = path; + this.size = size; + this.count = count; + this.rss = rss; + this.pss = pss; + this.sharedClean = sharedClean; + this.sharedDirty = sharedDirty; + this.privateClean = privateClean; + this.privateDirty = privateDirty; + this.swap = swap; + this.swapPss = swapPss; + } + + clone(isBase?: boolean): SmapsCompareStruct { + if (isBase) { + return new SmapsCompareStruct( + this.type, + this.path, + this.size, + this.count, + this.rss, + this.pss, + this.sharedClean, + this.sharedDirty, + this.privateClean, + this.privateDirty, + this.swap, + this.swapPss + ); + } else { + return new SmapsCompareStruct( + this.type, + this.path, + -this.size, + -this.count, + -this.rss, + -this.pss, + -this.sharedClean, + -this.sharedDirty, + -this.privateClean, + -this.privateDirty, + -this.swap, + -this.swapPss + ); + } + } +} diff --git a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts index 4aabeb88547854cbfd76d42a78bd795598942cad..4b31e8cb5293e8155e39deff42a4bc9178a18761 100644 --- a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts +++ b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.ts @@ -91,17 +91,17 @@ export class TabPaneSmapsRecord extends BaseElement { if (result.length !== null && result.length > 0) { for (const smaps of result) { smaps.typeName = TYPE_STRING[smaps.type]; - smaps.address = smaps.start_addr + ' - ' + smaps.end_addr; + smaps.address = smaps.startAddr + ' - ' + smaps.endAddr; smaps.swapStr = Utils.getBinaryByteWithUnit(smaps.swap); smaps.rssStr = Utils.getBinaryByteWithUnit(smaps.rss); smaps.pssStr = Utils.getBinaryByteWithUnit(smaps.pss); smaps.sizeStr = Utils.getBinaryByteWithUnit(smaps.size); - smaps.sharedCleanStr = Utils.getBinaryByteWithUnit(smaps.shared_clean); - smaps.sharedDirtyStr = Utils.getBinaryByteWithUnit(smaps.shared_dirty); - smaps.privateCleanStr = Utils.getBinaryByteWithUnit(smaps.private_clean); - smaps.privateDirtyStr = Utils.getBinaryByteWithUnit(smaps.private_dirty); - smaps.swapPssStr = Utils.getBinaryByteWithUnit(smaps.swap_pss); - smaps.time = Utils.getTimeString(smaps.tsNS); + smaps.sharedCleanStr = Utils.getBinaryByteWithUnit(smaps.sharedClean); + smaps.sharedDirtyStr = Utils.getBinaryByteWithUnit(smaps.sharedDirty); + smaps.privateCleanStr = Utils.getBinaryByteWithUnit(smaps.privateClean); + smaps.privateDirtyStr = Utils.getBinaryByteWithUnit(smaps.privateDirty); + smaps.swapPssStr = Utils.getBinaryByteWithUnit(smaps.swapPss); + smaps.time = Utils.getTimeString(smaps.startNs); smaps.path = SpSystemTrace.DATA_DICT.get(smaps.path)?.split('/'); smaps.permission = SpSystemTrace.DATA_DICT.get(smaps.pid)?.split('/'); let resideS = smaps.reside.toFixed(2); @@ -187,8 +187,6 @@ export class TabPaneSmapsRecord extends BaseElement { }; } if ( - detail.key === 'dirtyStr' || - detail.key === 'swapperStr' || detail.key === 'rssStr' || detail.key === 'sizeStr' || detail.key === 'resideStr' diff --git a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts index baea37e09a36507edcb1b481099ef15d178ec41c..c9b1349fea07d0d5e69fb3037f3f017e1f9186fe 100644 --- a/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts +++ b/ide/src/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.ts @@ -16,16 +16,13 @@ import { BaseElement, element } from '../../../../../base-ui/BaseElement.js'; import { LitTable } from '../../../../../base-ui/table/lit-table.js'; import { SelectionParam } from '../../../../bean/BoxSelection.js'; import { - getTabSmapsData, getTabSmapsMaxSize, - getTabSmapsRecordData, getTabSmapsStatisticData, getTabSmapsStatisticMaxSize, getTabSmapsStatisticSelectData, } from '../../../../database/SqlLite.js'; import { Smaps, SmapsTreeObj, SmapsType, TYPE_STRING } from '../../../../bean/SmapsStruct.js'; import { Utils } from '../../base/Utils.js'; -import { resizeObserver } from '../SheetUtils.js'; import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; import { SpSystemTrace } from '../../../SpSystemTrace.js'; @element('tabpane-smaps-statistics') @@ -34,15 +31,29 @@ export class TabPaneSmapsStatistics extends BaseElement { private isClick = false; private currentSelection: SelectionParam | null | undefined; private sumSize: number = 0; - private sortArray: Array = []; - private totalTree: Array = []; - private tabTitle: HTMLDivElement | undefined | null; + private sortArray: Array = []; + private totalTree: Array = []; + public tabTitle: HTMLDivElement | undefined | null; + private allTree: SmapsTreeObj | undefined | null; + + public initElements(): void { + this.tblSmapsStatistics = this.shadowRoot?.querySelector('lit-table'); + this.tabTitle = this.tblSmapsStatistics!.shadowRoot?.querySelector('.thead') as HTMLDivElement; + this.tblSmapsStatistics!.addEventListener('column-click', (evt) => { + // @ts-ignore + this.sortByColumn(evt.detail.key, evt.detail.sort, this.tblSmapsStatistics); + }); + } + set data(valSmapsStatistics: SelectionParam) { + if (!this.tblSmapsStatistics) { + return; + } this.parentElement!.style.overflow = 'unset'; this.currentSelection = valSmapsStatistics; this.isClick = valSmapsStatistics.smapsType.length === 0; - this.init(); this.tblSmapsStatistics!.loading = true; + this.init(this.tabTitle!); if (!this.isClick) { if (valSmapsStatistics.smapsType.length > 0) { this.queryDataByDB(valSmapsStatistics); @@ -51,20 +62,14 @@ export class TabPaneSmapsStatistics extends BaseElement { this.setSmaps(valSmapsStatistics); } } - initElements(): void { - this.tblSmapsStatistics = this.shadowRoot?.querySelector('#tb-smaps-statistics'); - this.tabTitle = this.tblSmapsStatistics!.shadowRoot?.querySelector('.thead') as HTMLDivElement; - this.tblSmapsStatistics!.addEventListener('column-click', (evt) => { - // @ts-ignore - this.sortByColumn(evt.detail.key, evt.detail.sort); - }); - } + connectedCallback(): void { super.connectedCallback(); new ResizeObserver(() => { if (this.parentElement?.clientHeight != 0) { // @ts-ignore - this.tblSmapsStatistics?.shadowRoot?.querySelector('.table').style.height = this.parentElement.clientHeight - 15+ 'px'; + this.tblSmapsStatistics?.shadowRoot?.querySelector('.table').style.height = + this.parentElement!.clientHeight - 15 + 'px'; this.tblSmapsStatistics?.reMeauseHeight(); } }).observe(this.parentElement!); @@ -81,9 +86,10 @@ export class TabPaneSmapsStatistics extends BaseElement { (MemoryConfig.getInstance().interval * 1000_000) / 5 ).then((result) => { this.tblSmapsStatistics!.loading = false; - this.filteredData(result, this.sumSize); + this.filteredData(result, this.tblSmapsStatistics!, this.sumSize); }); } + private calculatePercentage(divisor: number, dividend: number) { if (dividend === 0) { return 0; @@ -91,11 +97,12 @@ export class TabPaneSmapsStatistics extends BaseElement { return (divisor / dividend) * 100; } } - private init(): void { - const thTable = this.tabTitle!.querySelector('.th'); + + public init(tabTitle: HTMLDivElement): void { + const thTable = tabTitle!.querySelector('.th'); const list = thTable!.querySelectorAll('div'); - if (this.tabTitle!.hasAttribute('sort')) { - this.tabTitle!.removeAttribute('sort'); + if (tabTitle!.hasAttribute('sort')) { + tabTitle!.removeAttribute('sort'); list.forEach((item) => { item.querySelectorAll('svg').forEach((svg) => { svg.style.display = 'none'; @@ -103,16 +110,12 @@ export class TabPaneSmapsStatistics extends BaseElement { }); } } - private handleSmapsTreeObj(smapsTreeObj: SmapsTreeObj, sumRss: number): void { - smapsTreeObj.regStr = smapsTreeObj.reg + ''; - smapsTreeObj.rssStr = Utils.getBinaryByteWithUnit(smapsTreeObj.rss); - smapsTreeObj.dirtyStr = Utils.getBinaryByteWithUnit(smapsTreeObj.dirty); - smapsTreeObj.swapperStr = Utils.getBinaryByteWithUnit(smapsTreeObj.swapper); + + private handleSmapsTreeObj(smapsTreeObj: SmapsTreeObj, sumSize?: number): void { smapsTreeObj.sizeStr = Utils.getBinaryByteWithUnit(smapsTreeObj.size); - smapsTreeObj.respro = this.calculatePercentage(smapsTreeObj.rss, smapsTreeObj.size); + smapsTreeObj.rssStr = Utils.getBinaryByteWithUnit(smapsTreeObj.rss); smapsTreeObj.pssStr = Utils.getBinaryByteWithUnit(smapsTreeObj.pss); - smapsTreeObj.resproStr = smapsTreeObj.respro.toFixed(2) + '%'; - smapsTreeObj.sizePro = this.calculatePercentage(smapsTreeObj.size, sumRss); + smapsTreeObj.sizePro = this.calculatePercentage(smapsTreeObj.size, sumSize!); smapsTreeObj.sizeProStr = smapsTreeObj.sizePro.toFixed(2) + '%'; smapsTreeObj.sharedCleanStr = Utils.getBinaryByteWithUnit(smapsTreeObj.sharedClean); smapsTreeObj.sharedDirtyStr = Utils.getBinaryByteWithUnit(smapsTreeObj.sharedDirty); @@ -121,105 +124,101 @@ export class TabPaneSmapsStatistics extends BaseElement { smapsTreeObj.swapStr = Utils.getBinaryByteWithUnit(smapsTreeObj.swap); smapsTreeObj.swapPssStr = Utils.getBinaryByteWithUnit(smapsTreeObj.swapPss); } - private handleAllDataTree(smaps: Smaps, id: number, parentId: string, dataTree: SmapsTreeObj, sumRss: number): void { + + private handleAllDataTree( + smaps: Smaps, + id: number, + parentId: string, + dataTree: SmapsTreeObj, + sumSize?: number + ): void { let type = smaps.typeName; let objTree = new SmapsTreeObj(id + '', parentId, type); objTree.path = SpSystemTrace.DATA_DICT.get(Number(smaps.path))?.split('/'); - objTree.rss = smaps.rss; - objTree.sizePro = this.calculatePercentage(smaps.size, sumRss); - objTree.sizeProStr = objTree.sizePro.toFixed(2) + '%'; - objTree.rssStr = Utils.getBinaryByteWithUnit(smaps.rss); - objTree.dirty = smaps.dirty; - objTree.dirtyStr = Utils.getBinaryByteWithUnit(smaps.dirty); - objTree.swapper = smaps.swapper; - objTree.swapperStr = Utils.getBinaryByteWithUnit(smaps.swapper); + if (sumSize) { + objTree.sizePro = this.calculatePercentage(smaps.size, sumSize); + objTree.sizeProStr = objTree.sizePro.toFixed(2) + '%'; + } objTree.size = smaps.size; objTree.sizeStr = Utils.getBinaryByteWithUnit(smaps.size); + objTree.rss = smaps.rss; + objTree.rssStr = Utils.getBinaryByteWithUnit(smaps.rss); objTree.pss = smaps.pss; objTree.pssStr = Utils.getBinaryByteWithUnit(smaps.pss); - objTree.respro = smaps.reside; - objTree.resproStr = smaps.reside.toFixed(2) + '%'; - dataTree.reg += 1; if (dataTree.children.length >= 1 && dataTree.path !== '< multiple >') { dataTree.path = '< multiple >'; } - dataTree.rss += smaps.rss; - dataTree.dirty += smaps.dirty; - dataTree.swapper += smaps.swapper; + dataTree.size += smaps.size; - dataTree.respro += smaps.reside; - dataTree.pss += smaps.pss; dataTree.count += smaps.count; - dataTree.sharedClean += smaps.shared_clean; - dataTree.sharedDirty += smaps.shared_dirty; - dataTree.privateClean += smaps.private_clean; - dataTree.privateDirty += smaps.private_dirty; + dataTree.rss += smaps.rss; + dataTree.pss += smaps.pss; + dataTree.sharedClean += smaps.sharedClean; + dataTree.sharedDirty += smaps.sharedDirty; + dataTree.privateClean += smaps.privateClean; + dataTree.privateDirty += smaps.privateDirty; dataTree.swap += smaps.swap; - dataTree.swapPss += smaps.swap_pss; + dataTree.swapPss += smaps.swapPss; } - private handleTree(smaps: Smaps, id: number, parentId: string, dataTree: SmapsTreeObj, sumRss: number): void { + + private handleTree(smaps: Smaps, id: number, parentId: string, dataTree: SmapsTreeObj, sumSize?: number): void { let type = TYPE_STRING[smaps.type]; let treeObj = new SmapsTreeObj(id + '', parentId, type); treeObj.path = SpSystemTrace.DATA_DICT.get(Number(smaps.path))?.split('/'); - treeObj.rss = smaps.rss; - treeObj.pss = smaps.pss; - treeObj.sizePro = this.calculatePercentage(smaps.size, sumRss); - treeObj.sizeProStr = treeObj.sizePro.toFixed(2) + '%'; - treeObj.rssStr = Utils.getBinaryByteWithUnit(smaps.rss); - treeObj.dirty = smaps.dirty; - treeObj.count = smaps.count; - treeObj.dirtyStr = Utils.getBinaryByteWithUnit(smaps.dirty); - treeObj.swapper = smaps.swapper; - treeObj.swapperStr = Utils.getBinaryByteWithUnit(smaps.swapper); treeObj.size = smaps.size; treeObj.sizeStr = Utils.getBinaryByteWithUnit(smaps.size); + treeObj.count = smaps.count; + treeObj.rss = smaps.rss; + treeObj.rssStr = Utils.getBinaryByteWithUnit(smaps.rss); treeObj.pss = smaps.pss; treeObj.pssStr = Utils.getBinaryByteWithUnit(smaps.pss); - treeObj.respro = smaps.reside; - treeObj.resproStr = smaps.reside.toFixed(2) + '%'; - treeObj.sharedClean = smaps.shared_clean; - treeObj.sharedCleanStr = Utils.getBinaryByteWithUnit(smaps.shared_clean); - treeObj.sharedDirty = smaps.shared_dirty; - treeObj.sharedDirtyStr = Utils.getBinaryByteWithUnit(smaps.shared_dirty); - treeObj.privateClean = smaps.private_clean; - treeObj.privateCleanStr = Utils.getBinaryByteWithUnit(smaps.private_clean); - treeObj.privateDirty = smaps.private_dirty; - treeObj.privateDirtyStr = Utils.getBinaryByteWithUnit(smaps.private_dirty); + treeObj.sharedClean = smaps.sharedClean; + treeObj.sharedCleanStr = Utils.getBinaryByteWithUnit(smaps.sharedClean); + treeObj.sharedDirty = smaps.sharedDirty; + treeObj.sharedDirtyStr = Utils.getBinaryByteWithUnit(smaps.sharedDirty); + treeObj.privateClean = smaps.privateClean; + treeObj.privateCleanStr = Utils.getBinaryByteWithUnit(smaps.privateClean); + treeObj.privateDirty = smaps.privateDirty; + treeObj.privateDirtyStr = Utils.getBinaryByteWithUnit(smaps.privateDirty); treeObj.swap = smaps.swap; treeObj.swapStr = Utils.getBinaryByteWithUnit(smaps.swap); - treeObj.swapPss = smaps.swap_pss; - treeObj.swapPssStr = Utils.getBinaryByteWithUnit(smaps.swap_pss); - dataTree.reg += 1; + treeObj.swapPss = smaps.swapPss; + treeObj.swapPssStr = Utils.getBinaryByteWithUnit(smaps.swapPss); + + if (sumSize) { + treeObj.sizePro = this.calculatePercentage(smaps.size, sumSize || 0); + treeObj.sizeProStr = treeObj.sizePro.toFixed(2) + '%'; + } + if (dataTree.children.length >= 1 && dataTree.path !== '< multiple >') { dataTree.path = '< multiple >'; } - dataTree.rss += smaps.rss; - dataTree.dirty += smaps.dirty; - dataTree.swapper += smaps.swapper; + dataTree.size += smaps.size; - dataTree.pss += smaps.pss; dataTree.count += smaps.count; - dataTree.sharedClean += smaps.shared_clean; - dataTree.sharedDirty += smaps.shared_dirty; - dataTree.privateClean += smaps.private_clean; - dataTree.privateDirty += smaps.private_dirty; - dataTree.swap += smaps.swap; - dataTree.swapPss += smaps.swap_pss; + dataTree.rss += smaps.rss; + dataTree.pss += smaps.pss; + dataTree.sharedClean += smaps.sharedClean; + dataTree.sharedDirty += smaps.sharedDirty; + dataTree.privateClean += smaps.privateClean; + dataTree.privateDirty += smaps.privateDirty; dataTree.swap += smaps.swap; - dataTree.swapPss += smaps.swap_pss; + dataTree.swapPss += smaps.swapPss; dataTree.children.push(treeObj); } + async setSmaps(data: SelectionParam) { - getTabSmapsStatisticMaxSize(data.rightNs).then((maxRes) => { + getTabSmapsStatisticMaxSize(data.leftNs).then((maxRes) => { this.sumSize = maxRes[0].max_value; }); - await getTabSmapsStatisticData(data.rightNs).then((result) => { + await getTabSmapsStatisticData(data.leftNs).then((result) => { this.tblSmapsStatistics!.loading = false; - this.filteredData(result, this.sumSize); + this.filteredData(result, this.tblSmapsStatistics!, this.sumSize); }); } - filteredData(result: any, sumRss: number): void { - let allTree: SmapsTreeObj = new SmapsTreeObj('All', '', '*All*'); + + public filteredData(result: Array, table: LitTable, sumSize?: number): void { + this.allTree = new SmapsTreeObj('All', '', '*All*'); let codeSysTree: SmapsTreeObj = new SmapsTreeObj('CODE_SYS', '', 'CODE_SYS'); let codeAppTree: SmapsTreeObj = new SmapsTreeObj('CODE_APP', '', 'CODE_APP'); let dataSysTree: SmapsTreeObj = new SmapsTreeObj('DATA_SYS', '', 'DATA_SYS'); @@ -238,61 +237,62 @@ export class TabPaneSmapsStatistics extends BaseElement { smaps.typeName = TYPE_STRING[smaps.type]; switch (smaps.type) { case SmapsType.TYPE_CODE_SYS: - this.handleTree(smaps, id, smaps.typeName, codeSysTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, codeSysTree, sumSize); break; case SmapsType.TYPE_CODE_APP: - this.handleTree(smaps, id, smaps.typeName, codeAppTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, codeAppTree, sumSize); break; case SmapsType.TYPE_DATA_SYS: - this.handleTree(smaps, id, smaps.typeName, dataSysTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, dataSysTree, sumSize); break; case SmapsType.TYPE_DATA_APP: - this.handleTree(smaps, id, smaps.typeName, dataAppTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, dataAppTree, sumSize); break; case SmapsType.TYPE_UNKNOWN_ANON: - this.handleTree(smaps, id, smaps.typeName, unKownTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, unKownTree, sumSize); break; case SmapsType.TYPE_STACK: - this.handleTree(smaps, id, smaps.typeName, stackTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, stackTree, sumSize); break; case SmapsType.TYPE_JS_HEAP: - this.handleTree(smaps, id, smaps.typeName, jsTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, jsTree, sumSize); break; case SmapsType.TYPE_JAVA_VM: - this.handleTree(smaps, id, smaps.typeName, javaVmTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, javaVmTree, sumSize); break; case SmapsType.TYPE_NATIVE_HEAP: - this.handleTree(smaps, id, smaps.typeName, nativeTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, nativeTree, sumSize); break; case SmapsType.TYPE_ASHMEM: - this.handleTree(smaps, id, smaps.typeName, ashMemTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, ashMemTree, sumSize); break; case SmapsType.TYPE_OTHER_SYS: - this.handleTree(smaps, id, smaps.typeName, otherSysTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, otherSysTree, sumSize); break; case SmapsType.TYPE_OTHER_APP: - this.handleTree(smaps, id, smaps.typeName, otherAppTree, sumRss); + this.handleTree(smaps, id, smaps.typeName, otherAppTree, sumSize); break; } - this.handleAllDataTree(smaps, id, 'All', allTree, sumRss); + + this.handleAllDataTree(smaps, id, 'All', this.allTree, sumSize!); if (id === result.length - 1) { - this.handleSmapsTreeObj(codeSysTree, sumRss); - this.handleSmapsTreeObj(codeAppTree, sumRss); - this.handleSmapsTreeObj(dataSysTree, sumRss); - this.handleSmapsTreeObj(dataAppTree, sumRss); - this.handleSmapsTreeObj(unKownTree, sumRss); - this.handleSmapsTreeObj(stackTree, sumRss); - this.handleSmapsTreeObj(jsTree, sumRss); - this.handleSmapsTreeObj(javaVmTree, sumRss); - this.handleSmapsTreeObj(nativeTree, sumRss); - this.handleSmapsTreeObj(ashMemTree, sumRss); - this.handleSmapsTreeObj(otherSysTree, sumRss); - this.handleSmapsTreeObj(otherAppTree, sumRss); - this.handleSmapsTreeObj(allTree, sumRss); + this.handleSmapsTreeObj(codeSysTree, sumSize); + this.handleSmapsTreeObj(codeAppTree, sumSize); + this.handleSmapsTreeObj(dataSysTree, sumSize); + this.handleSmapsTreeObj(dataAppTree, sumSize); + this.handleSmapsTreeObj(unKownTree, sumSize); + this.handleSmapsTreeObj(stackTree, sumSize); + this.handleSmapsTreeObj(jsTree, sumSize); + this.handleSmapsTreeObj(javaVmTree, sumSize); + this.handleSmapsTreeObj(nativeTree, sumSize); + this.handleSmapsTreeObj(ashMemTree, sumSize); + this.handleSmapsTreeObj(otherSysTree, sumSize); + this.handleSmapsTreeObj(otherAppTree, sumSize); + this.handleSmapsTreeObj(this.allTree, sumSize!); } } let treeList = [ - allTree, + this.allTree, codeSysTree, codeAppTree, dataSysTree, @@ -313,100 +313,103 @@ export class TabPaneSmapsStatistics extends BaseElement { this.totalTree.push(tree); } } - this.totalTree.push(allTree); + // @ts-ignore - this.totalTree.sort((a, b) => b.size - a.size); - this.tblSmapsStatistics!.recycleDataSource = this.totalTree; - this.tblSmapsStatistics?.reMeauseHeight(); + this.totalTree.sort((previous, next) => next.size - previous.size); + this.totalTree.unshift(this.allTree); + table!.recycleDataSource = this.totalTree; + this.totalTree.shift(); + table?.reMeauseHeight(); } else { - this.tblSmapsStatistics!.recycleDataSource = []; - this.tblSmapsStatistics?.reMeauseHeight(); + table!.recycleDataSource = []; + table?.reMeauseHeight(); } } - sortByColumn(column: string, sort: number) { + + public sortByColumn(column: string, sort: number, table: LitTable) { + this.sortArray = [...this.totalTree]; switch (sort) { case 0: - this.tblSmapsStatistics!.snapshotDataSource = this.totalTree; + this.sortArray.sort((previous, next) => { + return next.size - previous.size; + }); + this.sortArray.unshift(this.allTree!); + table!.recycleDataSource = this.totalTree; + this.sortArray.shift(); break; default: - this.sortArray = [...this.totalTree]; switch (column) { case 'sizeStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.size - b.size : b.size - a.size; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.size - next.size : next.size - previous.size; + }); + break; + case 'sizeProStr': + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.size - next.size : next.size - previous.size; }); break; case 'count': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.count - b.count : b.count - a.count; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.count - next.count : next.count - previous.count; }); break; case 'rssStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.rss - b.rss : b.rss - a.rss; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.rss - next.rss : next.rss - previous.rss; }); break; case 'typeName': - this.tblSmapsStatistics!.recycleDataSource = this.sortArray.sort((a, b) => { - if (sort === 1) { - if (a.typeName > b.typeName) { - return 1; - } else if (a.typeName === b.typeName) { - return 0; - } else { - return -1; - } - } else { - if (b.typeName > a.typeName) { - return 1; - } else if (a.typeName === b.typeName) { - return 0; - } else { - return -1; - } - } + this.sortArray.sort((previous, next) => { + return sort === 1 + ? previous.typeName.toString().localeCompare(next.typeName.toString()) + : next.typeName.toString().localeCompare(previous.typeName.toString()); }); break; case 'pssStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.pss - b.pss : b.pss - a.pss; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.pss - next.pss : next.pss - previous.pss; }); break; case 'sharedCleanStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.sharedClean - b.sharedClean : b.sharedClean - a.sharedClean; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.sharedClean - next.sharedClean : next.sharedClean - previous.sharedClean; }); break; case 'sharedDirtyStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.sharedDirty - b.sharedDirty : b.sharedDirty - a.sharedDirty; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.sharedDirty - next.sharedDirty : next.sharedDirty - previous.sharedDirty; }); break; case 'privateCleanStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.privateClean - b.privateClean : b.privateClean - a.privateClean; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.privateClean - next.privateClean : next.privateClean - previous.privateClean; }); break; case 'privateDirtyStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.privateDirty - b.privateDirty : b.privateDirty - a.privateDirty; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.privateDirty - next.privateDirty : next.privateDirty - previous.privateDirty; }); break; case 'swapStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.swap - b.swap : b.swap - a.swap; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.swap - next.swap : next.swap - previous.swap; }); break; case 'swapPssStr': - this.tblSmapsStatistics!.snapshotDataSource = this.sortArray.sort((a, b) => { - return sort === 1 ? a.swapPss - b.swapPss : b.swapPss - a.swapPss; + this.sortArray.sort((previous, next) => { + return sort === 1 ? previous.swapPss - next.swapPss : next.swapPss - previous.swapPss; }); break; } break; } + this.sortArray.unshift(this.allTree!); + table!.recycleDataSource = this.sortArray; + this.sortArray.shift(); } - initHtml(): string { + + public initHtml(): string { return ` + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.ts index 49286f3b264ebddc2a6cc42752ecca7bcd5455c5..42e26db5ccf78515ecee2380332d5a152eb1fb37 100644 --- a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.ts +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.ts @@ -27,12 +27,6 @@ export class TabPaneGpuMemorySelectVmTracker extends BaseElement { private gpuMemoryClickSource: Array = []; private tableThead: HTMLDivElement | undefined | null; - set data(data: number) { - // @ts-ignore - this.queryDataByDB(data); - this.init(); - } - initElements(): void { this.gpuMemoryClickTable = this.shadowRoot?.querySelector('#gpuMemoryClickTable'); this.tableThead = this.gpuMemoryClickTable?.shadowRoot?.querySelector('.thead') as HTMLDivElement; @@ -67,7 +61,8 @@ export class TabPaneGpuMemorySelectVmTracker extends BaseElement { } } - queryDataByDB(startNs: number): void { + queryGpuMemoryVmTrackerClickDataByDB(startNs: number): void { + this.init(); getTabGpuMemoryVMTrackerClickData(startNs, MemoryConfig.getInstance().iPid).then((data) => { if (data.length !== null && data.length > 0) { data.forEach((item) => { diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.ts index 9bd139542768901982bcc8d14898055d6e78d655..6fa2338ae126a3c3c8a359394eff78445287c9a5 100644 --- a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.ts +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.ts @@ -21,6 +21,7 @@ import { getTabGpuMemoryData } from '../../../../database/SqlLite.js'; import { GpuMemory } from '../../../../bean/AbilityMonitor.js'; import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; import { Utils } from '../../base/Utils.js'; +import { SpSystemTrace } from '../../../SpSystemTrace.js'; @element('tabpane-gpu-memory-vmtracker') export class TabPaneGpuMemoryVmTracker extends BaseElement { @@ -28,6 +29,7 @@ export class TabPaneGpuMemoryVmTracker extends BaseElement { private gpuMemorySource: Array = []; private tableThead: HTMLDivElement | undefined | null; private gpuMemoryTimeRange: HTMLDivElement | undefined | null; + private total: GpuMemory = new GpuMemory(); set data(gpuMemoryValue: SelectionParam | any) { if (gpuMemoryValue.gpuMemoryTrackerData.length > 0) { @@ -59,27 +61,42 @@ export class TabPaneGpuMemoryVmTracker extends BaseElement { val.leftNs, val.rightNs, MemoryConfig.getInstance().iPid, - (MemoryConfig.getInstance().interval * 1000000) / 5 + MemoryConfig.getInstance().snapshotDur ).then((data) => { this.gpuMemoryTableTbl!.loading = false; if (data.length !== null && data.length > 0) { + this.total = new GpuMemory(); + this.total.thread = '*All*'; + this.total.gpuName = '*All*'; data.forEach((item) => { if (item.threadName !== null) { item.thread = `${item.threadName}(${item.threadId})`; } else { item.thread = `Thread(${item.threadId})`; } + this.total.avgSize += item.avgSize; + if (this.total.minSize < 0) { + this.total.minSize = item.minSize; + } + if (this.total.maxSize < 0) { + this.total.maxSize = item.maxSize; + } + this.total.minSize = Math.min(this.total.minSize, item.minSize); + this.total.maxSize = Math.max(this.total.maxSize, item.maxSize); + + item.gpuName = SpSystemTrace.DATA_DICT.get(item.gpuNameId) || ''; item.avgSizes = Utils.getBinaryByteWithUnit(Math.round(item.avgSize)); item.minSizes = Utils.getBinaryByteWithUnit(item.minSize); item.maxSizes = Utils.getBinaryByteWithUnit(item.maxSize); }); + this.total.avgSizes = Utils.getBinaryByteWithUnit(Math.round(this.total.avgSize / data.length)); + this.total.minSizes = Utils.getBinaryByteWithUnit(this.total.minSize); + this.total.maxSizes = Utils.getBinaryByteWithUnit(this.total.maxSize); this.gpuMemorySource = data; - this.gpuMemoryTableTbl!.recycleDataSource = this.gpuMemorySource.sort(function ( - gpuMemoryLeftData: GpuMemory, - gpuMemoryRightData: GpuMemory - ) { + this.gpuMemorySource.sort(function (gpuMemoryLeftData: GpuMemory, gpuMemoryRightData: GpuMemory) { return gpuMemoryRightData.avgSize - gpuMemoryLeftData.avgSize; }); + this.gpuMemoryTableTbl!.recycleDataSource = [...this.gpuMemorySource]; } else { this.gpuMemoryTableTbl!.recycleDataSource = []; this.gpuMemorySource = []; @@ -121,10 +138,10 @@ export class TabPaneGpuMemoryVmTracker extends BaseElement { - + - + 5 @@ -137,47 +154,48 @@ export class TabPaneGpuMemoryVmTracker extends BaseElement { sortGpuMemoryByColumn(column: string, sort: number): void { switch (sort) { case 0: - this.gpuMemoryTableTbl!.recycleDataSource = this.gpuMemorySource; + this.gpuMemoryTableTbl!.recycleDataSource = [...this.gpuMemorySource]; break; default: let array = [...this.gpuMemorySource]; switch (column) { case 'gpuName': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? `${gpuMemoryLeftData.gpuName}`.localeCompare(`${gpuMemoryRightData.gpuName}`) : `${gpuMemoryRightData.gpuName}`.localeCompare(`${gpuMemoryLeftData.gpuName}`); }); break; case 'avgSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.avgSize - gpuMemoryRightData.avgSize : gpuMemoryRightData.avgSize - gpuMemoryLeftData.avgSize; }); break; case 'minSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.minSize - gpuMemoryRightData.minSize : gpuMemoryRightData.minSize - gpuMemoryLeftData.minSize; }); break; case 'maxSize': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? gpuMemoryLeftData.maxSize - gpuMemoryRightData.maxSize : gpuMemoryRightData.maxSize - gpuMemoryLeftData.maxSize; }); break; case 'thread': - this.gpuMemoryTableTbl!.recycleDataSource = array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { + array.sort((gpuMemoryLeftData, gpuMemoryRightData) => { return sort === 1 ? `${gpuMemoryLeftData.thread}`.localeCompare(`${gpuMemoryRightData.thread}`) : `${gpuMemoryRightData.thread}`.localeCompare(`${gpuMemoryLeftData.thread}`); }); break; } + this.gpuMemoryTableTbl!.recycleDataSource = [...array]; break; } } diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.ts new file mode 100644 index 0000000000000000000000000000000000000000..75e235cf96b567095fc7e4f7830ae2a1c3ba0789 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.ts @@ -0,0 +1,189 @@ +/* + * 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { GpuMemoryComparison } from '../../../../bean/AbilityMonitor.js'; +import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; +import { getTabGpuMemoryVmTrackerComparisonData } from '../../../../database/SqlLite.js'; +import { SnapshotStruct } from '../../../../database/ui-worker/ProcedureWorkerSnapshot.js'; +import { SpSystemTrace } from '../../../SpSystemTrace.js'; +import { Utils } from '../../base/Utils.js'; +import { compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import '../TabPaneJsMemoryFilter.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; + +@element('tabpane-gpu-memory-vmtracker-comparison') +export class TabPaneGpuMemoryVmTrackerComparison extends BaseElement { + private gpuMemoryClickTable: LitTable | null | undefined; + private comparisonSelect: TabPaneJsMemoryFilter | null | undefined; + private selectEl: LitSelect | null | undefined; + private selfData = new Array(); + private comparisonSource: Array = []; + + initElements(): void { + this.gpuMemoryClickTable = this.shadowRoot?.querySelector('#gpuMemoryClickTable'); + this.comparisonSelect = this.shadowRoot?.querySelector('#filter') as TabPaneJsMemoryFilter; + this.selectEl = this.comparisonSelect?.shadowRoot?.querySelector('lit-select'); + this.gpuMemoryClickTable!.addEventListener('column-click', (e) => { + // @ts-ignore + this.sortGpuMemoryByColumn(e.detail.key, e.detail.sort); + }); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.gpuMemoryClickTable!, this.comparisonSelect!); + } + + async queryDataByDB(startNs: number): Promise { + let timeStampData: Array = []; + await getTabGpuMemoryVmTrackerComparisonData(startNs, MemoryConfig.getInstance().iPid).then((data) => { + data.forEach((item) => { + if (item.threadName !== null) { + item.thread = `${item.threadName}(${item.threadId})`; + } else { + item.thread = `Thread(${item.threadId})`; + } + item.gpuName = SpSystemTrace.DATA_DICT.get(item.gpuNameId as number) || '-'; + }); + timeStampData = data; + }); + return timeStampData; + } + + async comparisonDataByDB(startNs: number, dataList: Array): Promise { + this.selfData = []; + const selfData = await this.queryDataByDB(startNs); + const dataArray = []; + for (const item of selfData) { + this.selfData.push(new GpuMemoryComparison('', item.thread, item.gpuName, item.value)); + } + for (let item of dataList) { + if (item.startNs !== startNs) { + dataArray.push(item); + } + } + this.selectStamps(dataArray); + this.getComparisonData(dataArray[0].startNs); + } + + selectStamps(dataList: Array): void { + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (dataList[0].name) { + option.setAttribute('value', dataList[0].name); + } + option.setAttribute('value', dataList[0].name); + this.selectEl!.defaultValue = dataList[0].name || ''; + this.selectEl!.placeholder = dataList[0].name || ''; + this.selectEl!.dataSource = dataList; + this.selectEl!.querySelectorAll('lit-select-option').forEach((option) => { + option.addEventListener('onSelected', async (e) => { + for (let f of dataList) { + if (input.value === f.name) { + this.getComparisonData(f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + + async getComparisonData(targetStartNs: number) { + let comparisonData: GpuMemoryComparison[] = []; + let comparison: GpuMemoryComparison[] = []; + let data = await this.queryDataByDB(targetStartNs); + for (const item of data) { + comparison.push(new GpuMemoryComparison('', item.thread, item.gpuName, item.value)); + } + comparisonData = compare(this.selfData!, comparison); + for (const item of comparisonData) { + item.sizes = Utils.getBinaryByteWithUnit(item.value); + } + this.comparisonSource = comparisonData; + this.gpuMemoryClickTable!.recycleDataSource = comparisonData; + } + + sortGpuMemoryByColumn(column: string, sort: number): void { + switch (sort) { + case 0: + this.gpuMemoryClickTable!.recycleDataSource = this.comparisonSource; + break; + default: + let array = [...this.comparisonSource]; + switch (column) { + case 'thread': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? `${gpuMComparisonLeftData.thread}`.localeCompare(`${gpuMComparisonRightData.thread}`) + : `${gpuMComparisonRightData.thread}`.localeCompare(`${gpuMComparisonLeftData.thread}`); + } + ); + break; + case 'gpuName': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? `${gpuMComparisonLeftData.gpuName}`.localeCompare(`${gpuMComparisonRightData.gpuName}`) + : `${gpuMComparisonRightData.gpuName}`.localeCompare(`${gpuMComparisonLeftData.gpuName}`); + } + ); + break; + case 'sizeDelta': + this.gpuMemoryClickTable!.recycleDataSource = array.sort( + (gpuMComparisonLeftData, gpuMComparisonRightData) => { + return sort === 1 + ? gpuMComparisonLeftData.value - gpuMComparisonRightData.value + : gpuMComparisonRightData.value - gpuMComparisonLeftData.value; + } + ); + break; + } + break; + } + } + + initHtml(): string { + return ` + + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d2a1981df6cbf1661575426591b4afa9984b829 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.ts @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this data 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; +import { queryProcessPurgeableSelectionTab } from '../../../../database/SqlLite.js'; +import { Utils } from '../../base/Utils.js'; +import { CompareStruct, compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +@element('tabpane-purgeable-pin-comparison-vm') +export class TabPanePurgPinComparisonVM extends BaseElement { + private purgeablePinTable: LitTable | null | undefined; + private purgeablePinSource: Array = []; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private selectEl: LitSelect | undefined | null; + + public initElements(): void { + this.purgeablePinTable = this.shadowRoot?.querySelector('#tb-purgeable-pin'); + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + } + public totalData(data: SelectionParam | any, dataList: any): void { + //@ts-ignore + this.purgeablePinTable?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.purgeablePinSource = []; + let fileArr: any[] = []; + for (let file of dataList) { + if (file.startNs !== data.startNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.initSelect(data.startNs, fileArr); + this.updateComparisonData(data.startNs, fileArr[0].startNs); + } + private initSelect(fileStartNs: number, fileArr: Array): void { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) { + option.setAttribute('value', fileArr[0].name); + } + this.selectEl!.defaultValue = fileArr[0].name; + this.selectEl!.placeholder = fileArr[0].name; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e: any) => { + for (let f of fileArr) { + if (input.value === f.name) { + that.updateComparisonData(fileStartNs, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + private async updateComparisonData(baseTime: number, targetTime: number): Promise { + this.purgeablePinSource = []; + let tableData = await this.queryPinVMData(baseTime, targetTime); + this.purgeablePinSource.push(tableData); + if (this.purgeablePinSource.length > 0) { + this.purgeablePinTable!.recycleDataSource = this.purgeablePinSource; + } else { + this.purgeablePinTable!.recycleDataSource = []; + } + } + private async queryPinVMData(baseTime: number, targetTime: number): Promise { + let delta = { + purgPinDelta: '0Bytes', + shmPurgPinDelta: '0Bytes', + }; + const baseArr: CompareStruct[] = []; + const targetArr: CompareStruct[] = []; + // 点击的 + await queryProcessPurgeableSelectionTab(baseTime, MemoryConfig.getInstance().iPid).then(async (results) => { + for (let i = 0; i < results.length; i++) { + baseArr.push(new CompareStruct(results[i].name, results[i].value)); + } + // 被比较的 + await queryProcessPurgeableSelectionTab(targetTime, MemoryConfig.getInstance().iPid).then((results) => { + for (let i = 0; i < results.length; i++) { + targetArr.push(new CompareStruct(results[i].name, results[i].value)); + } + let compareData = compare(targetArr, baseArr); + for (let data of compareData) { + if (data.key === 'PinedPurg') { + delta.purgPinDelta = Utils.getBinaryByteWithUnit(data.value); + } else if (data.key === 'ShmPurg') { + delta.shmPurgPinDelta = Utils.getBinaryByteWithUnit(data.value); + } + } + }); + }); + return delta; + } + + public connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.purgeablePinTable!, this.filterEl!); + } + public initHtml(): string { + return ` + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.ts new file mode 100644 index 0000000000000000000000000000000000000000..499792e731fa6b05254dd3d6bcf1e8b2fec3d722 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.ts @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this data 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 { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitTable } from '../../../../../base-ui/table/lit-table.js'; +import { SelectionParam } from '../../../../bean/BoxSelection.js'; +import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; +import { queryProcessPurgeableSelectionTab } from '../../../../database/SqlLite.js'; +import { Utils } from '../../base/Utils.js'; +import { CompareStruct, compare, resizeObserverFromMemory } from '../SheetUtils.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +@element('tabpane-purgeable-total-comparison-vm') +export class TabPanePurgTotalComparisonVM extends BaseElement { + private purgeableTotalTable: LitTable | null | undefined; + private purgeableTotalSource: Array = []; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private selectEl: LitSelect | undefined | null; + + public initElements(): void { + this.purgeableTotalTable = this.shadowRoot?.querySelector('#tb-purgeable-total'); + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + } + public totalData(data: SelectionParam | any, dataList: any): void { + //@ts-ignore + this.purgeableTotalTable?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.purgeableTotalSource = []; + let fileArr: any[] = []; + for (let file of dataList) { + if (file.startNs !== data.startNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.initSelect(data.startNs, fileArr); + this.updateComparisonData(data.startNs, fileArr[0].startNs); + } + private initSelect(fileStartNs: number, fileArr: Array): void { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) { + option.setAttribute('value', fileArr[0].name); + } + this.selectEl!.defaultValue = fileArr[0].name; + this.selectEl!.placeholder = fileArr[0].name; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e: any) => { + for (let f of fileArr) { + if (input.value === f.name) { + that.updateComparisonData(fileStartNs, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + private async updateComparisonData(baseTime: number, targetTime: number): Promise { + this.purgeableTotalSource = []; + let tableData = await this.queryTotalVMData(baseTime, targetTime); + this.purgeableTotalSource.push(tableData); + if (this.purgeableTotalSource.length > 0) { + this.purgeableTotalTable!.recycleDataSource = this.purgeableTotalSource; + } else { + this.purgeableTotalTable!.recycleDataSource = []; + } + } + private async queryTotalVMData(baseTime: number, targetTime: number): Promise { + let delta = { + purgSumDelta: '0Bytes', + shmPurgDelta: '0Bytes', + }; + const baseArr: CompareStruct[] = []; + const targetArr: CompareStruct[] = []; + // 点击的 + await queryProcessPurgeableSelectionTab(baseTime, MemoryConfig.getInstance().iPid).then(async (results) => { + for (let i = 0; i < results.length; i++) { + baseArr.push(new CompareStruct(results[i].name, results[i].value)); + } + // 被比较的 + await queryProcessPurgeableSelectionTab(targetTime, MemoryConfig.getInstance().iPid).then((results) => { + for (let i = 0; i < results.length; i++) { + targetArr.push(new CompareStruct(results[i].name, results[i].value)); + } + let compareData = compare(targetArr, baseArr); + for (let data of compareData) { + if (data.key === 'TotalPurg') { + delta.purgSumDelta = Utils.getBinaryByteWithUnit(data.value); + } else if (data.key === 'ShmPurg') { + delta.shmPurgDelta = Utils.getBinaryByteWithUnit(data.value); + } + } + }); + }); + return delta; + } + + public connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.purgeableTotalTable!, this.filterEl!); + } + public initHtml(): string { + return ` + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.ts index e97b8cfec78b1b17fd5322f18618d91fd3d8b0b2..5f50375290632037b376b7726db6297eedc4ad87 100644 --- a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.ts +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.ts @@ -171,10 +171,6 @@ export class TabPaneVmTrackerShm extends BaseElement { - - - - diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.ts new file mode 100644 index 0000000000000000000000000000000000000000..4446f54cb45b071c76b9c989c215929cbb04b396 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.ts @@ -0,0 +1,208 @@ +/* + * 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 { queryVmTrackerShmSelectionData } from '../../../../database/SqlLite.js'; +import { SnapshotStruct } from '../../../../database/ui-worker/ProcedureWorkerSnapshot.js'; +import { MemoryConfig } from '../../../../bean/MemoryConfig.js'; +import { ns2s } from '../../../../database/ui-worker/ProcedureWorkerCommon.js'; +import { Utils } from '../../base/Utils.js'; +import { LitSelectOption } from '../../../../../base-ui/select/LitSelectOption.js'; +import { LitSelect } from '../../../../../base-ui/select/LitSelect.js'; +import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter.js'; +import { resizeObserverFromMemory } from '../SheetUtils.js'; + +@element('tabpane-vmtracker-shm-comparison') +export class TabPaneVmTrackerShmComparison extends BaseElement { + private comparisonTableEl: LitTable | undefined | null; + private baseFileTs: number | undefined | null; + private targetFileTs: number | undefined | null; + private comparisonData!: any[]; + private baseFileData: Array = []; + private targetFileData: Array = []; + private memoryConfig: MemoryConfig = MemoryConfig.getInstance(); + private selectEl: LitSelect | undefined | null; + private filterEl: TabPaneJsMemoryFilter | undefined | null; + private comparisonSource: Array = []; + + initElements(): void { + this.comparisonTableEl = this.shadowRoot!.querySelector('#tb-comparison') as LitTable; + this.filterEl = this.shadowRoot!.querySelector('#filter'); + this.selectEl = this.filterEl?.shadowRoot?.querySelector('lit-select'); + this.comparisonTableEl!.addEventListener('column-click', (e) => { + // @ts-ignore + this.sortShmByColumn(e.detail.key, e.detail.sort); + }); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserverFromMemory(this.parentElement!, this.comparisonTableEl!, this.filterEl!); + } + + setShmData(data: SnapshotStruct, dataList: Array): void { + let fileArr: SnapshotStruct[] = []; + let that = this; + for (let file of dataList) { + if (file.startNs !== data.startNs) { + fileArr.push(file); + } + } + fileArr = fileArr.sort(); + this.baseFileTs = data.startNs; + this.initSelect(data.startNs, fileArr); + this.targetFileTs = fileArr[0].startNs; + that.updateComparisonData(data.startNs, fileArr[0].startNs); + } + + async updateComparisonData(baseFileTs: number, targetFileTs: number) { + await queryVmTrackerShmSelectionData(baseFileTs, this.memoryConfig.iPid).then((result) => { + this.baseFileData = result; + }); + await queryVmTrackerShmSelectionData(targetFileTs, this.memoryConfig.iPid).then((result) => { + this.targetFileData = result; + }); + let sizeData = this.calSizeObj(this.baseFileData, this.targetFileData); + this.comparisonData = []; + this.comparisonData.push(sizeData); + this.comparisonSource = this.comparisonData; + this.comparisonTableEl!.snapshotDataSource = this.comparisonData; + } + + calSizeObj(baseFileData: Array, targetFileData: Array): ShmObj { + let sizeObj = new ShmObj(); + let baseSumSize = 0; + let targetSumSize = 0; + for (let file of baseFileData) { + baseSumSize += file.size; + } + for (let file of targetFileData) { + targetSumSize += file.size; + } + sizeObj.sizeDelta = baseSumSize - targetSumSize; + sizeObj.sizeDeltaStr = Utils.getBinaryByteWithUnit(sizeObj.sizeDelta); + return sizeObj; + } + + initSelect(fileId: number, fileArr: Array) { + let that = this; + let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; + this.selectEl!.innerHTML = ''; + let option = new LitSelectOption(); + option.innerHTML = 'File Name'; + option.setAttribute('disabled', 'disabled'); + this.selectEl?.appendChild(option); + if (fileArr[0].name) { + option.setAttribute('value', fileArr[0].name); + } + this.selectEl!.defaultValue = fileArr[0].name || ''; + this.selectEl!.placeholder = fileArr[0].name || ''; + this.selectEl!.dataSource = fileArr; + this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { + a.addEventListener('onSelected', (e) => { + this.comparisonTableEl!.scrollTop = 0; + for (let f of fileArr) { + if (input.value == f.name) { + that.updateComparisonData(fileId, f.startNs); + } + } + e.stopPropagation(); + }); + }); + } + + sortShmByColumn(column: string, sort: number): void { + switch (sort) { + case 0: + this.comparisonTableEl!.snapshotDataSource = this.comparisonSource; + break; + default: + let array = [...this.comparisonSource]; + switch (column) { + case 'sizeDelta': + this.comparisonTableEl!.snapshotDataSource = array.sort((shmComparisonLeftData, shmComparisonRightData) => { + return sort === 1 + ? shmComparisonLeftData.sizeDelta - shmComparisonRightData.sizeDelta + : shmComparisonRightData.sizeDelta - shmComparisonLeftData.sizeDelta; + }); + break; + } + break; + } + } + + initHtml(): string { + return ` + +
+ + +
+ + + + +
+
+
+ + +
+
+ `; + } +} + +class ShmObj { + sizeDelta = 0; + sizeDeltaStr: string = ''; +} diff --git a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.ts b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.ts index 2dd4a19b606e2fd9433eb286118f967dfbcae58d..6eb48eb5f9d50c723a9cc0822d71f4af3a9dc5f5 100644 --- a/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.ts +++ b/ide/src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.ts @@ -52,9 +52,9 @@ export class TabPaneVmTrackerShmSelection extends BaseElement { filter.sizeStr = Utils.getBinaryByteWithUnit(filter.size); this.TableEl!.getItemTextColor = (filter): any => { if (filter.flag === 1) { - return '#6b6b6b96'; + return '#d4b550'; } else if (filter.flag === 2) { - return '#4a4a4a'; + return '#f86b6b'; } else { return '#000000'; } diff --git a/ide/src/trace/database/SqlLite.ts b/ide/src/trace/database/SqlLite.ts index 66832e467e0cb0887287f6c8a6a1b6ded53aa8f9..aa29d078182ede50b44b2f935f6bf60fc4ce4919 100644 --- a/ide/src/trace/database/SqlLite.ts +++ b/ide/src/trace/database/SqlLite.ts @@ -31,7 +31,9 @@ import { } from '../bean/NativeHook.js'; import { Dma, + DmaComparison, GpuMemory, + GpuMemoryComparison, LiveProcess, ProcessHistory, SystemCpuSummary, @@ -1256,8 +1258,6 @@ export const queryAppStartupProcessIds = (): Promise> => SELECT ipid FROM app_startup UNION SELECT t.ipid FROM app_startup a LEFT JOIN thread t ON a.call_id = t.itid - UNION - SELECT ipid FROM static_initalize );`); export const queryProcessContentCount = (): Promise> => query(`queryProcessContentCount`, `select pid,switch_count,thread_count,slice_count,mem_count from process;`); @@ -1628,38 +1628,6 @@ export const queryNativeHookStatisticSubType = (leftNs: number, rightNs: number) { $leftNs: leftNs, $rightNs: rightNs } ); -export const queryNativeHookEventTid = ( - leftNs: number, - rightNs: number, - types: Array -): Promise> => - query( - 'queryNativeHookEventTid', - ` - select - callchain_id as eventId, - event_type as eventType, - heap_size as heapSize, - addr, - (A.start_ts - B.start_ts) as startTs, - (A.end_ts - B.start_ts) as endTs, - tid, - sub_type_id as subTypeId, - ifnull(last_lib_id,0) as lastLibId, - t.name as threadName - from - native_hook A, - trace_range B - left join - thread t - on - A.itid = t.id - where - A.start_ts - B.start_ts - between ${leftNs} and ${rightNs} and A.event_type in (${types.join(',')})`, - { $leftNs: leftNs, $rightNs: rightNs, $types: types } - ); - export const queryNativeHookStatisticsCount = (): Promise> => query('queryNativeHookStatisticsCount', `select count(1) num from native_hook_statistic`, {}); @@ -3595,8 +3563,9 @@ export const queryGpuTotalType = (): Promise 'queryGpuTotalType', ` select distinct module_name_id id,data - from memory_window_gpu A left join data_dict B on A.module_name_id = B.id - where window_name_id = 0; + from memory_window_gpu A, trace_range TR left join data_dict B on A.module_name_id = B.id + where window_name_id = 0 + and A.ts < TR.end_ts; ` ); @@ -3606,6 +3575,7 @@ export const queryGpuDataByTs = ( module: number | null ): Promise< Array<{ + windowNameId: number; windowId: number; moduleId: number; categoryId: number; @@ -3616,7 +3586,8 @@ export const queryGpuDataByTs = ( module === null ? `and window_name_id = ${window}` : `and window_name_id = ${window} and module_name_id = ${module}`; - let sql = `select window_name_id as windowId, + let sql = `select window_name_id as windowNameId, + window_id as windowId, module_name_id as moduleId, category_name_id as categoryId, size @@ -3631,6 +3602,7 @@ export const queryGpuTotalData = (moduleId: number | null): Promise > => { - let sql = ` - select (ts - start_ts) startTs, + let sql = `select (ts - start_ts) startTs, window_name_id windowId, module_name_id moduleId, category_name_id categoryId, - sum(size) sumSize, avg(size) avgSize, max(size) maxSize, min(size) minSize from memory_window_gpu,trace_range where not ((startTs + ${interval} < ${leftNs}) or (startTs > ${rightNs})) - group by ts,window_name_id,module_name_id,category_name_id; + group by window_name_id,module_name_id,category_name_id + order by avgSize DESC; `; return query('queryGpuWindowData', sql); }; @@ -3712,6 +3682,7 @@ export const queryGpuWindowData = ( select (ts - start_ts) startNs, sum(size) value from memory_window_gpu,trace_range where window_name_id = ${windowId} ${moduleCondition} + and ts < end_ts group by ts; `; return query('queryGpuWindowData', sql); @@ -3722,12 +3693,14 @@ export const queryGpuWindowType = (): Promise> => export const querySmapsData = (columnName: string): Promise> => query( 'querySmapsCounterData', - `SELECT (A.timestamp - B.start_ts) as startNs, sum(${columnName}) * 1024 as value, $columnName as name FROM smaps A,trace_range B GROUP by A.timestamp;`, + `SELECT (A.timestamp - B.start_ts) as startNs, sum(${columnName}) * 1024 as value, $columnName as name FROM smaps A,trace_range B WHERE A.timestamp < B.end_ts GROUP by A.timestamp;`, { $columnName: columnName } ); @@ -3767,21 +3740,19 @@ export const getTabSmapsData = (leftNs: number, rightNs: number, dur: number): P query( 'getTabSmapsData', ` - SELECT - (A.timestamp - t.start_ts) AS tsNS, - start_addr, - end_addr, - dirty * 1024 as dirty, + SELECT + (A.timestamp - t.start_ts) AS startNs, + start_addr as startAddr, + end_addr as endAddr, A.type, - swapper * 1024 as swapper, resident_size * 1024 AS rss, protection_id as pid, pss * 1024 as pss,virtaul_size * 1024 AS size,reside,A.path_id AS path, - shared_clean * 1024 as shared_clean,shared_dirty * 1024 as shared_dirty,private_clean * 1024 as private_clean , - private_dirty * 1024 as private_dirty,swap * 1024 as swap,swap_pss * 1024 as swap_pss + shared_clean * 1024 as sharedClean,shared_dirty * 1024 as sharedDirty,private_clean * 1024 as privateClean, + private_dirty * 1024 as privateDirty,swap * 1024 as swap,swap_pss * 1024 as swapPss FROM smaps A, - trace_range AS t - WHERE (tsNS) <= $rightNs and (tsNs+$dur) >=$leftNs`, + trace_range AS t + WHERE (startNs) <= $rightNs and (startNs+$dur) >=$leftNs`, { $rightNs: rightNs, $leftNs: leftNs, $dur: dur }, 'exec' ); @@ -4652,6 +4623,7 @@ export const queryVmTrackerShmData = (iPid: number): Promise> => memory_ashmem A,trace_range B where A.ipid = ${iPid} + AND A.ts < B.end_ts and flag = 0 GROUP by A.ts`, @@ -4677,8 +4649,7 @@ export const queryVmTrackerShmSizeData = ( trace_range B WHERE startNS <= ${rightNs} and (startNS+ ${dur}) >=${leftNs} - AND ipid = ${iPid} - GROUP by flag`, + AND ipid = ${iPid}`, {} ); @@ -4697,21 +4668,19 @@ export const getTabSmapsRecordData = (rightNs: number): Promise> => query( 'getTabSmapsRecordData', ` - SELECT - (A.timestamp - t.start_ts) AS tsNS, - start_addr, - end_addr, - dirty * 1024 as dirty, + SELECT + (A.timestamp - t.start_ts) AS startNs, + start_addr as startAddr, + end_addr as endAddr, A.type, - swapper * 1024 as swapper, resident_size * 1024 AS rss, protection_id as pid, pss * 1024 as pss,virtaul_size * 1024 AS size,reside,A.path_id AS path, - shared_clean * 1024 as shared_clean,shared_dirty * 1024 as shared_dirty,private_clean * 1024 as private_clean , - private_dirty * 1024 as private_dirty,swap * 1024 as swap,swap_pss * 1024 as swap_pss + shared_clean * 1024 as sharedClean,shared_dirty * 1024 as sharedDirty,private_clean * 1024 as privateClean, + private_dirty * 1024 as privateDirty,swap * 1024 as swap,swap_pss * 1024 as swapPss FROM smaps A, - trace_range AS t - WHERE (tsNS) = $rightNs`, + trace_range AS t + WHERE (startNs) = $rightNs`, { $rightNs: rightNs }, 'exec' ); @@ -4749,8 +4718,9 @@ export const queryDmaAbilityData = (): Promise> => A.flag as flag FROM memory_dma A,trace_range B left join data_dict as E on E.id=A.exp_task_comm_id - WHERE + WHERE A.flag = 0 + AND A.ts < B.end_ts GROUP by A.ts;` ); @@ -4761,7 +4731,8 @@ export const queryGpuMemoryAbilityData = (): Promise> => `SELECT (A.ts - B.start_ts) as startNs, sum(A.used_gpu_size) as value - FROM memory_process_gpu A,trace_range B + FROM memory_process_gpu A,trace_range B + WHERE A.ts < B.end_ts GROUP by A.ts;` ); @@ -4779,8 +4750,8 @@ export const queryDmaSampsData = (process: number): Promise> => { trace_range tr LEFT JOIN sys_event_filter f ON f.id = m.filter_id WHERE - f.name IN ${names} + m.ts < tr.end_ts + AND f.name IN ${names} GROUP BY m.ts UNION ALL SELECT @@ -4855,7 +4828,8 @@ export const queryPurgeableProcessData = (ipid: number, isPin?: boolean): Promis trace_range tr LEFT JOIN process_measure_filter f ON f.id = m.filter_id WHERE - f.name = ${names} + m.ts < tr.end_ts + AND f.name = ${names} AND f.ipid = ${ipid} GROUP BY m.ts UNION ALL @@ -5039,23 +5013,20 @@ export const queryProcessPurgeableSelectionTab = ( export const getTabSmapsStatisticData = (rightNs: number): Promise> => query( 'getTabSmapsStatisticData', - ` - SELECT - (A.timestamp - t.start_ts) AS tsNS, - start_addr, - end_addr, - (dirty * 1021) as dirty, - (swapper *1024) as swapper, + `SELECT + (A.timestamp - t.start_ts) AS startNs, + start_addr as startAddr, + end_addr as endAddr, A.type, - sum(resident_size) * 1024 AS rss, + sum(resident_size) * 1024 AS rss, protection_id as pid, count(A.path_id) as count, sum(pss) * 1024 as pss ,sum(virtaul_size) * 1024 AS size,sum(reside) as reside,A.path_id AS path, - sum(shared_clean) * 1024 as shared_clean,sum(shared_dirty) * 1024 as shared_dirty,sum(private_clean) * 1024 as private_clean,sum(private_dirty) * 1024 as private_dirty, - sum(swap) * 1024 as swap,sum(swap_pss) * 1024 as swap_pss + sum(shared_clean) * 1024 as sharedClean,sum(shared_dirty) * 1024 as sharedDirty,sum(private_clean) * 1024 as privateClean,sum(private_dirty) * 1024 as privateDirty, + sum(swap) * 1024 as swap,sum(swap_pss) * 1024 as swapPss FROM smaps A, - trace_range AS t - WHERE (tsNS) =$rightNs + trace_range AS t + WHERE (startNs) =$rightNs group by type,path`, { $rightNs: rightNs }, 'exec' @@ -5064,23 +5035,20 @@ export const getTabSmapsStatisticData = (rightNs: number): Promise> export const getTabSmapsStatisticSelectData = (leftNs: number, rightNs: number, dur: number): Promise> => query( 'getTabSmapsStatisticData', - ` - SELECT - (A.timestamp - t.start_ts) AS tsNS, - start_addr, - end_addr, - (dirty * 1021) as dirty, - (swapper *1024) as swapper, + `SELECT + (A.timestamp - t.start_ts) AS startNs, + start_addr as startAddr, + end_addr as endAddr, A.type, - sum(resident_size) * 1024 AS rss, + sum(resident_size) * 1024 AS rss, protection_id as pid, count(A.path_id) as count, sum(pss) * 1024 as pss ,sum(virtaul_size) * 1024 AS size,sum(reside) as reside,A.path_id AS path, - sum(shared_clean) * 1024 as shared_clean,sum(shared_dirty) * 1024 as shared_dirty,sum(private_clean) * 1024 as private_clean,sum(private_dirty) * 1024 as private_dirty, - sum(swap) * 1024 as swap,sum(swap_pss) * 1024 as swap_pss + sum(shared_clean) * 1024 as sharedClean,sum(shared_dirty) * 1024 as sharedDirty,sum(private_clean) * 1024 as privateClean,sum(private_dirty) * 1024 as privateDirty, + sum(swap) * 1024 as swap,sum(swap_pss) * 1024 as swapPss FROM smaps A, - trace_range AS t - WHERE (tsNS) <=$rightNs and (tsNS+$dur)>=$leftNs + trace_range AS t + WHERE (startNs) <=$rightNs and (startNs+$dur)>=$leftNs group by type,path`, { $rightNs: rightNs, $leftNs: leftNs, $dur: dur }, 'exec' @@ -5110,16 +5078,14 @@ export const getTabDmaAbilityData = (leftNs: number, rightNs: number, dur: numbe export const getTabGpuMemoryAbilityData = (leftNs: number, rightNs: number, dur: number): Promise> => query( 'getTabGpuMemoryAbilityData', - `SELECT - (S.ts-TR.start_ts) as startNs, - A.data as gpuName, + `SELECT (S.ts-TR.start_ts) as startNs, + gpu_name_id as gpuNameId, MAX(S.used_gpu_size) as maxSize, MIN(S.used_gpu_size) as minSize, Avg(S.used_gpu_size) as avgSize, E.pid as processId, E.name as processName from trace_range as TR,memory_process_gpu as S - left join data_dict as A on A.id=S.gpu_name_id left join process as E on E.ipid=S.ipid WHERE $leftNS <= startNs + ${dur} @@ -5165,14 +5131,13 @@ export const getTabGpuMemoryData = ( 'getTabGpuMemoryData', `SELECT (S.ts-TR.start_ts) as startNs, - A.data as gpuName, + gpu_name_id as gpuNameId, T.tid as threadId, T.name as threadName, MAX(S.used_gpu_size) as maxSize, MIN(S.used_gpu_size) as minSize, Avg(S.used_gpu_size) as avgSize from trace_range as TR,memory_process_gpu as S - left join data_dict as A on A.id=S.gpu_name_id left join thread as T on T.itid=S.itid where $leftNS <= startNs + ${dur} @@ -5180,6 +5145,7 @@ export const getTabGpuMemoryData = ( $rightNS >= startNs and $pid = S.ipid + group by gpu_name_id,threadId `, { $leftNS: leftNs, $rightNS: rightNs, $pid: processId } ); @@ -5270,3 +5236,81 @@ export const getTabGpuMemoryVMTrackerClickData = (startNs: number, processId: nu `, { $startNs: startNs, $pid: processId } ); + +//Ability Monitor Dma 点选比较 +export const getTabDmaAbilityComparisonData = (startNs: number): Promise> => + query( + 'getTabDmaAbilityComparisonData', + `SELECT + (S.ts-TR.start_ts) as startNs, + sum(S.size) as value, + E.pid as processId, + E.name as processName + from trace_range as TR,memory_dma as S + left join process as E on E.ipid=S.ipid + WHERE + startNs = ${startNs} + GROUP by + E.pid + `, + { $startNs: startNs } + ); + +//Ability Monitor Gpu Memory 点选比较 +export const getTabGpuMemoryComparisonData = (startNs: number): Promise> => + query( + 'getTabGpuMemoryComparisonData', + `SELECT + (S.ts-TR.start_ts) as startNs, + sum(S.used_gpu_size) as value, + E.pid as processId, + S.gpu_name_id as gpuNameId, + E.name as processName + from trace_range as TR,memory_process_gpu as S + left join process as E on E.ipid=S.ipid + WHERE + startNs = ${startNs} + GROUP by + E.pid, S.gpu_name_id + `, + { $startNs: startNs } + ); + +//VM Tracker Dma 点选比较 +export const getTabDmaVmTrackerComparisonData = (startNs: number, processId: number): Promise> => + query( + 'getTabDmaVmTrackerComparisonData', + `SELECT + (S.ts-TR.start_ts) as startNs, + sum(S.size) as value + from trace_range as TR,memory_dma as S + WHERE + startNs = ${startNs} + AND + $pid = S.ipid + `, + { $startNs: startNs, $pid: processId } + ); + +//VM Tracker Gpu Memory 点选比较 +export const getTabGpuMemoryVmTrackerComparisonData = ( + startNs: number, + processId: number +): Promise> => + query( + 'getTabGpuMemoryVmTrackerComparisonData', + `SELECT + (S.ts-TR.start_ts) as startNs, + sum(S.used_gpu_size) as value, + T.tid as threadId, + T.name as threadName, + S.gpu_name_id as gpuNameId + from trace_range as TR,memory_process_gpu as S + left join thread as T on T.itid=S.itid + WHERE + startNs = ${startNs} + AND + $pid = S.ipid + `, + { $startNs: startNs, $pid: processId } + ); diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts index 53d2a7f02095637f1ce61969dc8f0eaeb6e9b24f..1b6af208a331e027d86c362f570e7c1003286700 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts @@ -309,9 +309,9 @@ let pagination = (page: number, pageSize: number, source: Array): any[] => }; const PAGE_SIZE: number = 50_0000; -export let postMessage = (id: any, action: string, results: Array): void => { - if (results.length > PAGE_SIZE) { - let pageCount = Math.ceil(results.length / PAGE_SIZE); +export let postMessage = (id: any, action: string, results: Array, pageSize: number = PAGE_SIZE): void => { + if (results.length > pageSize) { + let pageCount = Math.ceil(results.length / pageSize); for (let i = 1 ; i <= pageCount ; i++) { let tag = 'start'; if (i == 1) { diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts index 2ea8b17947120488538c5193aabef35a4cdc56d4..4e3536455388750b85ab7f87eb2c265bf2db94e6 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts @@ -15,9 +15,7 @@ import { convertJSON, DataCache, - formatRealDateMs, getByteWithUnit, - getTimeString, HeapTreeDataBean, LogicHandler, MerageBean, @@ -25,6 +23,7 @@ import { postMessage, setFileName, } from './ProcedureLogicWorkerCommon.js'; + export class ProcedureLogicWorkerNativeMemory extends LogicHandler { selectTotalSize = 0; selectTotalCount = 0; @@ -44,7 +43,11 @@ export class ProcedureLogicWorkerNativeMemory extends LogicHandler { totalNS: number = 0; isAnalysis: boolean = false; isStatistic: boolean = false; + boxRangeNativeHook: Array = []; + clearBoxSelectionData: boolean = false; + nativeMemoryArgs?: Map private dataCache = DataCache.getInstance(); + handle(data: any): void { this.currentEventId = data.id; if (data && data.type) { @@ -142,9 +145,36 @@ export class ProcedureLogicWorkerNativeMemory extends LogicHandler { } } break; + case 'native-memory-queryNativeHookEvent': + if (data.params) { + if (data.params.list) { + this.boxRangeNativeHook = convertJSON(data.params.list); + if (this.nativeMemoryArgs?.get('refresh')) { + this.clearBoxSelectionData = this.boxRangeNativeHook.length > 100_0000; + } + this.supplementNativeHoodData(); + postMessage(data.id, data.action, this.resolvingActionNativeMemory(this.nativeMemoryArgs!), 100_0000); + if (this.clearBoxSelectionData) { + this.boxRangeNativeHook = []; + } + } else if (data.params.get('refresh') || this.boxRangeNativeHook.length === 0) { + this.nativeMemoryArgs = data.params; + let leftNs = data.params.get('leftNs'); + let rightNs = data.params.get('rightNs'); + let types = data.params.get('types'); + this.boxRangeNativeHook = []; + this.queryNativeHookEvent(leftNs, rightNs, types); + } else { + this.nativeMemoryArgs = data.params; + postMessage(data.id, data.action, this.resolvingActionNativeMemory(this.nativeMemoryArgs!), 100_0000); + if (this.clearBoxSelectionData) { + this.boxRangeNativeHook = []; + } + } + } + break; case 'native-memory-action': if (data.params) { - // @ts-ignore self.postMessage({ id: data.id, action: data.action, @@ -223,8 +253,9 @@ export class ProcedureLogicWorkerNativeMemory extends LogicHandler { {} ); } + queryNativeHookStatistic(type: number) { - let condition = ''; + let condition: string; if (type === 0) { condition = 'and type = 0'; } else if (type === 1) { @@ -245,6 +276,89 @@ where ts between start_ts and end_ts ${condition}; this.queryData(this.currentEventId, 'native-memory-queryNativeHookStatistic', sql, {}); } + queryNativeHookEvent(leftNs: number, rightNs: number, types: Array) { + let condition = types.length === 1 ? `and A.event_type = ${types[0]}` : `and (A.event_type = 'AllocEvent' or A.event_type = 'MmapEvent')`; + let libId = this.nativeMemoryArgs?.get('filterResponseType'); + let allocType = this.nativeMemoryArgs?.get('filterAllocType'); + let eventType = this.nativeMemoryArgs?.get('filterEventType'); + if (libId !== undefined && libId !== -1) { + condition = `${condition} and last_lib_id = ${libId}`;// filter lib + } + if (eventType === '1') { + condition = `${condition} and event_type = 'AllocEvent'`; + } + if (eventType === '2') { + condition = `${condition} and event_type = 'MmapEvent'`; + } + if (allocType === '1') { + condition = `${condition} and ((A.end_ts - B.start_ts) > ${rightNs} or A.end_ts is null)`; + } + if (allocType === '2') { + condition = `${condition} and (A.end_ts - B.start_ts) <= ${rightNs}`; + } + let sql = ` + select + callchain_id as eventId, + event_type as eventType, + heap_size as heapSize, + ('0x' || addr) as addr, + (A.start_ts - B.start_ts) as startTs, + (A.end_ts - B.start_ts) as endTs, + tid as threadId, + sub_type_id as subTypeId, + ifnull(last_lib_id,0) as lastLibId + from + native_hook A, + trace_range B + left join + thread t + on + A.itid = t.id + where + A.start_ts - B.start_ts between ${leftNs} and ${rightNs} ${condition} + `; + this.queryData(this.currentEventId, 'native-memory-queryNativeHookEvent', sql, {}); + } + + supplementNativeHoodData() { + let len = this.boxRangeNativeHook.length; + for(let i = 0, j = len -1; i <= j; i++, j--){ + this.fillNativeHook(this.boxRangeNativeHook[i], i); + if (i !== j) { + this.fillNativeHook(this.boxRangeNativeHook[j], j); + } + } + } + + fillNativeHook(memory: NativeMemory, index: number) { + if (memory.subTypeId !== null && memory.subType === undefined) { + memory.subType = this.dataCache.dataDict.get(memory.subTypeId) || '-'; + } + memory.index = index; + let arr = this.dataCache.nmHeapFrameMap.get(memory.eventId) || []; + let frame = Array.from(arr) + .reverse() + .find((item) => { + let fileName = this.dataCache.dataDict.get(item.fileId); + return !((fileName ?? '').includes('libc++') || (fileName ?? '').includes('musl')); + }); + if (frame === null || frame === undefined) { + if (arr.length > 0) { + frame = arr[0]; + } + } + if (frame !== null && frame !== undefined) { + memory.symbol = this.groupCutFilePath(frame.symbolId, this.dataCache.dataDict.get(frame.symbolId) || ''); + memory.library = this.groupCutFilePath( + frame.fileId, + this.dataCache.dataDict.get(frame.fileId) || 'Unknown Path' + ); + } else { + memory.symbol = '-'; + memory.library = '-'; + } + } + statisticDataHandler(arr: Array) { let callGroupMap: Map = new Map(); let obj = {}; @@ -367,12 +481,17 @@ where ts between start_ts and end_ts ${condition}; } resolvingAction(paramMap: Map): Array { let actionType = paramMap.get('actionType'); - if (actionType == 'call-info') { - return this.resolvingActionCallInfo(paramMap); - } else if (actionType == 'native-memory') { - return this.resolvingActionNativeMemory(paramMap); - } else if (actionType == 'memory-stack') { + if (actionType === 'memory-stack') { return this.resolvingActionNativeMemoryStack(paramMap); + } else if (actionType === 'native-memory-state-change') { + let startTs = paramMap.get('startTs'); + let currentSelection = this.boxRangeNativeHook.filter((item) => { + return item.startTs === startTs; + }); + if (currentSelection.length > 0) { + currentSelection[0].isSelected = true; + } + return []; } else { return []; } @@ -492,119 +611,78 @@ where ts between start_ts and end_ts ${condition}; }); return arr; } + resolvingActionNativeMemory(paramMap: Map): Array { - let dataSource = paramMap.get('data') as Array; let filterAllocType = paramMap.get('filterAllocType'); let filterEventType = paramMap.get('filterEventType'); let filterResponseType = paramMap.get('filterResponseType'); let leftNs = paramMap.get('leftNs'); let rightNs = paramMap.get('rightNs'); + let sortColumn = paramMap.get('sortColumn'); + let sortType = paramMap.get('sortType'); let statisticsSelection = paramMap.get('statisticsSelection'); - let filter = dataSource.filter((item) => { - if (item.subTypeId != null && item.subType == undefined) { - item.subType = this.dataCache.dataDict.get(item.subTypeId) || '-'; - } - let filterAllocation = true; - if (filterAllocType == '1') { - filterAllocation = - item.startTs >= leftNs && - item.startTs <= rightNs && - (item.endTs > rightNs || item.endTs == 0 || item.endTs == null); - } else if (filterAllocType == '2') { - filterAllocation = - item.startTs >= leftNs && - item.startTs <= rightNs && + let filter = this.boxRangeNativeHook; + if ((filterAllocType !== undefined && filterAllocType !== 0) || + (filterEventType !== undefined && filterEventType !== 0) || + (filterResponseType !== undefined && filterResponseType !== -1) + ) { + filter = this.boxRangeNativeHook.filter((item) => { + let filterAllocation = true; + let freed = item.endTs > leftNs && item.endTs <= rightNs && - item.endTs != 0 && - item.endTs != null; - } - let filterNative = this.getTypeFromIndex(parseInt(filterEventType), item, statisticsSelection); - let filterLastLib = filterResponseType == -1 ? true : filterResponseType == item.lastLibId; - return filterAllocation && filterNative && filterLastLib; - }); - let data: Array = []; - for (let i = 0, len = filter.length; i < len; i++) { - let hook = filter[i]; - let memory = new NativeMemory(); - memory.index = i; - memory.eventId = hook.eventId; - memory.eventType = hook.eventType; - memory.subType = hook.subType; - memory.heapSize = hook.heapSize; - memory.endTs = hook.endTs; - memory.heapSizeUnit = getByteWithUnit(hook.heapSize); - memory.addr = '0x' + hook.addr; - memory.startTs = hook.startTs; - memory.timestamp = - this.realTimeDif == 0 ? getTimeString(hook.startTs) : formatRealDateMs(hook.startTs + this.realTimeDif); - memory.state = hook.endTs > leftNs && hook.endTs <= rightNs ? 'Freed' : 'Existing'; - memory.threadId = hook.tid; - memory.threadName = hook.threadName; - memory.lastLibId = hook.lastLibId; - (memory as any).isSelected = hook.isSelected; - let arr = this.dataCache.nmHeapFrameMap.get(hook.eventId) || []; - let frame = Array.from(arr) - .reverse() - .find((item) => { - let fileName = this.dataCache.dataDict.get(item.fileId); - return !((fileName ?? '').includes('libc++') || (fileName ?? '').includes('musl')); - }); - if (frame == null || frame == undefined) { - if (arr.length > 0) { - frame = arr[0]; + item.endTs !== 0 && + item.endTs !== null; + if (filterAllocType === '1') { + filterAllocation = !freed; + } else if (filterAllocType == '2') { + filterAllocation = freed; } - } - if (frame != null && frame != undefined) { - memory.symbol = this.groupCutFilePath(frame.symbolId, this.dataCache.dataDict.get(frame.symbolId) || ''); - memory.library = this.groupCutFilePath( - frame.fileId, - this.dataCache.dataDict.get(frame.fileId) || 'Unknown Path' - ); - } else { - memory.symbol = '-'; - memory.library = '-'; - } - data.push(memory); + let filterNative = this.getTypeFromIndex(parseInt(filterEventType), item, statisticsSelection); + let filterLastLib = filterResponseType == -1 ? true : filterResponseType == item.lastLibId; + return filterAllocation && filterNative && filterLastLib; + }); + } + if (sortColumn !== undefined && sortType !== undefined && sortColumn !== '' && sortType !== 0) { + return this.sortByNativeMemoryColumn(sortColumn, sortType, filter); + } else { + return filter; } - return data; } - resolvingActionCallInfo(paramMap: Map): Array { - let dataSource = paramMap.get('data') as Array; - let filterAllocType = paramMap.get('filterAllocType'); - let filterEventType = paramMap.get('filterEventType'); - let leftNs = paramMap.get('leftNs'); - let rightNs = paramMap.get('rightNs'); - let filter: Array = []; - dataSource.map((item) => { - let filterAllocation = true; - let filterNative = true; - if (filterAllocType == '1') { - filterAllocation = - item.startTs >= leftNs && - item.startTs <= rightNs && - (item.endTs > rightNs || item.endTs == 0 || item.endTs == null); - } else if (filterAllocType == '2') { - filterAllocation = - item.startTs >= leftNs && - item.startTs <= rightNs && - item.endTs <= rightNs && - item.endTs != 0 && - item.endTs != null; - } - if (filterEventType == '1') { - filterNative = item.eventType == 'AllocEvent'; - } else if (filterEventType == '2') { - filterNative = item.eventType == 'MmapEvent'; - } - if (filterAllocation && filterNative) { - filter.push(item); - } - }); - this.freshCurrentCallchains(filter, true); - return this.allThreads; + + sortByNativeMemoryColumn(nmMemoryColumn: string, nmMemorySort: number, list: Array) { + if (nmMemorySort === 0) { + return list; + } else { + return list.sort((memoryLeftData: any, memoryRightData: any) => { + if (nmMemoryColumn === 'index' || nmMemoryColumn === 'startTs' || nmMemoryColumn === 'heapSize') { + return nmMemorySort == 1 + ? memoryLeftData[nmMemoryColumn] - memoryRightData[nmMemoryColumn] + : memoryRightData[nmMemoryColumn] - memoryLeftData[nmMemoryColumn]; + } else { + if (nmMemorySort == 1) { + if (memoryLeftData[nmMemoryColumn] > memoryRightData[nmMemoryColumn]) { + return 1; + } else if (memoryLeftData[nmMemoryColumn] === memoryRightData[nmMemoryColumn]) { + return 0; + } else { + return -1; + } + } else { + if (memoryRightData[nmMemoryColumn] > memoryLeftData[nmMemoryColumn]) { + return 1; + } else if (memoryLeftData[nmMemoryColumn] == memoryRightData[nmMemoryColumn]) { + return 0; + } else { + return -1; + } + } + } + }); + } } + groupCutFilePath(fileId: number, path: string): string { - let name = ''; + let name: string; if (this.dataCache.nmFileDict.has(fileId)) { name = this.dataCache.nmFileDict.get(fileId) ?? ''; } else { @@ -614,32 +692,7 @@ where ts between start_ts and end_ts ${condition}; } return name == '' ? '-' : name; } - mergeTree(target: NativeHookCallInfo, src: NativeHookCallInfo) { - let len = src.children.length; - src.size += target.size; - src.heapSizeStr = `${getByteWithUnit(src!.size)}`; - src.heapPercent = `${((src!.size / this.selectTotalSize) * 100).toFixed(1)}%`; - if (len == 0) { - src.children.push(target); - } else { - let index = src.children.findIndex((hook) => hook.symbol == target.symbol && hook.depth == target.depth); - if (index != -1) { - let srcChild = src.children[index]; - srcChild.count += target.count; - srcChild!.countValue = `${srcChild.count}`; - srcChild!.countPercent = `${((srcChild!.count / this.selectTotalCount) * 100).toFixed(1)}%`; - if (target.children.length > 0) { - this.mergeTree(target.children[0], srcChild); - } else { - srcChild.size += target.size; - srcChild.heapSizeStr = `${getByteWithUnit(src!.size)}`; - srcChild.heapPercent = `${((srcChild!.size / this.selectTotalSize) * 100).toFixed(1)}%`; - } - } else { - src.children.push(target); - } - } - } + traverseSampleTree(stack: NativeHookCallInfo, hook: NativeHookStatistics) { stack.count += 1; stack.countValue = `${stack.count}`; @@ -672,7 +725,7 @@ where ts between start_ts and end_ts ${condition}; } getTypeFromIndex( indexOf: number, - item: NativeHookStatistics, + item: NativeHookStatistics | NativeMemory, statisticsSelection: Array ): boolean { if (indexOf == -1) { @@ -715,6 +768,8 @@ where ts between start_ts and end_ts ${condition}; this.currentTreeMapData = {}; this.currentTreeList.length = 0; this.responseTypes.length = 0; + this.boxRangeNativeHook = []; + this.nativeMemoryArgs?.clear(); } queryCallchainsSamples(action: string, leftNs: number, rightNs: number, types: Array) { @@ -1133,14 +1188,18 @@ where ts between start_ts and end_ts ${condition}; }); } getFilterLevel(len: number): number { - if (len > 100_0000) { + if (len > 300_0000) { + return 50_0000; + } else if (len > 200_0000) { + return 30_0000; + } else if (len > 100_0000) { return 10_0000; } else if (len > 50_0000) { return 5_0000; } else if (len > 30_0000) { return 2_0000; } else if (len > 15_0000) { - return 5000; + return 1_0000; } else { return 0; } @@ -1226,20 +1285,18 @@ export class NativeMemory { eventId: number = 0; eventType: string = ''; subType: string = ''; + subTypeId: number = 0; addr: string = ''; startTs: number = 0; endTs: number = 0; - timestamp: string = ''; heapSize: number = 0; - heapSizeUnit: string = ''; symbol: string = ''; library: string = ''; lastLibId: number = 0; isSelected: boolean = false; - state: string = ''; threadId: number = 0; - threadName: string = ''; } + export class HeapStruct { startTime: number | undefined; endTime: number | undefined; diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts index 054c6f57e777f383729d092003ee44d3134334c8..b2d02724c764165f46d8c7ec2081a30c7edfa37d 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts @@ -186,11 +186,11 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { 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, @@ -209,7 +209,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { where timestamp_trace between $startTime + t.start_ts and $endTime + t.start_ts and callchain_id != -1 - and s.thread_id != 0 ${ sql } + and s.thread_id != 0 ${sql} group by callchain_id, s.thread_id, thread_state, process_id) p`, { $startTime: selectionParam.leftNs, @@ -288,7 +288,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { threadCallChain.depth = 0; PerfCallChain.merageCallChain(threadCallChain, callChain); threadCallChain.canCharge = false; - threadCallChain.name = this.threadData[callChain.tid].threadName || 'Thread' + '(' + callChain.tid + ')'; + threadCallChain.name = (this.threadData[callChain.tid].threadName || 'Thread') + '(' + callChain.tid + ')'; let threadStateCallChain = new PerfCallChain(); //新增的线程状态数据 PerfCallChain.merageCallChain(threadStateCallChain, callChain); threadStateCallChain.name = callChain.threadState || 'Unknown State'; @@ -322,11 +322,11 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { let threadCallChain = new PerfCallChain(); //新增的线程数据 threadCallChain.tid = countSample.tid; threadCallChain.canCharge = false; - threadCallChain.name = this.threadData[countSample.tid].threadName || 'Thead' + '(' + countSample.tid + ')'; + threadCallChain.name = this.threadData[countSample.tid].threadName || 'Thread' + '(' + countSample.tid + ')'; let threadStateCallChain = new PerfCallChain(); //新增的线程状态数据 threadStateCallChain.tid = countSample.tid; - threadStateCallChain.name = countSample.threadState || 'Unkown State'; - threadStateCallChain.fileName = threadStateCallChain.name == '-' ? 'Unkown Thead State' : ''; + threadStateCallChain.name = countSample.threadState || 'Unknown State'; + threadStateCallChain.fileName = threadStateCallChain.name == '-' ? 'Unknown Thread State' : ''; threadStateCallChain.canCharge = false; list.unshift(threadCallChain, threadStateCallChain); } @@ -359,7 +359,8 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { 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); @@ -429,7 +430,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { 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; @@ -450,7 +451,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { 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); @@ -552,7 +553,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { 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); @@ -760,7 +761,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { for (let sample of this.samplesData) { let callChains = [...this.callChainData[sample.sampleId]]; const lastCallChain = callChains[callChains.length - 1]; - const threadName = this.threadData[sample.tid].threadName || 'Thead'; + const threadName = this.threadData[sample.tid].threadName || 'Thread'; const processName = this.threadData[sample.pid].threadName || 'Process'; let analysisSample = new PerfAnalysisSample( threadName, @@ -789,12 +790,14 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { for (let sample of this.samplesData) { let currentNode = topUp; let callChains = this.callChainData[sample.sampleId]; - for (let i = 0 ; i < callChains.length ; i++) { + 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 + ')'); + const existingNode = currentNode.children.find( + (child) => child.symbolName === item.name + '(' + item.fileName + ')' + ); if (existingNode) { currentNode = existingNode; existingNode.totalTime += perfTime * sample.count; @@ -810,7 +813,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { } } } - topUp.children.forEach(child => { + topUp.children.forEach((child) => { child.parentNode = undefined; }); @@ -825,9 +828,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { let reverseTreeArray: Array = []; const recursionTree = (perfBottomUpStruct: PerfBottomUpStruct) => { if (perfBottomUpStruct.selfTime > 0) { - const clonePerfBottomUpStruct = new PerfBottomUpStruct( - perfBottomUpStruct.symbolName, - ); + const clonePerfBottomUpStruct = new PerfBottomUpStruct(perfBottomUpStruct.symbolName); clonePerfBottomUpStruct.selfTime = perfBottomUpStruct.selfTime; clonePerfBottomUpStruct.totalTime = perfBottomUpStruct.totalTime; reverseTreeArray.push(clonePerfBottomUpStruct); @@ -885,16 +886,13 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { } } - /** * 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, - ); + const copyParent = new PerfBottomUpStruct(bottomUpStruct.parentNode.symbolName); copyParent.selfTime = perfBottomUpStruct.selfTime; copyParent.totalTime = perfBottomUpStruct.totalTime; perfBottomUpStruct.addChildren(copyParent); @@ -1022,8 +1020,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() { @@ -1032,13 +1030,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) { @@ -1060,14 +1058,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; @@ -1103,7 +1101,6 @@ export class PerfCmdLine { report_value: string = ''; } - class PerfAnalysisSample extends PerfCountSample { threadName: string; processName: string; diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts index 279f577c898599b6a30f8a52d3b7380cb303ec67..8b98a4c7bd0a3618f43b35ff41952fa76373222d 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts @@ -550,7 +550,18 @@ where cpu not null if (map.has(ca.cpu)) { map.get(ca.cpu)!.push(ca); } else { - map.set(ca.cpu, [ca]); + let cpuArr: CpuMeasure[] = []; + if (ca.ts > 0) { + cpuArr.push({ + cpu: ca.cpu, + value: -1, + block: '', + ts: 0, + dur: ca.ts, + }) + } + cpuArr.push(ca) + map.set(ca.cpu, cpuArr); } } } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts index da140ed41fbb3dfce56caaf48bfdc5a7435bff0b..c1fab11770a3bd658e32fff4ea199cd809464ba5 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts @@ -317,7 +317,7 @@ export class FrameSpacingStruct extends BaseStruct { let pointY = rowFrame.height - Math.floor((dashedLines[index] - minValue) * (rowFrame.height - padding * multiple) / (maxValue - minValue)) - padding; let lineDash = 10; - let textPadding = 5; + let textPadding = 4; ctx.beginPath(); ctx.lineWidth = 2; ctx.setLineDash([lineDash]); @@ -326,9 +326,15 @@ export class FrameSpacingStruct extends BaseStruct { ctx.moveTo(0, pointY); ctx.lineTo(rowFrame.width, pointY); ctx.stroke(); - ctx.strokeStyle = ColorUtils.ANIMATION_COLOR[8]; - ctx.fillStyle = ColorUtils.ANIMATION_COLOR[8]; - ctx.fillText(dashedLines[index].toString(), 0, pointY - textPadding); + ctx.strokeStyle = ColorUtils.ANIMATION_COLOR[3]; + ctx.fillStyle = ColorUtils.ANIMATION_COLOR[3]; + if (index === 0) { + ctx.fillText(dashedLines[index].toString(), 0, pointY + multiple * textPadding); + } else if (index === unitIndex) { + ctx.fillText(dashedLines[index].toString(), 0, pointY + textPadding); + } else { + ctx.fillText(dashedLines[index].toString(), 0, pointY - textPadding); + } ctx.closePath(); } diff --git a/ide/test/base-ui/tabs/LitTabs.test.ts b/ide/test/base-ui/tabs/LitTabs.test.ts index 51833e58ad1fac64136fc9a9d3538bc151aad5a3..92f70f5649476c324d4ae4d1f8b7c39a04e82aa2 100644 --- a/ide/test/base-ui/tabs/LitTabs.test.ts +++ b/ide/test/base-ui/tabs/LitTabs.test.ts @@ -144,6 +144,7 @@ describe('LitSwitch Test', () => { width:100%; height:100%; flex-shrink:0; + overflow: auto; } .nav-item{ display: inline-flex; diff --git a/ide/test/base-ui/tree/LitTreeNode.test.ts b/ide/test/base-ui/tree/LitTreeNode.test.ts index 908353993fc6ed945e7628efb4855394536a0bf6..96407d0f9f2b2c66947fb434b056063b32562105 100644 --- a/ide/test/base-ui/tree/LitTreeNode.test.ts +++ b/ide/test/base-ui/tree/LitTreeNode.test.ts @@ -15,6 +15,9 @@ // @ts-ignore import { LitTreeNode } from '../../../dist/base-ui/tree/LitTreeNode.js'; +jest.mock('../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); describe('LitTreeNode Test', () => { let litTreeNode = new LitTreeNode(); @@ -83,4 +86,7 @@ describe('LitTreeNode Test', () => { it('LitTreeNodeTest16', () => { expect(litTreeNode.drawLine('bottom-right')).toBeUndefined(); }); + it('LitTreeNodeTest17', () => { + expect(litTreeNode.collapse()).toBeUndefined(); + }); }); \ No newline at end of file diff --git a/ide/test/trace/component/chart/FrameChart.test.ts b/ide/test/trace/component/chart/FrameChart.test.ts index 8bef681405798c5ff371813b2bdeba83b5fceb8f..174394b860377a3db6efdbd3b674448a70e72c85 100644 --- a/ide/test/trace/component/chart/FrameChart.test.ts +++ b/ide/test/trace/component/chart/FrameChart.test.ts @@ -17,6 +17,8 @@ import { FrameChart } from '../../../../dist/trace/component/chart/FrameChart.js'; // @ts-ignore import {TraceRow} from '../../../../dist/trace/component/trace/base/TraceRow.js'; +// @ts-ignore +import {ChartMode} from "../../../../dist/trace/bean/FrameChartStruct.js"; jest.mock('../../../../dist/trace/component/SpSystemTrace.js', () => { return {}; @@ -269,4 +271,22 @@ describe('FrameChart Test', () => { it('FrameChartTest41', function () { expect(frameChart.drawDataSet(node, true)).toBeUndefined(); }); + it('FrameChartTest42', function () { + let frameChart = new FrameChart(); + frameChart._mode = ChartMode.Byte; + frameChart.drawScale = jest.fn(() => true); + expect(frameChart.calculateChartData()).not.toBeUndefined(); + }); + it('FrameChartTest44', function () { + let frameChart = new FrameChart(); + frameChart._mode = ChartMode.Count; + frameChart.drawScale = jest.fn(() => true); + expect(frameChart.calculateChartData()).not.toBeUndefined(); + }); + it('FrameChartTest45', function () { + let frameChart = new FrameChart(); + frameChart._mode = ChartMode.Duration; + frameChart.drawScale = jest.fn(() => true); + expect(frameChart.calculateChartData()).not.toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/chart/SpFileSystemChart.test.ts b/ide/test/trace/component/chart/SpFileSystemChart.test.ts index 2ef9afb517236a549fa36a8fcc91229a14dcb5a0..dc537cba5d1aec5ab5229be8609d6ee01fa4bea7 100644 --- a/ide/test/trace/component/chart/SpFileSystemChart.test.ts +++ b/ide/test/trace/component/chart/SpFileSystemChart.test.ts @@ -34,7 +34,7 @@ describe('SpFileSystemChart Test', () => { { fsCount: 2, vmCount: 2, - ioCount: 0, + ioCount: 2, }, ]); diff --git a/ide/test/trace/component/trace/base/TraceRow.test.ts b/ide/test/trace/component/trace/base/TraceRow.test.ts index 2c7f2e02353c4808b3ff69097f64a916ac2e5a25..b21af3725724675e84adeb173826fd839e4b8e21 100644 --- a/ide/test/trace/component/trace/base/TraceRow.test.ts +++ b/ide/test/trace/component/trace/base/TraceRow.test.ts @@ -942,4 +942,13 @@ describe('TraceRow Test', () => { }); expect(traceRow.getTransferArray()).toStrictEqual([undefined]); }); + it('TraceRow Test67', () => { + let traceRow = new TraceRow({ + canvasNumber: 1, + alpha: true, + contextId: '2d', + isOffScreen: true, + }); + expect(traceRow.clearMemory()).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/base/TraceSheet.test.ts b/ide/test/trace/component/trace/base/TraceSheet.test.ts index 2860f272d744028e4fad027f18f97b2fef67a68d..85113922531cab710125a72a2c0c5a8256579792 100644 --- a/ide/test/trace/component/trace/base/TraceSheet.test.ts +++ b/ide/test/trace/component/trace/base/TraceSheet.test.ts @@ -126,4 +126,8 @@ describe('TraceSheet Test', () => {
" `); }); + it('TraceSheet Test10', () => { + let traceSheet = new TraceSheet(); + expect(traceSheet.updateRangeSelect()).toBeFalsy(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts index d224ddad10c8dd6c82de00312a0a58ba3a63467d..2f86489ebd228871361ee9f242e2c102165668f1 100644 --- a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts @@ -350,9 +350,6 @@ describe('TabPaneCurrentSelection Test', () => { expect(tabPaneCurrentSelection.transferString(str)).toBe(''); }); - it('TabPaneCurrentSelectionTest15', function () { - expect(tabPaneCurrentSelection.transferString('&')).not.toBeUndefined(); - }); it('TabPaneCurrentSelectionTest16', function () { expect(tabPaneCurrentSelection.drawRight(null)).toBeUndefined(); @@ -419,9 +416,6 @@ describe('TabPaneCurrentSelection Test', () => { expect(tabPaneCurrentSelection.transferString(str)).toBe(''); }); - it('TabPaneCurrentSelectionTest15', function () { - expect(tabPaneCurrentSelection.transferString('&')).not.toBeUndefined(); - }); it('TabPaneCurrentSelectionTest16', function () { expect(tabPaneCurrentSelection.drawRight(null)).toBeUndefined(); @@ -530,10 +524,6 @@ describe('TabPaneCurrentSelection Test', () => { expect(result).toBeUndefined(); }); - it('TabPaneCurrentSelectionTest15', function () { - let result = tabPaneCurrentSelection.setThreadData(threadData, undefined, 1); - expect(result).toBeUndefined(); - }); it('TabPaneCurrentSelectionTest16', function () { let result = tabPaneCurrentSelection.setClockData(clockData); @@ -544,4 +534,21 @@ describe('TabPaneCurrentSelection Test', () => { let result = tabPaneCurrentSelection.setFunctionData(functionDataTest); expect(result).toBeUndefined(); }); + it('TabPaneCurrentSelectionTest18', function () { + let result = tabPaneCurrentSelection.setStartupData(irqData,1); + expect(result).toBeUndefined(); + }); + it('TabPaneCurrentSelectionTest19', function () { + let result = tabPaneCurrentSelection.setStaticInitData(irqData,1); + expect(result).toBeUndefined(); + }); + it('TabPaneCurrentSelectionTest20', function () { + let list: never[] = []; + let data =[{ + jank_tag:1, + frame_type:'render_service', + }] + let result = tabPaneCurrentSelection.setJankType(data,list); + expect(result).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..59ecd003f834c564870698a9fbaa26bb91a970f4 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts @@ -0,0 +1,77 @@ +/* + * 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 { TabPaneDmaAbilityComparison } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPaneDmaAbilityComparison Test', () => { + let tabPaneDmaComparisonAbility = new TabPaneDmaAbilityComparison(); + let getTabDmaAbilityComparisonData = sqlite.getTabDmaAbilityComparisonData; + let dmaSelectionData = [ + { + startNs: 0, + value:100, + processId:10, + processName:'a', + } + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPaneDmaComparisonAbility.init = jest.fn(() => true); + getTabDmaAbilityComparisonData.mockResolvedValue(dmaSelectionData); + it('TabPaneDmaSelectAbility01', function () { + expect(tabPaneDmaComparisonAbility.queryDataByDB(10)).toBeTruthy(); + }); + it('TabPaneDmaSelectAbility02', function () { + expect(tabPaneDmaComparisonAbility.getComparisonData(10)).toBeTruthy(); + }); + it('TabPaneDmaSelectAbility03', function () { + expect(tabPaneDmaComparisonAbility.comparisonDataByDB(10,datalist)).toBeTruthy(); + }); + it('TabPaneDmaSelectAbility04', function () { + expect(tabPaneDmaComparisonAbility.selectStamps(datalist)).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 95ad8ecf5ba56c6e02daa377ccaa32be51e85aea..3bf66fe67be0d1897958b31ec2fae0c59e14d5ab 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts @@ -21,6 +21,7 @@ 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(() => ({ diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b02a85804c728a317a85355649ea0118d97fbfab --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts @@ -0,0 +1,78 @@ +/* + * 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 { TabPaneGpuMemoryComparison } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPaneGpuMemoryComparison Test', () => { + let tabPaneGpuMemoryComparison = new TabPaneGpuMemoryComparison(); + let getTabGpuMemoryComparisonData = sqlite.getTabGpuMemoryComparisonData; + let gpuMemoryComparisonData = [ + { + startNs: 0, + value:100, + gpuNameId:10, + processId:2, + processName:'a', + } + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPaneGpuMemoryComparison.init = jest.fn(() => true); + getTabGpuMemoryComparisonData.mockResolvedValue(gpuMemoryComparisonData); + it('TabPaneGpuMemoryComparison01', function () { + expect(tabPaneGpuMemoryComparison.queryDataByDB(10)).toBeTruthy(); + }); + it('TabPaneGpuMemoryComparison02', function () { + expect(tabPaneGpuMemoryComparison.getComparisonData(10)).toBeTruthy(); + }); + it('TabPaneGpuMemoryComparison03', function () { + expect(tabPaneGpuMemoryComparison.comparisonDataByDB(10,datalist)).toBeTruthy(); + }); + it('TabPaneGpuMemoryComparison04', function () { + expect(tabPaneGpuMemoryComparison.selectStamps(datalist)).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 index 4452f3a3fc5089a36de742c6fad472fb6b0b8687..3b44d5ce82e2801c938f60e00f6a47c6c0cebf09 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts @@ -65,6 +65,7 @@ describe('TabPaneGpuMemorySelectAbility Test', () => { expect(tabPaneGpuMemorySelectAbility.sortGpuMemoryByColumn('size',1)).toBeUndefined(); }); it('TabPaneGpuMemorySelectAbility06', function () { - expect(tabPaneGpuMemorySelectAbility.queryDataByDB(val)).toBeUndefined(); + tabPaneGpuMemorySelectAbility.init = jest.fn(()=>true) + expect(tabPaneGpuMemorySelectAbility.queryGpuMemoryClickDataByDB(val)).toBeUndefined(); }); }) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8dcf812c53c114b94b87511b21ce525f6d3820a8 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts @@ -0,0 +1,90 @@ +/* + * 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 { TabPanePurgPinComparisonAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.js'; +import '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.js'; + +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPanePurgPinComparisonAbility Test', () => { + let tabPanePurgPinComparisonAbility = new TabPanePurgPinComparisonAbility(); + let querySysPurgeableSelectionTab = sqlite.querySysPurgeableSelectionTab; + querySysPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + ]); + let data = [ + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPanePurgPinComparisonAbility.init = jest.fn(() => true); + it('TabPanePurgPinComparisonAbility02', function () { + expect(tabPanePurgPinComparisonAbility.updateComparisonData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgPinComparisonAbility03', function () { + expect(tabPanePurgPinComparisonAbility.queryTableData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgPinComparisonAbility01', function () { + tabPanePurgPinComparisonAbility.initSelect = jest.fn(() => true); + expect(tabPanePurgPinComparisonAbility.totalData(data, datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb43489eb9f50704927e133374d68974b347f13c --- /dev/null +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts @@ -0,0 +1,88 @@ +/* + * 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 { TabPanePurgTotalComparisonAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPanePurgTotalComparisonAbility Test', () => { + let tabPanePurgTotalComparisonAbility = new TabPanePurgTotalComparisonAbility(); + let querySysPurgeableSelectionTab = sqlite.querySysPurgeableSelectionTab; + querySysPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + ]); + let data = [ + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPanePurgTotalComparisonAbility.init = jest.fn(() => true); + it('TabPanePurgTotalComparisonAbility01', function () { + expect(tabPanePurgTotalComparisonAbility.updateComparisonData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgTotalComparisonAbility02', function () { + expect(tabPanePurgTotalComparisonAbility.queryTableData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgTotalComparisonAbility03', function () { + tabPanePurgTotalComparisonAbility.initSelect = jest.fn(() => true); + expect(tabPanePurgTotalComparisonAbility.totalData(data, datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneCallTree.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneCallTree.test.ts index 2f0158149daa4902c8b56cceb1a9fbc64126cfb0..db6dab2eb122338827a0c1d1b19e1cf034ca8c4a 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneCallTree.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneCallTree.test.ts @@ -24,155 +24,155 @@ import { FrameChart } from '../../../../../../dist/trace/component/chart/FrameCh import '../../../../../../dist/trace/component/chart/FrameChart.js'; jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; + return {}; }); import crypto from 'crypto'; -import {showButtonMenu} from "../../../../../../src/trace/component/trace/sheet/SheetUtils.js"; +import { showButtonMenu } from '../../../../../../src/trace/component/trace/sheet/SheetUtils.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneCallTree Test', () => { - let data = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; - it('TabPaneCallTreeTest01', function () { - document.body.innerHTML = ``; - let calltree = document.querySelector('#calltree'); - let filter = new TabPaneFilter(); - calltree.callTreeFilter = filter; - let frameChart = new FrameChart(); - calltree.frameChart = frameChart; - calltree.callTreeFilter.getDataLibrary = jest.fn(() => true); - calltree.data = data; - expect(calltree.currentSelection).not.toBeUndefined(); - }); + let data = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; + it('TabPaneCallTreeTest01', function () { + document.body.innerHTML = ``; + let calltree = document.querySelector('#calltree'); + let filter = new TabPaneFilter(); + calltree.callTreeFilter = filter; + let frameChart = new FrameChart(); + calltree.frameChart = frameChart; + calltree.callTreeFilter.getDataLibrary = jest.fn(() => true); + calltree.data = data; + expect(calltree.currentSelection).not.toBeUndefined(); + }); - it('TabPaneCallTreeTest02', function () { - document.body.innerHTML = ``; - let calltree = document.querySelector('#calltree'); - let filter = new TabPaneFilter(); - calltree.callTreeFilter = filter; - let frameChart = new FrameChart(); - calltree.frameChart = frameChart; - calltree.callTreeFilter.getDataLibrary = jest.fn(() => true); - calltree.data = data; - let call = { - id: '1', - dur: 1, - children: [], - }; - expect(calltree.setRightTableData(call)).toBeUndefined(); - }); + it('TabPaneCallTreeTest02', function () { + document.body.innerHTML = ``; + let calltree = document.querySelector('#calltree'); + let filter = new TabPaneFilter(); + calltree.callTreeFilter = filter; + let frameChart = new FrameChart(); + calltree.frameChart = frameChart; + calltree.callTreeFilter.getDataLibrary = jest.fn(() => true); + calltree.data = data; + let call = { + id: '1', + dur: 1, + children: [], + }; + expect(calltree.setRightTableData(call)).toBeUndefined(); + }); - it('TabPaneCallTreeTest03', function () { - document.body.innerHTML = ``; - let calltree = document.querySelector('#calltree'); - let filter = new TabPaneFilter(); - calltree.callTreeFilter = filter; - calltree.showButtonMenu = jest.fn(() => true); - calltree.showButtonMenu(calltree.callTreeFilter, true); - expect(calltree.callTreeFilter.getAttribute('tree')).toBe(null); - calltree.showButtonMenu(calltree.callTreeFilter, false); - }); + it('TabPaneCallTreeTest03', function () { + document.body.innerHTML = ``; + let calltree = document.querySelector('#calltree'); + let filter = new TabPaneFilter(); + calltree.callTreeFilter = filter; + calltree.showButtonMenu = jest.fn(() => true); + calltree.showButtonMenu(calltree.callTreeFilter, true); + expect(calltree.callTreeFilter.getAttribute('tree')).toBe(null); + calltree.showButtonMenu(calltree.callTreeFilter, false); + }); - it('TabPaneCallTreeTest04', function () { - document.body.innerHTML = ``; - let calltree = document.querySelector('#calltree'); - let resultData = [ - { - addr: '', - canCharge: false, - count: 67, - depth: 0, - drawCount: 0, - drawDur: 0, - drawSize: 0, - dur: 43334510310, - frame: { x: 0, y: 30, width: 594, height: 20 }, - id: '38', - ip: '', - isDraw: false, - isSearch: false, - isSelected: false, - isStore: 0, - lib: '', - libName: '', - parentId: '', - path: '', - pathId: 0, - percent: 0.3642222150324375, - pid: 0, - processName: '', - searchShow: true, - self: '0s', - selfDur: 0, - size: 0, - symbol: 'symbol', - symbolName: 'symbolName', - symbolsId: 0, - textMetricsWidth: 62.7783203125, - type: 0, - weight: '43.33s ', - weightPercent: '36.4%', - children: [], - }, - ]; - calltree.setLTableData(resultData); - expect(calltree.callTreeDataSource.length).toEqual(1); - }); + it('TabPaneCallTreeTest04', function () { + document.body.innerHTML = ``; + let calltree = document.querySelector('#calltree'); + let resultData = [ + { + addr: '', + canCharge: false, + count: 67, + depth: 0, + drawCount: 0, + drawDur: 0, + drawSize: 0, + dur: 43334510310, + frame: { x: 0, y: 30, width: 594, height: 20 }, + id: '38', + ip: '', + isDraw: false, + isSearch: false, + isSelected: false, + isStore: 0, + lib: '', + libName: '', + parentId: '', + path: '', + pathId: 0, + percent: 0.3642222150324375, + pid: 0, + processName: '', + searchShow: true, + self: '0s', + selfDur: 0, + size: 0, + symbol: 'symbol', + symbolName: 'symbolName', + symbolsId: 0, + textMetricsWidth: 62.7783203125, + type: 0, + weight: '43.33s ', + weightPercent: '36.4%', + children: [], + }, + ]; + calltree.setLTableData(resultData); + expect(calltree.callTreeDataSource.length).toEqual(1); + }); }); 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 f7f155a178d2566eb0f3f54f171ab4bf07e2a997..fe70ccec6ebd68357e440cc385f4fc8207ed578a 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 @@ -33,7 +33,7 @@ jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorkerCPU.js return { cpuCount: 1, CpuRender: Object, - EmptyRender: Object + EmptyRender: Object, }; }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescHistory.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescHistory.test.ts index 8daf241c35b4b4963ae1a224cf19f5326970f273..311d26ac2088e80c5d83eac08c43d13401bb70b6 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescHistory.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescHistory.test.ts @@ -23,176 +23,176 @@ import crypto from 'crypto'; import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneFileSystemDescHistory Test', () => { - document.body.innerHTML = ``; - let tabPane = document.querySelector('#history'); + document.body.innerHTML = ``; + let tabPane = document.querySelector('#history'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; - let filterSource = [ - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 13, - depth: 10, - dur: 240916, - durStr: '240.92μs ', - fd: 14, - fileId: 546, - isHover: false, - path: '/data/local/tmp/test', - process: 'power_host[911]', - startTs: 285141821, - startTsStr: '285ms 141μs 821ns ', - symbol: '0x7faa10f228', - type: 0, - typeStr: 'OPEN', - }, - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 15, - depth: 10, - dur: 7583, - durStr: '7.58μs ', - fd: 14, - fileId: null, - isHover: false, - path: '-', - process: 'test[911]', - startTs: 285449632, - startTsStr: '285ms 449μs 821ns ', - symbol: '0x7faa10f228', - type: 1, - typeStr: 'CLOSE', - }, - ]; + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; + let filterSource = [ + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 13, + depth: 10, + dur: 240916, + durStr: '240.92μs ', + fd: 14, + fileId: 546, + isHover: false, + path: '/data/local/tmp/test', + process: 'power_host[911]', + startTs: 285141821, + startTsStr: '285ms 141μs 821ns ', + symbol: '0x7faa10f228', + type: 0, + typeStr: 'OPEN', + }, + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 15, + depth: 10, + dur: 7583, + durStr: '7.58μs ', + fd: 14, + fileId: null, + isHover: false, + path: '-', + process: 'test[911]', + startTs: 285449632, + startTsStr: '285ms 449μs 821ns ', + symbol: '0x7faa10f228', + type: 1, + typeStr: 'CLOSE', + }, + ]; - it('TabPaneFileSystemDescHistoryTest01', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - expect(tabPane.currentSelection).not.toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest01', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + expect(tabPane.currentSelection).not.toBeUndefined(); + }); - it('TabPaneFileSystemDescHistoryTest02', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.setProcessFilter(); - expect(tabPane.processList).toEqual(['All Process']); - }); + it('TabPaneFileSystemDescHistoryTest02', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.setProcessFilter(); + expect(tabPane.processList).toEqual(['All Process']); + }); - it('TabPaneFileSystemDescHistoryTest03', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - expect(tabPane.filterData()).toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest03', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + expect(tabPane.filterData()).toBeUndefined(); + }); - it('TabPaneFileSystemDescHistoryTest04', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.filterSource = filterSource; - expect(tabPane.sortFsDescHistoryTable('startTsStr', 1)).toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest04', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.filterSource = filterSource; + expect(tabPane.sortFsDescHistoryTable('startTsStr', 1)).toBeUndefined(); + }); - it('TabPaneFileSystemDescHistoryTest05', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.filterSource = filterSource; - expect(tabPane.sortFsDescHistoryTable('durStr', 1)).toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest05', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.filterSource = filterSource; + expect(tabPane.sortFsDescHistoryTable('durStr', 1)).toBeUndefined(); + }); - it('TabPaneFileSystemDescHistoryTest06', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.filterSource = filterSource; - expect(tabPane.sortFsDescHistoryTable('typeStr', 1)).toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest06', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.filterSource = filterSource; + expect(tabPane.sortFsDescHistoryTable('typeStr', 1)).toBeUndefined(); + }); - it('TabPaneFileSystemDescHistoryTest07', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.filterSource = filterSource; - expect(tabPane.sortFsDescHistoryTable('fd', 1)).toBeUndefined(); - }); + it('TabPaneFileSystemDescHistoryTest07', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.filterSource = filterSource; + expect(tabPane.sortFsDescHistoryTable('fd', 1)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescTimeSlice.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescTimeSlice.test.ts index 78ecc656ef4582fa828bd2a964a0790955029c8d..3622a5953db28fbd7d04bcb48f2807e77fac0d01 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescTimeSlice.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemDescTimeSlice.test.ts @@ -23,156 +23,156 @@ import crypto from 'crypto'; import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneFileSystemDescTimeSlice Test', () => { - document.body.innerHTML = ``; - let tabPane = document.querySelector('#desc-time-slice'); + document.body.innerHTML = ``; + let tabPane = document.querySelector('#desc-time-slice'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; - let filterSource = [ - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 13, - depth: 10, - dur: 240916, - durStr: '240.92μs ', - fd: 14, - fileId: 546, - isHover: false, - path: '/data/local/tmp/test', - process: 'power_host[911]', - startTs: 285141821, - startTsStr: '285ms 141μs 821ns ', - symbol: '0x7faa10f228', - type: 0, - typeStr: 'OPEN', - }, - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 15, - depth: 10, - dur: 7583, - durStr: '7.58μs ', - fd: 14, - fileId: null, - isHover: false, - path: '-', - process: 'test[911]', - startTs: 285449632, - startTsStr: '285ms 449μs 821ns ', - symbol: '0x7faa10f228', - type: 1, - typeStr: 'CLOSE', - }, - ]; + let filterSource = [ + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 13, + depth: 10, + dur: 240916, + durStr: '240.92μs ', + fd: 14, + fileId: 546, + isHover: false, + path: '/data/local/tmp/test', + process: 'power_host[911]', + startTs: 285141821, + startTsStr: '285ms 141μs 821ns ', + symbol: '0x7faa10f228', + type: 0, + typeStr: 'OPEN', + }, + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 15, + depth: 10, + dur: 7583, + durStr: '7.58μs ', + fd: 14, + fileId: null, + isHover: false, + path: '-', + process: 'test[911]', + startTs: 285449632, + startTsStr: '285ms 449μs 821ns ', + symbol: '0x7faa10f228', + type: 1, + typeStr: 'CLOSE', + }, + ]; - it('descTimeSliceTest01', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - expect(tabPane.currentSelection).not.toBeUndefined(); - }); + it('descTimeSliceTest01', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + expect(tabPane.currentSelection).not.toBeUndefined(); + }); - it('descTimeSliceTest02', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.source = filterSource; - expect(tabPane.sortFsDescTimeSliceTable('startTsStr', 1)).toBeUndefined(); - }); + it('descTimeSliceTest02', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.source = filterSource; + expect(tabPane.sortFsDescTimeSliceTable('startTsStr', 1)).toBeUndefined(); + }); - it('descTimeSliceTest03', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.source = filterSource; - expect(tabPane.sortFsDescTimeSliceTable('durStr', 1)).toBeUndefined(); - }); + it('descTimeSliceTest03', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.source = filterSource; + expect(tabPane.sortFsDescTimeSliceTable('durStr', 1)).toBeUndefined(); + }); - it('descTimeSliceTest04', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.source = filterSource; - expect(tabPane.sortFsDescTimeSliceTable('typeStr', 1)).toBeUndefined(); - }); + it('descTimeSliceTest04', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.source = filterSource; + expect(tabPane.sortFsDescTimeSliceTable('typeStr', 1)).toBeUndefined(); + }); - it('descTimeSliceTest05', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - tabPane.source = filterSource; - expect(tabPane.sortFsDescTimeSliceTable('fd', 1)).toBeUndefined(); - }); + it('descTimeSliceTest05', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + tabPane.source = filterSource; + expect(tabPane.sortFsDescTimeSliceTable('fd', 1)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.test.ts index ef83f82426f7cfc2a5e7148ed82c8af3fceb30e0..4a743ab0d73bed615b7ab96226fccef97534ed43 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.test.ts @@ -18,179 +18,179 @@ import '../../../../../../dist/trace/component/trace/sheet/file-system/TabPaneFi // @ts-ignore import { TabPaneFileSystemEvents } from '../../../../../../dist/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.js'; // @ts-ignore -import {LitTable} from '../../../../../../dist/base-ui/table/lit-table.js'; +import { LitTable } from '../../../../../../dist/base-ui/table/lit-table.js'; import crypto from 'crypto'; // @ts-ignore -import {TabPaneFilter} from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; +import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneFileSystemEvents Test', () => { - document.body.innerHTML = ``; - let tabPaneFileSystemEvents = document.querySelector('#files') as TabPaneFileSystemEvents; - let filterSource = [ - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 13, - depth: 10, - dur: 240916, - durStr: '240.92μs ', - fd: 14, - fileId: 546, - isHover: false, - path: '/data/local/tmp/test', - process: 'power_host[911]', - startTs: 285141821, - startTsStr: '285ms 141μs 821ns ', - symbol: '0x7faa10f228', - type: 0, - typeStr: 'OPEN', - }, - { - backtrace: ['0x7faa10f228', '(10 other frames)'], - callchainId: 15, - depth: 10, - dur: 7583, - durStr: '7.58μs ', - fd: 14, - fileId: null, - isHover: false, - path: '-', - process: 'test[911]', - startTs: 285449632, - startTsStr: '285ms 449μs 821ns ', - symbol: '0x7faa10f228', - type: 1, - typeStr: 'CLOSE', - }, - ]; + document.body.innerHTML = ``; + let tabPaneFileSystemEvents = document.querySelector('#files') as TabPaneFileSystemEvents; + let filterSource = [ + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 13, + depth: 10, + dur: 240916, + durStr: '240.92μs ', + fd: 14, + fileId: 546, + isHover: false, + path: '/data/local/tmp/test', + process: 'power_host[911]', + startTs: 285141821, + startTsStr: '285ms 141μs 821ns ', + symbol: '0x7faa10f228', + type: 0, + typeStr: 'OPEN', + }, + { + backtrace: ['0x7faa10f228', '(10 other frames)'], + callchainId: 15, + depth: 10, + dur: 7583, + durStr: '7.58μs ', + fd: 14, + fileId: null, + isHover: false, + path: '-', + process: 'test[911]', + startTs: 285449632, + startTsStr: '285ms 449μs 821ns ', + symbol: '0x7faa10f228', + type: 1, + typeStr: 'CLOSE', + }, + ]; - let param = { - anomalyEnergy: [], - clockMapData: {size: 0}, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: {size: 0}, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - fileSystemFsData:{title:'All'} - }; + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + fileSystemFsData: { title: 'All' }, + }; - it('TabPaneFileStatisticsTest01', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('', 0)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest01', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('', 0)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest02', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('startTsStr', 1)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest02', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('startTsStr', 1)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest03', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('durStr', 1)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest03', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('durStr', 1)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest04', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('process', 2)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest04', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('process', 2)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest05', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('thread', 2)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest05', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('thread', 2)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest06', function () { - tabPaneFileSystemEvents.filterSource = filterSource; - expect(tabPaneFileSystemEvents.sortFsSysEventTable('typeStr', 2)).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest06', function () { + tabPaneFileSystemEvents.filterSource = filterSource; + expect(tabPaneFileSystemEvents.sortFsSysEventTable('typeStr', 2)).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest07', function () { - let litTable = new LitTable(); - tabPaneFileSystemEvents.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPaneFileSystemEvents.filter = filter; - tabPaneFileSystemEvents.loadingList = []; - tabPaneFileSystemEvents.data = param; - expect(tabPaneFileSystemEvents.currentSelection).not.toBeUndefined(); - }); + it('TabPaneFileStatisticsTest07', function () { + let litTable = new LitTable(); + tabPaneFileSystemEvents.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPaneFileSystemEvents.filter = filter; + tabPaneFileSystemEvents.loadingList = []; + tabPaneFileSystemEvents.data = param; + expect(tabPaneFileSystemEvents.currentSelection).not.toBeUndefined(); + }); - it('TabPaneFileStatisticsTest08', function () { - let litTable = new LitTable(); - tabPaneFileSystemEvents.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPaneFileSystemEvents.filter = filter; - tabPaneFileSystemEvents.loadingList = []; - tabPaneFileSystemEvents.data = param; - tabPaneFileSystemEvents.setProcessFilter(); - expect(tabPaneFileSystemEvents.pathList).toEqual(['All Path']); - }); + it('TabPaneFileStatisticsTest08', function () { + let litTable = new LitTable(); + tabPaneFileSystemEvents.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPaneFileSystemEvents.filter = filter; + tabPaneFileSystemEvents.loadingList = []; + tabPaneFileSystemEvents.data = param; + tabPaneFileSystemEvents.setProcessFilter(); + expect(tabPaneFileSystemEvents.pathList).toEqual(['All Path']); + }); - it('TabPaneFileStatisticsTest09', function () { - let litTable = new LitTable(); - tabPaneFileSystemEvents.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPaneFileSystemEvents.filter = filter; - tabPaneFileSystemEvents.loadingList = []; - tabPaneFileSystemEvents.data = param; - expect(tabPaneFileSystemEvents.filterData()).toBeUndefined(); - }); + it('TabPaneFileStatisticsTest09', function () { + let litTable = new LitTable(); + tabPaneFileSystemEvents.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPaneFileSystemEvents.filter = filter; + tabPaneFileSystemEvents.loadingList = []; + tabPaneFileSystemEvents.data = param; + expect(tabPaneFileSystemEvents.filterData()).toBeUndefined(); + }); - it('TabPaneFileStatisticsTest10', function () { - let litTable = new LitTable(); - tabPaneFileSystemEvents.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPaneFileSystemEvents.filter = filter; - tabPaneFileSystemEvents.loadingList = []; - tabPaneFileSystemEvents.data = param; - tabPaneFileSystemEvents.fromStastics(param); - expect(tabPaneFileSystemEvents.filterEventType).toEqual('0'); - }); + it('TabPaneFileStatisticsTest10', function () { + let litTable = new LitTable(); + tabPaneFileSystemEvents.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPaneFileSystemEvents.filter = filter; + tabPaneFileSystemEvents.loadingList = []; + tabPaneFileSystemEvents.data = param; + tabPaneFileSystemEvents.fromStastics(param); + expect(tabPaneFileSystemEvents.filterEventType).toEqual('0'); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.test.ts index 1137bf7f64af40f642b06235e7f8ee95570bfeab..b84b6a49522c7c290d976ff8f2ec8a7d7a157555 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.test.ts @@ -27,156 +27,155 @@ import { LitTable } from '../../../../../../dist/base-ui/table/lit-table.js'; import '../../../../../../dist/base-ui/table/lit-table.js'; // @ts-ignore import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; -import '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; +import '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneFileStatistics Test', () => { - document.body.innerHTML = `
`; - let tabPaneFileStatistics = document.querySelector('#statistics'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; - - it('TabPaneFileStatisticsTest01', function () { - tabPaneFileStatistics.setInitDua = jest.fn(() => true); - let item = { - allDuration: '', - minDuration: '', - avgDuration: '', - maxDuration: '', - }; - expect(tabPaneFileStatistics.setInitDua(item)).toBeTruthy(); - }); + document.body.innerHTML = `
`; + let tabPaneFileStatistics = document.querySelector('#statistics'); + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; - it('TabPaneFileStatisticsTest02', function () { - tabPaneFileStatistics.getInitData = jest.fn(() => true); - let item = { - allDuration: '', - minDuration: '', - avgDuration: '', - maxDuration: '', - }; - expect(tabPaneFileStatistics.getInitData(item)).toBeTruthy(); - }); + it('TabPaneFileStatisticsTest01', function () { + tabPaneFileStatistics.setInitDua = jest.fn(() => true); + let item = { + allDuration: '', + minDuration: '', + avgDuration: '', + maxDuration: '', + }; + expect(tabPaneFileStatistics.setInitDua(item)).toBeTruthy(); + }); - it('TabPaneFileStatisticsTest04', function () { - tabPaneFileStatistics.showButtomMenu = jest.fn(() => true); - let isShow = { - filter: { - setAttribute: 'tree, input, inputLeftText', - }, - }; - expect(tabPaneFileStatistics.showButtomMenu(isShow)).toBeTruthy(); - }); + it('TabPaneFileStatisticsTest02', function () { + tabPaneFileStatistics.getInitData = jest.fn(() => true); + let item = { + allDuration: '', + minDuration: '', + avgDuration: '', + maxDuration: '', + }; + expect(tabPaneFileStatistics.getInitData(item)).toBeTruthy(); + }); - it('TabPaneFileStatisticsTest08', function () { - let FileStatistics = new TabPaneFileStatistics(); - let item = { - allDuration: '', - minDuration: '', - avgDuration: '', - maxDuration: '', - name: 'as', - logicalWrites: '', - logicalReads: '', - otherFile: '0 Bytes', - pid: 1, - }; - Utils.getBinaryByteWithUnit = jest.fn(() => true); - expect(FileStatistics.getInitData(item)).toEqual({ - allDuration: '', - avgDuration: '', - logicalReads: true, - logicalWrites: true, - maxDuration: '', - minDuration: '', - name: 'as', - node: { - allDuration: '', - avgDuration: '', - children: [], - logicalReads: '', - logicalWrites: '', - maxDuration: '', - minDuration: '', - name: 'as', - otherFile: '0 Bytes', - pid: 1, - }, - otherFile: true, - pid: 1, - title: 'as(1)', - }); - }); + it('TabPaneFileStatisticsTest04', function () { + tabPaneFileStatistics.showButtomMenu = jest.fn(() => true); + let isShow = { + filter: { + setAttribute: 'tree, input, inputLeftText', + }, + }; + expect(tabPaneFileStatistics.showButtomMenu(isShow)).toBeTruthy(); + }); - it('TabPaneFileStatisticsTest09', function () { - let FileStatistics = new TabPaneFileStatistics(); - let node = { - children: [], - }; - expect(FileStatistics.sortTable(node, '')).toBeUndefined(); + it('TabPaneFileStatisticsTest08', function () { + let FileStatistics = new TabPaneFileStatistics(); + let item = { + allDuration: '', + minDuration: '', + avgDuration: '', + maxDuration: '', + name: 'as', + logicalWrites: '', + logicalReads: '', + otherFile: '0 Bytes', + pid: 1, + }; + Utils.getBinaryByteWithUnit = jest.fn(() => true); + expect(FileStatistics.getInitData(item)).toEqual({ + allDuration: '', + avgDuration: '', + logicalReads: true, + logicalWrites: true, + maxDuration: '', + minDuration: '', + name: 'as', + node: { + allDuration: '', + avgDuration: '', + children: [], + logicalReads: '', + logicalWrites: '', + maxDuration: '', + minDuration: '', + name: 'as', + otherFile: '0 Bytes', + pid: 1, + }, + otherFile: true, + pid: 1, + title: 'as(1)', }); + }); + it('TabPaneFileStatisticsTest09', function () { + let FileStatistics = new TabPaneFileStatistics(); + let node = { + children: [], + }; + expect(FileStatistics.sortTable(node, '')).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.test.ts index edf327441fbac5734597fc7a110cbd0cf9b802fa..197b8c57cc15d877663abe26794334f4c7edaf90 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.test.ts @@ -23,253 +23,255 @@ import crypto from 'crypto'; import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneFilesystemStatisticsAnalysis Test', () => { - document.body.innerHTML = ``; - let tabPane = document.querySelector('#statistics-analysis'); + document.body.innerHTML = ``; + let tabPane = document.querySelector('#statistics-analysis'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; - let item = { - durFormat: '194.23ms ', - duration: 194230478, - isHover: true, - percent: '99.00', - pid: 3744, - tableName: 'test(3744)', - }; + let item = { + durFormat: '194.23ms ', + duration: 194230478, + isHover: true, + percent: '99.00', + pid: 3744, + tableName: 'test(3744)', + }; - let res = [ - { - durFormat: '194.23ms ', - duration: 194230478, - isHover: true, - percent: '99.00', - pid: 3744, - tableName: 'test(3744)', - }, - ]; + let res = [ + { + durFormat: '194.23ms ', + duration: 194230478, + isHover: true, + percent: '99.00', + pid: 3744, + tableName: 'test(3744)', + }, + ]; - let processData = [ - { - callChainId: 13, - dur: 240916, - libId: 539, - libName: 'libName.z.so', - pid: 911, - processName: 'processName(911)', - symbolId: 799, - symbolName: 'symbolName', - threadName: 'threadName', - tid: 404, - type: 0, - }, - ]; + let processData = [ + { + callChainId: 13, + dur: 240916, + libId: 539, + libName: 'libName.z.so', + pid: 911, + processName: 'processName(911)', + symbolId: 799, + symbolName: 'symbolName', + threadName: 'threadName', + tid: 404, + type: 0, + }, + ]; - let threadStatisticsData = { durFormat: '194.23ms ', duration: 0, isHover: false, percent: '100.00', tableName: '' }; + let threadStatisticsData = { durFormat: '194.23ms ', duration: 0, isHover: false, percent: '100.00', tableName: '' }; - it('systemStatisticsAnalysis01', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - expect(tabPane.fileStatisticsAnalysisCurrentSelection).not.toBeUndefined(); - }); + it('systemStatisticsAnalysis01', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + expect(tabPane.fileStatisticsAnalysisCurrentSelection).not.toBeUndefined(); + }); - it('systemStatisticsAnalysis02', function () { - expect(tabPane.clearData()).toBeUndefined(); - }); + it('systemStatisticsAnalysis02', function () { + expect(tabPane.clearData()).toBeUndefined(); + }); - it('systemStatisticsAnalysis03', function () { - tabPane.fileStatisticsAnalysisProcessData = processData; - tabPane.getFilesystemType(item, param); - expect(tabPane.fileStatisticsAnalysisProgressEL.loading).toBeFalsy(); - }); + it('systemStatisticsAnalysis03', function () { + tabPane.fileStatisticsAnalysisProcessData = processData; + tabPane.getFilesystemType(item, param); + expect(tabPane.fileStatisticsAnalysisProgressEL.loading).toBeFalsy(); + }); - it('systemStatisticsAnalysis04', function () { - tabPane.fileStatisticsAnalysisProcessData = processData; - tabPane.getFilesystemThread(item, param); - expect(tabPane.currentLevel).toEqual(2); - }); + it('systemStatisticsAnalysis04', function () { + tabPane.fileStatisticsAnalysisProcessData = processData; + tabPane.getFilesystemThread(item, param); + expect(tabPane.currentLevel).toEqual(2); + }); - it('systemStatisticsAnalysis05', function () { - tabPane.fileStatisticsAnalysisProcessData = processData; - tabPane.getFilesystemSo(item, param); - expect(tabPane.currentLevel).toEqual(3); - }); + it('systemStatisticsAnalysis05', function () { + tabPane.fileStatisticsAnalysisProcessData = processData; + tabPane.getFilesystemSo(item, param); + expect(tabPane.currentLevel).toEqual(3); + }); - it('systemStatisticsAnalysis06', function () { - tabPane.fileStatisticsAnalysisProcessData = processData; - tabPane.getFilesystemFunction(item, param); - expect(tabPane.currentLevel).toEqual(4); - }); + it('systemStatisticsAnalysis06', function () { + tabPane.fileStatisticsAnalysisProcessData = processData; + tabPane.getFilesystemFunction(item, param); + expect(tabPane.currentLevel).toEqual(4); + }); - it('systemStatisticsAnalysis07', function () { - expect(tabPane.typeIdToString(0)).toEqual('OPEN'); - }); + it('systemStatisticsAnalysis07', function () { + expect(tabPane.typeIdToString(0)).toEqual('OPEN'); + }); - it('systemStatisticsAnalysis08', function () { - expect(tabPane.typeIdToString(2)).toEqual('READ'); - }); + it('systemStatisticsAnalysis08', function () { + expect(tabPane.typeIdToString(2)).toEqual('READ'); + }); - it('systemStatisticsAnalysis09', function () { - expect(tabPane.typeIdToString(1)).toEqual('CLOSE'); - }); + it('systemStatisticsAnalysis09', function () { + expect(tabPane.typeIdToString(1)).toEqual('CLOSE'); + }); - it('systemStatisticsAnalysis10', function () { - expect(tabPane.getPieChartData(res).length).toEqual(1); - }); + it('systemStatisticsAnalysis10', function () { + expect(tabPane.getPieChartData(res).length).toEqual(1); + }); - it('systemStatisticsAnalysis11', function () { - tabPane.fileStatisticsAnalysisProcessData = jest.fn(() => true); - tabPane.fileStatisticsAnalysisProcessData.reMeauseHeight = jest.fn(() => true); - let parames = [ - { - "type": 0, - "callChainId": 13, - "dur": 240916, - "pid": 911, - "tid": 404, - "threadName": null, - "processName": "power_host(911)", - "libId": 542, - "symbolId": 802, - "libName": "libbattery_interface_service_1.0.z.so", - "symbolName": "OHOS::HDI::Battery::V1_0::PowerSupplyProvider::ReadBatterySysfsToBuff(char const*, char*, unsigned long) const" - }, - { - "type": 0, - "callChainId": 17, - "dur": 42000, - "pid": 911, - "tid": 404, - "threadName": null, - "processName": "power_host(911)", - "libId": 542, - "symbolId": 802, - "libName": "libbattery_interface_service_1.0.z.so", - "symbolName": "OHOS::HDI::Battery::V1_0::PowerSupplyProvider::ReadBatterySysfsToBuff(char const*, char*, unsigned long) const" - } - ] - tabPane.getFilesystemProcess(parames, processData); - expect(tabPane.fileStatisticsAnalysisProcessData).not.toBeUndefined(); - }); - it('systemStatisticsAnalysis12', function () { - tabPane.currentLevel = 0; - let paras = [ - { - type: 3, - callChainId: 1, - dur: 4757959, - pid: 237, - tid: 237, - threadName: 'jbd2/mmcblk0p11', - processName: 'jbd2/mmcblk0p11(237)', - libId: 263, - symbolId: 12560, - libName: 'kallsyms', - symbolName: 'submit_bh', - }, - { - type: 3, - callChainId: 1, - dur: 4673084, - pid: 237, - tid: 237, - threadName: 'jbd2/mmcblk0p11', - processName: 'jbd2/mmcblk0p11(237)', - libId: 263, - symbolId: 12560, - libName: 'kallsyms', - symbolName: 'submit_bh', - }, - ]; - tabPane.currentLevelData = paras; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 0; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 0; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - }); + it('systemStatisticsAnalysis11', function () { + tabPane.fileStatisticsAnalysisProcessData = jest.fn(() => true); + tabPane.fileStatisticsAnalysisProcessData.reMeauseHeight = jest.fn(() => true); + let parames = [ + { + type: 0, + callChainId: 13, + dur: 240916, + pid: 911, + tid: 404, + threadName: null, + processName: 'power_host(911)', + libId: 542, + symbolId: 802, + libName: 'libbattery_interface_service_1.0.z.so', + symbolName: + 'OHOS::HDI::Battery::V1_0::PowerSupplyProvider::ReadBatterySysfsToBuff(char const*, char*, unsigned long) const', + }, + { + type: 0, + callChainId: 17, + dur: 42000, + pid: 911, + tid: 404, + threadName: null, + processName: 'power_host(911)', + libId: 542, + symbolId: 802, + libName: 'libbattery_interface_service_1.0.z.so', + symbolName: + 'OHOS::HDI::Battery::V1_0::PowerSupplyProvider::ReadBatterySysfsToBuff(char const*, char*, unsigned long) const', + }, + ]; + tabPane.getFilesystemProcess(parames, processData); + expect(tabPane.fileStatisticsAnalysisProcessData).not.toBeUndefined(); + }); + it('systemStatisticsAnalysis12', function () { + tabPane.currentLevel = 0; + let paras = [ + { + type: 3, + callChainId: 1, + dur: 4757959, + pid: 237, + tid: 237, + threadName: 'jbd2/mmcblk0p11', + processName: 'jbd2/mmcblk0p11(237)', + libId: 263, + symbolId: 12560, + libName: 'kallsyms', + symbolName: 'submit_bh', + }, + { + type: 3, + callChainId: 1, + dur: 4673084, + pid: 237, + tid: 237, + threadName: 'jbd2/mmcblk0p11', + processName: 'jbd2/mmcblk0p11(237)', + libId: 263, + symbolId: 12560, + libName: 'kallsyms', + symbolName: 'submit_bh', + }, + ]; + tabPane.currentLevelData = paras; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 0; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 0; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.test.ts index 51e810bebdd06af2103718579e88ec21f41cf17a..0cb795ddfec05d274f1369621d6f7c0da8dc7d86 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.test.ts @@ -22,126 +22,126 @@ import crypto from 'crypto'; // @ts-ignore import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore -import {getTabPaneIOTierStatisticsData} from '../../../../../../dist/trace/database/SqlLite.js'; +import { getTabPaneIOTierStatisticsData } from '../../../../../../dist/trace/database/SqlLite.js'; // @ts-ignore -window.ResizeObserver - = window.ResizeObserver - || jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); const sqlit = require('../../../../../../dist/trace/database/SqlLite.js'); jest.mock('../../../../../../dist/trace/database/SqlLite.js'); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneIOTierStatistics Test', () => { - document.body.innerHTML = ''; - let tabPane = document.querySelector('#io-tier-statistics'); + document.body.innerHTML = ''; + let tabPane = document.querySelector('#io-tier-statistics'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; - it('ioTierStatistics01', function () { - let queryResult = sqlit.getTabPaneIOTierStatisticsData; - queryResult.mockResolvedValue([ - { - 'pid': 186, - 'pname': 'kworker/u8:4', - 'tier': 0, - 'ipid': 2, - 'path': '-', - 'count': 3, - 'allDuration': 19543418, - 'minDuration': 6408209, - 'maxDuration': 6668084, - 'avgDuration': 6514472.66666667 - }, - { - 'pid': 186, - 'pname': 'kworker/u8:4', - 'tier': 0, - 'ipid': 2, - 'path': '/data/thermal/config/configLevel', - 'count': 1, - 'allDuration': 5916167, - 'minDuration': 5916167, - 'maxDuration': 5916167, - 'avgDuration': 5916167 - }, - { - 'pid': 186, - 'pname': 'kworker/u8:4', - 'tier': 0, - 'ipid': 2, - 'path': '/data/local/tmp/hiebpf.data', - 'count': 2, - 'allDuration': 9192751, - 'minDuration': 2386417, - 'maxDuration': 6806334, - 'avgDuration': 4596375.5 - }, - { - 'pid': 237, - 'pname': 'jbd2/mmcblk0p11', - 'tier': 0, - 'ipid': 7, - 'path': '-', - 'count': 7, - 'allDuration': 32377630, - 'minDuration': 2749251, - 'maxDuration': 5033292, - 'avgDuration': 4625375.71428571 - } - ]); - tabPane.data = param; - expect(tabPane.ioTierStatisticsSelectionParam).not.toBeUndefined(); - }); + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; + it('ioTierStatistics01', function () { + let queryResult = sqlit.getTabPaneIOTierStatisticsData; + queryResult.mockResolvedValue([ + { + pid: 186, + pname: 'kworker/u8:4', + tier: 0, + ipid: 2, + path: '-', + count: 3, + allDuration: 19543418, + minDuration: 6408209, + maxDuration: 6668084, + avgDuration: 6514472.66666667, + }, + { + pid: 186, + pname: 'kworker/u8:4', + tier: 0, + ipid: 2, + path: '/data/thermal/config/configLevel', + count: 1, + allDuration: 5916167, + minDuration: 5916167, + maxDuration: 5916167, + avgDuration: 5916167, + }, + { + pid: 186, + pname: 'kworker/u8:4', + tier: 0, + ipid: 2, + path: '/data/local/tmp/hiebpf.data', + count: 2, + allDuration: 9192751, + minDuration: 2386417, + maxDuration: 6806334, + avgDuration: 4596375.5, + }, + { + pid: 237, + pname: 'jbd2/mmcblk0p11', + tier: 0, + ipid: 7, + path: '-', + count: 7, + allDuration: 32377630, + minDuration: 2749251, + maxDuration: 5033292, + avgDuration: 4625375.71428571, + }, + ]); + tabPane.data = param; + expect(tabPane.ioTierStatisticsSelectionParam).not.toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa3c454798e33acd7779820967ed9ba7dd3ec744 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.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 { TabPaneIoCompletionTimes } from '../../../../../../dist/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +Object.defineProperty(global.self, 'crypto', { + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, +}); +// @ts-ignore +import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; +import crypto from 'crypto'; +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('TabPaneIoCompletionTimes Test', () => { + let ioCompletionTimesTypeData = sqlite.getTabIoCompletionTimesType; + let ioCompletionData = [ + { + tier: 1, + }, + ]; + ioCompletionTimesTypeData.mockResolvedValue(ioCompletionData); + let tabPaneIoCompletionTimes = new TabPaneIoCompletionTimes(); + let filter = new TabPaneFilter(); + filter.getFilterData = jest.fn(() => true); + it('TabPaneIoCompletionTimes01', function () { + expect(tabPaneIoCompletionTimes.sortioCompletionTimesTable('', 0)).toBeUndefined(); + }); + it('TabPaneIoCompletionTimes02', function () { + expect(tabPaneIoCompletionTimes.sortioCompletionTimesTable('startTsStr', 1)).toBeUndefined(); + }); + it('TabPaneIoCompletionTimes06', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + }, + ]; + expect(tabPaneIoCompletionTimes.initFilterTypes(val)).toBeTruthy(); + }); + it('TabPaneIoCompletionTimes07', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + fileSystemIoData: 'aa', + }, + ]; + expect(tabPaneIoCompletionTimes.fromStastics(val)).toBeTruthy(); + }); + it('TabPaneIoCompletionTimes08', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + }, + ]; + expect(tabPaneIoCompletionTimes.queryData(val)).toBeUndefined(); + }); + it('TabPaneIoCompletionTimes09', function () { + let val = [ + { + pid: 10, + tid: 100, + type: 0, + }, + ]; + expect(tabPaneIoCompletionTimes.filterTypeData(val)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneVMEvents.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneVMEvents.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ccce7bbc2c85ac7d9fd255f2c3df759348bc0c9b --- /dev/null +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneVMEvents.test.ts @@ -0,0 +1,108 @@ +/* + * 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 { TabPaneVirtualMemoryEvents } from '../../../../../../dist/trace/component/trace/sheet/file-system/TabPaneVMEvents.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +Object.defineProperty(global.self, 'crypto', { + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, +}); +// @ts-ignore +import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; +import crypto from 'crypto'; +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('TabPaneVMEvents Test', () => { + let VMTypeData = sqlite.getTabVirtualMemoryType; + let VMData = [ + { + type: 1, + }, + ]; + VMTypeData.mockResolvedValue(VMData); + let tabPaneVMEvents = new TabPaneVirtualMemoryEvents(); + let filter = new TabPaneFilter(); + filter.getFilterData = jest.fn(() => true); + it('TabPaneVMEvents01', function () { + expect(tabPaneVMEvents.sortVmEventTable('', 0)).toBeUndefined(); + }); + it('TabPaneVMEvents02', function () { + expect(tabPaneVMEvents.sortVmEventTable('startTsStr', 1)).toBeUndefined(); + }); + it('TabPaneVMEvents03', function () { + expect(tabPaneVMEvents.sortVmEventTable('durStr', 1)).toBeUndefined(); + }); + it('TabPaneVMEvents04', function () { + expect(tabPaneVMEvents.sortVmEventTable('thread', 1)).toBeUndefined(); + }); + it('TabPaneVMEvents05', function () { + expect(tabPaneVMEvents.sortVmEventTable('sizeStr', 1)).toBeUndefined(); + }); + it('TabPaneVMEvents06', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + }, + ]; + expect(tabPaneVMEvents.initFilterTypes(val)).toBeTruthy(); + }); + it('TabPaneVMEvents07', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + fileSystemVMData: 'aa', + }, + ]; + expect(tabPaneVMEvents.fromStastics(val)).toBeTruthy(); + }); + it('TabPaneVMEvents08', function () { + let val = [ + { + leftNs: 10, + rightNs: 2000, + }, + ]; + expect(tabPaneVMEvents.queryData(val)).toBeUndefined(); + }); + it('TabPaneVMEvents09', function () { + let val = [ + { + pid: 10, + tid: 100, + type: 0, + }, + ]; + expect(tabPaneVMEvents.filterTypeData(val)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.test.ts index b3e4fbce498c331167e4046ebee4e6d51c60f55d..cf45ff46586303cba312ac239e845e42219e7ecd 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.test.ts @@ -19,7 +19,6 @@ import '../../../../../../dist/trace/component/trace/sheet/file-system/TabPaneVi const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); jest.mock('../../../../../../dist/trace/database/SqlLite.js'); - window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -31,34 +30,34 @@ describe('TabPaneVirtualMemoryStatistics Test', () => { document.body.innerHTML = ` `; let tabPaneVirtualMemoryStatistics = document.querySelector('#statistics') as TabPaneVirtualMemoryStatistics; - let val = [ - { - leftNs: 0, - rightNs: 1000, - }, - ]; - let VMStatisticData = sqlite.getTabPaneVirtualMemoryStatisticsData; - let VMData = [ - { - pid: 0, - tid: 1, - pname: 'aa', - tname: 'bb', - type: 1, - ipid:1, - itid:100, - count:1000, - allDuration:10, - minDuration:10, - maxDuration:10, - avgDuration:10, - }, - ]; - VMStatisticData.mockResolvedValue(VMData); + let val = [ + { + leftNs: 0, + rightNs: 1000, + }, + ]; + let VMStatisticData = sqlite.getTabPaneVirtualMemoryStatisticsData; + let VMData = [ + { + pid: 0, + tid: 1, + pname: 'aa', + tname: 'bb', + type: 1, + ipid: 1, + itid: 100, + count: 1000, + allDuration: 10, + minDuration: 10, + maxDuration: 10, + avgDuration: 10, + }, + ]; + VMStatisticData.mockResolvedValue(VMData); it('TabPaneVirtualMemoryStatisticsTest01', function () { expect(tabPaneVirtualMemoryStatistics).toBeDefined(); }); - it('TabPaneVirtualMemoryStatisticsTest02', function () { - expect(tabPaneVirtualMemoryStatistics.queryDataByDB(val)).toBeUndefined(); - }); + it('TabPaneVirtualMemoryStatisticsTest02', function () { + expect(tabPaneVirtualMemoryStatistics.queryDataByDB(val)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.test.ts b/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.test.ts index 4b3398543e59306fc54d28b33b45889e4f24ecde..e5f366c77fd7069a2e876154b74bda8c8e43755a 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.test.ts @@ -23,232 +23,232 @@ import crypto from 'crypto'; import { TabPaneFilter } from '../../../../../../dist/trace/component/trace/sheet/TabPaneFilter.js'; // @ts-ignore window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); describe('TabPaneVirtualMemoryStatisticsAnalysis Test', () => { - document.body.innerHTML = ``; - let tabPane = document.querySelector('#statistics-analysis'); - let param = { - anomalyEnergy: [], - clockMapData: { size: 0 }, - cpuAbilityIds: [], - cpuFreqFilterIds: [], - cpuFreqLimitDatas: [], - cpuStateFilterIds: [], - cpus: [], - diskAbilityIds: [], - diskIOLatency: false, - diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], - diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], - diskIOipids: [2, 7, 1, 3, 4, 5, 6], - fileSysVirtualMemory: false, - fileSystemType: [], - fsCount: 0, - funAsync: [], - funTids: [], - hasFps: false, - irqMapData: { size: 0 }, - jsMemory: [], - leftNs: 964699689, - memoryAbilityIds: [], - nativeMemory: [], - nativeMemoryStatistic: [], - networkAbilityIds: [], - perfAll: false, - perfCpus: [], - perfProcess: [], - perfSampleIds: [], - perfThread: [], - powerEnergy: [], - processTrackIds: [], - promiseList: [], - recordStartNs: 780423789228, - rightNs: 24267556624, - sdkCounterIds: [], - sdkSliceIds: [], - smapsType: [], - systemEnergy: [], - threadIds: [], - virtualTrackIds: [], - vmCount: 0, - }; - let processData = [ - { - callChainId: 13, - dur: 240916, - libId: 539, - libName: 'libName.z.so', - pid: 911, - processName: 'processName(911)', - symbolId: 799, - symbolName: 'symbolName', - threadName: 'threadName', - tid: 404, - type: 0, - }, - ]; - let item = { - durFormat: '194.23ms ', - duration: 194230478, - isHover: true, - percent: '99.00', - pid: 3744, - tableName: 'test(3744)', - }; - let res = [ - { - durFormat: '194.23ms ', - duration: 194230478, - isHover: true, - percent: '99.00', - pid: 3744, - tableName: 'test(3744)', - }, + document.body.innerHTML = ``; + let tabPane = document.querySelector('#statistics-analysis'); + let param = { + anomalyEnergy: [], + clockMapData: { size: 0 }, + cpuAbilityIds: [], + cpuFreqFilterIds: [], + cpuFreqLimitDatas: [], + cpuStateFilterIds: [], + cpus: [], + diskAbilityIds: [], + diskIOLatency: false, + diskIOReadIds: [2, 7, 1, 3, 4, 5, 6], + diskIOWriteIds: [2, 7, 1, 3, 4, 5, 6], + diskIOipids: [2, 7, 1, 3, 4, 5, 6], + fileSysVirtualMemory: false, + fileSystemType: [], + fsCount: 0, + funAsync: [], + funTids: [], + hasFps: false, + irqMapData: { size: 0 }, + jsMemory: [], + leftNs: 964699689, + memoryAbilityIds: [], + nativeMemory: [], + nativeMemoryStatistic: [], + networkAbilityIds: [], + perfAll: false, + perfCpus: [], + perfProcess: [], + perfSampleIds: [], + perfThread: [], + powerEnergy: [], + processTrackIds: [], + promiseList: [], + recordStartNs: 780423789228, + rightNs: 24267556624, + sdkCounterIds: [], + sdkSliceIds: [], + smapsType: [], + systemEnergy: [], + threadIds: [], + virtualTrackIds: [], + vmCount: 0, + }; + let processData = [ + { + callChainId: 13, + dur: 240916, + libId: 539, + libName: 'libName.z.so', + pid: 911, + processName: 'processName(911)', + symbolId: 799, + symbolName: 'symbolName', + threadName: 'threadName', + tid: 404, + type: 0, + }, + ]; + let item = { + durFormat: '194.23ms ', + duration: 194230478, + isHover: true, + percent: '99.00', + pid: 3744, + tableName: 'test(3744)', + }; + let res = [ + { + durFormat: '194.23ms ', + duration: 194230478, + isHover: true, + percent: '99.00', + pid: 3744, + tableName: 'test(3744)', + }, + ]; + it('tabPaneVirtualMemoryStatisticsAnalysis01', function () { + let litTable = new LitTable(); + tabPane.appendChild(litTable); + let filter = new TabPaneFilter(); + tabPane.filter = filter; + tabPane.loadingList = []; + tabPane.data = param; + expect(tabPane.vmStatisticsAnalysisSelection).toBeUndefined(); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis02', function () { + expect(tabPane.clearData()).toBeUndefined(); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis03', function () { + tabPane.vmStatisticsAnalysisProcessData = jest.fn(() => true); + let data = [ + { + type: 7, + callChainId: 12, + dur: 30625, + pid: 1374, + tid: 1374, + threadName: 'com.ohos.mms', + processName: 'com.ohos.mms(1374)', + libId: 344, + symbolId: 727, + libName: 'libmmi-util.z.so', + symbolName: 'OHOS::MMI::GetThisThreadIdOfString()', + }, + { + type: 7, + callChainId: 24, + dur: 42000, + pid: 1818, + tid: 1374, + threadName: null, + processName: 'RSRenderThread(1818)', + libId: null, + symbolId: null, + libName: '', + symbolName: '0x7f7380e670 ()', + }, ]; - it('tabPaneVirtualMemoryStatisticsAnalysis01', function () { - let litTable = new LitTable(); - tabPane.appendChild(litTable); - let filter = new TabPaneFilter(); - tabPane.filter = filter; - tabPane.loadingList = []; - tabPane.data = param; - expect(tabPane.vmStatisticsAnalysisSelection).toBeUndefined(); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis02', function () { - expect(tabPane.clearData()).toBeUndefined(); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis03', function () { - tabPane.vmStatisticsAnalysisProcessData = jest.fn(() => true); - let data = [ - { - "type": 7, - "callChainId": 12, - "dur": 30625, - "pid": 1374, - "tid": 1374, - "threadName": "com.ohos.mms", - "processName": "com.ohos.mms(1374)", - "libId": 344, - "symbolId": 727, - "libName": "libmmi-util.z.so", - "symbolName": "OHOS::MMI::GetThisThreadIdOfString()" - }, - { - "type": 7, - "callChainId": 24, - "dur": 42000, - "pid": 1818, - "tid": 1374, - "threadName": null, - "processName": "RSRenderThread(1818)", - "libId": null, - "symbolId": null, - "libName": "", - "symbolName": "0x7f7380e670 ()" - } - ]; - tabPane.getVirtualMemoryProcess(data, processData); - expect(tabPane.vmStatisticsAnalysisProcessData).not.toBeUndefined(); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis04', function () { - tabPane.vmStatisticsAnalysisProcessData = processData; - tabPane.getVirtualMemoryType(item, param); - expect(tabPane.vmStatisticsAnalysisProgressEL.loading).toBeFalsy(); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis05', function () { - tabPane.vmStatisticsAnalysisProcessData = processData; - tabPane.getVirtualMemoryThread(item, param); - expect(tabPane.currentLevel).toEqual(2); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis06', function () { - tabPane.vmStatisticsAnalysisProcessData = processData; - tabPane.getVirtualMemorySo(item, param); - expect(tabPane.currentLevel).toEqual(3); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis07', function () { - tabPane.vmStatisticsAnalysisProcessData = processData; - tabPane.getVirtualMemoryFunction(item, param); - expect(tabPane.currentLevel).toEqual(4); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis08', function () { - expect(tabPane.typeIdToString(1)).toEqual('File Backed In'); - }); + tabPane.getVirtualMemoryProcess(data, processData); + expect(tabPane.vmStatisticsAnalysisProcessData).not.toBeUndefined(); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis04', function () { + tabPane.vmStatisticsAnalysisProcessData = processData; + tabPane.getVirtualMemoryType(item, param); + expect(tabPane.vmStatisticsAnalysisProgressEL.loading).toBeFalsy(); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis05', function () { + tabPane.vmStatisticsAnalysisProcessData = processData; + tabPane.getVirtualMemoryThread(item, param); + expect(tabPane.currentLevel).toEqual(2); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis06', function () { + tabPane.vmStatisticsAnalysisProcessData = processData; + tabPane.getVirtualMemorySo(item, param); + expect(tabPane.currentLevel).toEqual(3); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis07', function () { + tabPane.vmStatisticsAnalysisProcessData = processData; + tabPane.getVirtualMemoryFunction(item, param); + expect(tabPane.currentLevel).toEqual(4); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis08', function () { + expect(tabPane.typeIdToString(1)).toEqual('File Backed In'); + }); - it('tabPaneVirtualMemoryStatisticsAnalysis09', function () { - expect(tabPane.typeIdToString(7)).toEqual('Copy On Writer'); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis10', function () { - expect(tabPane.getPieChartData(res).length).toEqual(1); - }); - it('tabPaneVirtualMemoryStatisticsAnalysis11', function () { - tabPane.currentLevel = 0; - let paras = [ - { - type: 2, - callChainId: 1, - dur: 4757959, - pid: 237, - tid: 237, - threadName: 'jbd2/mmcblk0p11', - processName: 'jbd2/mmcblk0p11(237)', - libId: 263, - symbolId: 12560, - libName: 'kallsyms', - symbolName: 'submit_bh', - }, - { - type: 2, - callChainId: 1, - dur: 4673084, - pid: 237, - tid: 237, - threadName: 'jbd2/mmcblk0p11', - processName: 'jbd2/mmcblk0p11(237)', - libId: 263, - symbolId: 12560, - libName: 'kallsyms', - symbolName: 'submit_bh', - }, - ]; - tabPane.currentLevelData = paras; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); - tabPane.currentLevel = 0; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); - tabPane.currentLevel = 0; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 1; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 2; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 3; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - tabPane.currentLevel = 4; - expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); - }); -}) \ No newline at end of file + it('tabPaneVirtualMemoryStatisticsAnalysis09', function () { + expect(tabPane.typeIdToString(7)).toEqual('Copy On Writer'); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis10', function () { + expect(tabPane.getPieChartData(res).length).toEqual(1); + }); + it('tabPaneVirtualMemoryStatisticsAnalysis11', function () { + tabPane.currentLevel = 0; + let paras = [ + { + type: 2, + callChainId: 1, + dur: 4757959, + pid: 237, + tid: 237, + threadName: 'jbd2/mmcblk0p11', + processName: 'jbd2/mmcblk0p11(237)', + libId: 263, + symbolId: 12560, + libName: 'kallsyms', + symbolName: 'submit_bh', + }, + { + type: 2, + callChainId: 1, + dur: 4673084, + pid: 237, + tid: 237, + threadName: 'jbd2/mmcblk0p11', + processName: 'jbd2/mmcblk0p11(237)', + libId: 263, + symbolId: 12560, + libName: 'kallsyms', + symbolName: 'submit_bh', + }, + ]; + tabPane.currentLevelData = paras; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('tableName', 0)).toBeUndefined(); + tabPane.currentLevel = 0; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('tableName', 1)).toBeUndefined(); + tabPane.currentLevel = 0; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 1; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 2; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 3; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + tabPane.currentLevel = 4; + expect(tabPane.sortByColumn('durFormat', 1)).toBeUndefined(); + }); +}); 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 b34cd3dfea78bc00dc3969687f9f5879b544a4a5..558fa9fe4105d6ceb37864ed57dbb2cdc7862ccc 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts @@ -16,6 +16,9 @@ import { TabPaneGpuClickSelect } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.js'; jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.js', () => { return {}; }); const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); @@ -52,7 +55,7 @@ describe('TabPaneGpuClickSelect Test', () => { type: '', startTs: 1, }; - expect(tabPaneGpuClickSelect.data).toBeUndefined(); + expect(tabPaneGpuClickSelect.data).toBeTruthy(); }); it('TabPaneGpuClickSelectTest02', () => { let tabPaneGpuClickSelects = new TabPaneGpuClickSelect(); diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..a936929d48c39dc941668b130b5f0510de14dc09 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts @@ -0,0 +1,89 @@ +/* + * 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 { TabPaneGpuClickSelectComparison } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); + +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneGpuClickSelectComparison Test', () => { + document.body.innerHTML = `
`; + let tabPaneGpuClickSelectComparison = 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('TabPaneGpuClickSelectComparisonTest01', () => { + let type = 'total'; + let startTs = 10; + let tabPaneGpuClickSelectComparison = new TabPaneGpuClickSelectComparison(); + expect(tabPaneGpuClickSelectComparison.queryDataByDB(type, startTs)).toBeTruthy(); + }); + it('TabPaneGpuClickSelectComparisonTest02', () => { + let type = 'total'; + let targetStartNs = 10; + let tabPaneGpuClickSelectComparison = new TabPaneGpuClickSelectComparison(); + expect(tabPaneGpuClickSelectComparison.getComparisonData(targetStartNs, type)).toBeTruthy(); + }); + it('TabPaneGpuClickSelectComparisonTest03', () => { + let type = 'total'; + let dataList = [ + { + name: 'Snapshot2', + startNs: 9800526561, + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + value: 0, + }, + ]; + let tabPaneGpuClickSelectComparison = new TabPaneGpuClickSelectComparison(); + expect(tabPaneGpuClickSelectComparison.selectStamps(dataList, type)).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 index e799ac8117726c2d9c1d3b50e84e93695edc08e2..2cc4ee01ac0901d88d95ea8cd495ad5a8b022b32 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts @@ -16,38 +16,39 @@ import { TabPaneGpuGL } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuGL.js'; jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + 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(), - })); +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}); - }); + 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 index 66f964ae077cfc27c5be64135141b50584cc6b17..c1cde77883db5e914f811ab33d84c9af90eb79c4 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts @@ -16,57 +16,60 @@ import { TabPaneGpuTotalBoxSelect } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.js'; jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + 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(), - })); +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(); - }); + 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 index 9e1922ff0a5706977569427c33c2cbf3e7fa184e..ab1fae97be0cacb39614309d7e4b76124212dc9b 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts @@ -16,64 +16,69 @@ import { TabPaneGpuWindowBoxSelect } from '../../../../../../dist/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.js'; jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + 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(), - })); +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(); - }); + 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/TabPerfBottomUp.test.ts b/ide/test/trace/component/trace/sheet/hiperf/TabPerfBottomUp.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c658ffd89671584c572ecfd6cae01767ea57fe44 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/hiperf/TabPerfBottomUp.test.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. + */ + +//@ts-ignore +import { TabpanePerfBottomUp } from '../../../../../../dist/trace/component/trace/sheet/hiperf/TabPerfBottomUp.js'; +//@ts-ignore +import {showButtonMenu} from "../../../../../../dist/trace/component/trace/sheet/SheetUtils.js"; + +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {} +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('TabPanePerfBottomUp Test', () => { + let tabPanePerfBottomUp = new TabpanePerfBottomUp(); + let data = { + leftNs: 1222, + rightNs: 5286, + }; + it('TabPanePerfBottomUp02 ', function () { + tabPanePerfBottomUp.data = data + expect(tabPanePerfBottomUp.data).toBeUndefined(); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.test.ts deleted file mode 100644 index 81241369cbf3d14b4245abac79484e03841ab7cc..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.test.ts +++ /dev/null @@ -1,361 +0,0 @@ -/* - * 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 { TabPaneNMCallInfo } from '../../../../../../dist/trace/component/trace/sheet/native-memory/TabPaneNMCallInfo.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('TabPaneNMCallInfo Test', () => { - document.body.innerHTML = ''; - let tabPaneNMCallInfo = document.querySelector('#ddd'); - - let nativeHookData = [ - { - eventId: 0, - eventType: '', - subType: '', - heapSize: 0, - addr: '', - startTs: 0, - endTs: 0, - sumHeapSize: 0, - max: 0, - count: 0, - tid: 0, - isSelected: false, - }, - { - eventId: 0, - eventType: '', - subType: '', - heapSize: 0, - addr: '', - startTs: 0, - endTs: 0, - sumHeapSize: 0, - max: 0, - count: 0, - tid: 0, - isSelected: false, - }, - ]; - - tabPaneNMCallInfo.currentSelection = jest.fn(() => true); - TabPaneNMCallInfo.data = { - cpus: [], - threadIds: [], - trackIds: [], - funTids: [], - heapIds: [], - nativeMemory: [], - leftNs: 0, - rightNs: 0, - hasFps: false, - statisticsSelectData: undefined, - }; - - let sortArr = [{ - id: '0', - pid: '', - library: '', - symbolId: 0, - title: '', - count: 0, - countValue: '', - countPercent: '', - type: 0, - heapSize: 0, - heapPercent: '', - heapSizeStr: '', - eventId: 0, - threadId: 0, - threadName: '', - isSelected: false, - }, { - id: '1', - pid: '', - library: '', - symbolId: 0, - title: '', - count: 0, - countValue: '', - countPercent: '', - type: 0, - heapSize: 0, - heapPercent: '', - heapSizeStr: '', - eventId: 0, - threadId: 0, - threadName: '', - isSelected: false, - }] - - let iconRowClick = new CustomEvent('row-click', { - detail: { - data: { - id: '', - pid: '', - library: '', - symbolId: 0, - title: '', - count: 0, - countValue: '', - countPercent: '', - type: 0, - heapSize: 0, - heapPercent: '', - heapSizeStr: '', - eventId: 0, - threadId: 0, - threadName: '', - isSelected: false, - children: [] - }, - callBack: (call: boolean) => {} - }, - composed: true, - }); - - it('TabPaneNMCallInfoTest2', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'size', 0)).toBe(sortArr); - }); - it('TabPaneNMCallInfoTest3', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'size', 1)).toBe(sortArr); - }); - it('TabPaneNMCallInfoTest4', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'size', 2)).toBe(sortArr); - }); - it('TabPaneNMCallInfoTest5', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'num', 0)).toBe(sortArr); - }); - it('TabPaneNMCallInfoTest6', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'num', 1)).toBe(sortArr); - }); - it('TabPaneNMCallInfoTest7', function () { - sortArr.map = jest.fn(()=>[]) - expect(tabPaneNMCallInfo.sortTree(sortArr, 'num', 2)).toBe(sortArr); - }); - - it('TabPaneNMCallInfoTest08', function () { - let hookLeft = { - id: '', - pid: '', - library: '', - title: '', - count: 0, - children: [], - depth: 0, - frame: undefined, - isHover: false, - parent: undefined, - size: 2, - symbol: '', - type: 0, - heapSize: 0, - heapSizeStr: '', - eventId: 0, - threadId: 0, - }; - let groupByWithTid = tabPaneNMCallInfo.setRightTableData(hookLeft); - expect(groupByWithTid).toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest10', function () { - expect(tabPaneNMCallInfo.sortTreeByColumn()).toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest11', function () { - let MockqueryNativeHookEventTid = sqlit.queryNativeHookEventTid; - MockqueryNativeHookEventTid.mockResolvedValue([ - { - eventId: 0, - eventType: 'AllocEvent', - heap_size: 2, - addr: 'addr', - startTs: 0, - endTs: 500, - tid: 2, - threadName: 'threadName', - }, - ]); - tabPaneNMCallInfo.data = { - leftNs: 0, - rightNs: 500, - nativeMemory: 'All Heap & Anonymous VM', - }; - - tabPaneNMCallInfo.startWorker = jest.fn(() => true); - expect(tabPaneNMCallInfo.data).toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest12', function () { - expect(tabPaneNMCallInfo.initHtml()).toMatchInlineSnapshot(` -" - -
- - -
- - - - - - - - - - - - - - - -
- - - - - - - - -
-
- - - - - -
-
- " -`); - }); - it('TabPaneNMCallInfoTest11', function () { - let hook = { - id: 1, - dur: 1, - children: [], - }; - let id = '1'; - expect(tabPaneNMCallInfo.getParentTree([hook], { id: 1 }, [])).not.toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest13', function () { - expect(tabPaneNMCallInfo.showButtomMenu()).toBeUndefined(); - }); - it('TabPaneNMCallInfoTest14', function () { - let isShow = 1; - expect(tabPaneNMCallInfo.showButtomMenu(isShow)).toBeUndefined(); - }); - it('TabPaneNMCallInfoTest15', function () { - expect(tabPaneNMCallInfo.showButtomMenu({},{})).toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest16', function () { - let hook = { - eventId: 1, - dur: 1, - children: [], - }; - expect(tabPaneNMCallInfo.getChildTree([hook], 1, [])).not.toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest17', function () { - let hook = { - eventId: 1, - dur: 1, - children: [], - }; - expect(tabPaneNMCallInfo.getChildTree([hook], 2, [])).not.toBeUndefined(); - }); - - it('TabPaneNMCallInfoTest18', function () { - tabPaneNMCallInfo.tblData.clearAllSelection = jest.fn(()=>true); - tabPaneNMCallInfo.tblData.setCurrentSelection = jest.fn(()=>[]); - tabPaneNMCallInfo.callInfoTbl.clearAllSelection = jest.fn(()=>true); - tabPaneNMCallInfo.callInfoTbl.scrollToData = jest.fn(()=>true); - tabPaneNMCallInfo.callInfoTbl.dispatchEvent(iconRowClick); - tabPaneNMCallInfo.tblData.dispatchEvent(iconRowClick); - let hook = { - id: 1, - dur: 1, - children: [], - }; - let id = '1'; - expect(tabPaneNMCallInfo.getParentTree([hook], { id: 2 }, [])).not.toBeUndefined(); - }); -}); diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.test.ts index 3907bf3608e4950768f8f0638eaf95ecfe5dc0cb..9975487901fe06deb84c6257a51ab8aab854e590 100644 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.test.ts +++ b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.test.ts @@ -26,16 +26,16 @@ 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 {} + return {}; }); window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneNMCallTree Test', () => { document.body.innerHTML = '
'; @@ -223,16 +223,30 @@ describe('TabPaneNMCallTree Test', () => { }); it('TabPaneNMCallTreeTest11', function () { let data = [ - { callTreeConstraints:{ - inputs:[1] - } - , dataMining: 20, callTree: [] ,icon : 'block'}, - { callTreeConstraints:{ - inputs:[1] - }, dataMining: 21, callTree: [] ,icon : 'block'}, - { callTreeConstraints:{ - inputs:[1] - }, dataMining: 31, callTree: [] ,icon : 'block'}, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 20, + callTree: [], + icon: 'block', + }, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 21, + callTree: [], + icon: 'block', + }, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 31, + callTree: [], + icon: 'block', + }, ]; expect(tabPaneNMCallTree.switchFlameChart(data)).toBeUndefined(); }); @@ -248,21 +262,35 @@ describe('TabPaneNMCallTree Test', () => { expect(tabPaneNMCallTree.setRightTableData(data)).toBeTruthy(); }); it('TabPaneNMCallTreeTest14', function () { - expect(tabPaneNMCallTree.getDataByWorkerQuery({},{})).toBeUndefined(); + expect(tabPaneNMCallTree.getDataByWorkerQuery({}, {})).toBeUndefined(); }); it('TabPaneNMCallTreeTest15', function () { let data = [ - { callTreeConstraints:{ - inputs:[1] - } - , dataMining: 20, callTree: [] ,icon : 'tree'}, - { callTreeConstraints:{ - inputs:[1] - }, dataMining: 21, callTree: [] ,icon : 'tree'}, - { callTreeConstraints:{ - inputs:[1] - }, dataMining: 31, callTree: [] ,icon : 'tree'}, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 20, + callTree: [], + icon: 'tree', + }, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 21, + callTree: [], + icon: 'tree', + }, + { + callTreeConstraints: { + inputs: [1], + }, + dataMining: 31, + callTree: [], + icon: 'tree', + }, ]; expect(tabPaneNMCallTree.switchFlameChart(data)).toBeUndefined(); }); diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMSampleList.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMSampleList.test.ts index 36e30f077f8c3ac55de2f25a7f1860bc6911111a..0074f02394febac065362770d8d3a9b1e9fa962f 100644 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMSampleList.test.ts +++ b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMSampleList.test.ts @@ -27,7 +27,7 @@ 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 {} + return {}; }); window.ResizeObserver = @@ -94,7 +94,6 @@ describe('TabPaneNMSampleList Test', () => { MockNativeHookSnapshotTypes.mockResolvedValue([new NativeHookSampleQueryInfo()]); - let samplerInfo = [ { current: '', @@ -129,7 +128,7 @@ describe('TabPaneNMSampleList Test', () => { eventId: -1, threadId: 0, threadName: '', - } + }, ]; tabPaneNMSampleList.data = dat; @@ -284,114 +283,122 @@ describe('TabPaneNMSampleList Test', () => { }); it('TabPaneNMSampleListTest13', function () { - TabPaneNMSampleList.samplerInfoSource = [{ - current: '', - currentSize: 0, - startTs: 0, - heapSize: 0, - snapshot: '', - growth: '', - total: 0, - totalGrowth: '', - existing: 0, - children: samplerInfo, - tempList: samplerInfo, - timestamp: '', - eventId: -1, - threadId: 0, - threadName: '', - }] + TabPaneNMSampleList.samplerInfoSource = [ + { + current: '', + currentSize: 0, + startTs: 0, + heapSize: 0, + snapshot: '', + growth: '', + total: 0, + totalGrowth: '', + existing: 0, + children: samplerInfo, + tempList: samplerInfo, + timestamp: '', + eventId: -1, + threadId: 0, + threadName: '', + }, + ]; TabPaneNMSampleList.filterSelect = '0'; expect(tabPaneNMSampleList.filterAllList()).toBeUndefined(); }); it('TabPaneNMSampleListTest14', function () { - TabPaneNMSampleList.samplerInfoSource = [{ - current: '', - currentSize: 0, - startTs: 0, - heapSize: 0, - snapshot: '', - growth: '', - total: 0, - totalGrowth: '', - existing: 0, - children: samplerInfo, - tempList: samplerInfo, - timestamp: '', - eventId: -1, - threadId: 0, - threadName: '', - }] + TabPaneNMSampleList.samplerInfoSource = [ + { + current: '', + currentSize: 0, + startTs: 0, + heapSize: 0, + snapshot: '', + growth: '', + total: 0, + totalGrowth: '', + existing: 0, + children: samplerInfo, + tempList: samplerInfo, + timestamp: '', + eventId: -1, + threadId: 0, + threadName: '', + }, + ]; TabPaneNMSampleList.filterSelect = '1'; expect(tabPaneNMSampleList.filterAllList()).toBeUndefined(); }); it('TabPaneNMSampleListTest15', function () { - TabPaneNMSampleList.samplerInfoSource = [{ - current: '', - currentSize: 0, - startTs: 0, - heapSize: 0, - snapshot: '', - growth: '', - total: 0, - totalGrowth: '', - existing: 0, - children: [], - tempList: [], - timestamp: '', - eventId: -1, - threadId: 0, - threadName: '', - }] + TabPaneNMSampleList.samplerInfoSource = [ + { + current: '', + currentSize: 0, + startTs: 0, + heapSize: 0, + snapshot: '', + growth: '', + total: 0, + totalGrowth: '', + existing: 0, + children: [], + tempList: [], + timestamp: '', + eventId: -1, + threadId: 0, + threadName: '', + }, + ]; TabPaneNMSampleList.filterSelect = '1'; expect(tabPaneNMSampleList.filterAllList()).toBeUndefined(); }); it('TabPaneNMSampleListTest16', function () { - TabPaneNMSampleList.samplerInfoSource = [{ - current: '', - currentSize: 0, - startTs: 0, - heapSize: 0, - snapshot: '', - growth: '', - total: 0, - totalGrowth: '', - existing: 0, - children: samplerInfo, - tempList: samplerInfo, - timestamp: '', - eventId: -1, - threadId: 0, - threadName: '', - }] + TabPaneNMSampleList.samplerInfoSource = [ + { + current: '', + currentSize: 0, + startTs: 0, + heapSize: 0, + snapshot: '', + growth: '', + total: 0, + totalGrowth: '', + existing: 0, + children: samplerInfo, + tempList: samplerInfo, + timestamp: '', + eventId: -1, + threadId: 0, + threadName: '', + }, + ]; TabPaneNMSampleList.filterSelect = '2'; expect(tabPaneNMSampleList.filterAllList()).toBeUndefined(); }); it('TabPaneNMSampleListTest17', function () { - TabPaneNMSampleList.samplerInfoSource = [{ - current: '', - currentSize: 0, - startTs: 0, - heapSize: 0, - snapshot: '', - growth: '', - total: 0, - totalGrowth: '', - existing: 0, - children: [], - tempList: [], - timestamp: '', - eventId: -1, - threadId: 0, - threadName: '', - }] + TabPaneNMSampleList.samplerInfoSource = [ + { + current: '', + currentSize: 0, + startTs: 0, + heapSize: 0, + snapshot: '', + growth: '', + total: 0, + totalGrowth: '', + existing: 0, + children: [], + tempList: [], + timestamp: '', + eventId: -1, + threadId: 0, + threadName: '', + }, + ]; TabPaneNMSampleList.filterSelect = '2'; expect(tabPaneNMSampleList.filterAllList()).toBeUndefined(); }); - - }); diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.test.ts index 6bcd4d2f46b65a4b6ec84552e607b95a0cb31c86..232afac119a187b639e84ecae3244d60086497f1 100644 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.test.ts +++ b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.test.ts @@ -20,325 +20,361 @@ import { TabPaneNMStatisticAnalysis } from '../../../../../../dist/trace/compone import { LitTable } from '../../../../../../dist/base-ui/table/lit-table.js'; window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { - return { - - } + return {}; }); Object.defineProperty(global.self, 'crypto', { - value: { - getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), - }, + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, }); jest.mock('../../../../../../dist/base-ui/chart/pie/LitChartPie.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); describe('TabPaneNMStatisticAnalysis Test', () => { - let htmlDivElement = document.createElement('div'); - let tabStatisticAnalysis = new TabPaneNMStatisticAnalysis(); - tabStatisticAnalysis.tableType.reMeauseHeight = jest.fn(() => true); - tabStatisticAnalysis.soUsageTbl.reMeauseHeight = jest.fn(() => true); - tabStatisticAnalysis.functionUsageTbl.reMeauseHeight = jest.fn(() => true); - htmlDivElement.append(tabStatisticAnalysis); - let dataArray = { - applyCount: 25336, - applyCountPercent: '99', - applySize: 13372754, - applySizeFormat: '12.75MB', - applySizePercent: '25023.87', - existCount: 1011, - existCountPercent: '98.54', - existSize: 809825, - existSizeFormat: '790.84KB', - existSizePercent: '2.36', - releaseCount: 52168, - releaseCountPercent: '99.53', - releaseSize: 12562929, - releaseSizeFormat: '11.98MB', - releaseSizePercent: '1.79', - tableName: 'Test', - typeId: 0, - typeName: 'Test', - }; - let select = { - recordStartNs: 8406282873525, - leftNs: 16648778040, - rightNs: 48320174407, - hasFps: false, - nativeMemory: ['All Heap & Anonymous VM', 'All Heap'], - }; - let processData = [ - { - applyId: 22945, - callChainId: 91, - count: 1, - endTs: 4831690110, - id: 22945, - libId: 420, - libName: 'test.z.so', - pid: 1, - size: 304, - startTs: 4806916233, - symbolId: 429, - symbolName: 'test', - tid: 5211, - type: 0, - }, - ]; - tabStatisticAnalysis.processData = processData; - - it('statisticAnalysis01', function () { - tabStatisticAnalysis.initElements(); - tabStatisticAnalysis.data = select; - expect(tabStatisticAnalysis.currentSelection).toEqual(select); - }); + let htmlDivElement = document.createElement('div'); + let tabStatisticAnalysis = new TabPaneNMStatisticAnalysis(); + tabStatisticAnalysis.tableType.reMeauseHeight = jest.fn(() => true); + tabStatisticAnalysis.soUsageTbl.reMeauseHeight = jest.fn(() => true); + tabStatisticAnalysis.functionUsageTbl.reMeauseHeight = jest.fn(() => true); + htmlDivElement.append(tabStatisticAnalysis); + let dataArray = { + applyCount: 25336, + applyCountPercent: '99', + applySize: 13372754, + applySizeFormat: '12.75MB', + applySizePercent: '25023.87', + existCount: 1011, + existCountPercent: '98.54', + existSize: 809825, + existSizeFormat: '790.84KB', + existSizePercent: '2.36', + releaseCount: 52168, + releaseCountPercent: '99.53', + releaseSize: 12562929, + releaseSizeFormat: '11.98MB', + releaseSizePercent: '1.79', + tableName: 'Test', + typeId: 0, + typeName: 'Test', + }; + let select = { + recordStartNs: 8406282873525, + leftNs: 16648778040, + rightNs: 48320174407, + hasFps: false, + nativeMemory: ['All Heap & Anonymous VM', 'All Heap'], + }; + let processData = [ + { + applyId: 22945, + callChainId: 91, + count: 1, + endTs: 4831690110, + id: 22945, + libId: 420, + libName: 'test.z.so', + pid: 1, + size: 304, + startTs: 4806916233, + symbolId: 429, + symbolName: 'test', + tid: 5211, + type: 0, + }, + ]; + tabStatisticAnalysis.processData = processData; - it('statisticAnalysis02', function () { - tabStatisticAnalysis.tabName.textContent = 'Statistic By Library Size'; - tabStatisticAnalysis.eventTypeData = [dataArray]; - let mouseMoveEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); - tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); - tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); - }); + it('statisticAnalysis01', function () { + tabStatisticAnalysis.initElements(); + tabStatisticAnalysis.data = select; + expect(tabStatisticAnalysis.currentSelection).toEqual(select); + }); - it('statisticAnalysis03', function () { - tabStatisticAnalysis.getLibSize(dataArray, select); - expect(tabStatisticAnalysis.currentLevel).toEqual(1); - }); + it('statisticAnalysis02', function () { + tabStatisticAnalysis.tabName.textContent = 'Statistic By Library Size'; + tabStatisticAnalysis.eventTypeData = [dataArray]; + let mouseMoveEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); + tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); + tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); + }); - it('statisticAnalysis04', function () { - expect(tabStatisticAnalysis.getNMFunctionSize(dataArray, select)).toBeUndefined(); - }); + it('statisticAnalysis03', function () { + tabStatisticAnalysis.getLibSize(dataArray, select); + expect(tabStatisticAnalysis.currentLevel).toEqual(1); + }); - it('statisticAnalysis05', function () { - tabStatisticAnalysis.calTypeSize(select, processData); - expect(tabStatisticAnalysis.processData.length).toBe(1); - }); + it('statisticAnalysis04', function () { + expect(tabStatisticAnalysis.getNMFunctionSize(dataArray, select)).toBeUndefined(); + }); - it('statisticAnalysis06', function () { - let processData = [ - { - applyId: 22945, - callChainId: 91, - count: 1, - endTs: 4831690110, - id: 22945, - libId: 420, - libName: 'test.z.so', - pid: 1, - size: 304, - startTs: 4806916233, - symbolId: 429, - symbolName: 'test', - tid: 5211, - type: 1, - }, - ]; - tabStatisticAnalysis.calTypeSize(select, processData); - expect(tabStatisticAnalysis.currentLevelReleaseCount).toBe(0); - }); + it('statisticAnalysis05', function () { + tabStatisticAnalysis.calTypeSize(select, processData); + expect(tabStatisticAnalysis.processData.length).toBe(1); + }); - it('statisticAnalysis07', function () { - let processData = [ - { - applyId: 22945, - callChainId: 91, - count: 1, - endTs: 4831690110, - id: 22945, - libId: 420, - libName: 'test.z.so', - pid: 1, - size: 304, - startTs: 4806916233, - symbolId: 429, - symbolName: 'test', - tid: 5211, - type: 2, - }, - ]; - tabStatisticAnalysis.calTypeSize(select, processData); - expect(tabStatisticAnalysis.currentLevelApplySize).toBe(0); - }); + it('statisticAnalysis06', function () { + let processData = [ + { + applyId: 22945, + callChainId: 91, + count: 1, + endTs: 4831690110, + id: 22945, + libId: 420, + libName: 'test.z.so', + pid: 1, + size: 304, + startTs: 4806916233, + symbolId: 429, + symbolName: 'test', + tid: 5211, + type: 1, + }, + ]; + tabStatisticAnalysis.calTypeSize(select, processData); + expect(tabStatisticAnalysis.currentLevelReleaseCount).toBe(0); + }); - it('statisticAnalysis08', function () { - let processData = [ - { - applyId: 22945, - callChainId: 91, - count: 1, - endTs: 4831690110, - id: 22945, - libId: 420, - libName: 'test.z.so', - pid: 1, - size: 304, - startTs: 4806916233, - symbolId: 429, - symbolName: 'test', - tid: 5211, - type: 3, - }, - ]; - tabStatisticAnalysis.calTypeSize(select, processData); - expect(tabStatisticAnalysis.processData.length).toBe(1); - }); + it('statisticAnalysis07', function () { + let processData = [ + { + applyId: 22945, + callChainId: 91, + count: 1, + endTs: 4831690110, + id: 22945, + libId: 420, + libName: 'test.z.so', + pid: 1, + size: 304, + startTs: 4806916233, + symbolId: 429, + symbolName: 'test', + tid: 5211, + type: 2, + }, + ]; + tabStatisticAnalysis.calTypeSize(select, processData); + expect(tabStatisticAnalysis.currentLevelApplySize).toBe(0); + }); - it('statisticAnalysis09', function () { - tabStatisticAnalysis.currentLevel = 0; - tabStatisticAnalysis.sortByColumn('', 0); - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); - }); + it('statisticAnalysis08', function () { + let processData = [ + { + applyId: 22945, + callChainId: 91, + count: 1, + endTs: 4831690110, + id: 22945, + libId: 420, + libName: 'test.z.so', + pid: 1, + size: 304, + startTs: 4806916233, + symbolId: 429, + symbolName: 'test', + tid: 5211, + type: 3, + }, + ]; + tabStatisticAnalysis.calTypeSize(select, processData); + expect(tabStatisticAnalysis.processData.length).toBe(1); + }); - it('statisticAnalysis10', function () { - tabStatisticAnalysis.currentLevel = 1; - tabStatisticAnalysis.sortByColumn('', 0); - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); - }); + it('statisticAnalysis09', function () { + tabStatisticAnalysis.currentLevel = 0; + tabStatisticAnalysis.sortByColumn('', 0); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); + }); - it('statisticAnalysis11', function () { - tabStatisticAnalysis.currentLevel = 2; - tabStatisticAnalysis.sortByColumn('', 0); - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); - }); + it('statisticAnalysis10', function () { + tabStatisticAnalysis.currentLevel = 1; + tabStatisticAnalysis.sortByColumn('', 0); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); + }); - it('statisticAnalysis12', function () { - tabStatisticAnalysis.currentLevel = 0; - tabStatisticAnalysis.currentLevelData = [{ - tableName: 0 - }, { - tableName: 1 - }] - tabStatisticAnalysis.sortByColumn('tableName', 1) - tabStatisticAnalysis.currentLevelData = [{ - existSize: 0 - }, { - existSize: 1 - }] - tabStatisticAnalysis.sortByColumn('existSizeFormat', 1) - tabStatisticAnalysis.currentLevelData = [{ - existSize: 0 - }, { - existSize: 1 - }] - tabStatisticAnalysis.sortByColumn('existSizePercent', 1) - tabStatisticAnalysis.currentLevelData = [{ - existCount: 0 - }, { - existCount: 1 - }] - tabStatisticAnalysis.sortByColumn('existCount', 1) - tabStatisticAnalysis.currentLevelData = [{ - existCount: 0 - }, { - existCount: 1 - }] - tabStatisticAnalysis.sortByColumn('existCountPercent', 1) - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); - }); + it('statisticAnalysis11', function () { + tabStatisticAnalysis.currentLevel = 2; + tabStatisticAnalysis.sortByColumn('', 0); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(1); + }); - it('statisticAnalysis13', function () { - tabStatisticAnalysis.currentLevel = 1; - tabStatisticAnalysis.currentLevelData = [{ - releaseSize : 0 - }, { - releaseSize : 1 - }] - tabStatisticAnalysis.sortByColumn('releaseSizeFormat', 1) - tabStatisticAnalysis.currentLevelData = [{ - releaseSize : 0 - }, { - releaseSize : 1 - }] - tabStatisticAnalysis.sortByColumn('releaseSizePercent', 1) - tabStatisticAnalysis.currentLevelData = [{ - releaseCount : 0 - }, { - releaseCount : 1 - }] - tabStatisticAnalysis.sortByColumn('releaseCount', 1) - tabStatisticAnalysis.currentLevelData = [{ - releaseCount : 0 - }, { - releaseCount : 1 - }] - tabStatisticAnalysis.sortByColumn('releaseCountPercent', 1) - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); - }); + it('statisticAnalysis12', function () { + tabStatisticAnalysis.currentLevel = 0; + tabStatisticAnalysis.currentLevelData = [ + { + tableName: 0, + }, + { + tableName: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('tableName', 1); + tabStatisticAnalysis.currentLevelData = [ + { + existSize: 0, + }, + { + existSize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('existSizeFormat', 1); + tabStatisticAnalysis.currentLevelData = [ + { + existSize: 0, + }, + { + existSize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('existSizePercent', 1); + tabStatisticAnalysis.currentLevelData = [ + { + existCount: 0, + }, + { + existCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('existCount', 1); + tabStatisticAnalysis.currentLevelData = [ + { + existCount: 0, + }, + { + existCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('existCountPercent', 1); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); + }); - it('statisticAnalysis14', function () { - tabStatisticAnalysis.currentLevel = 2; - tabStatisticAnalysis.currentLevelData = [{ - applySize : 0 - }, { - applySize : 1 - }] - tabStatisticAnalysis.sortByColumn('applySizeFormat', 1) - tabStatisticAnalysis.currentLevelData = [{ - applySize : 0 - }, { - applySize : 1 - }] - tabStatisticAnalysis.sortByColumn('applySizePercent', 1) - tabStatisticAnalysis.currentLevelData = [{ - applyCount : 0 - }, { - applyCount : 1 - }] - tabStatisticAnalysis.sortByColumn('applyCount', 1) - tabStatisticAnalysis.currentLevelData = [{ - applyCount : 0 - }, { - applyCount : 1 - }] - tabStatisticAnalysis.sortByColumn('applyCountPercent', 1) - expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); - }); + it('statisticAnalysis13', function () { + tabStatisticAnalysis.currentLevel = 1; + tabStatisticAnalysis.currentLevelData = [ + { + releaseSize: 0, + }, + { + releaseSize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('releaseSizeFormat', 1); + tabStatisticAnalysis.currentLevelData = [ + { + releaseSize: 0, + }, + { + releaseSize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('releaseSizePercent', 1); + tabStatisticAnalysis.currentLevelData = [ + { + releaseCount: 0, + }, + { + releaseCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('releaseCount', 1); + tabStatisticAnalysis.currentLevelData = [ + { + releaseCount: 0, + }, + { + releaseCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('releaseCountPercent', 1); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); + }); - it('statisticAnalysis15', function () { - tabStatisticAnalysis.isStatistic = true; - let val = { - leftNs: 0, - rightNs: 1000, - nativeMemoryStatistic: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], - } - expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); - }); + it('statisticAnalysis14', function () { + tabStatisticAnalysis.currentLevel = 2; + tabStatisticAnalysis.currentLevelData = [ + { + applySize: 0, + }, + { + applySize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('applySizeFormat', 1); + tabStatisticAnalysis.currentLevelData = [ + { + applySize: 0, + }, + { + applySize: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('applySizePercent', 1); + tabStatisticAnalysis.currentLevelData = [ + { + applyCount: 0, + }, + { + applyCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('applyCount', 1); + tabStatisticAnalysis.currentLevelData = [ + { + applyCount: 0, + }, + { + applyCount: 1, + }, + ]; + tabStatisticAnalysis.sortByColumn('applyCountPercent', 1); + expect(tabStatisticAnalysis.tableType.recycleDataSource.length).toBe(3); + }); - it('statisticAnalysis16', function () { - tabStatisticAnalysis.isStatistic = false; - let val = { - leftNs: 0, - rightNs: 1000, - nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], - } - expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); - }); + it('statisticAnalysis15', function () { + tabStatisticAnalysis.isStatistic = true; + let val = { + leftNs: 0, + rightNs: 1000, + nativeMemoryStatistic: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], + }; + expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); + }); - it('statisticAnalysis17', function () { - tabStatisticAnalysis.tabName.textContent - let mouseMoveEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); - tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); + it('statisticAnalysis16', function () { + tabStatisticAnalysis.isStatistic = false; + let val = { + leftNs: 0, + rightNs: 1000, + nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], + }; + expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); + }); - tabStatisticAnalysis.isStatistic = false; - let val = { - leftNs: 0, - rightNs: 1000, - nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], - } - expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); - }); + it('statisticAnalysis17', function () { + tabStatisticAnalysis.tabName.textContent; + let mouseMoveEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); + tabStatisticAnalysis.back.dispatchEvent(mouseMoveEvent); + tabStatisticAnalysis.isStatistic = false; + let val = { + leftNs: 0, + rightNs: 1000, + nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'Heap'], + }; + expect(tabStatisticAnalysis.getNMEventTypeSize(val)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.test.ts index 63fa1f347df22f7f5a7c544649a53316e2e77c73..5fed27a67a4dc8f349f39a65156a5673173bbf7e 100644 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.test.ts +++ b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.test.ts @@ -31,7 +31,7 @@ window.ResizeObserver = })); jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {} + return {}; }); describe('TabPaneNMStatstics Test', () => { @@ -405,4 +405,24 @@ describe('TabPaneNMStatstics Test', () => { tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) ).toBeUndefined(); }); + it('TabPaneNMStatsticsTest11', function () { + tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); + tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + expect(tabPaneNMStatstics.sortByColumn('', 0)).toBeUndefined(); + }); + it('TabPaneNMStatsticsTest12', function () { + tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); + tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + expect(tabPaneNMStatstics.sortByColumn('existingString', 1)).toBeUndefined(); + }); + it('TabPaneNMStatsticsTest13', function () { + tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); + tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + expect(tabPaneNMStatstics.sortByColumn('allocCount', 1)).toBeUndefined(); + }); + it('TabPaneNMStatsticsTest14', function () { + tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); + tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + expect(tabPaneNMStatstics.sortByColumn('freeByteString', 1)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMemory.test.ts b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMemory.test.ts index 9484b4e4b3702429505cbdb220b4b55f98674a80..1f043a7c82a6f2545a2bd30b38696541177f857b 100644 --- a/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMemory.test.ts +++ b/ide/test/trace/component/trace/sheet/native-memory/TabPaneNMemory.test.ts @@ -13,10 +13,13 @@ * limitations under the License. */ -import crypto from "crypto"; +import crypto from 'crypto'; //@ts-ignore -import {TabPaneNMemory, initFilterTypes} from '../../../../../../dist/trace/component/trace/sheet/native-memory/TabPaneNMemory.js'; +import { + TabPaneNMemory, + initFilterTypes, +} from '../../../../../../dist/trace/component/trace/sheet/native-memory/TabPaneNMemory.js'; // @ts-ignore import { TabPaneNMSampleList } from '../../../../../../dist/trace/component/trace/sheet/native-memory/TabPaneNMSampleList.js'; @@ -25,12 +28,13 @@ jest.mock('../../../../../../dist/trace/database/SqlLite.js'); // @ts-ignore import { LitTable } from '../../../../../../dist/base-ui/table/lit-table.js'; // @ts-ignore -import {queryNativeHookEventTid, queryNativeHookSnapshotTypes} from '../../../../../../dist/trace/database/SqlLite.js'; - - +import { + queryNativeHookEventTid, + queryNativeHookSnapshotTypes, +} from '../../../../../../dist/trace/database/SqlLite.js'; jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {} + return {}; }); Object.defineProperty(global.self, 'crypto', { @@ -40,17 +44,16 @@ Object.defineProperty(global.self, 'crypto', { }); window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneNMemory Test', () => { - document.body.innerHTML = - `
`; - let tabPaneNMemory = new TabPaneNMemory() + document.body.innerHTML = `
`; + let tabPaneNMemory = new TabPaneNMemory(); let val = { statisticsSelectData: { memoryTap: 1, @@ -219,20 +222,20 @@ describe('TabPaneNMemory Test', () => { }; let queryNativeHookSnapshotTypes = sqlit.queryNativeHookSnapshotTypes; queryNativeHookSnapshotTypes.mockResolvedValue( - { event_type: 11, data: 111 }, - { - event_type: 222, - data: 142446, - } + { event_type: 11, data: 111 }, + { + event_type: 222, + data: 142446, + } ); let queryNativeHookEventTid = sqlit.queryNativeHookEventTid; queryNativeHookEventTid.mockResolvedValue( - { callchain_id: 1, event_type: '2', heap_size: 66 }, - { - callchain_id: 2, - event_type: '5', - heap_size: 666, - } + { callchain_id: 1, event_type: '2', heap_size: 66 }, + { + callchain_id: 2, + event_type: '5', + heap_size: 666, + } ); TabPaneNMSampleList.serSelection = jest.fn().mockResolvedValue({}); tabPaneNMemory.data = a; @@ -243,9 +246,9 @@ describe('TabPaneNMemory Test', () => { expect(tabPaneNMemory.fromStastics(val)).toBeUndefined(); }); it('TabPaneNMemoryTest19', function () { - expect(tabPaneNMemory.startWorker({},{})).toBeTruthy(); + expect(tabPaneNMemory.startWorker({}, {})).toBeTruthy(); }); it('TabPaneNMemoryTest20', function () { - expect(tabPaneNMemory.startWorker({},{})).toBeTruthy(); + expect(tabPaneNMemory.startWorker({}, {})).toBeTruthy(); }); }); diff --git a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..3454e92b0b165aae3608cd25bcef22ba5c8a2ce1 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts @@ -0,0 +1,97 @@ +/* + * 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 { + TabPaneSmapsComparison, + SmapsCompareStruct, +} from '../../../../../../dist/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.js'; +// @ts-ignore +import { Smaps, SmapsTreeObj } from '../../../../../../dist/trace/bean/SmapsStruct.js'; +const sqlit = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); + +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); + +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneSmapsStatistics Test', () => { + let MockgetTabSmapsData = sqlit.getTabSmapsStatisticData; + let smaps = new Smaps(); + smaps.tsNS = -1; + smaps.start_addr = 'aaaaa'; + smaps.end_addr = 'bbbbb'; + smaps.permission = 'dddd'; + smaps.path = '/asdasdas'; + smaps.size = 0; + smaps.rss = 0; + smaps.pss = 0; + smaps.reside = 0; + smaps.dirty = 0; + smaps.swapper = 0; + smaps.address = 'aaaaa-bbbbb'; + smaps.type = '1'; + smaps.dirtyStr = '1212'; + smaps.swapperStr = '222'; + smaps.rssStr = '333'; + smaps.pssStr = '444'; + smaps.sizeStr = '555'; + smaps.resideStr = '666'; + smaps.pss = 2; + let result = [smaps, smaps]; + MockgetTabSmapsData.mockResolvedValue([smaps]); + let tabPaneSmapsComparison = new TabPaneSmapsComparison(); + it('TabPaneSmapsStatistics01', () => { + let result = [ + { + name: 'Snapshot1', + startNs: 4778214061, + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + value: 0, + }, + ]; + expect(tabPaneSmapsComparison.initSelect(result, datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts index 51d687f604ca517c62b3734a68f3ac2f13c5ace5..0148680ea49d4f7ef78e39d0974027a66752c204 100644 --- a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts @@ -17,7 +17,9 @@ import { TabPaneSmapsStatistics } from '../../../../../../dist/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.js'; // @ts-ignore import { Smaps, SmapsTreeObj } from '../../../../../../dist/trace/bean/SmapsStruct.js'; - +jest.mock('../../../../../../dist/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.js', () => { + return {}; +}); const sqlit = require('../../../../../../dist/trace/database/SqlLite.js'); jest.mock('../../../../../../dist/trace/database/SqlLite.js'); jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { @@ -65,7 +67,7 @@ describe('TabPaneSmapsStatistics Test', () => { smaps.dirty = 0; smaps.swapper = 0; smaps.address = 'aaaaa-bbbbb'; - smaps.type = 'Dta'; + smaps.type = '1'; smaps.dirtyStr = '1212'; smaps.swapperStr = '222'; smaps.rssStr = '333'; @@ -81,7 +83,7 @@ describe('TabPaneSmapsStatistics Test', () => { it('TabPaneSmapsStatisticsTest01', () => { tabPaneSmapsStatistics.handleSmapsTreeObj(dataTree, 2); - expect(dataTree.rsspro).toBe(0); + expect(dataTree.rsspro).toBeUndefined(); }); it('TabPaneSmapsStatisticsTest02', () => { @@ -93,40 +95,11 @@ describe('TabPaneSmapsStatistics Test', () => { tabPaneSmapsStatistics.handleTree(smaps, 0, 'TEXT', dataTree, 4); expect(dataTree.pss).toBe(2); }); - it('TabPaneSmapsStatisticsTest04', () => { - expect(tabPaneSmapsStatistics.sortByColumn('sizeStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest05', () => { - expect(tabPaneSmapsStatistics.sortByColumn('', 0)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest06', () => { - expect(tabPaneSmapsStatistics.sortByColumn('count', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest07', () => { - expect(tabPaneSmapsStatistics.sortByColumn('rssStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest08', () => { - expect(tabPaneSmapsStatistics.sortByColumn('typeName', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest09', () => { - expect(tabPaneSmapsStatistics.sortByColumn('pssStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest10', () => { - expect(tabPaneSmapsStatistics.sortByColumn('sharedCleanStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest11', () => { - expect(tabPaneSmapsStatistics.sortByColumn('sharedDirtyStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest12', () => { - expect(tabPaneSmapsStatistics.sortByColumn('privateCleanStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest13', () => { - expect(tabPaneSmapsStatistics.sortByColumn('privateDirtyStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest14', () => { - expect(tabPaneSmapsStatistics.sortByColumn('swapStr', 1)).toBeUndefined(); - }); - it('TabPaneSmapsStatisticsTest15', () => { - expect(tabPaneSmapsStatistics.sortByColumn('swapPssStr', 1)).toBeUndefined(); + it('TabPaneSmapsStatisticsTest1', () => { + tabPaneSmapsStatistics.tblSmapsStatistics.reMeauseHeight = jest.fn(() => true); + let result = [smaps, smaps]; + expect( + tabPaneSmapsStatistics.filteredData(result, tabPaneSmapsStatistics.tblSmapsStatistics, 1000) + ).toBeUndefined(); }); }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts index 6b9e574a27490c5e84c35480b437c49308e9128f..915cadf3645868b37fc0f7140cdb43767d38eed4 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts @@ -19,84 +19,85 @@ import { TabPaneDmaSelectVmTracker } from '../../../../../../dist/trace/componen jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { - return {}; + 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(), - })); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneDmaSelectVmTracker Test', () => { - let tabPaneDmaSelectVmTracker = new TabPaneDmaSelectVmTracker(); - let val = [ - { - leftNs: 0, - rightNs: 1000, - startNs:0, - }, - ]; - let dmaSelectionData = sqlite.getTabDmaVMTrackerClickData; - let selectiondata = [ - { - startNs: 0, - fd: 1, - size: 100, - ino: 0, - expPid: 0, - bufName: 'aaa', - expName: 'aaa', - expTaskComm:'bb', - flag:1, - }, - ]; - dmaSelectionData.mockResolvedValue(selectiondata); - it('TabPaneDmaSelectVmTracker01', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('', 0)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker02', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('startNs', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker03', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expTaskComm', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker04', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('fd', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker05', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('size', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker06', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('ino', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker07', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expPid', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker08', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('flag', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker09', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('bufName', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker10', () => { - expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expName', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker11', () => { - expect(tabPaneDmaSelectVmTracker.queryDataByDB(val)).toBeUndefined(); - }); -}) \ No newline at end of file + let tabPaneDmaSelectVmTracker = new TabPaneDmaSelectVmTracker(); + let val = [ + { + leftNs: 0, + rightNs: 1000, + startNs: 0, + }, + ]; + let dmaSelectionData = sqlite.getTabDmaVMTrackerClickData; + let selectiondata = [ + { + startNs: 0, + fd: 1, + size: 100, + ino: 0, + expPid: 0, + bufName: 'aaa', + expName: 'aaa', + expTaskComm: 'bb', + flag: 1, + }, + ]; + dmaSelectionData.mockResolvedValue(selectiondata); + it('TabPaneDmaSelectVmTracker01', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('', 0)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker02', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('startNs', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker03', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expTaskComm', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker04', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('fd', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker05', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('size', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker06', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('ino', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker07', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expPid', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker08', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('flag', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker09', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('bufName', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker10', () => { + expect(tabPaneDmaSelectVmTracker.sortDmaByColumn('expName', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker11', () => { + tabPaneDmaSelectVmTracker.init = jest.fn(() => true); + expect(tabPaneDmaSelectVmTracker.queryDmaVmTrackerClickDataByDB(val)).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 5185d8ec262b3a463ea5789fcd2be7b792a14d17..da41104c731e5d869672092dafa537172d46eac6 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts @@ -19,63 +19,63 @@ import { TabPaneDmaVmTracker } from '../../../../../../dist/trace/component/trac jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { - return {}; + 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(), - })); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneDmaSelectVmTracker Test', () => { - let dmaVmTracker = new TabPaneDmaVmTracker(); - let val = [ - { - leftNs: 0, - rightNs: 1000, - startNs:0, - }, - ]; - let dmaData = sqlite.getTabDmaVmTrackerData; - let data = [ - { - startNs: 0, - expTaskComm: 'aaa', - sumSize: 100, - maxSize: 100, - minSize: 10, - avgSize: 'aaa', - }, - ]; - dmaData.mockResolvedValue(data); - it('TabPaneDmaSelectVmTracker01', () => { - expect(dmaVmTracker.sortDmaByColumn('', 0)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker05', () => { - expect(dmaVmTracker.sortDmaByColumn('avgSize', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker06', () => { - expect(dmaVmTracker.sortDmaByColumn('minSize', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker07', () => { - expect(dmaVmTracker.sortDmaByColumn('maxSize', 1)).toBeUndefined(); - }); - it('TabPaneDmaSelectVmTracker08', () => { - expect(dmaVmTracker.queryDataByDB(val)).toBeUndefined(); - }); -}) \ No newline at end of file + let dmaVmTracker = new TabPaneDmaVmTracker(); + let val = [ + { + leftNs: 0, + rightNs: 1000, + startNs: 0, + }, + ]; + let dmaData = sqlite.getTabDmaVmTrackerData; + let data = [ + { + startNs: 0, + expTaskComm: 'aaa', + sumSize: 100, + maxSize: 100, + minSize: 10, + avgSize: 'aaa', + }, + ]; + dmaData.mockResolvedValue(data); + it('TabPaneDmaSelectVmTracker01', () => { + expect(dmaVmTracker.sortDmaByColumn('', 0)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker05', () => { + expect(dmaVmTracker.sortDmaByColumn('avgSize', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker06', () => { + expect(dmaVmTracker.sortDmaByColumn('minSize', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker07', () => { + expect(dmaVmTracker.sortDmaByColumn('maxSize', 1)).toBeUndefined(); + }); + it('TabPaneDmaSelectVmTracker08', () => { + expect(dmaVmTracker.queryDataByDB(val)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..be6d332e54c79141498b77e9e5aef9f2558cce15 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.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 { TabPaneDmaVmTrackerComparison } from '../../../../../../dist/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); + +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneDmaVmTrackerComparison Test', () => { + let tabPaneDmaVmTrackerComparison = new TabPaneDmaVmTrackerComparison(); + let getTabDmaVmTrackerComparisonData = sqlite.getTabDmaVmTrackerComparisonData; + let dmaVmTrackerData = [ + { + startNs: 0, + value: 100, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'VmTracker', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'VmTracker', + value: 0, + }, + ]; + tabPaneDmaVmTrackerComparison.init = jest.fn(() => true); + getTabDmaVmTrackerComparisonData.mockResolvedValue(dmaVmTrackerData); + it('TabPaneDmaVmTrackerComparison01', function () { + expect(tabPaneDmaVmTrackerComparison.queryDataByDB(10)).toBeTruthy(); + }); + it('TabPaneDmaVmTrackerComparison03', function () { + expect(tabPaneDmaVmTrackerComparison.comparisonDataByDB(10, datalist)).toBeTruthy(); + }); + it('TabPaneDmaVmTrackerComparison04', function () { + expect(tabPaneDmaVmTrackerComparison.selectStamps(datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts index 9a980afd64f3c89a61400563744e117048b7e108..5f6cc16950694ab14da7efca2baec1a0303998c9 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts @@ -19,60 +19,61 @@ import { TabPaneGpuMemorySelectVmTracker } from '../../../../../../dist/trace/co jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; + return {}; }); jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { - return {}; + 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(), - })); + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('TabPaneGpuMemorySelectVmTracker Test', () => { - let tabPaneGpuMemorySelectVmTracker = new TabPaneGpuMemorySelectVmTracker(); - let val = [ - { - leftNs: 0, - rightNs: 1000, - }, - ]; - let gpuMemoryVMData = sqlite.getTabGpuMemoryVMTrackerClickData; - let gpuVMData = [ - { - startNs: 0, - size: 1, - threadId: 1, - threadName: 'bb', - gpuName: 'aa', - }, - ]; - gpuMemoryVMData.mockResolvedValue(gpuVMData); - it('TabPaneGpuMemorySelectVmTracker01', () => { - expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('', 0)).toBeUndefined(); - }); - it('TabPaneGpuMemorySelectVmTracker02', () => { - expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('startNs', 1)).toBeUndefined(); - }); - it('TabPaneGpuMemorySelectVmTracker03', () => { - expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('gpuName', 1)).toBeUndefined(); - }); - it('TabPaneGpuMemorySelectVmTracker04', () => { - expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('size', 1)).toBeUndefined(); - }); - it('TabPaneGpuMemorySelectVmTracker05', () => { - expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('thread', 1)).toBeUndefined(); - }); - it('TabPaneGpuMemorySelectVmTracker06', () => { - expect(tabPaneGpuMemorySelectVmTracker.queryDataByDB(val)).toBeUndefined(); - }); -}) \ No newline at end of file + let tabPaneGpuMemorySelectVmTracker = new TabPaneGpuMemorySelectVmTracker(); + let val = [ + { + leftNs: 0, + rightNs: 1000, + }, + ]; + let gpuMemoryVMData = sqlite.getTabGpuMemoryVMTrackerClickData; + let gpuVMData = [ + { + startNs: 0, + size: 1, + threadId: 1, + threadName: 'bb', + gpuName: 'aa', + }, + ]; + gpuMemoryVMData.mockResolvedValue(gpuVMData); + it('TabPaneGpuMemorySelectVmTracker01', () => { + expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('', 0)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectVmTracker02', () => { + expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('startNs', 1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectVmTracker03', () => { + expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('gpuName', 1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectVmTracker04', () => { + expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('size', 1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectVmTracker05', () => { + expect(tabPaneGpuMemorySelectVmTracker.sortGpuMemoryByColumn('thread', 1)).toBeUndefined(); + }); + it('TabPaneGpuMemorySelectVmTracker06', () => { + tabPaneGpuMemorySelectVmTracker.init = jest.fn(() => true); + expect(tabPaneGpuMemorySelectVmTracker.queryGpuMemoryVmTrackerClickDataByDB(val)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..521ef27f1a89780157317bda256058e9d9b5f927 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts @@ -0,0 +1,75 @@ +/* + * 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 { TabPaneGpuMemoryVmTrackerComparison } from '../../../../../../dist/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPaneGpuMemoryVmTrackerComparison Test', () => { + let tabPaneGpuMemoryVmTrackerComparison = new TabPaneGpuMemoryVmTrackerComparison(); + let getTabGpuMemoryVmTrackerComparisonData = sqlite.getTabGpuMemoryVmTrackerComparisonData; + let gpuMemoryVmTrackerData = [ + { + startNs: 0, + value: 100, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'VmTracker', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'VmTracker', + value: 0, + }, + ]; + tabPaneGpuMemoryVmTrackerComparison.init = jest.fn(() => true); + getTabGpuMemoryVmTrackerComparisonData.mockResolvedValue(gpuMemoryVmTrackerData); + it('TabPaneGpuMemoryVmTrackerComparison01', function () { + expect(tabPaneGpuMemoryVmTrackerComparison.queryDataByDB(10)).toBeTruthy(); + }); + it('TabPaneGpuMemoryVmTrackerComparison02', function () { + expect(tabPaneGpuMemoryVmTrackerComparison.getComparisonData(10)).toBeTruthy(); + }); + it('TabPaneGpuMemoryVmTrackerComparison03', function () { + expect(tabPaneGpuMemoryVmTrackerComparison.comparisonDataByDB(10, datalist)).toBeTruthy(); + }); + it('TabPaneGpuMemoryVmTrackerComparison04', function () { + expect(tabPaneGpuMemoryVmTrackerComparison.selectStamps(datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..abe5b570a41b74d177f72cb2b4d3b4432b55b17c --- /dev/null +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.test.ts @@ -0,0 +1,88 @@ +/* + * 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 { TabPanePurgPinComparisonVM } from '../../../../../../dist/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.js'; +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPanePurgPinComparisonVM Test', () => { + let tabPanePurgPinComparisonVM = new TabPanePurgPinComparisonVM(); + let queryProcessPurgeableSelectionTab = sqlite.queryProcessPurgeableSelectionTab; + queryProcessPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + ]); + let data = [ + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPanePurgPinComparisonVM.init = jest.fn(() => true); + it('TabPanePurgPinComparisonVM01', function () { + expect(tabPanePurgPinComparisonVM.updateComparisonData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgPinComparisonVM02', function () { + expect(tabPanePurgPinComparisonVM.queryPinVMData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgPinComparisonVM03', function () { + tabPanePurgPinComparisonVM.initSelect = jest.fn(() => true); + expect(tabPanePurgPinComparisonVM.totalData(data, datalist)).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8aa8849ff64bbb3d51c893cc97c1ae7e2bc74d3b --- /dev/null +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts @@ -0,0 +1,90 @@ +/* + * 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 { TabPanePurgTotalComparisonVM } from '../../../../../../dist/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.js'; +import '../../../../../../dist/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.js'; + +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +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('TabPanePurgTotalComparisonVM Test', () => { + let tabPanePurgTotalComparisonVM = new TabPanePurgTotalComparisonVM(); + let queryProcessPurgeableSelectionTab = sqlite.queryProcessPurgeableSelectionTab; + queryProcessPurgeableSelectionTab.mockResolvedValue([ + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + { + value: 25165824, + name: '24.00MB', + }, + ]); + let data = [ + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + type: 'ability', + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + type: 'ability', + value: 0, + }, + ]; + tabPanePurgTotalComparisonVM.init = jest.fn(() => true); + it('TabPanePurgPinComparisonAbility01', function () { + tabPanePurgTotalComparisonVM.initSelect = jest.fn(() => true); + expect(tabPanePurgTotalComparisonVM.totalData(data, datalist)).toBeUndefined(); + }); + it('TabPanePurgTotalComparisonVM01', function () { + expect(tabPanePurgTotalComparisonVM.updateComparisonData(0, 1000)).toBeTruthy(); + }); + it('TabPanePurgTotalComparisonVM02', function () { + expect(tabPanePurgTotalComparisonVM.queryTotalVMData(0, 1000)).toBeTruthy(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts index fb53c7a7190f83986448516607382653d5cb335e..65f0de64cee715945269dfec676e602d2b59a626 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts @@ -61,7 +61,7 @@ describe('TabPaneVmTrackerShm Test', () => { let val = [ { leftNs: 0, - rightNs: 1000 + rightNs: 1000, }, ]; it('TabPaneVmTrackerShm01', () => { diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..eac5f4865b5f6561b7cf3ffbe2f6dad2d72a50b3 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts @@ -0,0 +1,95 @@ +/* + * 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 { TabPaneVmTrackerShmComparison } from '../../../../../../dist/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.js'; + +const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/trace/database/SqlLite.js'); +jest.mock('../../../../../../dist/base-ui/select/LitSelect.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/base-ui/table/lit-table.js', () => { + return { + snapshotDataSource: () => {}, + removeAttribute: () => {}, + }; +}); +jest.mock('../../../../../../dist/js-heap/model/DatabaseStruct.js', () => {}); +jest.mock('../../../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return {}; +}); +jest.mock('../../../../../../dist/trace/database/ui-worker/ProcedureWorkerCommon.js', () => { + return { + ns2s: () => {}, + }; +}); +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneVmTrackerShmComparison Test', () => { + let tabPaneVmTrackerShmComparison = new TabPaneVmTrackerShmComparison(); + let getVmTrackerShmSelectionData = sqlite.queryVmTrackerShmSelectionData; + getVmTrackerShmSelectionData.mockResolvedValue([ + { + startNS: 25165824, + ipid: 1, + fd: 2, + size: 1000, + adj: 10, + name: 1, + id: 4, + time: 2, + purged: 20, + count: 2, + flag: 0, + }, + ]); + let data = [ + { + name: 'Snapshot1', + startNs: 4778214061, + value: 0, + }, + ]; + let datalist = [ + { + name: 'Snapshot2', + startNs: 9800526561, + value: 0, + }, + { + name: 'Snapshot1', + startNs: 4778214061, + value: 0, + }, + ]; + tabPaneVmTrackerShmComparison.init = jest.fn(() => true); + it('TabPaneVmTrackerShmComparison01', function () { + tabPaneVmTrackerShmComparison.initSelect = jest.fn(() => true); + expect(tabPaneVmTrackerShmComparison.setShmData(data, datalist)).toBeUndefined(); + }); + it('TabPaneVmTrackerShmComparison02', function () { + expect(tabPaneVmTrackerShmComparison.updateComparisonData(0, 10)).toBeTruthy(); + }); + it('TabPaneVmTrackerShmComparison03', function () { + expect(tabPaneVmTrackerShmComparison.calSizeObj(data, datalist)).toBeTruthy(); + }); +}); 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 76848fb68d374d80404e73e3a713a91d82e20bec..1c88d8a53a5bdfd847d22fe2e9e2507a0d3600f6 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts @@ -39,7 +39,8 @@ 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(), @@ -53,33 +54,33 @@ describe('TabPaneVmTrackerShmSelection Test', () => { queryVmTrackerShmSelectionData.mockResolvedValue([ { startNs: 0, - ipid:1, - fd:123, - size:12, + ipid: 1, + fd: 123, + size: 12, adj: 3, - name:'NAME', - id:1, - time:12333, - purged:6, - count:3, - flag:0 - } - ]) + name: 'NAME', + id: 1, + time: 12333, + purged: 6, + count: 3, + flag: 0, + }, + ]); let data = { startNs: 0, endNs: 0, - dur:0, - name:'', + dur: 0, + name: '', textWidth: 0, value: 0, type: '', - } + }; let dataList = [ { startNs: 0, endNs: 0, - dur:0, - name:'', + dur: 0, + name: '', textWidth: 0, value: 0, type: '', @@ -87,13 +88,13 @@ describe('TabPaneVmTrackerShmSelection Test', () => { { startNs: 1, endNs: 2, - dur:1, - name:'a', + dur: 1, + name: 'a', textWidth: 0, value: 0, type: 'a', - } - ] + }, + ]; it('TabPaneVmTrackerShmSelection01', () => { expect(tabPaneVmTrackerShmSelection.sortByColumn('ts', 1)).toBeUndefined(); }); @@ -134,7 +135,7 @@ describe('TabPaneVmTrackerShmSelection Test', () => { tabPaneVmTrackerShmSelection.init = jest.fn(() => true); tabPaneVmTrackerShmSelection.clear = jest.fn(() => true); tabPaneVmTrackerShmSelection.queryDataByDB = jest.fn(() => true); - expect(tabPaneVmTrackerShmSelection.setShmData(data,dataList)).toBeUndefined(); + expect(tabPaneVmTrackerShmSelection.setShmData(data, dataList)).toBeUndefined(); }); it('TabPaneVmTrackerShmSelection14', () => { expect(tabPaneVmTrackerShmSelection.queryDataByDB(data)).toBe(true); diff --git a/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts b/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts index c9929ff3cb2c3f10ed675955ab4898e3c9f6a0d2..1419db5143713df9e45f53ca4fb30dc64f1ab6e4 100644 --- a/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts @@ -25,7 +25,9 @@ jest.mock('../../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () }); jest.mock('../../../../../dist/trace/component/SpSystemTrace.js', () => { - return {}; + return { + CurrentSlicesTime:() => {}, + }; }); // @ts-ignore diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts index 48b702cc4ef02718b3b2428315827450e1fd2f59..cf49ed5db6c5fbce1af18637cb2a4f213e2c5171 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts @@ -23,6 +23,7 @@ import { FileMerageBean, IoCompletionTimes, VirtualMemoryEvent, + FileAnalysisSample, //@ts-ignore } from '../../../../dist/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.js'; @@ -416,4 +417,84 @@ describe('ProcedureLogicWorkerFileSystem Test', () => { let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem (); expect(procedureLogicWorkerFileSystem.queryIOEvents(1,0,[1])).toBeUndefined(); }); + it('procedureLogicWorkerFileSystemTest51', function () { + let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem(); + window.postMessage = jest.fn(() => true); + let data = { + type: 'fileSystem-queryIoSamples', + params: { + list: [], + }, + }; + expect(procedureLogicWorkerF.handle(data)).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest52', function () { + window.postMessage = jest.fn(() => true); + let data = { + type: 'fileSystem-queryVirtualMemorySamples', + params: { + list: [], + }, + }; + expect(procedureLogicWorkerF.handle(data)).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest53', function () { + window.postMessage = jest.fn(() => true); + let data = { + type: 'fileSystem-queryVMEvents', + params: { + list: [], + }, + }; + expect(procedureLogicWorkerF.handle(data)).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest54', function () { + window.postMessage = jest.fn(() => true); + let data = { + type: 'fileSystem-queryIOEvents', + params: { + list: [], + }, + }; + expect(procedureLogicWorkerF.handle(data)).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest55', function () { + let procedureLogicWorkerFileSystem = new ProcedureLogicWorkerFileSystem (); + expect(procedureLogicWorkerFileSystem.clearAll()).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest56', function () { + let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem'); + let selectionParam = { + diskIOipids: { + length: 1, + join: jest.fn(() => true), + }, + fileSystemType: { + length: 1, + join: jest.fn(() => true), + }, + }; + window.postMessage = jest.fn(() => true); + expect(handlerMap.queryCallChainsSamples(selectionParam)).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest57', function () { + let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem'); + window.postMessage = jest.fn(() => true); + expect(handlerMap.clear()).toBeUndefined(); + }); + it('procedureLogicWorkerFileSystemTest59', function () { + let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem'); + let selectionParam = { + diskIOipids: { + length: 1, + join: jest.fn(() => true), + }, + fileSystemType: { + length: 1, + join: jest.fn(() => true), + }, + }; + window.postMessage = jest.fn(() => true); + expect(handlerMap.queryPageFaultSamples(selectionParam)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts index cb7163a3316b012bb2078afa64b52714b365105a..4045564ed5b9d9307fcb92f3a729f1d9ae90d135 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts @@ -17,46 +17,57 @@ import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.j // @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'; - +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 {}; + 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('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(); - }); + it('AppStartupStructTest02', () => { + expect(AppStartupStruct.getStartupName(12)).toBe('Unknown Start Step'); + }); + it('AppStartupStructTest03', () => { + expect(AppStartupStruct).not.toBeUndefined(); + }); + it('AppStartupStructTest04', () => { + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + let appStartupRender = new AppStartupRender(); + expect(appStartupRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts index 50f4259d60149e8a8c1a63621c13e37fdeb8a1d5..733ec200b59a185c70d3bd8fdeb03bde03c7ceff 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; -}); +// @ts-ignore +import {TraceRow} from "../../../../dist/trace/component/trace/base/TraceRow.js"; + // @ts-ignore import { @@ -28,6 +28,10 @@ import { // @ts-ignore import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; +jest.mock('../../../../dist/trace/component/trace/timer-shaft/RangeRuler.js', () => { + return { + }; +}); jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); @@ -211,8 +215,16 @@ describe(' Test', () => { width: 100, height: 100, }, - canvas: '', - context: {}, + canvas: 'a', + context: { + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + }, lineColor: '', isHover: '', hoverX: 1, @@ -249,11 +261,18 @@ describe(' Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -272,4 +291,17 @@ describe(' Test', () => { window.postMessage = jest.fn(() => true); expect(cpuRender.render(req, [], [])).toBeUndefined(); }); + it('CPUTest12', function () { + let emptyRender = new EmptyRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(emptyRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts index fd6c170b2efda0015944d6d64315f84d07435c06..47383831594c69de73a631c97a863a7136b5b7db 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts @@ -13,12 +13,14 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore -import { ClockStruct } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerClock.js'; +import { ClockStruct, ClockRender } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerClock.js'; describe('ProcedureWorkerClock Test', () => { it('ProcedureWorkerClock01', () => { @@ -42,4 +44,16 @@ describe('ProcedureWorkerClock Test', () => { }; expect(ClockStruct.draw(ctx!, data, 2)).toBeUndefined(); }); + it('ProcedureWorkerClock02', () => { + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + let clockRender = new ClockRender(); + expect(clockRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts index c156d9b49f63e0ef66dacde82aa79ba14d3745aa..6192a10045f8ace51e4430eac8a51dd8897b8e68 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts @@ -15,7 +15,11 @@ jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorkerCPU.js', () => {}); jest.mock('../../../../dist/trace/component/trace/base/TraceSheet.js', () => {}); -jest.mock('../../../../dist/trace/component/SpSystemTrace.js', () => {}); +jest.mock('../../../../dist/trace/component/SpSystemTrace.js', () => { + return { + CurrentSlicesTime: () => {}, + }; +}); // @ts-ignore import { ChartStruct, @@ -143,7 +147,7 @@ describe('ProcedureWorkerCommon Test', () => { useCache: true, }; - document.body.innerHTML = ''; + document.body.innerHTML = ''; let timerShaftElement = document.querySelector('#timerShaftEL') as TimerShaftElement; timerShaftElement.totalNS = 1000; timerShaftElement.startNS = 1000; @@ -410,23 +414,29 @@ describe('ProcedureWorkerCommon Test', () => { { startTime: 11, endTime: 22, - color: '#dadada' + color: '#dadada', }, { startTime: 33, endTime: 66, - color: '#dadada' + color: '#dadada', }, - ] - } + ], + }, }; expect( - drawFlagLineSegment(ctx, hoverFlag, selectFlag, { - y: 5, - height: 30, - x: 1, - width: 3, - }, data) + drawFlagLineSegment( + ctx, + hoverFlag, + selectFlag, + { + y: 5, + height: 30, + x: 1, + width: 3, + }, + data + ) ).toBeUndefined(); }); @@ -456,32 +466,4 @@ describe('ProcedureWorkerCommon Test', () => { }; expect(drawSelectionRange(context, params)).toBeUndefined(); }); - - it('ProcedureWorkerCommon36', function () { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const context = canvas.getContext('2d'); - let nodes = [ - [ - { - isRight: true, - ns: 1075112000, - offsetY: 30, - rowEL: null, - x: 303.29713978126495, - y: 190, - }, - { - isRight: true, - ns: 5255566, - offsetY: 52, - rowEL: null, - x: 235, - y: 525, - }, - ], - ]; - expect(drawLinkLines(context, nodes, timerShaftElement)).toBeUndefined(); - }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts index ec0713332c9732c4945d16a8c1d89069303dc543..687c242ee2dc77bdebf1162f4b7249024ad73ff6 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts @@ -13,7 +13,9 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); // @ts-ignore @@ -127,4 +129,17 @@ describe('CpuAbilityMonitorStruct Test', () => { window.postMessage = jest.fn(() => true); expect(cpuAbilityRender.render(req, [], [])).toBeUndefined(); }); + it('CpuAbilityMonitorStructTest07', function () { + let cpuAbilityRender = new CpuAbilityRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(cpuAbilityRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts index 769f84cd3a349db6b776965ffbbe96e4b9618941..d5ce22c1bf1a9f5e0051b825a7afc50b7b9b67dd 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts @@ -13,10 +13,12 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore import { CpuFreqLimitRender, @@ -101,8 +103,16 @@ describe('ProcedureWorkerCpuFreqLimits Test', () => { width: 100, height: 100, }, - canvas: '', - context: {}, + canvas: 'a', + context: { + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + }, lineColor: '', isHover: '', hoverX: 1, @@ -120,4 +130,17 @@ describe('ProcedureWorkerCpuFreqLimits Test', () => { window.postMessage = jest.fn(() => true); expect(cpuFreqLimitRender.render(req, [], [])).toBeUndefined(); }); + it('Test05', function () { + let cpuFreqLimitRender = new CpuFreqLimitRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(cpuFreqLimitRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts index d8c84307896c2db0078e3360b625aa30acd800f1..e0036e334ebb2e18739d974eb0530470d3a29a33 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts @@ -17,100 +17,104 @@ import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.j // @ts-ignore import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; // @ts-ignore -import { jsCpuProfiler, JsCpuProfilerRender, JsCpuProfilerStruct} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCpuProfiler.js'; +import { + jsCpuProfiler, + JsCpuProfilerRender, + JsCpuProfilerStruct, +} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCpuProfiler.js'; jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + return {}; }); describe('ProcedureWorkerCpuProfiler Test', () => { - let jsCpuProfilerRender = new JsCpuProfilerRender(); + let jsCpuProfilerRender = new JsCpuProfilerRender(); + let traceRow = new TraceRow(); + traceRow.frame = { height: 40, width: 1407, x: 0, y: 0 }; + it('jsCpuProfilerTest', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); let traceRow = new TraceRow(); traceRow.frame = { height: 40, width: 1407, x: 0, y: 0 }; - it('jsCpuProfilerTest', () => { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - let traceRow = new TraceRow(); - traceRow.frame = { height: 40, width: 1407, x: 0, y: 0 }; - let rect = new Rect(0, 10, 10, 10); - let filter = [ - { - startTime: 50, - endTime: 1520000, - name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 40 }, - id: 0, - depth: 1, - selfTime: 0, - url:'', - totalTime: 88473061693464, - parentId: 123, - children:[], - isSelect: true, - }, - ]; - let list = [ - { - startTime: 50, - endTime: 1520000, - name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 40 }, - id: 0, - depth: 1, - selfTime: 0, - url:'', - totalTime: 88473061693464, - parentId: 123, - children:[], - isSelect: true, - }, - ]; - jsCpuProfiler(list, filter, 100254, 100254, rect, traceRow.frame,true); - }); + let rect = new Rect(0, 10, 10, 10); + let filter = [ + { + startTime: 50, + endTime: 1520000, + name: 'Snapshot0', + frame: { x: 0, y: 0, width: 25, height: 40 }, + id: 0, + depth: 1, + selfTime: 0, + url: '', + totalTime: 88473061693464, + parentId: 123, + children: [], + isSelect: true, + }, + ]; + let list = [ + { + startTime: 50, + endTime: 1520000, + name: 'Snapshot0', + frame: { x: 0, y: 0, width: 25, height: 40 }, + id: 0, + depth: 1, + selfTime: 0, + url: '', + totalTime: 88473061693464, + parentId: 123, + children: [], + isSelect: true, + }, + ]; + jsCpuProfiler(list, filter, 100254, 100254, rect, traceRow.frame, true); + }); - it('JsCpuProfilerStructTest01', () => { - const data = { - cpu: 1, - startNs: 1, - value: 1, - frame: { - x: 20, - y: 20, - width: 100, - height: 100, - }, - maxValue: undefined, - startTime: 1, - filterID: 2, - size: 102 - }; - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - expect(JsCpuProfilerStruct.draw(ctx, data)).toBeUndefined(); - }); + it('JsCpuProfilerStructTest01', () => { + const data = { + cpu: 1, + startNs: 1, + value: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + maxValue: undefined, + startTime: 1, + filterID: 2, + size: 102, + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(JsCpuProfilerStruct.draw(ctx, data)).toBeUndefined(); + }); - it('JsCpuProfilerStructTest02', () => { - let node = { - startTime: 50, - endTime: 1520000, - name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 40 }, - id: 0, - depth: 1, - selfTime: 0, - url:'', - totalTime: 88473061693464, - parentId: 123, - children:[], - isSelect: true, - }; - expect(JsCpuProfilerStruct.setJsCpuProfilerFrame(node, 0, 1, 2, traceRow.frame)).toBeUndefined(); - }); - it('JsCpuProfilerStructTest04', () => { - expect(JsCpuProfilerStruct).not.toBeUndefined(); - }); + it('JsCpuProfilerStructTest02', () => { + let node = { + startTime: 50, + endTime: 1520000, + name: 'Snapshot0', + frame: { x: 0, y: 0, width: 25, height: 40 }, + id: 0, + depth: 1, + selfTime: 0, + url: '', + totalTime: 88473061693464, + parentId: 123, + children: [], + isSelect: true, + }; + expect(JsCpuProfilerStruct.setJsCpuProfilerFrame(node, 0, 1, 2, traceRow.frame)).toBeUndefined(); + }); + it('JsCpuProfilerStructTest04', () => { + expect(JsCpuProfilerStruct).not.toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts index 44628852c3649faaa563c34c602bfb56590291ff..2a2ffb7fdfe96ea4f8d35b45213a96eebaf61604 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts @@ -13,10 +13,12 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore import { CpuStateRender, @@ -160,4 +162,109 @@ describe('ProcedureWorkerCpuState Test', () => { }; expect(cpuStateRender.cpuState([], dataList, '', res, 1, 6, 5, frame, true)).toBeUndefined(); }); + it('ProcedureWorkerCpuStateTest05', function () { + let res = [ + { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startNS: 10, + length: 1, + height: 2, + dur: 1, + }, + ]; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + let path = new Path2D(); + expect(CpuStateStruct.draw(ctx, path, res)).toBeUndefined(); + }); + it('ProcedureWorkerCpuStateTest06', function () { + let node = { + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + startNS: 200, + value: 50, + startTs: 3, + dur: 1, + height: 2, + }; + let frame = { + x: 20, + y: 20, + width: 100, + height: 100, + }; + expect(CpuStateStruct.setCpuFrame(node, 2, 2, 6, frame)).toBeUndefined(); + }); + it('ProcedureWorkerCpuStateTest07', function () { + let req = { + lazyRefresh: true, + type: '', + startNS: 1, + endNS: 1, + totalNS: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#ec407a', + globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fill: jest.fn(() => true), + }, + lineColor: '', + isHover: '', + hoverX: 1, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 20, + y: 20, + width: 100, + height: 100, + }; + let cpuStateRender = new CpuStateRender(); + window.postMessage = jest.fn(() => true); + expect(cpuStateRender.render(req, [], [], [])).toBeUndefined(); + }); + it('ProcedureWorkerCpuStateTest07', function () { + let cpuStateRender = new CpuStateRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(cpuStateRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts index b72c91314f395fcb2e43026b2b74293c599adb49..ccf31d3cd5675117f2661921cf8ce7fa714ba5f5 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts @@ -13,10 +13,12 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore import { DiskAbilityMonitorStruct, @@ -112,11 +114,18 @@ describe('ProcedureWorkerDiskIoAbility Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -135,4 +144,17 @@ describe('ProcedureWorkerDiskIoAbility Test', () => { window.postMessage = jest.fn(() => true); expect(diskIoAbilityRender.render(req, [], [])).toBeUndefined(); }); + it('CpuAbilityMonitorStructTest05', function () { + let diskIoAbilityRender = new DiskIoAbilityRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(diskIoAbilityRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts index ae1d980a78554dd3d7eb4f97db2f56824ce29080..ac8e7465ac5bc2375215d0a9b5f3bc7c33a9b5ed 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts @@ -143,11 +143,21 @@ describe('ProcedureWorkerEnergyAnomaly Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + canvas: { + clientWidth: 10, + }, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts index 81504adf0546ae4a09b07b48a381ce481fb13ad7..719ba4dfb01d42e83a3f0c5b76427582832e968c 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts @@ -153,11 +153,21 @@ describe('ProcedureWorkerEnergyPower Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + canvas: { + clientWidth: 10, + }, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts index f603afa6c929e787e5bf4a032f5bb6da114e8989..7928061791101e000af987c7ce7951defcbc3626 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts @@ -131,13 +131,23 @@ describe('ProcedureWorkerEnergyState Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, height: 150, width: 100, + canvas: { + clientWidth: 10, + }, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts index ae1918d81e15e14d6414555eb989b40315f12411..ec593b6bca6222b25702c2aa9c6b0701ed51e06d 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts @@ -209,13 +209,23 @@ describe('ProcedureWorkerEnergySystem Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, height: 150, width: 100, + canvas: { + clientWidth: 10, + }, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts index 2ae7209b15cc37bfdaccd841c11250ec223551b6..2dd17f6e232c3e8786f53d59c41c76350cfbf5a9 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts @@ -134,13 +134,20 @@ describe(' FPSTest', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, height: 150, width: 100, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts index a7a16950b23dcd1ac919109a627c7f67cc49d5e8..374f7ea5036a3ca2e73610ef02b6a144f683bc49 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts @@ -53,7 +53,7 @@ describe('FrameAnimation Test', () => { status: 'Completion delay', textMetricsWidth: 133.0703125, ts: 4091445476, - } + }, ]; TraceRow.range = { startNS: 0, @@ -62,11 +62,15 @@ describe('FrameAnimation Test', () => { }; it('FrameAnimationTest01', function () { - frameAnimationRender.frameAnimation(dataList, [], TraceRow.range.startNS, + frameAnimationRender.frameAnimation( + dataList, + [], + TraceRow.range.startNS, TraceRow.range.endNS, TraceRow.range.totalNS, TraceRow.skeleton(), - false); + false + ); let node = { animationId: 1, dur: 0, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts index fb2cff3d441ab42cb660b4750cdccca5d411bf6d..6a97f2328996ad4f0ff8a9123ec09dda48cffcae 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts @@ -82,7 +82,7 @@ describe('FrameDynamic Test', () => { useCache: false, context: ctx, type: 'dynamicEffectCurve', - animationRanges: [{start: 4091445476, end: 4774481414}], + animationRanges: [{ start: 4091445476, end: 4774481414 }], }; TraceRow.range = { startNS: 0, @@ -90,7 +90,7 @@ describe('FrameDynamic Test', () => { totalNS: 16868000000, }; - let animationRanges = [{start: 4091445476, end: 4774481414}]; + let animationRanges = [{ start: 4091445476, end: 4774481414 }]; frameDynamicRender.frameDynamic(dataList, [], TraceRow.skeleton(), animationRanges, false); it('FrameDynamicTest01', function () { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts index 1d94bf8e41cd8da0180b3b57616200e8f20f1681..18736bc67ac8c85c7692a7e8538bfd11eb09c6ae 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts @@ -20,7 +20,10 @@ jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => // @ts-ignore import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; // @ts-ignore -import { FrameSpacingRender, FrameSpacingStruct } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFrameSpacing.js'; +import { + FrameSpacingRender, + FrameSpacingStruct, +} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFrameSpacing.js'; // @ts-ignore import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts index dc07c94cf02afafc83c846d28b8c972854e152ac..15986dada26213b1c7ebc07cd6dabd0afd385ffe 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts @@ -13,10 +13,12 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore import { CpuFreqStruct, FreqRender, freq } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFreq.js'; // @ts-ignore @@ -59,4 +61,16 @@ describe('freqTest', () => { }; expect(CpuFreqStruct.draw(ctx, Sourcedata)).toBeUndefined(); }); + it('freqTest03', () => { + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + let freqRender = new FreqRender(); + expect(freqRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts index 17ae84096f6fd0be851a8fa4b53f54868815160d..a50fa820e044216ed6f391def1e78caf6cb28970 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts @@ -84,7 +84,7 @@ describe(' ProcedureWorkerFuncTest', () => { startNS: 200, value: 50, dur: undefined || null || 0, - funName: '' + funName: '', }; expect(FuncStruct.draw(ctx, data)).toBeUndefined(); }); @@ -105,7 +105,7 @@ describe(' ProcedureWorkerFuncTest', () => { startNS: 200, value: 50, dur: 10, - funName: 'H:Task PerformTask End: taskId : 1, executeId : 1, performResult : IsCanceled' + funName: 'H:Task PerformTask End: taskId : 1, executeId : 1, performResult : IsCanceled', }; expect(FuncStruct.draw(ctx, data)).toBeUndefined(); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts index 521b229459e413f6ac7d9bd23101d0e1b9e50e54..9abbc5d2c884bde29e5cca4fa20516365ae8698f 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts @@ -13,10 +13,11 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - // @ts-ignore import { heap, @@ -127,11 +128,18 @@ describe(' Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -178,4 +186,17 @@ describe(' Test', () => { }; expect(HeapStruct.setFrame(node, 2, 1, 5, 4, data)).toBeUndefined(); }); + it('HeapTest07', function () { + let nativeMemoryRender = new HeapRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(nativeMemoryRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts index edf610a79c1e51a70754f54f715a5849dce1ce9f..1c7fcd0f45162780cd7045e4c1015c6867b29959 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts @@ -17,114 +17,118 @@ import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.j // @ts-ignore import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; // @ts-ignore -import { HeapSnapshot, HeapSnapshotRender, HeapSnapshotStruct} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.js'; +import { + HeapSnapshot, + HeapSnapshotRender, + HeapSnapshotStruct, +} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.js'; jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { - return {}; + return {}; }); describe('ProcedureWorkerHeapTimeline Test', () => { - it('HeapSnapshotTest', () => { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - let dataList = new Array(); - dataList.push({ - startTime: 0, - dur: 10, - frame: { x: 0, y: 9, width: 10, height: 10 }, - }); - dataList.push({ startTime: 1, dur: 111 }); - let rect = new Rect(0, 10, 10, 10); - let filter = [ - { - end_time: 50, - end_ts: 1520000, - file_name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 40 }, - id: 0, - pid: 4243, - start_time: 0, - start_ts: 88473061693464, - textMetricsWidth: 50.5810546875, - }, - ]; - let list = [ - { - end_time: 50, - end_ts: 1520000, - file_name: 'Snapshot0', - frame: { x: 0, y: 0, width: 6222, height: 62222 }, - id: 0, - pid: 4243, - start_time: 0, - start_ts: 88473061693464, - textMetricsWidth: 50.5810546875, - }, - ]; - HeapSnapshot(list, filter, 100254, 100254, rect, { height: 40, width: 1407, x: 0, y: 0 }); + it('HeapSnapshotTest', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + let dataList = new Array(); + dataList.push({ + startTime: 0, + dur: 10, + frame: { x: 0, y: 9, width: 10, height: 10 }, }); + dataList.push({ startTime: 1, dur: 111 }); + let rect = new Rect(0, 10, 10, 10); + let filter = [ + { + end_time: 50, + end_ts: 1520000, + file_name: 'Snapshot0', + frame: { x: 0, y: 0, width: 25, height: 40 }, + id: 0, + pid: 4243, + start_time: 0, + start_ts: 88473061693464, + textMetricsWidth: 50.5810546875, + }, + ]; + let list = [ + { + end_time: 50, + end_ts: 1520000, + file_name: 'Snapshot0', + frame: { x: 0, y: 0, width: 6222, height: 62222 }, + id: 0, + pid: 4243, + start_time: 0, + start_ts: 88473061693464, + textMetricsWidth: 50.5810546875, + }, + ]; + HeapSnapshot(list, filter, 100254, 100254, rect, { height: 40, width: 1407, x: 0, y: 0 }); + }); - it('HeapSnapshotStructTest01', () => { - const data = { - cpu: 1, - startNs: 1, - value: 1, - frame: { - x: 20, - y: 20, - width: 100, - height: 100, - }, - maxValue: undefined, - startTime: 1, - filterID: 2, - size: 102 - }; - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - expect(HeapSnapshotStruct.draw(ctx, data)).toBeUndefined(); - }); + it('HeapSnapshotStructTest01', () => { + const data = { + cpu: 1, + startNs: 1, + value: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + maxValue: undefined, + startTime: 1, + filterID: 2, + size: 102, + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(HeapSnapshotStruct.draw(ctx, data)).toBeUndefined(); + }); - it('HeapSnapshotStructTest02', () => { - const data = { - cpu: 1, - startNs: 1, - value: 1, - frame: { - x: 20, - y: 20, - width: 100, - height: 100, - }, - maxValue: undefined, - startTime: 1, - filterID: 2, - }; - let node = { - start_time: 1, - end_time: 2, - frame: null, - }; - expect(HeapSnapshotStruct.setFrame(node, 0, 1, 2, data)).toBeUndefined(); - }); + it('HeapSnapshotStructTest02', () => { + const data = { + cpu: 1, + startNs: 1, + value: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + maxValue: undefined, + startTime: 1, + filterID: 2, + }; + let node = { + start_time: 1, + end_time: 2, + frame: null, + }; + expect(HeapSnapshotStruct.setFrame(node, 0, 1, 2, data)).toBeUndefined(); + }); - it('HeapSnapshotRenderTest03', () => { - let canvas = document.createElement('canvas') as HTMLCanvasElement; - let context = canvas.getContext('2d'); - const data = { - context: context!, - useCache: true, - type: '', - traceRange: [], - }; - let heapSnapshotRender = new HeapSnapshotRender(); - expect(heapSnapshotRender.renderMainThread(data, new TraceRow())).toBeUndefined(); - }); - it('HeapSnapshotStructTest04', () => { - expect(HeapSnapshotStruct).not.toBeUndefined(); - }); + it('HeapSnapshotRenderTest03', () => { + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + let heapSnapshotRender = new HeapSnapshotRender(); + expect(heapSnapshotRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); + it('HeapSnapshotStructTest04', () => { + expect(HeapSnapshotStruct).not.toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts index 13c06c1c95b4d54b350df72d33ef20eca4efce6f..5e0c5c6ea88717caaffeba5a842c0184e8f92444 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts @@ -62,4 +62,27 @@ describe('ProcedureWorkerHeapTimeline Test', () => { const ctx = canvas.getContext('2d'); expect(HeapTimelineStruct.draw(ctx, data)).toBeUndefined(); }); + it('HeapTimelineStructTest02', () => { + const data = { + cpu: 1, + startNs: 1, + value: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + maxValue: undefined, + startTime: 1, + filterID: 2, + }; + let frame = { + x: 20, + y: 20, + width: 100, + height: 100, + }; + expect(HeapTimelineStruct.setFrame(1, 2, 1, data, 0, 2, 2, frame)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts index 94f22da6f7e502927ea24b400af388111e9cd9ed..5ba3f244588b669f8dfbd607959ae3a24b3aa460 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts @@ -18,8 +18,18 @@ jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { }); //@ts-ignore -import { hiPerfCpu, HiPerfCpuStruct,HiperfCpuRender } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.js'; +import { + hiPerfCpu, + HiPerfCpuStruct, + HiperfCpuRender, +} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.js'; +// @ts-ignore import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +// @ts-ignore +import { hiPerf } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCommon.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); describe('ProcedureWorkerHiPerfCPU Test', () => { let frame = { @@ -55,4 +65,64 @@ describe('ProcedureWorkerHiPerfCPU Test', () => { { dur: 10000000, height: Infinity, startNS: NaN }, ]); }); + it('ProcedureWorkerHiPerfCPUTest06', function () { + let req = { + lazyRefresh: true, + type: 'a', + startNS: 1, + endNS: 1, + totalNS: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#ec407a', + globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fill: jest.fn(() => true), + }, + lineColor: '', + isHover: '', + hoverX: 1, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 20, + y: 20, + width: 100, + height: 100, + scale: 100_000_001, + }; + let hiperfCpuRender = new HiperfCpuRender(); + window.postMessage = jest.fn(() => true); + expect(hiperfCpuRender.render(req, [], [], [])).toBeUndefined(); + }); + it('ProcedureWorkerHiPerfCPUTest08', function () { + let dataList = new Array(); + dataList.push({ + startNS: 0, + dur: 10, + length: 1, + frame: { x: 0, y: 9, width: 10, height: 10 }, + }); + dataList.push({ startNS: 1, dur: 2, length: 1 }); + hiPerf(dataList, [{ length: 0 }], dataList, 8, 3, '', true, 1, true); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts index 6b884347bbb19622046d33a89ace5db3ac1608b9..215d559250b68025460af3ec17f88599be5a51ca 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts @@ -18,12 +18,17 @@ import { HiperfEventRender, } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.js'; // @ts-ignore -import { Rect } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCommon'; +import { hiPerf } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerCommon.js'; +// @ts-ignore import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; - -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); +jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { + return { + TraceRow: () => {}, + }; +}); describe('ProcedureWorkerHiPerfEvent Test', () => { it('ProcedureWorkerHiPerfEventTest03', () => { @@ -93,7 +98,68 @@ describe('ProcedureWorkerHiPerfEvent Test', () => { it('ProcedureWorkerHiPerfEventTest06', function () { expect(HiPerfEventStruct.eventGroupBy10MS([{ ps: 1 }, { coX: '1' }], 10, '')).toEqual([ - { dur: 10000000, height: NaN, startNS: NaN,max: 0,sum:NaN}, + { dur: 10000000, height: NaN, startNS: NaN, max: 0, sum: NaN }, ]); }); + it('ProcedureWorkerHiPerfProcessTest08', function () { + let hiperfEventRender = new HiperfEventRender(); + let req = { + lazyRefresh: true, + type: '', + startNS: 1, + endNS: 1, + totalNS: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#ec407a', + globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + fill: jest.fn(() => true), + }, + lineColor: '', + isHover: '', + hoverX: 1, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 20, + y: 20, + width: 100, + height: 100, + scale: 100_000_001, + }; + window.postMessage = jest.fn(() => true); + expect(hiperfEventRender.render(req, [], [], [])).toBeUndefined(); + }); + it('ProcedureWorkerHiPerfEventTest09', function () { + let dataList = new Array(); + dataList.push({ + startNS: 0, + dur: 10, + length: 1, + frame: { x: 0, y: 9, width: 10, height: 10 }, + }); + dataList.push({ startNS: 1, dur: 2, length: 1 }); + hiPerf(dataList, [{ length: 0 }], dataList, 8, 3, '', false, 1, false); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts index 470c7e5f94bf67491efc80a77626ad0c6284a2a6..11e4afd712fa02d319704a4aa01116d78ce22adb 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts @@ -13,10 +13,11 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - //@ts-ignore import { HiPerfProcessStruct, @@ -88,11 +89,19 @@ describe('ProcedureWorkerHiPerfProcess Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + fill: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -112,4 +121,17 @@ describe('ProcedureWorkerHiPerfProcess Test', () => { window.postMessage = jest.fn(() => true); expect(hiperfProcessRender.render(req, [], [], [])).toBeUndefined(); }); + it('ProcedureWorkerHiPerfProcessTest06', function () { + let hiperfProcessRender = new HiperfProcessRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(hiperfProcessRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts index 981048d35450a669e2dc268ebf8444e152256b9b..eaf3b3c79d3cd44ca82a40b0ef40343785b68468 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts @@ -178,7 +178,57 @@ describe('ProcedureWorkerHiPerfReport Test', () => { it('ProcedureWorkerHiPerfReportTest06', function () { expect(HiPerfReportStruct.reportGroupBy10MS([{ ps: 1 }, { coX: '1' }], 10)).toEqual([ - { dur: 10000000, height: NaN, startNS: NaN, sum:NaN}, + { dur: 10000000, height: NaN, startNS: NaN, sum: NaN }, ]); }); + it('ProcedureWorkerHiPerfProcessTest05', function () { + let hiperfReportRender = new HiperfReportRender(); + let req = { + lazyRefresh: true, + type: '', + startNS: 1, + endNS: 1, + totalNS: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 100, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#ec407a', + globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + fill: jest.fn(() => true), + }, + lineColor: '', + isHover: '', + hoverX: 1, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 20, + y: 20, + width: 100, + height: 100, + scale: 100_000_001, + }; + window.postMessage = jest.fn(() => true); + expect(hiperfReportRender.render(req, [], [], [])).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts index 45bb6743c4af489e92ffaa5866d70137f150768d..e3cb0ab2f1f1d8cf7a35b27d63c6856a84a6ac57 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts @@ -13,10 +13,12 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - //@ts-ignore import { HiperfThreadRender, @@ -112,11 +114,19 @@ describe('ProcedureWorkerHiPerfThread Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), + fill: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -157,4 +167,17 @@ describe('ProcedureWorkerHiPerfThread Test', () => { expect(hiperfThreadRender.render(req, [], [], [])).toBeUndefined(); }); + it('ProcedureWorkerHiPerfThreadTest06', function () { + let hiperfThreadRender = new HiperfThreadRender(); + window.postMessage = jest.fn(() => true); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + expect(hiperfThreadRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts index 18ff54a3a56da4e2840fe5b0692160f45d316bac..dd8c74170342e82a8d8045e19947400a76beefaf 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts @@ -48,14 +48,20 @@ describe('ProcedureWorkerIrq Test', () => { canvas.width = 1; canvas.height = 1; const ctx = canvas.getContext('2d'); - let data = {textMetricsWidth: 1} + let data = { textMetricsWidth: 1 }; expect( - IrqStruct.draw(ctx, '253', 2, { - x: 20, - y: 20, - width: 100, - height: 100, - },data) + IrqStruct.draw( + ctx, + '253', + 2, + { + x: 20, + y: 20, + width: 100, + height: 100, + }, + data + ) ).toBeUndefined(); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts index 44f63dd1a94c8b2041c7f7b134a43103a07141ca..18a03ad220febdb40a664cb93ada5d0d0e0fb860 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts @@ -18,7 +18,7 @@ jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { }); // @ts-ignore -import { ProcessMemStruct, MemRender } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerMem.js'; +import { ProcessMemStruct, MemRender } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerMem.js'; // @ts-ignore import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js'; // @ts-ignore @@ -100,11 +100,18 @@ describe(' Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts index 95116aaa87e2a74af64193536babdd99368f20cd..093d03a92f150d3ee5bcf42875eb9bca7744d54c 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); - //@ts-ignore import { memoryAbility, @@ -90,11 +90,18 @@ describe('ProcedureWorkerMemoryAbility Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -113,4 +120,17 @@ describe('ProcedureWorkerMemoryAbility Test', () => { window.postMessage = jest.fn(() => true); expect(memoryAbilityRender.render(req, [], [])).toBeUndefined(); }); + it('ProcedureWorkerMemoryAbilityTest04', function () { + let memoryAbilityRender = new MemoryAbilityRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(memoryAbilityRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts index aa3ad2e2b5991df519e336ec45dc5f368733ac0e..9d9bddc77253232b3588ebd1bb44f5096b1ad4ba 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts @@ -13,7 +13,10 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); @@ -97,4 +100,17 @@ describe('ProcedureWorkerNetworkAbility Test', () => { window.postMessage = jest.fn(() => true); expect(networkAbilityRender.render(req, [], [])).toBeUndefined(); }); + it('ProcedureWorkerNetworkAbilityTest03', function () { + let networkAbilityRender = new NetworkAbilityRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(networkAbilityRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts index 5bbfebad5cb12f908dbf44d8c9793d7d28a3cafd..24f3c26e7fef34e208a9c2c55f5f9cbd18458e13 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts @@ -133,11 +133,18 @@ describe(' ProcessTest', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fill: jest.fn(() => true), }, lineColor: '', isHover: '', diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts index 5fcc3df8a0a248f9eb9acbdeee46d664a32de1b9..58124bd7ef92208484491f05ec154d092cdc3290 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts @@ -13,7 +13,10 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); @@ -86,7 +89,7 @@ describe('ProcedureWorkerThread Test', () => { value: 50, state: 'R', }; - expect(ThreadStruct.draw(ctx, data)).toBeUndefined(); + expect(ThreadStruct.drawThread(ctx, data)).toBeUndefined(); }); it('ProcedureWorkerThreadTest04', () => { @@ -106,7 +109,7 @@ describe('ProcedureWorkerThread Test', () => { value: 50, state: 'D', }; - expect(ThreadStruct.draw(ctx, data)).toBeUndefined(); + expect(ThreadStruct.drawThread(ctx, data)).toBeUndefined(); }); it('ProcedureWorkerThreadTest05', () => { @@ -126,7 +129,7 @@ describe('ProcedureWorkerThread Test', () => { value: 50, state: 'Running', }; - expect(ThreadStruct.draw(ctx, data)).toBeUndefined(); + expect(ThreadStruct.drawThread(ctx, data)).toBeUndefined(); }); it('ProcedureWorkerThreadTest06', () => { @@ -208,4 +211,17 @@ describe('ProcedureWorkerThread Test', () => { window.postMessage = jest.fn(() => true); expect(threadRender.render(req, [], [])).toBeUndefined(); }); + it('ProcedureWorkerThreadTest08', function () { + let threadRender = new ThreadRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(threadRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts index b39e65c716d0780a9455213d475c8215ffc3ed69..a119af59146fe32e1b20802bb0d04b68047b1fe4 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts @@ -13,7 +13,10 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); @@ -101,11 +104,17 @@ describe('ProcedureWorkerVirtualMemory Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -124,4 +133,17 @@ describe('ProcedureWorkerVirtualMemory Test', () => { window.postMessage = jest.fn(() => true); expect(virtualMemoryRender.render(req, [], [])).toBeUndefined(); }); + it('ProcedureWorkerVirtualMemoryTest05', function () { + let virtualMemoryRender = new VirtualMemoryRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(virtualMemoryRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts b/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts index faf2a0179b4ec6c0becfa5be96d876afe502a86d..bc9f3048fd0553568f252c89075cff885dc78955 100644 --- a/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts +++ b/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts @@ -13,7 +13,10 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { return {}; }); @@ -161,11 +164,18 @@ describe('ProduceWorkerSdkCounter Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillText: jest.fn(() => true), + fillRect: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -184,4 +194,17 @@ describe('ProduceWorkerSdkCounter Test', () => { window.postMessage = jest.fn(() => true); expect(sdkCounterRender.render(req, [], [])).toBeUndefined(); }); + it('ProduceWorkerSdkCounterTest06', function () { + let sdkCounterRender = new SdkCounterRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + expect(sdkCounterRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts b/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts index 403e6ac7d4c2b01b5671ac9fc6a1f02c1a5560fa..211b288ed311c62d7b33ee6063bc9b71dc4adfe0 100644 --- a/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts +++ b/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts @@ -13,12 +13,13 @@ * limitations under the License. */ -jest.mock('../../../../dist/trace/component/trace/base/TraceRow.js', () => { - return {}; -}); - +// @ts-ignore +import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js'; // @ts-ignore import { SdkSliceRender, SdkSliceStruct } from '../../../../dist/trace/database/ui-worker/ProduceWorkerSdkSlice.js'; +jest.mock('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => { + return {}; +}); describe('ProduceWorkerSdkSlice Test', () => { it('ProduceWorkerSdkSliceTest01', function () { @@ -146,11 +147,18 @@ describe('ProduceWorkerSdkSlice Test', () => { range: { refresh: '', }, - canvas: '', + canvas: 'a', context: { font: '11px sans-serif', fillStyle: '#ec407a', globalAlpha: 0.6, + clearRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => true), + fillRect: jest.fn(() => true), + fillText: jest.fn(() => true), }, lineColor: '', isHover: '', @@ -169,4 +177,17 @@ describe('ProduceWorkerSdkSlice Test', () => { window.postMessage = jest.fn(() => true); expect(sdkSliceRender.render(req, [], [])).toBeUndefined(); }); + it('ProduceWorkerSdkSliceTest07', function () { + let sdkSliceRender = new SdkSliceRender(); + window.postMessage = jest.fn(() => true); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + expect(sdkSliceRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); diff --git a/trace_streamer/gn/BUILD.gn b/trace_streamer/gn/BUILD.gn index 64ef1b31a88184821aea611e1d1d2364c6a3e650..f740442674f1381aa7fb91d80d6afb43d97807c4 100755 --- a/trace_streamer/gn/BUILD.gn +++ b/trace_streamer/gn/BUILD.gn @@ -53,7 +53,7 @@ config("default") { cflags_c = [] cflags_cc = [] libs = [] - + ldflags = [] cflags = [ "-fstrict-aliasing", "-g", @@ -61,7 +61,14 @@ config("default") { "-Wno-unused-variable", ] if (is_debug && is_win) { - ldflags = [ "-fstack-protector" ] + ldflags += [ "-fstack-protector" ] + } + if (is_debug && is_linux) { + cflags += [ + "-fsanitize=address", + "-fno-omit-frame-pointer", + ] + ldflags += [ "-fsanitize=address" ] } if (target_os == "windows") { cflags += [ "-D target_cpu_x86_64" ] @@ -192,7 +199,7 @@ config("executable") { ldflags += [] } if (!is_macx && !use_wasm && !is_win) { - ldflags = [ + ldflags += [ "-Wl,--disable-new-dtags", "-Wl,-z,noexecstack", "-lrt", diff --git a/trace_streamer/src/filter/animation_filter.cpp b/trace_streamer/src/filter/animation_filter.cpp index 3d9d0b9270c207d8886de08c4e5add4878b43166..301cce0b34d4f24d802690cb4f11277b17568f63 100644 --- a/trace_streamer/src/filter/animation_filter.cpp +++ b/trace_streamer/src/filter/animation_filter.cpp @@ -38,13 +38,13 @@ bool AnimationFilter::UpdateDeviceInfoEvent(const TracePoint& point, const Bytra { if (traceDataCache_->GetConstDeviceInfo().PhysicalFrameRate() == INVALID_UINT32 && StartWith(point.name_, generateVsyncCmd_)) { - if (generateCurTimePoint_ == 0) { - generateCurTimePoint_ = line.ts; + if (generateFirstTime_ == INVALID_UINT64) { + generateFirstTime_ = line.ts; } generateVsyncCnt_++; // calculate the average frame rate if (generateVsyncCnt_ == GENERATE_VSYNC_EVENT_MAX) { - uint64_t generateTimePeriod = (line.ts - generateCurTimePoint_) / (GENERATE_VSYNC_EVENT_MAX - 1); + uint64_t generateTimePeriod = (line.ts - generateFirstTime_) / (GENERATE_VSYNC_EVENT_MAX - 1); uint32_t fps = BILLION_NANOSECONDS / generateTimePeriod; if (fps < FPS_70) { traceDataCache_->GetDeviceInfo()->UpdateFrameRate(FPS_60); @@ -61,45 +61,41 @@ bool AnimationFilter::UpdateDeviceInfoEvent(const TracePoint& point, const Bytra // get width and height, eg:funcArgs=(0, 0, 1344, 2772) Alpha: 1.00 std::smatch matcheLine; std::regex entryViewArgsPattern(R"(\(\d+,\s*\d+,\s*(\d+),\s*(\d+)\))"); - if (std::regex_search(point.funcArgs_, matcheLine, entryViewArgsPattern)) { - uint8_t index = 0; - uint32_t width = base::StrToInt(matcheLine[++index].str()).value(); - uint32_t height = base::StrToInt(matcheLine[++index].str()).value(); - traceDataCache_->GetDeviceInfo()->UpdateWidthAndHeight(matcheLine); - TS_LOGI("physical width is %u, height is %u", width, height); - } else { + if (!std::regex_search(point.funcArgs_, matcheLine, entryViewArgsPattern)) { TS_LOGE("Not support this event: %s\n", point.name_.data()); return false; } + uint8_t index = 0; + uint32_t width = base::StrToInt(matcheLine[++index].str()).value(); + uint32_t height = base::StrToInt(matcheLine[++index].str()).value(); + traceDataCache_->GetDeviceInfo()->UpdateWidthAndHeight(matcheLine); + TS_LOGI("physical width is %u, height is %u", width, height); return true; } return false; } bool AnimationFilter::BeginDynamicFrameEvent(const TracePoint& point, size_t callStackRow) { - // matches the 'H:RSUniRender::Process:[' event - if (StartWith(point.funcPrefix_, rsUniProcessCmd_)) { - // get the parent frame of data - CallStack* callStackSlice = traceDataCache_->GetInternalSlicesData(); - const std::optional& parentId = callStackSlice->ParentIdData()[callStackRow]; - uint8_t depth = callStackSlice->Depths()[callStackRow]; - if (depth >= DYNAMIC_STACK_DEPTH_MIN && parentId.has_value()) { - const std::string& curStackName = - traceDataCache_->GetDataFromDict(callStackSlice->NamesData()[callStackRow]); - // get name 'xxx' from [xxx], eg:H:RSUniRender::Process:[xxx] - auto nameSize = point.funcPrefix_.size() - rsUniProcessCmd_.size() - 1; - if (nameSize <= 0) { - return false; - } - auto nameIndex = traceDataCache_->GetDataIndex(point.funcPrefix_.substr(rsUniProcessCmd_.size(), nameSize)); - if (StartWith(curStackName, leashWindowCmd_)) { - auto dynamicFramRow = traceDataCache_->GetDynamicFrame()->AppendDynamicFrame(nameIndex); - callStackRowMap_.emplace(callStackRow, dynamicFramRow); - return true; - } - } + // get the parent frame of data + CallStack* callStackSlice = traceDataCache_->GetInternalSlicesData(); + const std::optional& parentId = callStackSlice->ParentIdData()[callStackRow]; + uint8_t depth = callStackSlice->Depths()[callStackRow]; + if (depth < DYNAMIC_STACK_DEPTH_MIN || !parentId.has_value()) { + return false; } - return false; + const std::string& curStackName = traceDataCache_->GetDataFromDict(callStackSlice->NamesData()[callStackRow]); + if (!StartWith(curStackName, leashWindowCmd_)) { + return false; + } + // get name 'xxx' from [xxx], eg:H:RSUniRender::Process:[xxx] + auto nameSize = point.funcPrefix_.size() - rsUniProcessCmd_.size() - 1; + if (nameSize <= 0) { + return false; + } + auto nameIndex = traceDataCache_->GetDataIndex(point.funcPrefix_.substr(rsUniProcessCmd_.size(), nameSize)); + auto dynamicFramRow = traceDataCache_->GetDynamicFrame()->AppendDynamicFrame(nameIndex); + callStackRowMap_.emplace(callStackRow, dynamicFramRow); + return true; } void AnimationFilter::StartAnimationEvent(const BytraceLine& line, size_t callStackRow) { @@ -109,13 +105,13 @@ void AnimationFilter::StartAnimationEvent(const BytraceLine& line, size_t callSt bool AnimationFilter::FinishAnimationEvent(const BytraceLine& line, size_t callStackRow) { auto iter = animationCallIds_.find(callStackRow); - if (iter != animationCallIds_.end()) { - auto animationRow = iter->second; - traceDataCache_->GetAnimation()->UpdateEndPoint(animationRow, line.ts); - animationCallIds_.erase(iter); - return true; + if (iter == animationCallIds_.end()) { + return false; } - return false; + auto animationRow = iter->second; + traceDataCache_->GetAnimation()->UpdateEndPoint(animationRow, line.ts); + animationCallIds_.erase(iter); + return true; } void AnimationFilter::UpdateDynamicFrameInfo() { @@ -133,21 +129,19 @@ void AnimationFilter::UpdateDynamicFrameInfo() auto nameDataIndex = callStackSlice->NamesData()[curStackRow]; const std::string& curStackName = traceDataCache_->GetDataFromDict(nameDataIndex); const std::string& funcArgs = curStackName.substr(leashWindowCmd_.size()); - if (std::regex_search(funcArgs, matcheLine, leashWindowPattern)) { - dynamicFrame->UpdatePosition( - curFrameRow, matcheLine, - traceDataCache_->GetDataIndex((matcheLine[DYNAMICFRAME_MATCH_LAST].str()))); // alpha - } else { + if (!std::regex_search(funcArgs, matcheLine, leashWindowPattern)) { TS_LOGE("Not support this event: %s\n", funcArgs.data()); - break; + continue; } + dynamicFrame->UpdatePosition( + curFrameRow, matcheLine, + traceDataCache_->GetDataIndex((matcheLine[DYNAMICFRAME_MATCH_LAST].str()))); // alpha // update dynamicFrame endTime, filter up from the curStackRow, until reach the top for (uint8_t stackCurDepth = stackDepth; stackCurDepth > 0; stackCurDepth--) { - if (callStackSlice->ParentIdData()[curStackRow].has_value()) { - curStackRow = callStackSlice->ParentIdData()[curStackRow].value(); - } else { + if (!callStackSlice->ParentIdData()[curStackRow].has_value()) { break; } + curStackRow = callStackSlice->ParentIdData()[curStackRow].value(); // use 'H:RSMainThread::DoComposition' endTime as dynamicFrame endTime if (rsDoCompCmd_ == callStackSlice->NamesData()[curStackRow]) { auto endTime = callStackSlice->TimeStampData()[curStackRow] + callStackSlice->DursData()[curStackRow]; @@ -162,7 +156,7 @@ void AnimationFilter::UpdateDynamicFrameInfo() } void AnimationFilter::Clear() { - generateCurTimePoint_ = 0; + generateFirstTime_ = INVALID_UINT64; generateVsyncCnt_ = 0; animationCallIds_.clear(); } diff --git a/trace_streamer/src/filter/animation_filter.h b/trace_streamer/src/filter/animation_filter.h index 7a0a8d83c1b599609b3656ec0e58beb653a0251c..ae8ffd3eb057e700bf84fb175e442ce371d7d0a3 100644 --- a/trace_streamer/src/filter/animation_filter.h +++ b/trace_streamer/src/filter/animation_filter.h @@ -44,7 +44,7 @@ private: std::map callStackRowMap_ = {}; // for update animationInfo, first is callStackRow, second is animationRow std::unordered_map animationCallIds_ = {}; - uint64_t generateCurTimePoint_ = 0; + uint64_t generateFirstTime_ = INVALID_UINT64; uint8_t generateVsyncCnt_ = 0; }; } // namespace TraceStreamer diff --git a/trace_streamer/src/filter/task_pool_filter.cpp b/trace_streamer/src/filter/task_pool_filter.cpp index 3d6f7653f70e971283e506b9d1884bb388fdf5d9..acc31635cff34c0bf34833d8c20c6c09e9c3f93d 100644 --- a/trace_streamer/src/filter/task_pool_filter.cpp +++ b/trace_streamer/src/filter/task_pool_filter.cpp @@ -19,7 +19,6 @@ namespace SysTuning { namespace TraceStreamer { -const uint32_t EXECUTE_DATA_FLAG = 2; TaskPoolFilter::TaskPoolFilter(TraceDataCache* dataCache, const TraceStreamerFilters* filter) : FilterBase(dataCache, filter), IpidExecuteMap_(INVALID_INT32) @@ -64,30 +63,25 @@ void TaskPoolFilter::TaskPoolFieldSegmentation(const std::string& taskPoolStr, bool TaskPoolFilter::TaskPoolEvent(const std::string& taskPoolStr, uint32_t index) { - std::string targetStr = "H:Task "; - if (StartWith(taskPoolStr, targetStr)) { + if (StartWith(taskPoolStr, targetStr_)) { std::unordered_map args; - std::string allocationStr = "H:Task Allocation: "; - if (StartWith(taskPoolStr, allocationStr)) { - allocationStr = taskPoolStr.substr(allocationStr.length(), taskPoolStr.length()); - TaskPoolFieldSegmentation(allocationStr, args); + if (StartWith(taskPoolStr, allocationStr_)) { + const auto& infoStr = taskPoolStr.substr(allocationStr_.length(), taskPoolStr.length()); + TaskPoolFieldSegmentation(infoStr, args); return UpdateAssignData(args, index); } - std::string executeStr = "H:Task Perform: "; - if (StartWith(taskPoolStr, executeStr)) { - executeStr = taskPoolStr.substr(executeStr.length(), taskPoolStr.length()); - TaskPoolFieldSegmentation(executeStr, args); + if (StartWith(taskPoolStr, executeStr_)) { + const auto& infoStr = taskPoolStr.substr(executeStr_.length(), taskPoolStr.length()); + TaskPoolFieldSegmentation(infoStr, args); return UpdateExecuteData(args, index); } - std::string returnStr = "H:Task PerformTask End: "; - if (StartWith(taskPoolStr, returnStr)) { - returnStr = taskPoolStr.substr(returnStr.length(), taskPoolStr.length()); - TaskPoolFieldSegmentation(returnStr, args); + if (StartWith(taskPoolStr, returnStr_)) { + const auto& infoStr = taskPoolStr.substr(returnStr_.length(), taskPoolStr.length()); + TaskPoolFieldSegmentation(infoStr, args); return UpdateReturnData(args, index); } } - std::string timeoutStr = "H:Thread Timeout Exit"; - if (StartWith(taskPoolStr, timeoutStr)) { + if (StartWith(taskPoolStr, timeoutStr_)) { return AppendTimeoutRow(index); } return false; @@ -149,8 +143,8 @@ bool TaskPoolFilter::UpdateReturnData(const std::unordered_mapGetConstInternalSlicesData().CallIds()[index]; auto executeId = base::StrToInt(args.at(" executeId ")); - auto returnStr = std::string_view(args.at(" performResult ")); - uint32_t returnState = returnStr.compare(" Successful") ? 0 : 1; + auto returnStr_ = std::string_view(args.at(" performResult ")); + uint32_t returnState = returnStr_.compare(" Successful") ? 0 : 1; uint32_t returnValue = CheckTheSameTask(executeId.value(), index); if (returnValue == INVALID_INT32) { diff --git a/trace_streamer/src/filter/task_pool_filter.h b/trace_streamer/src/filter/task_pool_filter.h index 7792f14f62120fa5da2bd76d14e788ea9d879b3c..5c1f86eb8fafccfb9e6ff1f7298e93ee68a72600 100644 --- a/trace_streamer/src/filter/task_pool_filter.h +++ b/trace_streamer/src/filter/task_pool_filter.h @@ -43,6 +43,11 @@ public: bool AppendTimeoutRow(uint32_t index); private: + const std::string targetStr_ = "H:Task "; + const std::string allocationStr_ = "H:Task Allocation: "; + const std::string executeStr_ = "H:Task Perform: "; + const std::string returnStr_ = "H:Task PerformTask End: "; + const std::string timeoutStr_ = "H:Thread Timeout Exit"; DoubleMap IpidExecuteMap_; std::unordered_map timeoutMap_; }; diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp index 0c4543cd5b82b220165b807ebe1e2353af32ee2c..a2dfae8d8d1cc051a8d02d74f81bd5bb843acfe9 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp @@ -1068,7 +1068,7 @@ void HtraceMemParser::AshMemDeduplicate() const { auto ashMemData = traceDataCache_->GetAshMemData(); auto ashMemCount = ashMemData->Size(); - if (ashMemCount == 0) { + if (ashMemCount <= 1) { return; } @@ -1086,44 +1086,30 @@ void HtraceMemParser::AshMemDeduplicate() const dataByTs.emplace_back(std::make_pair(start, ashMemCount - 1)); for (const auto& iterator : dataByTs) { - std::multimap, std::pair> AshMemMap; - std::map, mem_process_type> processTypeMap; + /* L1 map (key = id+time, value = L2 map) + L2 map (key = ipid, value = index) */ + std::map, std::map> AshMemMap; for (auto i = iterator.first; i <= iterator.second; ++i) { auto ashmemId = ashMemData->AshmemIds()[i]; auto time = ashMemData->Times()[i]; auto key = std::make_pair(ashmemId, time); auto ipid = ashMemData->Ipids()[i]; - auto count = AshMemMap.count(key); - auto iter = AshMemMap.find(key); - bool needInert = true; - for (auto j = 0; j < count; j++, iter++) { - if (ashMemData->Ipids()[iter->second.first] == ipid) { - ashMemData->SetFlag(i, MEM_DEDUPLICATE_FLAG_DUP_SAME_PROCESS); - needInert = false; - break; - } - } - if (needInert) { - auto processType = GetMemProcessType(ipid); - AshMemMap.emplace(key, std::make_pair(i, processType)); - if (processTypeMap.count(key) == 0) { - processTypeMap.emplace(key, processType); - } else if (processTypeMap[key] < processType) { - processTypeMap[key] = processType; - } + auto& pidMap = AshMemMap[key]; + if (pidMap.find(ipid) == pidMap.end()) { + pidMap.emplace(ipid, i); + } else { + ashMemData->SetFlag(i, MEM_DEDUPLICATE_FLAG_DUP_SAME_PROCESS); } } - for (auto iter = AshMemMap.begin(); iter != AshMemMap.end(); iter = AshMemMap.upper_bound(iter->first)) { - auto maxPidType = processTypeMap[iter->first]; - auto count = AshMemMap.count(iter->first); - auto it = AshMemMap.find(iter->first); - for (auto j = 0; j < count; j++, it++) { - auto rowId = it->second.first; - auto processType = it->second.second; - if (processType < maxPidType) { - ashMemData->SetFlag(rowId, MEM_DEDUPLICATE_FLAG_DUP_DIFF_PROCESS); - } + for (const auto& item : AshMemMap) { + auto& pidMap = item.second; + auto iter = pidMap.begin(); + if (iter == pidMap.end()) { + continue; + } + for (++iter; iter != pidMap.end(); ++iter) { + ashMemData->SetFlag(iter->second, MEM_DEDUPLICATE_FLAG_DUP_DIFF_PROCESS); } } } @@ -1166,7 +1152,7 @@ void HtraceMemParser::DmaMemDeduplicate() const { auto dmaMemData = traceDataCache_->GetDmaMemData(); auto dmaCount = dmaMemData->Size(); - if (dmaCount == 0) { + if (dmaCount <= 1) { return; } @@ -1184,42 +1170,31 @@ void HtraceMemParser::DmaMemDeduplicate() const dataByTs.emplace_back(std::make_pair(start, dmaCount - 1)); for (const auto& iterator : dataByTs) { - std::multimap> inoMap; - std::map processTypeMap; + /* L1 map (key = ino, value = L2 map) + L2 map (key = ipid, value = pair(index, mem_process_type)) */ + std::map>> inoMap; + std::map processTypeMap; for (auto i = iterator.first; i <= iterator.second; ++i) { auto ino = dmaMemData->Inos()[i]; auto ipid = dmaMemData->Ipids()[i]; - auto count = inoMap.count(ino); - auto iter = inoMap.find(ino); - bool needInert = true; - for (auto j = 0; j < count; j++, iter++) { - if (dmaMemData->Ipids()[iter->second.first] == ipid) { - dmaMemData->SetFlag(i, MEM_DEDUPLICATE_FLAG_DUP_SAME_PROCESS); - needInert = false; - break; - } - } - if (needInert) { + auto& pidMap = inoMap[ino]; + if (pidMap.find(ipid) != pidMap.end()) { + dmaMemData->SetFlag(i, MEM_DEDUPLICATE_FLAG_DUP_SAME_PROCESS); + } else { auto processType = GetMemProcessType(ipid); - inoMap.emplace(ino, std::make_pair(i, processType)); - if (processTypeMap.count(ino) == 0) { - processTypeMap.emplace(ino, processType); - } else if (processTypeMap[ino] < processType) { + pidMap.emplace(ipid, std::make_pair(i, processType)); + if (processTypeMap[ino] < processType) { processTypeMap[ino] = processType; } } } - for (auto iter = inoMap.begin(); iter != inoMap.end(); iter = inoMap.upper_bound(iter->first)) { - auto ino = iter->first; - auto maxPidType = processTypeMap[ino]; - auto count = inoMap.count(iter->first); - auto it = inoMap.find(iter->first); - for (auto j = 0; j < count; j++, it++) { - auto rowId = it->second.first; - auto processType = it->second.second; - if (processType < maxPidType) { - dmaMemData->SetFlag(rowId, MEM_DEDUPLICATE_FLAG_DUP_DIFF_PROCESS); + for (const auto& item : inoMap) { + auto maxPidType = processTypeMap[item.first]; + auto& pidMap = item.second; + for (const auto& pidItem : pidMap) { + if (pidItem.second.second < maxPidType) { + dmaMemData->SetFlag(pidItem.second.first, MEM_DEDUPLICATE_FLAG_DUP_DIFF_PROCESS); } } } diff --git a/trace_streamer/src/rpc/rpc_server.h b/trace_streamer/src/rpc/rpc_server.h index b523a0c49944e900d06217f4887279ac946a2a76..7534ab651b06884684e0edffa17df0e01c05059c 100644 --- a/trace_streamer/src/rpc/rpc_server.h +++ b/trace_streamer/src/rpc/rpc_server.h @@ -40,7 +40,7 @@ public: int32_t UpdateTraceTime(const uint8_t* data, int32_t len); int32_t TraceStreamer_Init_ThirdParty_Config(const uint8_t* data, int32_t len); int32_t WasmExportDatabase(ResultCallBack resultCallBack); - bool ParserConfig(std::string parserConfig); + bool ParserConfig(std::string parserConfigJson); #ifdef IS_WASM int32_t DownloadELFCallback(const std::string& fileName, size_t totalLen, diff --git a/trace_streamer/src/trace_data/trace_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype.cpp index 48ca785eb6b3aa9da7f5835d08c8cbf665eae558..8928913a6472328b6a6eaef4d8e1303d8a5fe76d 100644 --- a/trace_streamer/src/trace_data/trace_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype.cpp @@ -3120,15 +3120,15 @@ void Animation::Clear() endPoins_.clear(); ids_.clear(); } -const uint32_t DeviceInfo::PhysicalWidth() const +uint32_t DeviceInfo::PhysicalWidth() const { return physicalWidth_; } -const uint32_t DeviceInfo::PhysicalHeight() const +uint32_t DeviceInfo::PhysicalHeight() const { return physicalHeight_; } -const uint32_t DeviceInfo::PhysicalFrameRate() const +uint32_t DeviceInfo::PhysicalFrameRate() const { return physicalFrameRate_; } diff --git a/trace_streamer/src/trace_data/trace_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype.h index 9436bead32dfcb21f054979f6d9b8e2ee123a2b1..24c3419519686c979ebda9c2da75ec474a4bbcc9 100644 --- a/trace_streamer/src/trace_data/trace_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype.h @@ -2481,7 +2481,7 @@ public: const std::deque& TimeoutRows() const; void Clear() override { - TaskPoolInfo::Clear(); + CacheBase::Clear(); allocationTaskRows_.clear(); executeTaskRows_.clear(); returnTaskRows_.clear(); @@ -2528,9 +2528,9 @@ private: }; class DeviceInfo { public: - const uint32_t PhysicalWidth() const; - const uint32_t PhysicalHeight() const; - const uint32_t PhysicalFrameRate() const; + uint32_t PhysicalWidth() const; + uint32_t PhysicalHeight() const; + uint32_t PhysicalFrameRate() const; void UpdateWidthAndHeight(const std::smatch& matcheLine); void UpdateFrameRate(uint32_t frameRate); diff --git a/trace_streamer/src/version.cpp b/trace_streamer/src/version.cpp index e788515b10d1e1f4cbecd28b837f5a2555e0ce0b..4f42cb94ab86aa7207fdffe51cc10c853808875f 100644 --- a/trace_streamer/src/version.cpp +++ b/trace_streamer/src/version.cpp @@ -14,5 +14,5 @@ */ #include "version.h" size_t g_loadSize = 0; -const std::string g_traceStreamerVersion = "3.4.4"; // version -const std::string g_traceStreamerPublishVersion = "2023/7/19"; // publish datetime +const std::string g_traceStreamerVersion = "3.4.7"; // version +const std::string g_traceStreamerPublishVersion = "2023/8/3"; // publish datetime diff --git a/trace_streamer/test/unittest/animation_filter_test.cpp b/trace_streamer/test/unittest/animation_filter_test.cpp index 5a9145e6e3015448b23ac9ca195c5304d57ddc8d..487c7b94ab6b648fb6db13acc0e731d266f9df61 100644 --- a/trace_streamer/test/unittest/animation_filter_test.cpp +++ b/trace_streamer/test/unittest/animation_filter_test.cpp @@ -162,9 +162,9 @@ HWTEST_F(AnimationFilterTest, UpdateDeviceFps, TestSize.Level1) BytraceLine line; std::string validName{"H:GenerateVsyncCount:1"}; - auto timeDiffFps60 = (1000 * ONE_MILLION_NANOSECONDS) / FPS_60; + auto timeDiffFps60 = BILLION_NANOSECONDS / FPS_60; line.ts = 59557002299000; - for (size_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { + for (uint8_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { point.name_ = validName; point.funcPrefixId_ = stream_.traceDataCache_->GetDataIndex(point.name_); line.ts += timeDiffFps60; @@ -176,8 +176,8 @@ HWTEST_F(AnimationFilterTest, UpdateDeviceFps, TestSize.Level1) stream_.traceDataCache_->GetDeviceInfo()->Clear(); stream_.streamFilters_->animationFilter_->Clear(); - auto timeDiffFps90 = (1000 * ONE_MILLION_NANOSECONDS) / FPS_90; - for (size_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { + auto timeDiffFps90 = BILLION_NANOSECONDS / FPS_90; + for (uint8_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { point.name_ = validName; point.funcPrefixId_ = stream_.traceDataCache_->GetDataIndex(point.name_); line.ts += timeDiffFps90; @@ -189,8 +189,8 @@ HWTEST_F(AnimationFilterTest, UpdateDeviceFps, TestSize.Level1) stream_.traceDataCache_->GetDeviceInfo()->Clear(); stream_.streamFilters_->animationFilter_->Clear(); - auto timeDiffFps120 = (1000 * ONE_MILLION_NANOSECONDS) / FPS_120; - for (size_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { + auto timeDiffFps120 = BILLION_NANOSECONDS / FPS_120; + for (uint8_t i = 0; i < GENERATE_VSYNC_EVENT_MAX; i++) { point.name_ = validName; point.funcPrefixId_ = stream_.traceDataCache_->GetDataIndex(point.name_); line.ts += timeDiffFps120; diff --git a/trace_streamer/test/unittest/htrace_mem_parser_test.cpp b/trace_streamer/test/unittest/htrace_mem_parser_test.cpp index ddaff58f86e8d42070f8e5e3f0a07bf1e71f6f9a..47d802153afc0fb73b821558d2b405aa5c2b0e9c 100644 --- a/trace_streamer/test/unittest/htrace_mem_parser_test.cpp +++ b/trace_streamer/test/unittest/htrace_mem_parser_test.cpp @@ -19,11 +19,12 @@ #include #include -#include "../../third_party/protogen/types/plugins/memory_data/memory_plugin_result.pb.h" +#include "memory_plugin_result.pb.h" #include "htrace_mem_parser.h" #include "memory_plugin_result.pbreader.h" #include "parser/common_types.h" #include "trace_streamer_selector.h" +#include "process_filter.h" using namespace testing::ext; using namespace SysTuning::TraceStreamer; @@ -476,5 +477,125 @@ HWTEST_F(HtraceMemParserTest, ParseGpuWindowMemInfo, TestSize.Level1) delete memParser; EXPECT_EQ(stream_.traceDataCache_->GetConstGpuWindowMemData().Size(), 0); } + +/** + * @tc.name: AshMemDeduplicateTest + * @tc.desc: AshMem Deduplicate Test + * @tc.type: FUNC + */ +HWTEST_F(HtraceMemParserTest, AshMemDeduplicateTest, TestSize.Level1) +{ + TS_LOGI("test16-10"); + + HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); + uint32_t adj = 6; + uint32_t fd = 6; + DataIndex ashmemNameId = stream_.traceDataCache_->GetDataIndex("xxx"); + uint64_t size = 222; + uint64_t refCount = 3; + uint64_t purged = 1; + uint32_t flag = 0; + uint64_t pss = 0; + + struct DeduplicateVar { + uint64_t timeStamp; + uint64_t pid; + std::string_view pidName; + uint32_t ashmemId; + uint64_t time; + }; + vector stubVars = { + {1616439852302, 1, "aaa", 1, 1}, {1616439852302, 1, "aaa", 1, 1}, {1616439852302, 1, "aaa", 2, 2}, + {1616439852302, 2, "bbb", 1, 1}, {1616439852302, 2, "bbb", 2, 2}, {1616439852302, 3, "ccc", 1, 1}, + {1616439852302, 3, "ccc", 2, 2}, {1616439852302, 3, "ccc", 2, 2}, + + {1616439855302, 1, "aaa", 1, 1}, {1616439855302, 1, "aaa", 1, 1}, {1616439855302, 2, "bbb", 2, 2}, + {1616439855302, 3, "ccc", 2, 2}, + }; + for (auto& m : stubVars) { + auto ipid = stream_.streamFilters_->processFilter_->UpdateOrCreateProcessWithName(m.pid, m.pidName); + stream_.traceDataCache_->GetAshMemData()->AppendNewData(ipid, m.timeStamp, adj, fd, ashmemNameId, size, pss, + m.ashmemId, m.time, refCount, purged, flag); + } + + memParser->AshMemDeduplicate(); + + auto ashMemData = stream_.traceDataCache_->GetConstAshMemData(); + EXPECT_EQ(ashMemData.Flags()[0], 0); + EXPECT_EQ(ashMemData.Flags()[1], 1); + EXPECT_EQ(ashMemData.Flags()[2], 0); + EXPECT_EQ(ashMemData.Flags()[3], 2); + EXPECT_EQ(ashMemData.Flags()[4], 2); + EXPECT_EQ(ashMemData.Flags()[5], 2); + EXPECT_EQ(ashMemData.Flags()[6], 2); + EXPECT_EQ(ashMemData.Flags()[7], 1); + EXPECT_EQ(ashMemData.Flags()[8], 0); + EXPECT_EQ(ashMemData.Flags()[9], 1); + EXPECT_EQ(ashMemData.Flags()[10], 0); + EXPECT_EQ(ashMemData.Flags()[11], 2); +} + +/** + * @tc.name: DmaMemDeduplicateTest + * @tc.desc: DmaMem Deduplicate Test + * @tc.type: FUNC + */ +HWTEST_F(HtraceMemParserTest, DmaMemDeduplicateTest, TestSize.Level1) +{ + TS_LOGI("test16-11"); + + HtraceMemParser* memParser = new HtraceMemParser(stream_.traceDataCache_.get(), stream_.streamFilters_.get()); + uint32_t fd = 6; + uint64_t size = 222; + uint32_t flag = 0; + uint64_t expPid = 5; + DataIndex expTaskCommId = stream_.traceDataCache_->GetDataIndex("aaa"); + DataIndex bufNameId = stream_.traceDataCache_->GetDataIndex("bbb"); + DataIndex expNameId = stream_.traceDataCache_->GetDataIndex("ccc"); + + struct DeduplicateVar { + uint64_t timeStamp; + uint64_t pid; + std::string_view pidName; + uint32_t ino; + }; + vector stubVars = { + {1616439852302, 1, "render_service", 1}, + {1616439852302, 1, "render_service", 1}, + {1616439852302, 1, "render_service", 2}, + {1616439852302, 2, "app", 1}, + {1616439852302, 2, "app", 2}, + {1616439852302, 3, "composer_host", 1}, + {1616439852302, 3, "composer_host", 2}, + {1616439852302, 3, "composer_host", 2}, + + {1616439855302, 1, "render_service", 1}, + {1616439855302, 1, "render_service", 2}, + {1616439855302, 3, "composer_host", 2}, + {1616439855302, 3, "composer_host", 2}, + }; + for (auto& m : stubVars) { + auto ipid = stream_.streamFilters_->processFilter_->UpdateOrCreateProcessWithName(m.pid, m.pidName); + stream_.traceDataCache_->GetDmaMemData()->AppendNewData(ipid, m.timeStamp, fd, size, m.ino, expPid, + expTaskCommId, bufNameId, expNameId, flag); + } + + memParser->DmaMemDeduplicate(); + + auto DmaData = stream_.traceDataCache_->GetConstDmaMemData(); + EXPECT_EQ(DmaData.Flags()[0], 2); + EXPECT_EQ(DmaData.Flags()[1], 1); + EXPECT_EQ(DmaData.Flags()[2], 2); + EXPECT_EQ(DmaData.Flags()[3], 0); + EXPECT_EQ(DmaData.Flags()[4], 0); + EXPECT_EQ(DmaData.Flags()[5], 2); + EXPECT_EQ(DmaData.Flags()[6], 2); + EXPECT_EQ(DmaData.Flags()[7], 1); + EXPECT_EQ(DmaData.Flags()[8], 0); + EXPECT_EQ(DmaData.Flags()[9], 0); + EXPECT_EQ(DmaData.Flags()[10], 2); + EXPECT_EQ(DmaData.Flags()[11], 1); +} + } // namespace TraceStreamer } // namespace SysTuning