diff --git a/README_zh.md b/README_zh.md index b01b7e41e86b4a9ea9947ab326dc222150c9e824..a69806f902339e2c8bf4f3314aa9aa7aa6fb5e19 100644 --- a/README_zh.md +++ b/README_zh.md @@ -53,7 +53,7 @@ PC端以Smartperf_Host网站的形式进行发布,内部分为Trace Streamer ### Bio抓取 使用Smartperf_Host抓取每次IO访问的起始时间、总延迟、进程、每4k数据的平均延迟、线程、操作(写数据、页面换入、Metadata)、访问量、路径等、Block number、优先级、Backtrace调用栈,详见《[Bio的抓取和展示说明](./ide/src/doc/md/quickstart_bio.md)》。 ### 进程Smaps抓取 -使用Smartperf_Host抓取单个进程的smaps数据(类别、Pss、Rss、Vss等),数据源为/proc/$pid/smaps,详见《[进程smaps的抓取和展示说明](./ide/src/doc/md/quickstart_smaps.md)》。 +使用Smartperf_Host抓取单个进程的smaps数据(类别、Pss、Rss、Vss等),数据源为/proc/$pid/smaps,详见《[进程smaps的抓取和展示说明](./ide/src/doc/md/quickstart_memory_template.md)》。 ### Sql分析和Metrics说明 Smartperf_Host网站trace解析完成后在线数据库使用说明,详见《[Sql分析和Metrics说明](./ide/src/doc/md/quickstart_sql_metrics.md)》。 ## 发行版指南 diff --git a/ide/src/base-ui/chart/scatter/LitChartScatter.ts b/ide/src/base-ui/chart/scatter/LitChartScatter.ts new file mode 100644 index 0000000000000000000000000000000000000000..2abbb7c2156b01c3f65ea080c89276a7b970c03a --- /dev/null +++ b/ide/src/base-ui/chart/scatter/LitChartScatter.ts @@ -0,0 +1,601 @@ +/* + * Copyright (C) 2023 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 { resizeCanvas } from '../helper'; +import { BaseElement, element } from '../../BaseElement'; +import { LitChartScatterConfig } from './LitChartScatterConfig'; + +@element('lit-chart-scatter') +export class LitChartScatter extends BaseElement { + private scatterTipEL: HTMLDivElement | null | undefined; + private labelsEL: HTMLDivElement | null | undefined; + canvas: HTMLCanvasElement | undefined | null; + canvas2: HTMLCanvasElement | undefined | null; + ctx: CanvasRenderingContext2D | undefined | null; + originX: number = 0; + finalX: number = 0; + originY: number = 0; + finalY: number = 0; + options: LitChartScatterConfig | undefined; + + set config(LitChartScatterConfig: LitChartScatterConfig) { + this.options = LitChartScatterConfig; + this.init(); + } + init(): void { + if (this.options) { + // 清楚上一次绘制的数据 + this.ctx?.clearRect(0, 0, this.clientWidth, this.clientHeight); + this.drawBackground(); + this.drawScatterChart(this.options); + //使用off-screen-canvas保存绘制的像素点 + this.setOffScreen(); + this.labelsEL!.innerText = this.options.title; + } + } + // 使用离屏技术保存绘制的像素点 + setOffScreen(): void { + this.canvas2 = document.createElement('canvas'); + this.canvas2.height = this.clientHeight; + this.canvas2.width = this.clientWidth; + let context2: CanvasRenderingContext2D | null = this.canvas2.getContext('2d'); + if (this.canvas?.width !== 0 && this.canvas?.height !== 0) { + context2!.drawImage(this.canvas!, 0, 0); + } + } + /*绘制渐变色背景*/ + drawBackground(): void { + let w: number = this.clientWidth; + let h: number = this.clientHeight; + let color: CanvasGradient = this.ctx?.createRadialGradient( + w / 2, + h / 2, + 0.2 * w, + w / 2, + h / 2, + 0.5 * w + )!; + color?.addColorStop(0, '#eaeaea'); + color?.addColorStop(1, '#ccc'); + if (this.options) { + this.options!.globalGradient = color; + } + this.ctx?.save(); + this.ctx!.fillStyle = color; + this.ctx?.fillRect(0, 0, w, h); + this.ctx?.restore(); + } + /** + * 绘制散点图 + */ + drawScatterChart(options: LitChartScatterConfig): void { + this.drawAxis(options); //绘制坐标轴 + this.drawYLabels(options); //绘制y轴坐标 + this.drawXLabels(options); //绘制x轴坐标 + let drawload: boolean = false; + if (options) { + drawload = options.drawload; + } + if (drawload) { + let load: Array = []; + if (options) { + load = options.load; + this.drawBalanceLine(load); //绘制均衡线 + this.drawLoadLine(load); //绘制最大负载线 + } + } + this.drawData(options); //绘制散点图 + } + /** + * 绘制坐标轴 + */ + drawAxis(options: LitChartScatterConfig): void { + let text: Array = new Array(); + if (options) { + text = options.axisLabel; + } + this.ctx!.font = '10px KATTI'; + this.ctx!.fillStyle = '#000000'; + this.ctx!.strokeStyle = '#000000'; + // 画x轴 + this.ctx?.beginPath(); + this.ctx?.moveTo(this.originX, this.originY); + this.ctx?.lineTo(this.finalX, this.originY); + this.ctx?.fillText(text[0], this.finalX, this.originY); + this.ctx?.stroke(); + // 画Y轴 + this.ctx?.beginPath(); + this.ctx?.moveTo(this.originX, this.originY); + this.ctx?.lineTo(this.originX, this.finalY); + this.ctx?.fillText(text[1], this.originX - 20, this.finalY - 10); + this.ctx?.stroke(); + } + /** + * 绘制y轴坐标 + */ + drawYLabels(options: LitChartScatterConfig): void { + const AXAIS_DELTA: number = 5; + const QUYU: number = 100; + // 添加原点刻度 + this.ctx!.font = '12px KATTI'; + this.ctx!.fillStyle = '#000000'; + this.ctx!.strokeStyle = '#000000'; + this.ctx?.fillText('0', this.originX - AXAIS_DELTA, this.originY + AXAIS_DELTA * 2); + let yAxis: Array = []; + if (options) { + yAxis = options.yAxisLabel; + } + // 画Y轴坐标尺 + for (let i = 0; i < yAxis.length; i++) { + let length1: number = + (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) * + (yAxis[i] / yAxis[yAxis.length - 1]); + let length2: number = this.originY - length1; + let text: string = yAxis[i].toString(); + let x: number = this.originX - this.ctx?.measureText(text).width! - AXAIS_DELTA; + this.ctx?.beginPath(); + this.ctx?.moveTo(this.originX, length2); + this.ctx?.lineTo(this.originX + AXAIS_DELTA, length2); + this.ctx?.fillText(text, x, length2 + AXAIS_DELTA); + this.ctx?.stroke(); + } + } + /** + * 绘制x轴坐标 + */ + drawXLabels(options: LitChartScatterConfig): void { + // 画X轴坐标尺 + this.ctx!.fillStyle = '#000000'; + this.ctx!.strokeStyle = '#000000'; + const QUYU: number = 100; + const DELTA: number = 5; + let xAxis: Array = []; + if (options) { + xAxis = options.xAxisLabel; + } + for (let i = 0; i < xAxis.length; i++) { + let length3: number = + (this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) * + (xAxis[i] / xAxis[xAxis.length - 1]); + let length4: number = this.originX + length3; + this.ctx?.beginPath(); + this.ctx?.moveTo(length4, this.originY); + this.ctx?.lineTo(length4, this.originY - DELTA); + this.ctx?.fillText(xAxis[i].toString(), length4 - DELTA * 3, this.originY + DELTA * 2); + this.ctx?.stroke(); + } + } + + /** + * 绘制数据 + */ + drawData(options: LitChartScatterConfig): void { + let data: Array>> = []; + let yAxis: Array = []; + let xAxis: Array = []; + let colorPool: Array = new Array(); + let colorPoolText: Array = new Array(); + let rectY: number = this.clientHeight * 0.05; + const QUYU: number = 100; + const WIDTH_DELTA: number = 70; + if (options) { + data = options.data; + yAxis = options.yAxisLabel; + xAxis = options.xAxisLabel; + colorPool = options.colorPool(); + colorPoolText = options.colorPoolText(); + options.paintingData = []; + } + let xLength: number = this.finalX - this.originX - ((this.finalX - this.originX) % QUYU); + let yLength: number = this.originY - this.finalY - ((this.originY - this.finalY) % QUYU); + for (let i = 0; i < data.length; i++) { + for (let j = 0; j < data[i].length; j++) { + // 打点x坐标 + let x: number = this.originX + (data[i][j][0] / xAxis[xAxis.length - 1]) * xLength; + // 打点y坐标 + let y: number = this.originY - (data[i][j][1] / yAxis[yAxis.length - 1]) * yLength; + let r: number = 6; + if (i > 0) { + options.paintingData[data[i][j][2] - 1] = { + x, + y, + r, + c: data[i][j], + color: colorPool[i], + }; + } else { + options.paintingData.push({ + x, + y, + r, + c: data[i][j], + color: colorPool[i], + }); + } + this.drawCycle(x, y, r, 0.8, colorPool[i]); + } + if (data[i].length) { + rectY = rectY + 20; + this.ctx?.fillText(colorPoolText[i] + ': ', this.clientWidth - WIDTH_DELTA, rectY + 4); + this.drawCycle(this.clientWidth - (QUYU / 5), rectY, 7.5, 0.8, colorPool[i]); + } + } + } + /** + * 画圆点 + */ + drawCycle( + x: number, + y: number, + r: number, + transparency: number, + color: string + ): void { + this.ctx!.fillStyle = color; + this.ctx?.beginPath(); + this.ctx!.globalAlpha = transparency; + this.ctx?.arc(x, y, r, 0, Math.PI * 2, true); + this.ctx?.closePath(); + this.ctx?.fill(); + } + + /** + * 绘制最大负载线 + */ + drawLoadLine(data: Array): void { + let maxXAxis: number = 1; + const QUYU: number = 100; + const FOR_VALUE = 60; + if (this.options) { + maxXAxis = this.options.xAxisLabel[this.options.xAxisLabel.length - 1]; + } + // data[1]用来标注n Hz负载线 + let addr1: number = + this.originX + + (this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) * + (data[0] / maxXAxis); + let addr2: number = + (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) / FOR_VALUE; + let y: number = this.originY; + this.ctx!.strokeStyle = '#ff0000'; + for (let i = 0; i < FOR_VALUE; i++) { + this.ctx?.beginPath(); + this.ctx?.moveTo(addr1, y); + y -= addr2; + this.ctx?.lineTo(addr1, y); + if (i % 2 !== 0) { + this.ctx?.stroke(); + } + } + this.ctx!.font = '10px KATTI'; + this.ctx!.fillStyle = '#ff0000'; + this.ctx?.fillText( + data[1] + 'Hz最大负载线', + addr1 - FOR_VALUE / 3, + this.originY - addr2 * FOR_VALUE - FOR_VALUE / 4 + ); + this.ctx!.fillStyle = '#000000'; + this.ctx?.fillText('过供给区', addr1 / 2, y + FOR_VALUE / 2); + this.ctx?.fillText('欠供给区', addr1 / 2, this.originY - this.finalY); + this.ctx?.fillText( + '超负载区', + addr1 + FOR_VALUE / 3, + (this.finalY + this.originY) / 2 + ); + } + + /** + * 绘制均衡线 + */ + drawBalanceLine(data: Array): void { + let maxXAxis: number = 1; + const QUYU: number = 100; + const FOR_VALUE = 60; + if (this.options) { + maxXAxis = this.options.xAxisLabel[this.options.xAxisLabel.length - 1]; + } + // data[1]用来标注n Hz均衡线 + let addr1: number = + ((this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) * + (data[0] / maxXAxis)) / FOR_VALUE; + let addr2: number = + (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) / FOR_VALUE; + let x: number = this.originX; + let y: number = this.originY; + this.ctx!.strokeStyle = '#00ff00'; + for (let i = 0; i < FOR_VALUE; i++) { + this.ctx?.beginPath(); + this.ctx?.moveTo(x, y); + x += addr1; + y -= addr2; + this.ctx?.lineTo(x, y); + if (i % 2 === 0) { + this.ctx?.stroke(); + } + } + this.ctx?.save(); + this.ctx?.translate(addr1 * 25 + this.originX, addr2 * 40 + this.finalY); + this.ctx!.font = '10px KATTI'; + this.ctx!.fillStyle = '#ff0f00'; + this.ctx?.rotate(-Math.atan(addr2 / addr1)); + this.ctx?.fillText(data[1] + 'Hz均衡线', 0, 0); + this.ctx?.restore(); + } + + /*检测是否hover在散点之上*/ + checkHover( + options: LitChartScatterConfig | undefined, + pos: Object + ): Object | boolean { + let data: Array = []; + if (options) { + data = options.paintingData; + } + let found: boolean | Object = false; + for (let i = 0; i < data.length; i++) { + found = false; + // @ts-ignore + if ( + Math.sqrt( + // @ts-ignore + Math.pow(pos.x - data[i].x, 2) + Math.pow(pos.y - data[i].y, 2) + // @ts-ignore + ) < data[i].r + ) { + found = data[i]; + break; + } + } + return found; + } + + /*绘制hover状态*/ + paintHover(): void { + let obj: Object | null = this.options!.hoverData; + // @ts-ignore + let x: number = obj?.x; + // @ts-ignore + let y: number = obj?.y; + // @ts-ignore + let r: number = obj?.r; + // @ts-ignore + let c: string = obj?.color; + let step: number = 0.5; + this.ctx!.globalAlpha = 1; + this.ctx!.fillStyle = c; + for (let i = 0; i < 10; i++) { + this.ctx?.beginPath(); + this.ctx?.arc(x, y, r + i * step, 0, 2 * Math.PI, false); + this.ctx?.fill(); + this.ctx?.closePath(); + } + } + //利用离屏canvas恢复hover前的状态 + resetHoverWithOffScreen(): void { + let obj: Object | null = null; + const STEP_VALUE: number = 12; + const OUT_CYCLE: number = 2; + if (this.options) { + obj = this.options.hoverData; + } + if (!obj) { + return; + } + // @ts-ignore + let { x, y, r, c, color } = obj; + let step = 0.5; + this.ctx!.globalAlpha = 1; + for (let i = 10; i > 0; i--) { + this.ctx?.save(); + //绘制外圆范围 + this.ctx?.drawImage( + this.canvas2!, + x - r - STEP_VALUE * step, + y - r - STEP_VALUE * step, + OUT_CYCLE * (r + STEP_VALUE * step), + OUT_CYCLE * (r + STEP_VALUE * step), + x - r - STEP_VALUE * step, + y - r - STEP_VALUE * step, + OUT_CYCLE * (r + STEP_VALUE * step), + OUT_CYCLE * (r + STEP_VALUE * step) + ); + //绘制内圆 + this.ctx?.beginPath(); + this.ctx?.arc(x, y, r + i * step, 0, OUT_CYCLE * Math.PI, false); + this.ctx?.closePath(); + this.ctx!.fillStyle = color; + this.ctx!.globalAlpha = 0.8; + //填充内圆 + this.ctx?.fill(); + this.ctx?.restore(); + } + this.options!.hoverData = null; + } + /** + * 显示提示框 + */ + showTip(data: any): void { + const Y_DELTA: number = 70; + this.scatterTipEL!.style.display = 'flex'; + this.scatterTipEL!.style.top = `${data.y - Y_DELTA}px`; + this.scatterTipEL!.style.left = `${data.x}px`; + this.scatterTipEL!.innerHTML = this.options!.tip(data); + // @ts-ignore + this.options!.hoverEvent('CPU-FREQ', true, data.c[2] - 1); + } + /** + * 隐藏提示框 + */ + hideTip(): void { + this.scatterTipEL!.style.display = 'none'; + if (this.options) { + // @ts-ignore + this.options!.hoverEvent('CPU-FREQ', false); + } + } + + connectedCallback(): void { + super.connectedCallback(); + this.canvas = this.shadowRoot!.querySelector('#canvas'); + this.scatterTipEL = this.shadowRoot!.querySelector('#tip'); + this.ctx = this.canvas!.getContext('2d', { alpha: true }); + this.labelsEL = this.shadowRoot!.querySelector('#shape'); + resizeCanvas(this.canvas!); + this.originX = this.clientWidth * 0.1; + this.originY = this.clientHeight * 0.9; + this.finalX = this.clientWidth; + this.finalY = this.clientHeight * 0.1; + /*hover效果*/ + this.canvas!.onmousemove = (event) => { + let pos: Object = { + x: event.offsetX, + y: event.offsetY, + }; + let hoverPoint: Object | boolean = this.checkHover(this.options, pos); + /** + * 如果当前有聚焦点 + */ + if (hoverPoint) { + this.showTip(hoverPoint); + let samePoint: boolean = + this.options!.hoverData === hoverPoint ? true : false; + if (!samePoint) { + this.resetHoverWithOffScreen(); + this.options!.hoverData = hoverPoint; + } + this.paintHover(); + } else { + //使用离屏canvas恢复 + this.resetHoverWithOffScreen(); + this.hideTip(); + } + }; + } + + initElements(): void { + new ResizeObserver((entries, observer) => { + entries.forEach((it) => { + resizeCanvas(this.canvas!); + this.originX = this.clientWidth * 0.1; + this.originY = this.clientHeight * 0.95; + this.finalX = this.clientWidth * 0.9; + this.finalY = this.clientHeight * 0.1; + this.labelsEL!.innerText = ''; + this.init(); + }); + }).observe(this); + } + + initHtml(): string { + return ` + +
+
+ +
+
+
`; + } +} diff --git a/ide/src/base-ui/chart/scatter/LitChartScatterConfig.ts b/ide/src/base-ui/chart/scatter/LitChartScatterConfig.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb3b9daa588d795902778a5babfd86485367b25f --- /dev/null +++ b/ide/src/base-ui/chart/scatter/LitChartScatterConfig.ts @@ -0,0 +1,45 @@ + +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface LitChartScatterConfig { + // y轴坐标数组 + yAxisLabel: Array; + // x轴坐标数组 + xAxisLabel: Array; + // 坐标轴名称 + axisLabel: Array; + // 用于判断是否绘制负载线及均衡线 + drawload: boolean; + // 用于存放最大负载线及均衡线的参数值 + load: Array; + // 打点数据 + data: Array>>; + // 用于存放绘图数据 + paintingData: Array; + // 用于存放移入点数据 + hoverData: Object | null; + // 渐变色信息 + globalGradient: CanvasGradient | undefined; + // 颜色池 + colorPool: () => Array; + // 移入事件 + hoverEvent: void; + // 图表名称 + title: string; + // 颜色数据名称 + colorPoolText: () => Array; + // 提示信息 + tip: (a: any) => string; +} diff --git a/ide/src/base-ui/drawer/LitDrawer.ts b/ide/src/base-ui/drawer/LitDrawer.ts index b08930063204f2199e511ad1ce91eb2f0acbc47d..3c038ff539a50c9acfd6883753c6a9b323fb2d24 100644 --- a/ide/src/base-ui/drawer/LitDrawer.ts +++ b/ide/src/base-ui/drawer/LitDrawer.ts @@ -14,9 +14,8 @@ */ import { BaseElement, element } from '../BaseElement'; +import { replacePlaceholders } from '../utils/Template'; -let contentPadding = ''; -let contentWidth = ''; let css = ` -` - -const initHtmlStyle = (wid: string) => { - width = wid; - return css; -} - -@element('lit-modal') -export class LitModal extends BaseElement { - private headerTitleElement: HTMLElement | null | undefined; - private headerElement: HTMLElement | null | undefined; - private closeElement: HTMLElement | null | undefined; - private cancelElement: HTMLElement | null | undefined; - private okElement: HTMLElement | null | undefined; - private modalElement: HTMLElement | null | undefined; - private resizing: boolean = false; - private down: boolean = false; - private onmouseleaveMoveFunc: any; - private onmouseupFunc: any; - private onmousedownMoveFunc: any; - private onmousedownFunc: any; - private onmousemoveMoveFunc: any; - private onmousemoveFunc: any; - private onmouseupMoveFunc: any; - static get observedAttributes() { - return [ - 'title', //标题 - 'line', //body的线条 - 'visible', //是否显示modal窗口 - 'ok-text', //确定文本 - 'cancel-text', //取消文本 - 'moveable', //设置窗口是否可以鼠标拖动 - 'resizeable', //窗口可改变大小 - 'width', //modal宽度 - ]; - } - - get okText() { - return this.getAttribute('ok-text') || '确定'; - } - - set okText(value) { - this.setAttribute('ok-text', value); - } - - get cancelText() { - return this.getAttribute('cancel-text') || '取消'; - } - - set cancelText(value) { - this.setAttribute('cancel-text', value); - } - - get title() { - return this.getAttribute('title') || ''; - } - - set title(value) { - this.setAttribute('title', value); - } - - get visible() { - return this.hasAttribute('visible'); - } - - set visible(value) { - if (value) { - this.setAttribute('visible', ''); - } else { - this.removeAttribute('visible'); - } - } - - get width() { - return this.getAttribute('width') || '500px'; - } - - set width(value) { - this.setAttribute('width', value); - } - - get resizeable() { - return this.hasAttribute('resizeable'); - } - - set resizeable(value) { - if (value) { - this.setAttribute('resizeable', ''); - } else { - this.removeAttribute('resizeable'); - } - } - - get moveable() { - return this.hasAttribute('moveable'); - } - - set moveable(value) { - if (value) { - this.setAttribute('moveable', ''); - } else { - this.removeAttribute('moveable'); - } - } - - set onOk(fn: any) { - this.addEventListener('onOk', fn); - } - - set onCancel(fn: any) { - this.addEventListener('onCancel', fn); - } - - initHtml(): string { - return ` - ${initHtmlStyle(this.width)} - - `; - } - - //当 custom element首次被插入文档DOM时,被调用。 - initElements(): void { - this.headerTitleElement = this.shadowRoot!.querySelector('#modal-title'); - this.headerTitleElement!.textContent = this.title; - this.headerElement = this.shadowRoot!.querySelector('.header'); - this.closeElement = this.shadowRoot!.querySelector('.close-icon'); - this.cancelElement = this.shadowRoot!.querySelector('#cancel'); - this.okElement = this.shadowRoot!.querySelector('#ok'); - this.closeElement!.onclick = (ev) => (this.visible = false); - this.modalElement = this.shadowRoot!.querySelector('.modal'); - this.shadowRoot!.querySelector('.modal')!.onclick = (e) => { - e.stopPropagation(); - }; - this.setClick(); - if (this.moveable || this.resizeable) { - if (this.resizeable) { - let resizeWidth = 8; - this.resizing = false; - let srcResizeClientX = 0, - srcResizeClientY = 0, - srcResizeRect, - srcResizeHeight = 0, - srcResizeWidth = 0, - srcResizeRight = 0, - srcResizeLeft = 0, - srcResizeTop = 0; - let direction: string; - this.onmousemoveFunc = (e: any) => { - e.stopPropagation(); - srcResizeRect = this.modalElement!.getBoundingClientRect(); - direction = this.onmousemoveFuncRule(direction,e,srcResizeRect,resizeWidth); - this.resizingFunc(direction,e,srcResizeClientX,srcResizeClientY,srcResizeHeight,srcResizeWidth,srcResizeLeft,srcResizeTop); - }; - this.setOnmousedownFunc(resizeWidth); - this.onmouseupFunc = (e: any) => { - this.resizing = false; - }; - } - this.buildFunc(); - this.onmouseleave = this.onmouseup = (e) => { - if (this.onmouseleaveMoveFunc) this.onmouseleaveMoveFunc(e); - if (this.onmouseupFunc) this.onmouseupFunc(e); - document.body.style.userSelect = ''; - }; - } - } - - setClick():void{ - this.onclick = (ev) => { - ev.stopPropagation(); - if (!this.resizeable) { - this.visible = false; - } - }; - this.cancelElement!.onclick = (ev) => { - this.dispatchEvent(new CustomEvent('onCancel', ev)); - }; - this.okElement!.onclick = (ev) => { - this.dispatchEvent(new CustomEvent('onOk', ev)); - }; - } - - buildFunc():void{ - if (this.moveable) { - this.down = false; - let srcClientX = 0; - let srcClientY = 0; - let srcLeft = 0; - let srcTop = 0; - let srcRight = 0; - let srcBottom = 0; - let clientRect; - let rootRect: any; - this.onmousedownMoveFunc = (e: any) => { - if (this.resizing) return; - srcClientX = e.clientX; - srcClientY = e.clientY; - rootRect = this.getBoundingClientRect(); - clientRect = this.modalElement!.getBoundingClientRect(); - srcLeft = clientRect.left; - srcRight = clientRect.right; - srcTop = clientRect.top; - srcBottom = clientRect.bottom; - if ( - e.clientX > srcLeft + 10 && - e.clientX < srcRight - 10 && - e.clientY > srcTop + 10 && - e.clientY < srcTop + this.headerElement!.scrollHeight - ) { - this.down = true; - } else { - this.down = false; - } - if (this.down) document.body.style.userSelect = 'none'; - this.setOnmousemoveMoveFunc(e, srcClientX, srcClientY, srcLeft, srcTop, srcRight, srcBottom, clientRect, rootRect); - this.onmouseleaveMoveFunc = this.onmouseupMoveFunc = (e: any) => { - this.down = false; - this.headerElement!.style.cursor = ''; - }; - }; - } - this.onmousemove = (e) => { - if (this.onmousemoveFunc) this.onmousemoveFunc(e); - if (this.onmousemoveMoveFunc) this.onmousemoveMoveFunc(e); - }; - this.onmousedown = (e) => { - if (this.onmousedownFunc) this.onmousedownFunc(e); - if (this.onmousedownMoveFunc) this.onmousedownMoveFunc(e); - }; - } - - setOnmousemoveMoveFunc(e:any,srcClientX:number,srcClientY:number,srcLeft:number,srcTop:number,srcRight:number,srcBottom:number,clientRect:any,rootRect:any):void{ - this.onmousemoveMoveFunc = (ev: any) => { - if (this.down) { - let offsetY = e.clientY - srcClientY; - let offsetX = e.clientX - srcClientX; - if (e.clientX > srcLeft + 10 && e.clientX < srcRight - 10 && e.clientY > srcTop + 10) { - this.headerElement!.style.cursor = 'move'; - clientRect = this.modalElement!.getBoundingClientRect(); - //下面 rootRect.height 改成 this.scrollHeight 解决modal 过长会出现滚动条的情况 - if ( - ev.clientY - srcClientY + srcTop > 0 && - ev.clientY - srcClientY + srcTop < this.scrollHeight - clientRect.height - ) { - this.modalElement!.style.top = ev.clientY - srcClientY + srcTop + 'px'; - } else { - if (ev.clientY - srcClientY + srcTop <= 0) { - this.modalElement!.style.top = '0px'; - } else { - //下面 rootRect.height 改成 this.scrollHeight 解决modal 过长会出现滚动条的情况 - this.modalElement!.style.top = this.scrollHeight - clientRect.height + 'px'; - } - } - //ev.clientX-srcClientX 鼠标移动像素 - if ( - ev.clientX - srcClientX + srcLeft > 0 && - ev.clientX - srcClientX + srcLeft < rootRect.width - clientRect.width - ) { - this.modalElement!.style.left = ev.clientX - srcClientX + srcLeft + clientRect.width / 2 + 'px'; - } else { - if (ev.clientX - srcClientX + srcLeft <= 0) { - this.modalElement!.style.left = clientRect.width / 2 + 'px'; - } else { - this.modalElement!.style.left = rootRect.width - clientRect.width + clientRect.width / 2 + 'px'; - } - } - } - } - }; - } - - onmousemoveFuncRule(direction:string,e:any,srcResizeRect:any,resizeWidth:number):string{ - if ( - e.clientX > srcResizeRect.left - resizeWidth && - e.clientX < srcResizeRect.left + resizeWidth && - e.clientY > srcResizeRect.top - resizeWidth && - e.clientY < srcResizeRect.top + resizeWidth - ) { - this.style.cursor = 'nwse-resize'; - if (!this.resizing) return 'left-top'; - } else if ( - e.clientX > srcResizeRect.right - resizeWidth && - e.clientX < srcResizeRect.right + resizeWidth && - e.clientY > srcResizeRect.top - resizeWidth && - e.clientY < srcResizeRect.top + resizeWidth - ) { - this.style.cursor = 'nesw-resize'; - if (!this.resizing) return 'right-top'; - } else if ( - e.clientX > srcResizeRect.left - resizeWidth && - e.clientX < srcResizeRect.left + resizeWidth && - e.clientY > srcResizeRect.bottom - resizeWidth && - e.clientY < srcResizeRect.bottom + resizeWidth - ) { - this.style.cursor = 'nesw-resize'; - if (!this.resizing) return 'left-bottom'; - } else { - return this.funcRuleIf(direction,e,srcResizeRect,resizeWidth); - } - return '' - } - - funcRuleIf(direction:string,e:any,srcResizeRect:any,resizeWidth:number):string{ - if ( - e.clientX > srcResizeRect.right - resizeWidth && - e.clientX < srcResizeRect.right + resizeWidth && - e.clientY > srcResizeRect.bottom - resizeWidth && - e.clientY < srcResizeRect.bottom + resizeWidth - ) { - this.style.cursor = 'nwse-resize'; - if (!this.resizing) return 'right-bottom'; - } else if (e.clientX > srcResizeRect.left - resizeWidth && e.clientX < srcResizeRect.left + resizeWidth) { - this.style.cursor = 'ew-resize'; - if (!this.resizing) return 'left'; - } else if (e.clientX < srcResizeRect.right + resizeWidth && e.clientX > srcResizeRect.right - resizeWidth) { - this.style.cursor = 'ew-resize'; - if (!this.resizing) return 'right'; - } else if (e.clientY > srcResizeRect.top - resizeWidth && e.clientY < srcResizeRect.top + resizeWidth) { - this.style.cursor = 'ns-resize'; - if (!this.resizing) return 'top'; - } else if (e.clientY < srcResizeRect.bottom + resizeWidth && e.clientY > srcResizeRect.bottom - resizeWidth) { - this.style.cursor = 'ns-resize'; - if (!this.resizing) return 'bottom'; - } else { - this.style.cursor = ''; - if (!this.resizing) return ''; - } - return ''; - } - - resizingFunc(direction:string,e:any,srcResizeClientX:number,srcResizeClientY:number,srcResizeHeight:number,srcResizeWidth:number,srcResizeLeft:number,srcResizeTop:number):void{ - if (this.resizing) { - let offsetResizeY = e.clientY - srcResizeClientY; - let offsetResizeX = e.clientX - srcResizeClientX; - if (direction === 'bottom') { - this.modalElement!.style.height = srcResizeHeight + offsetResizeY + 'px'; - } else if (direction === 'top') { - this.modalElement!.style.top = srcResizeTop + offsetResizeY + 'px'; - this.modalElement!.style.height = srcResizeHeight - offsetResizeY + 'px'; - } else if (direction === 'right') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth + offsetResizeX + 'px'; - } else if (direction === 'left') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth - offsetResizeX + 'px'; - } else if (direction === 'left-top') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth - offsetResizeX + 'px'; - this.modalElement!.style.top = srcResizeTop + offsetResizeY + 'px'; - this.modalElement!.style.height = srcResizeHeight - offsetResizeY + 'px'; - } else if (direction === 'right-top') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth + offsetResizeX + 'px'; - this.modalElement!.style.top = srcResizeTop + offsetResizeY + 'px'; - this.modalElement!.style.height = srcResizeHeight - offsetResizeY + 'px'; - } else if (direction === 'left-bottom') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth - offsetResizeX + 'px'; - this.modalElement!.style.height = srcResizeHeight + offsetResizeY + 'px'; - } else if (direction === 'right-bottom') { - this.modalElement!.style.left = srcResizeLeft + srcResizeWidth / 2 + offsetResizeX / 2 + 'px'; - this.modalElement!.style.width = srcResizeWidth + offsetResizeX + 'px'; - this.modalElement!.style.height = srcResizeHeight + offsetResizeY + 'px'; - } - } - } - - setOnmousedownFunc(resizeWidth: number): void { - this.onmousedownFunc = (e: any) => { - const srcResizeRect = this.modalElement!.getBoundingClientRect(); - const { clientX, clientY } = e; - const { left, right, top, bottom, width, height } = srcResizeRect; - const resizeRange = resizeWidth * 2; - - const isWithinRange = (coord: number, target: number, range: number) => - coord > target - range && coord < target + range; - - const isWithinCornerRange = (cornerX: number, cornerY: number) => - isWithinRange(clientX, cornerX, resizeRange) && - isWithinRange(clientY, cornerY, resizeRange); - - const isWithinTopLeft = isWithinCornerRange(left, top); - const isWithinTopRight = isWithinCornerRange(right, top); - const isWithinBottomLeft = isWithinCornerRange(left, bottom); - const isWithinBottomRight = isWithinCornerRange(right, bottom); - - if ( - isWithinTopLeft || - isWithinTopRight || - isWithinBottomLeft || - isWithinBottomRight - ) { - this.resizing = true; - } else { - this.resizeIf(e, srcResizeRect, resizeWidth); - } - - if (this.resizing) { - document.body.style.userSelect = 'none'; - } - }; - } - - resizeIf(e:any,srcResizeRect:any,resizeWidth:number){ - if (e.clientX > srcResizeRect.left - resizeWidth && e.clientX < srcResizeRect.left + resizeWidth) { - this.resizing = true; - } else if (e.clientX < srcResizeRect.right + resizeWidth && e.clientX > srcResizeRect.right - resizeWidth) { - this.resizing = true; - } else if (e.clientY > srcResizeRect.top - resizeWidth && e.clientY < srcResizeRect.top + resizeWidth) { - this.resizing = true; - } else if (e.clientY < srcResizeRect.bottom + resizeWidth && e.clientY > srcResizeRect.bottom - resizeWidth) { - this.resizing = true; - } else { - this.resizing = false; - } - } - - //当 custom element从文档DOM中删除时,被调用。 - disconnectedCallback() {} - - //当 custom element被移动到新的文档时,被调用。 - adoptedCallback() {} - - //当 custom element增加、删除、修改自身属性时,被调用。 - attributeChangedCallback(name: string, oldValue: string, newValue: string) { - if (name === 'visible') { - if (!newValue && this.modalElement) { - this.modalElement.style.top = '100px'; - this.modalElement.style.left = '50%'; - } - } else if (name === 'title' && this.headerTitleElement) { - this.headerTitleElement.textContent = newValue; - } - } -} - -if (!customElements.get('lit-modal')) { - customElements.define('lit-modal', LitModal); -} diff --git a/ide/src/base-ui/popover/LitPopoverV.ts b/ide/src/base-ui/popover/LitPopoverV.ts index 2376d82b843eb42d5523c993bbb08ecc42dbd634..225e84e7c5b283737c614b239d7c2dfa438b827a 100644 --- a/ide/src/base-ui/popover/LitPopoverV.ts +++ b/ide/src/base-ui/popover/LitPopoverV.ts @@ -14,7 +14,7 @@ */ import { BaseElement, element } from '../BaseElement'; -let width = ''; +import { replacePlaceholders } from '../utils/Template'; let css = ` ` const initHtmlStyle = (wid: string) => { - width = wid; - return css; + return replacePlaceholders(css,wid); }; @element('lit-popover') diff --git a/ide/src/base-ui/select/LitAllocationSelect.ts b/ide/src/base-ui/select/LitAllocationSelect.ts index e1f783fbb7c80a77d76b8a6e8c02e5bd84cc6cc7..10c6d03fcfc33a7a33d12afd2a75236619977efa 100644 --- a/ide/src/base-ui/select/LitAllocationSelect.ts +++ b/ide/src/base-ui/select/LitAllocationSelect.ts @@ -14,8 +14,8 @@ */ import { BaseElement, element } from '../BaseElement'; +import { replacePlaceholders } from '../utils/Template'; -let listHeight = ''; let css = ` `; const initHtmlStyle = (height: string): string => { - listHeight = height; - return css; + return replacePlaceholders(css, height); }; @element('lit-allocation-select') diff --git a/ide/src/base-ui/select/LitSelectHtml.ts b/ide/src/base-ui/select/LitSelectHtml.ts index dad54d68e4f5801f8e2150c9c81fe5a8d60880ba..47aa38f32aa73f3b0f433bd75d57bcf9b4a42f2d 100644 --- a/ide/src/base-ui/select/LitSelectHtml.ts +++ b/ide/src/base-ui/select/LitSelectHtml.ts @@ -13,7 +13,8 @@ * limitations under the License. */ -let listHeight = ''; +import { replacePlaceholders } from '../utils/Template'; + let css = ` `; const initHtmlStyle = (str: string | null, text: string | null) => { - colorStr = str; - colorText = text; - return css; + return replacePlaceholders(css, str!, text!); }; @element('lit-slider') diff --git a/ide/src/base-ui/table/LitPageTable.ts b/ide/src/base-ui/table/LitPageTable.ts index c9d3161739eb1555e8b5d36f138de12433537442..f1022b52a23a598af662217bc269a31a514e12ae 100644 --- a/ide/src/base-ui/table/LitPageTable.ts +++ b/ide/src/base-ui/table/LitPageTable.ts @@ -22,12 +22,13 @@ import { addCopyEventListener, addSelectAllBox, createDownUpSvg, - exportData, fixed, + exportData, + fixed, formatExportData, formatName, iconPadding, iconWidth, - litPageTableHtml + litPageTableHtml, } from './LitTableHtml'; @element('lit-page-table') @@ -199,7 +200,6 @@ export class LitPageTable extends BaseElement { this.tableElement!.scrollLeft = 0; } else { this.tableElement!.scrollTop = 0; - this.tableElement!.scrollLeft = 0; } } @@ -321,9 +321,9 @@ export class LitPageTable extends BaseElement { rowElement.append(h); } }); - }; + } - resolvingAreaColumnOrder(column: any, index: number, key: string,head: any): void { + resolvingAreaColumnOrder(column: any, index: number, key: string, head: any): void { if (column.hasAttribute('order')) { (head as any).sortType = 0; head.classList.add('td-order'); @@ -389,6 +389,13 @@ export class LitPageTable extends BaseElement { this.gridTemplateColumns[i] = `${node.clientWidth}px`; } this.gridTemplateColumns[this.resizeColumnIndex - 1] = `${prePageWidth}px`; + let lastNode = header.childNodes.item(header.childNodes.length - 1) as HTMLDivElement; + let totalWidth = 0; + this.gridTemplateColumns.forEach((it) => { + totalWidth += parseInt(it); + }); + totalWidth = Math.max(totalWidth, this.shadowRoot!.querySelector('.table')!.scrollWidth); + this.gridTemplateColumns[this.gridTemplateColumns.length - 1] = `${totalWidth - lastNode.offsetLeft - 1}px`; header.style.gridTemplateColumns = this.gridTemplateColumns.join(' '); let preNode = header.childNodes.item(this.resizeColumnIndex - 1) as HTMLDivElement; preNode.style.width = `${prePageWidth}px`; @@ -424,12 +431,14 @@ export class LitPageTable extends BaseElement { header.style.cursor = 'pointer'; }); element.addEventListener('mousedown', (event) => { - this.resizeColumnIndex = index; - this.isResize = true; - this.resizeDownX = event.clientX; - let pre = header.childNodes.item(this.resizeColumnIndex - 1) as HTMLDivElement; - this.beforeResizeWidth = pre.clientWidth; - event.stopPropagation(); + if (event.button === 0) { + this.resizeColumnIndex = index; + this.isResize = true; + this.resizeDownX = event.clientX; + let pre = header.childNodes.item(this.resizeColumnIndex - 1) as HTMLDivElement; + this.beforeResizeWidth = pre.clientWidth; + event.stopPropagation(); + } }); element.addEventListener('click', (event) => { event.stopPropagation(); @@ -500,36 +509,36 @@ export class LitPageTable extends BaseElement { addOnScrollListener(visibleObjList: TableRowObject[]): void { this.tableElement && - (this.tableElement.onscroll = (event) => { - let tblScrollTop = this.tableElement!.scrollTop; - let skip = 0; - for (let i = 0; i < visibleObjList.length; i++) { - if ( - visibleObjList[i].top <= tblScrollTop && - visibleObjList[i].top + visibleObjList[i].height >= tblScrollTop - ) { - skip = i; - break; + (this.tableElement.onscroll = (event) => { + let tblScrollTop = this.tableElement!.scrollTop; + let skip = 0; + for (let i = 0; i < visibleObjList.length; i++) { + if ( + visibleObjList[i].top <= tblScrollTop && + visibleObjList[i].top + visibleObjList[i].height >= tblScrollTop + ) { + skip = i; + break; + } } - } - let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); - if (reduce == 0) { - return; - } - while ( - reduce <= this.tableElement!.clientHeight && - this.currentRecycleList.length + skip < visibleObjList.length + let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); + if (reduce == 0) { + return; + } + while ( + reduce <= this.tableElement!.clientHeight && + this.currentRecycleList.length + skip < visibleObjList.length ) { - let newTableElement = this.createNewTableElement(visibleObjList[skip]); - this.tbodyElement?.append(newTableElement); - this.currentRecycleList.push(newTableElement); - reduce += newTableElement.clientHeight; - } - this.startSkip = skip; - for (let i = 0; i < this.currentRecycleList.length; i++) { - this.freshCurrentLine(this.currentRecycleList[i], visibleObjList[i + skip]); - } - }); + let newTableElement = this.createNewTableElement(visibleObjList[skip]); + this.tbodyElement?.append(newTableElement); + this.currentRecycleList.push(newTableElement); + reduce += newTableElement.clientHeight; + } + this.startSkip = skip; + for (let i = 0; i < this.currentRecycleList.length; i++) { + this.freshCurrentLine(this.currentRecycleList[i], visibleObjList[i + skip]); + } + }); } measureReset(): void { @@ -593,40 +602,40 @@ export class LitPageTable extends BaseElement { addTreeRowScrollListener(): void { this.tableElement && - (this.tableElement.onscroll = (event) => { - let visibleObjs = this.recycleDs.filter((item) => { - return !item.rowHidden; - }); - let top = this.tableElement!.scrollTop; - this.treeElement!.style.transform = `translateY(${top}px)`; - let skip = 0; - for (let index = 0; index < visibleObjs.length; index++) { - if (visibleObjs[index].top <= top && visibleObjs[index].top + visibleObjs[index].height >= top) { - skip = index; - break; + (this.tableElement.onscroll = (event) => { + let visibleObjs = this.recycleDs.filter((item) => { + return !item.rowHidden; + }); + let top = this.tableElement!.scrollTop; + this.treeElement!.style.transform = `translateY(${top}px)`; + let skip = 0; + for (let index = 0; index < visibleObjs.length; index++) { + if (visibleObjs[index].top <= top && visibleObjs[index].top + visibleObjs[index].height >= top) { + skip = index; + break; + } } - } - let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); - if (reduce == 0) { - return; - } - while (reduce <= this.tableElement!.clientHeight) { - let newTableElement = this.createNewTreeTableElement(visibleObjs[skip]); - this.tbodyElement?.append(newTableElement); - if (this.treeElement?.lastChild) { - (this.treeElement?.lastChild as HTMLElement).style.height = visibleObjs[skip].height + 'px'; + let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); + if (reduce == 0) { + return; } - this.currentRecycleList.push(newTableElement); - reduce += newTableElement.clientHeight; - } - for (let i = 0; i < this.currentRecycleList.length; i++) { - this.freshCurrentLine( - this.currentRecycleList[i], - visibleObjs[i + skip], - this.treeElement?.children[i] as HTMLElement - ); - } - }); + while (reduce <= this.tableElement!.clientHeight) { + let newTableElement = this.createNewTreeTableElement(visibleObjs[skip]); + this.tbodyElement?.append(newTableElement); + if (this.treeElement?.lastChild) { + (this.treeElement?.lastChild as HTMLElement).style.height = visibleObjs[skip].height + 'px'; + } + this.currentRecycleList.push(newTableElement); + reduce += newTableElement.clientHeight; + } + for (let i = 0; i < this.currentRecycleList.length; i++) { + this.freshCurrentLine( + this.currentRecycleList[i], + visibleObjs[i + skip], + this.treeElement?.children[i] as HTMLElement + ); + } + }); } createNewTreeTableElement(rowData: TableRowObject): any { @@ -880,7 +889,7 @@ export class LitPageTable extends BaseElement { if (reduce === 0) { return; } - while (reduce <= this.tableElement!.clientHeight) { + while (reduce <= this.tableElement!.clientHeight + 1) { let rowElement; if (this.hasAttribute('tree')) { rowElement = this.createNewTreeTableElement(visibleObjs[skip]); @@ -917,7 +926,7 @@ export class LitPageTable extends BaseElement { let td: any; td = document.createElement('div'); td.classList.add('td'); - td.style.overflow = 'scroll hidden'; + td.style.overflow = 'hidden'; td.style.textOverflow = 'ellipsis'; td.style.whiteSpace = 'nowrap'; td.dataIndex = dataIndex; @@ -947,6 +956,7 @@ export class LitPageTable extends BaseElement { rowElement.style.position = 'absolute'; rowElement.style.top = '0px'; rowElement.style.left = '0px'; + rowElement.style.height = `${rowData.height}px`; if (this.getItemTextColor) { rowElement.style.color = this.getItemTextColor(rowData.data); } diff --git a/ide/src/base-ui/table/LitTableHtml.ts b/ide/src/base-ui/table/LitTableHtml.ts index a907921b54cfc18b1c7be3130af41ac15f90f86e..144d7a7d10560cf8e79fd09b4d34c9c3fe214904 100644 --- a/ide/src/base-ui/table/LitTableHtml.ts +++ b/ide/src/base-ui/table/LitTableHtml.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import {JSONToCSV} from "../utils/CSVFormater"; +import { JSONToCSV } from '../utils/CSVFormater'; export const iconWidth = 20; export const iconPadding = 5; @@ -37,6 +37,7 @@ export const litPageTableHtml = ` } .tr{ background-color: var(--dark-background,#FFFFFF); + line-height: 27px; } .tr:hover{ background-color: var(--dark-background6,#DEEDFF); @@ -55,6 +56,7 @@ export const litPageTableHtml = ` align-items: center; width: 100%; height: auto; + line-height: 21px; cursor: pointer; } .td label{ @@ -547,7 +549,7 @@ export function createDownUpSvg(index: number, head: any) { downSvg.style.display = 'none'; head.appendChild(upSvg); head.appendChild(downSvg); - return {upSvg, downSvg} + return { upSvg, downSvg }; } export function exportData(that: any): void { @@ -684,4 +686,4 @@ export function formatName(key: string, name: any, that: any): any { return content.toString().replace(//g, '>'); } return ''; -} \ No newline at end of file +} diff --git a/ide/src/base-ui/table/lit-table.ts b/ide/src/base-ui/table/lit-table.ts index e6724e7a3a71b883a9a7f034989f96fb307c1c36..4e218de42ef41bf56da7514d4e1ae9097ad8e11e 100644 --- a/ide/src/base-ui/table/lit-table.ts +++ b/ide/src/base-ui/table/lit-table.ts @@ -34,7 +34,7 @@ import { addCopyEventListener, addSelectAllBox, fixed, - formatName + formatName, } from './LitTableHtml'; @element('lit-table') @@ -173,26 +173,19 @@ export class LitTable extends HTMLElement { this.tableElement!.scrollLeft = 0; } else { this.tableElement!.scrollTop = 0; - this.tableElement!.scrollLeft = 0; } - if (this.hasAttribute('tree')) { - if (value.length === 0) { - this.value = []; - this.recycleDs = this.meauseTreeRowElement(value); - } else { - if ( - value !== this.value && - this.value.length !== 0 && - !this._isSearch && - this.querySelector('lit-table-column')?.hasAttribute('retract') - ) { + if (this.hasAttribute('tree') && this.querySelector('lit-table-column')?.hasAttribute('retract')) { + if ((value.length === 0 || this.value.length !== 0) && value !== this.value && !this._isSearch) { + if (this.shadowRoot!.querySelector('.top')) { this.shadowRoot!.querySelector('.top')!.name = 'up'; + } + if (this.shadowRoot!.querySelector('.bottom')) { this.shadowRoot!.querySelector('.bottom')!.name = 'down'; } - this._isSearch = false; - this.value = value; - this.recycleDs = this.meauseTreeRowElement(value, RedrawTreeForm.Retract); } + this.value = value; + this._isSearch = false; + this.recycleDs = this.meauseTreeRowElement(value, RedrawTreeForm.Retract); } else { this.recycleDs = this.meauseAllRowHeight(value); } @@ -274,8 +267,14 @@ export class LitTable extends HTMLElement { } }); } - - setStatus(list: any, status: boolean, depth: number = 0): void { + /** + * 设置表格每条数据的展开/收起状态 + * @param list 表格数据 + * @param status 展开/收起状态 + * @param depth 展开深度,用来实现和图标的联动 + * @param profundity 展开深度,用来实现逐级展开 + */ + public setStatus(list: any, status: boolean, depth: number = 0, profundity?: number): void { this.tableElement!.scrollTop = 0; // 添加depth参数,让切换图标的代码在递归中只走一遍 if (depth === 0) { @@ -288,9 +287,19 @@ export class LitTable extends HTMLElement { } } for (let item of list) { - item.status = status; + if (profundity) { + if (depth < profundity) { + item.status = true; + status = true; + } else { + item.status = false; + status = false; + } + } else { + item.status = status; + } if (item.children !== undefined && item.children.length > 0) { - this.setStatus(item.children, status, depth + 1); + this.setStatus(item.children, status, depth + 1, profundity); } } } @@ -384,7 +393,7 @@ export class LitTable extends HTMLElement { rowElement.append(head); } }); - }; + } resolvingAreaColumn(rowElement: HTMLDivElement, column: any, index: number, key: string): HTMLDivElement { let head: any = document.createElement('div'); @@ -456,7 +465,7 @@ export class LitTable extends HTMLElement { } } - resolvingAreaColumnOrder(column: any, index: number, key: string,columnHead: any): void { + resolvingAreaColumnOrder(column: any, index: number, key: string, columnHead: any): void { if (column.hasAttribute('order')) { (columnHead as any).sortType = 0; columnHead.classList.add('td-order'); @@ -512,7 +521,7 @@ export class LitTable extends HTMLElement { private beforeResizeWidth: number = 0; resizeEventHandler(header: HTMLDivElement, element: HTMLDivElement, index: number): void { - this.resizeMouseMoveEventHandler(header); + this.resizeMouseMoveEventHandler(header); header.addEventListener('mouseup', (event) => { if (!this.columnResizeEnable) return; this.isResize = false; @@ -556,11 +565,19 @@ export class LitTable extends HTMLElement { let width = event.clientX - this.resizeDownX; header.style.cursor = 'col-resize'; let preWidth = Math.max(this.beforeResizeWidth + width, this.columnMinWidth); + this.gridTemplateColumns[header.childNodes.length - 1] = '1fr'; for (let i = 0; i < header.childNodes.length; i++) { let node = header.childNodes.item(i) as HTMLDivElement; this.gridTemplateColumns[i] = `${node.clientWidth}px`; } this.gridTemplateColumns[this.resizeColumnIndex - 1] = `${preWidth}px`; + let lastNode = header.childNodes.item(header.childNodes.length - 1) as HTMLDivElement; + let totalWidth = 0; + this.gridTemplateColumns.forEach((it) => { + totalWidth += parseInt(it); + }); + totalWidth = Math.max(totalWidth, this.shadowRoot!.querySelector('.table')!.scrollWidth); + this.gridTemplateColumns[this.gridTemplateColumns.length - 1] = `${totalWidth - lastNode.offsetLeft - 1}px`; header.style.gridTemplateColumns = this.gridTemplateColumns.join(' '); let preNode = header.childNodes.item(this.resizeColumnIndex - 1) as HTMLDivElement; preNode.style.width = `${preWidth}px`; @@ -623,7 +640,7 @@ export class LitTable extends HTMLElement { Math.max(totalHeight, this.tableElement!.scrollTop + headHeight) <= Math.min(totalHeight + height, this.tableElement!.scrollTop + this.tableElement!.clientHeight + headHeight) ) { - let newTableElement = this.addTableElement(tableRowObject, false,false, true, totalHeight); + let newTableElement = this.addTableElement(tableRowObject, false, false, true, totalHeight); let td = newTableElement?.querySelectorAll('.td'); if (tableRowObject.data.rowName === 'cpu-profiler') { td[0].innerHTML = ''; @@ -673,7 +690,7 @@ export class LitTable extends HTMLElement { return; } while (reduce <= this.tableElement!.clientHeight) { - let newTableElement = this.addTableElement(visibleObjects[skip], false,false, false); + let newTableElement = this.addTableElement(visibleObjects[skip], false, false, false); reduce += newTableElement.clientHeight; } for (let i = 0; i < this.currentRecycleList.length; i++) { @@ -683,7 +700,7 @@ export class LitTable extends HTMLElement { return visibleObjects; } - freshLineHandler(index: number, skip: number, visibleObjects: TableRowObject[]){ + freshLineHandler(index: number, skip: number, visibleObjects: TableRowObject[]) { this.freshCurrentLine(this.currentRecycleList[index], visibleObjects[index + skip]); if (visibleObjects[index + skip]) { if (visibleObjects[index + skip].data.rowName === 'cpu-profiler') { @@ -711,10 +728,11 @@ export class LitTable extends HTMLElement { visibleObjects: TableRowObject[], parentNode?: TableRowObject, form?: RedrawTreeForm - ) { + ): number { + let th = totalHeight; let headHeight = this.theadElement?.clientHeight || 0; list.forEach((item) => { - let tableRowObject = this.newTableRowObject(item, totalHeight, depth, parentNode); + let tableRowObject = this.newTableRowObject(item, th, depth, parentNode); if (this._mode === TableMode.Expand && form === RedrawTreeForm.Retract && !item.status) { tableRowObject.expanded = false; } else if (this._mode === TableMode.Expand && form === RedrawTreeForm.Default) { @@ -726,22 +744,23 @@ export class LitTable extends HTMLElement { ) { tableRowObject.expanded = false; if (item.children != undefined && item.children.length > 0) { - this.newTableRowObject(item, totalHeight, depth, tableRowObject); + this.newTableRowObject(item, th, depth, tableRowObject); } } if ( - Math.max(totalHeight, this.tableElement!.scrollTop) <= + Math.max(th, this.tableElement!.scrollTop) <= Math.min( - totalHeight + tableRowObject.height, + th + tableRowObject.height, this.tableElement!.scrollTop + this.tableElement!.clientHeight - headHeight ) ) { - this.addTableElement(tableRowObject,true, false, true, totalHeight); + this.addTableElement(tableRowObject, true, false, true, th); } - totalHeight += tableRowObject.height; + th += tableRowObject.height; visibleObjects.push(tableRowObject); - this.resetAllHeightChildrenHandler(item, depth, totalHeight, visibleObjects, tableRowObject, form); + th = this.resetAllHeightChildrenHandler(item, depth, th, visibleObjects, tableRowObject, form); }); + return th; } resetAllHeightChildrenHandler( @@ -751,13 +770,14 @@ export class LitTable extends HTMLElement { visibleObjects: TableRowObject[], tableRowObject?: TableRowObject, form?: RedrawTreeForm - ) { + ): number { + let th = totalHeight; if (item.hasNext) { // js memory的表格 if (item.parents != undefined && item.parents.length > 0 && item.status) { - this.resetAllHeight(item.parents, depth + 1, totalHeight, visibleObjects, tableRowObject); + th = this.resetAllHeight(item.parents, depth + 1, totalHeight, visibleObjects, tableRowObject); } else if (item.children != undefined && item.children.length > 0 && item.status) { - this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); + th = this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); } } else { // 其他数据 @@ -768,11 +788,12 @@ export class LitTable extends HTMLElement { this._mode === TableMode.Expand ) { item.status = true; - this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); + th = this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); } else if (item.children != undefined && item.children.length > 0 && item.status) { - this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); + th = this.resetAllHeight(item.children, depth + 1, totalHeight, visibleObjects, tableRowObject); } } + return th; } measureReset(): void { @@ -787,7 +808,7 @@ export class LitTable extends HTMLElement { this.measureReset(); let visibleObjects: TableRowObject[] = []; let totalHeight = 0; - this.resetAllHeight(list,0, totalHeight, visibleObjects); + totalHeight = this.resetAllHeight(list, 0, totalHeight, visibleObjects); this.tbodyElement && (this.tbodyElement.style.height = totalHeight + 'px'); this.treeElement!.style.height = this.tableElement!.clientHeight - this.theadElement!.clientHeight + 'px'; this.tableElement && @@ -796,7 +817,7 @@ export class LitTable extends HTMLElement { return !item.rowHidden; }); let top = this.tableElement!.scrollTop; - this.treeElement!.style.transform = `translateY(${top}px)`; + this.treeElement && (this.treeElement!.style.transform = `translateY(${top}px)`); let skip = 0; for (let index = 0; index < visibleObjects.length; index++) { if (visibleObjects[index].top <= top && visibleObjects[index].top + visibleObjects[index].height >= top) { @@ -899,8 +920,8 @@ export class LitTable extends HTMLElement { this.currentTreeDivList.forEach((row) => { row.classList.remove('mouse-in'); }); - if (indexOf >= 0 && indexOf < this.treeElement!.children.length) { - this.setMouseIn(true, [this.treeElement?.children[indexOf] as HTMLElement]); + if (indexOf >= 0 && indexOf < this.currentTreeDivList.length) { + this.setMouseIn(true, [this.currentTreeDivList[indexOf]]); } }; rowTreeElement.onmouseleave = () => { @@ -913,6 +934,7 @@ export class LitTable extends HTMLElement { rowTreeElement.onmouseup = (e: MouseEvent) => { let indexOf = this.currentRecycleList.indexOf(rowTreeElement); this.dispatchRowClickEvent(rowData, [this.treeElement?.children[indexOf] as HTMLElement, rowTreeElement], e); + e.stopPropagation(); }; } @@ -957,6 +979,7 @@ export class LitTable extends HTMLElement { td.style.position = 'absolute'; td.style.top = '0px'; td.style.left = '0px'; + td.style.height = `${row.height}px`; this.addFirstElementEvent(td, tr, row); this.setHighLight(row.data.isSearch, td); this.treeElement!.style.width = column.getAttribute('width'); @@ -984,6 +1007,7 @@ export class LitTable extends HTMLElement { td.onmouseup = (e: MouseEvent) => { let indexOf = this.currentTreeDivList.indexOf(td); this.dispatchRowClickEvent(rowData, [td, tr], e); + e.stopPropagation(); }; } @@ -1024,6 +1048,7 @@ export class LitTable extends HTMLElement { }); newTableElement.onmouseup = (e: MouseEvent) => { this.dispatchRowClickEvent(rowData, [newTableElement], e); + e.stopPropagation(); }; newTableElement.onmouseenter = () => { this.dispatchRowHoverEvent(rowData, [newTableElement]); @@ -1064,7 +1089,10 @@ export class LitTable extends HTMLElement { // 但是对于Current Selection tab页来说,表格前两列是时间,第三列是input标签,第四列是button标签 // 而第一行的数据只有第四列一个button,和模板中的数据并不一样,所以要特别处理一下 if (column.template) { - if (dataIndex === 'color' && rowData.data.colorEl === undefined) { + if ( + (dataIndex === 'color' && rowData.data.colorEl === undefined) || + (dataIndex === 'text' && rowData.data.text === undefined) + ) { td.innerHTML = ''; td.template = ''; } else if (dataIndex === 'operate' && rowData.data.operate && rowData.data.operate.innerHTML === 'RemoveAll') { @@ -1151,7 +1179,7 @@ export class LitTable extends HTMLElement { } }; - setChildrenStatus(rowData:any, data: any) { + setChildrenStatus(rowData: any, data: any) { for (let d of data) { if (rowData.data === d) { d.status = false; @@ -1203,7 +1231,8 @@ export class LitTable extends HTMLElement { } reMeauseHeight(): void { - if (this.currentRecycleList.length === 0) { + if (this.currentRecycleList.length === 0 && this.ds.length !== 0) { + this.recycleDataSource = this.ds; return; } let totalHeight = 0; @@ -1214,36 +1243,39 @@ export class LitTable extends HTMLElement { } }); this.tbodyElement && (this.tbodyElement.style.height = totalHeight + (this.isScrollXOutSide ? 0 : 0) + 'px'); - this.treeElement!.style.height = this.tableElement!.clientHeight - this.theadElement!.clientHeight + 'px'; + this.treeElement && + (this.treeElement.style.height = this.tableElement!.clientHeight - this.theadElement!.clientHeight + 'px'); let visibleObjects = this.recycleDs.filter((item) => { return !item.rowHidden; }); - let top = this.tableElement!.scrollTop; - let skip = 0; - for (let i = 0; i < visibleObjects.length; i++) { - if (visibleObjects[i].top <= top && visibleObjects[i].top + visibleObjects[i].height >= top) { - skip = i; - break; + if (this.tableElement) { + let top = this.tableElement!.scrollTop; + let skip = 0; + for (let i = 0; i < visibleObjects.length; i++) { + if (visibleObjects[i].top <= top && visibleObjects[i].top + visibleObjects[i].height >= top) { + skip = i; + break; + } } - } - let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); - if (reduce === 0) { - return; - } - while (reduce <= this.tableElement!.clientHeight + 1) { - let isTree = this.hasAttribute('tree'); - let newTableElement = this.addTableElement(visibleObjects[skip], isTree, isTree, false); - reduce += newTableElement.clientHeight; - } - for (let i = 0; i < this.currentRecycleList.length; i++) { - if (this.hasAttribute('tree')) { - this.freshCurrentLine( - this.currentRecycleList[i], - visibleObjects[i + skip], - this.treeElement?.children[i] as HTMLElement - ); - } else { - this.freshLineHandler(i, skip, visibleObjects); + let reduce = this.currentRecycleList.map((item) => item.clientHeight).reduce((a, b) => a + b, 0); + if (reduce === 0) { + return; + } + while (reduce <= this.tableElement!.clientHeight + 1) { + let isTree = this.hasAttribute('tree'); + let newTableElement = this.addTableElement(visibleObjects[skip], isTree, isTree, false); + reduce += newTableElement.clientHeight; + } + for (let i = 0; i < this.currentRecycleList.length; i++) { + if (this.hasAttribute('tree')) { + this.freshCurrentLine( + this.currentRecycleList[i], + visibleObjects[i + skip], + this.treeElement?.children[i] as HTMLElement + ); + } else { + this.freshLineHandler(i, skip, visibleObjects); + } } } } @@ -1317,7 +1349,12 @@ export class LitTable extends HTMLElement { } } - renderTableRowColumnElement(tblColumn: LitTableColumn, tblRowElement: HTMLDivElement, dataIndex: string, rowData: any): void { + renderTableRowColumnElement( + tblColumn: LitTableColumn, + tblRowElement: HTMLDivElement, + dataIndex: string, + rowData: any + ): void { if (tblColumn.template) { // If you customize the rendering, you get the nodes from the template // @ts-ignore @@ -1351,6 +1388,7 @@ export class LitTable extends HTMLElement { renderTableRowElementEvent(tblRowElement: HTMLDivElement, rowData: any): void { tblRowElement.onmouseup = (e: MouseEvent) => { + e.stopPropagation(); this.dispatchEvent( new CustomEvent('row-click', { detail: { @@ -1367,6 +1405,7 @@ export class LitTable extends HTMLElement { composed: true, }) ); + e.stopPropagation(); }; } @@ -1425,10 +1464,20 @@ export class LitTable extends HTMLElement { } else { this.dispatchRowClickEvent(rowObject, [element], e); } + e.stopPropagation(); }; element.onmouseenter = () => { this.dispatchRowHoverEvent(rowObject, [element]); + if ((element as any).data.isSelected) return; + let indexOf = this.currentRecycleList.indexOf(element as HTMLDivElement); + this.currentTreeDivList.forEach((row) => { + row.classList.remove('mouse-in'); + }); + if (indexOf >= 0 && indexOf < this.currentTreeDivList.length) { + this.setMouseIn(true, [this.currentTreeDivList[indexOf]]); + } }; + (element as any).data = rowObject.data; if (rowObject.data.isSelected !== undefined) { this.setSelectedRow(rowObject.data.isSelected, [element]); @@ -1483,6 +1532,7 @@ export class LitTable extends HTMLElement { } firstElement.onmouseup = (e: MouseEvent) => { this.dispatchRowClickEvent(rowObject, [firstElement, element], e); + e.stopPropagation(); }; firstElement.style.transform = `translateY(${rowObject.top - this.tableElement!.scrollTop}px)`; if (rowObject.data.isSelected !== undefined) { @@ -1496,14 +1546,16 @@ export class LitTable extends HTMLElement { setSelectedRow(isSelected: boolean, rows: any[]): void { if (isSelected) { rows.forEach((row) => { - if (row.classList.contains('mouse-in')) { - row.classList.remove('mouse-in'); + if (row.classList) { + if (row.classList.contains('mouse-in')) { + row.classList.remove('mouse-in'); + } + row.classList.add('mouse-select'); } - row.classList.add('mouse-select'); }); } else { rows.forEach((row) => { - row.classList.remove('mouse-select'); + row.classList && row.classList.remove('mouse-select'); }); } } @@ -1703,6 +1755,7 @@ export class LitTable extends HTMLElement { composed: true, }) ); + event.stopPropagation(); } dispatchRowHoverEvent(rowObject: any, elements: any[]): void { diff --git a/ide/src/base-ui/tabs/lit-tabs.html.ts b/ide/src/base-ui/tabs/lit-tabs.html.ts index dc81b65c8c74421eb1559db27ce1c4ad6f32faf8..8165147caa31b2eee321e2103c64e66f9ee22952 100644 --- a/ide/src/base-ui/tabs/lit-tabs.html.ts +++ b/ide/src/base-ui/tabs/lit-tabs.html.ts @@ -403,6 +403,7 @@ export const LitTabsHtml = `
+
diff --git a/ide/src/base-ui/utils/Template.ts b/ide/src/base-ui/utils/Template.ts index 7066052d455a3ec46b39ab7b59b606ced74c4299..dbfd161e77e30bbc89348e0bd0bbcfc34a3cd71e 100644 --- a/ide/src/base-ui/utils/Template.ts +++ b/ide/src/base-ui/utils/Template.ts @@ -102,3 +102,11 @@ function escape2Html(str: string) { return arrEntities[t]; }); } + +export function replacePlaceholders(str: string, ...args: string[]): string { + return str.replace(/\{(\d+)\}/g, (match, placeholderIndex) => { + const argIndex = parseInt(placeholderIndex, 10); + const replacement = args[argIndex - 1]; + return replacement || match; + }); +} diff --git a/ide/src/doc/md/des_tables.md b/ide/src/doc/md/des_tables.md index 747e4980199cc483c98628ae9545e17e038334fc..40dff9d40a837c01321ed30cf901d87f182b7df6 100644 --- a/ide/src/doc/md/des_tables.md +++ b/ide/src/doc/md/des_tables.md @@ -270,7 +270,7 @@ log 表记录日志信息。可以根据 seq 字段的连续性,来判断是 frame_slice: 记录 RS(RenderService)和应用的帧渲染。 gpu_slice: 记录 RS 的帧对应的 gpu 渲染时长。 -frame_maps:记录应用到 RS 的帧的映射关系。 +frame_maps: 记录应用到 RS 的帧的映射关系。 ![GitHub Logo](../../figures/traceStreamer/frames.jpg) ### 查询示例 @@ -290,10 +290,10 @@ js_heap_files:记录 js 内存数据的文件名和文件索引 ![1683163158954](image/des_tables/js_heap_files.png) -js_heap_nodes:记录 js 内存类对象数据 -js_heap_edges:记录 js 内存类对象的成员数据 -js_heap_trace_node:记录 timeline 的调用栈信息 -js_heap_sample:记录 timeline 的时间轴信息 +js_heap_nodes: 记录 js 内存类对象数据 +js_heap_edges: 记录 js 内存类对象的成员数据 +js_heap_trace_node: 记录 timeline 的调用栈信息 +js_heap_sample: 记录 timeline 的时间轴信息 ![1683163373206](image/des_tables/js_heap_nodes.png) ## TraceStreamer 输出数据库表格详细介绍 @@ -765,13 +765,13 @@ js_heap_sample:记录 timeline 的时间轴信息 #### 相关字段描述 -- pid:目标进程 ID。 -- type:JS 数据类型,取值与枚举 HeapType 对应,0 表示 JS 内存数据为 snapshot 类型,1 表示 JS 内存数据为 timeline 类型,-1 表示没有 JS 内存数据。 -- interval:当 type=0 时生效,单位是秒,表示一次 snapshot 事件和下一次 snapshot 事件之间的间隔。 -- capture_numeric_value:当 type=0 时生效,表示是否同时抓取 numeric。 -- track_allocation:当 type=1 时生效,表示是否抓取 allocations。 -- enable_cpu_profiler:表示是否存在 cpuprofiler 的数据。 -- cpu_profiler_interval:表示 cpuprofiler 数据的采集间隔。 +- pid: 目标进程 ID。 +- type: JS 数据类型,取值与枚举 HeapType 对应,0 表示 JS 内存数据为 snapshot 类型,1 表示 JS 内存数据为 timeline 类型,-1 表示没有 JS 内存数据。 +- interval: 当 type=0 时生效,单位是秒,表示一次 snapshot 事件和下一次 snapshot 事件之间的间隔。 +- capture_numeric_value: 当 type=0 时生效,表示是否同时抓取 numeric。 +- track_allocation: 当 type=1 时生效,表示是否抓取 allocations。 +- enable_cpu_profiler: 表示是否存在 cpuprofiler 的数据。 +- cpu_profiler_interval: 表示 cpuprofiler 数据的采集间隔。 ### js_cpu_profiler_node 表 @@ -796,14 +796,14 @@ js_heap_sample:记录 timeline 的时间轴信息 #### 相关字段描述 - function_id: 函数的 ID 号。 -- function_index:函数名称在 data_dict 中的索引号。 -- script_id:关联到的类对象所在文件的绝对路径 ID。 -- url_index:关联到的类对象所在文件的绝对路径名称在 data_dict 中的索引号。 -- line_number:类对象所在文件的行号。 -- column_number:类对象所在文件的列号。 -- hit_count:采样次数。 -- children:子节点的 id 号。 -- parent_id:父节点的 id 号。 +- function_index: 函数名称在 data_dict 中的索引号。 +- script_id: 关联到的类对象所在文件的绝对路径 ID。 +- url_index: 关联到的类对象所在文件的绝对路径名称在 data_dict 中的索引号。 +- line_number: 类对象所在文件的行号。 +- column_number: 类对象所在文件的列号。 +- hit_count: 采样次数。 +- children: 子节点的 id 号。 +- parent_id: 父节点的 id 号。 ### js_cpu_profiler_sample 表 @@ -824,10 +824,10 @@ js_heap_sample:记录 timeline 的时间轴信息 #### 相关字段描述 - id: ts 内部 ID 号。 -- function_id:函数的 ID 号。 -- start_time:数据上报的起始时间。 -- end_time:数据上报的终止时间。 -- dur:数据上报的间隔时间。 +- function_id: 函数的 ID 号。 +- start_time: 数据上报的起始时间。 +- end_time: 数据上报的终止时间。 +- dur: 数据上报的间隔时间。 ### js_heap_edges 表 diff --git a/ide/src/doc/md/quickstart_ability_monitor.md b/ide/src/doc/md/quickstart_ability_monitor.md index e0325ef11faad9e62ea4383cb69499f15df0f121..4a448988bd8cf830e096c68f5d484ab8224ebc9b 100644 --- a/ide/src/doc/md/quickstart_ability_monitor.md +++ b/ide/src/doc/md/quickstart_ability_monitor.md @@ -15,7 +15,7 @@ ![GitHub Logo](../../figures/AbilityMonitor/abilitysetting.jpg) 点击 Trace command,就会根据上面的配置生成抓取命令,点击复制按钮,会将命令行复制。 ![GitHub Logo](../../figures/AbilityMonitor/abilitycommand.jpg) -输入 hdc_shell,进入设备,执行命令。 +输入 hdc shell,进入设备,执行命令。 ![GitHub Logo](../../figures/AbilityMonitor/abilityexcutecommand.jpg) 进入指定目录,cd /data/local/tmp 进入到目录,会看到生成的 trace 文件。 ![GitHub Logo](../../figures/AbilityMonitor/abilityhtrace.jpg) @@ -43,6 +43,10 @@ Ability Monitor 展开就可以看到泳道图,包括 CPU,内存,磁盘 IO - Network Bytes Out/Sec: 每秒发送的网络数据字节数。 - Network Packets In/Sec:每秒接收的网络数据包数。 - Network Packets Out/Sec: 每秒发送的网络数据包数。 +- Purgeable Total: 可清除总量。 +- Purgeable Pin:可清除编码。 +- DMA:直接内存存取。 +- Skia Gpu Memory:Skia显存。 ### Ability Monitor 泳道图的框选功能 diff --git a/ide/src/doc/md/quickstart_arkts.md b/ide/src/doc/md/quickstart_arkts.md index c5c40238edffe127b472213761168191c5943f74..e47cb29c516df4d6be0c7bb6cecfaecfcf12a9d7 100644 --- a/ide/src/doc/md/quickstart_arkts.md +++ b/ide/src/doc/md/quickstart_arkts.md @@ -20,7 +20,7 @@ Cpuprofiler 模板帮助 ArkTs 开发和测试分析虚拟机层执行开销大 ![GitHub Logo](../../figures/arkts/cpuprofilertip.jpg) - Name : 函数名。 -- Self Time: 函数自身执行时间(不包含其调用者)。 +- Self Time : 函数自身执行时间(不包含其调用者)。 - Total Time : 函数自身及调用者的调用时间总和。 - Url : 函数所在的文件名称。 @@ -38,13 +38,13 @@ Js Profiler Statistics 的 Tab 页显示数据的维度信息,以饼图和 Tab ![GitHub Logo](../../figures/arkts/cpuprofilerselectc.jpg) ![GitHub Logo](../../figures/arkts/cpuprofilerdragc.jpg) - Symbol : 函数名。 -- Self Time: 函数自身执行时间(不包含其调用者)。 +- Self Time : 函数自身执行时间(不包含其调用者)。 - Total Time : 函数自身及调用者的调用时间总和。 Js Profiler BottomUp 的 Tab 页把 name,url,depth,parent 相同的函数合并,构建成一个 bottom up 的树结构,以树形表格的形式显示,只不过作为根节点的是被调用者,表格中显示函数被调用关系,如下图: ![GitHub Logo](../../figures/arkts/cpuprofilerselectb.jpg) ![GitHub Logo](../../figures/arkts/cpuprofilerdragb.jpg) - Symbol : 函数名。 -- Self Time: 函数自身执行时间(不包含其调用者)。 +- Self Time : 函数自身执行时间(不包含其调用者)。 - Total Time : 函数自身及调用者的调用时间总和。 ### Cpuprofiler 的 Heaviest Stack 功能 diff --git a/ide/src/doc/md/quickstart_bio.md b/ide/src/doc/md/quickstart_bio.md index 4862bc402df44d8680c79329e67400ae5bb5aac5..ac305257e9bb82e196dd2cd91d53f0e4e1c67e1d 100644 --- a/ide/src/doc/md/quickstart_bio.md +++ b/ide/src/doc/md/quickstart_bio.md @@ -45,7 +45,7 @@ Disk I/O Tier Statistics 的 Tab 页如图: - Min Total Latency:最小延迟时间。 - Avg Total Latency:平均延迟时间。 - Max Total Latency:最大延迟时间。 - Disk I/O Latency Calltree 的 Tab 页如图: + Disk I/O Latency CallTree 的 Tab 页如图: ![GitHub Logo](../../figures/Bio/BioCalltree.jpg) - Call Stack:为经过符号解析后的Callstack,并且给出动态链接库或者进程名的信息。 - Local:为该调用方法自身占用的CPU时间。 @@ -66,7 +66,7 @@ Disk I/O Tier Statistics 的 Tab 页如图: ### Bio 支持多种 Options 展示风格 -点击 Disk I/O Latency Calltree 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 +点击 Disk I/O Latency CallTree 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 ![GitHub Logo](../../figures/Bio/BioOptions.jpg) - Invert:反向输出调用树。 @@ -74,7 +74,7 @@ Disk I/O Tier Statistics 的 Tab 页如图: ### Bio 支持过滤调用栈调用次数的展示风格 -点击 Disk I/O Latency Calltree 的 Tab 页底部的 Sample Counter Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 +点击 Disk I/O Latency CallTree 的 Tab 页底部的 Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 ![GitHub Logo](../../figures/Bio/Biocounter.jpg) ### Bio 功能的调用栈 Group 展示-数据分析支持剪裁功能 @@ -103,7 +103,7 @@ Disk I/O Tier Statistics 的 Tab 页如图: ### Bio 的火焰图功能 -点击 Disk I/O Latency Calltree 左下角的柱状图的图标,会切换到火焰图页面。 +点击 Disk I/O Latency CallTree 左下角的柱状图的图标,会切换到火焰图页面。 ![GitHub Logo](../../figures/Bio/Bioflame.jpg) 进入到火焰图页面,火焰图的展示跟 Callinfo 的 tab 页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称和 Duration 时长。 ![GitHub Logo](../../figures/Bio/Bioflameshow.jpg) diff --git a/ide/src/doc/md/quickstart_device_record.md b/ide/src/doc/md/quickstart_device_record.md index f072110f8f66c8481235e3d3b23e3b63e3d72070..9a1f750a7de1771577d1cca47d19e26fba85f3a6 100644 --- a/ide/src/doc/md/quickstart_device_record.md +++ b/ide/src/doc/md/quickstart_device_record.md @@ -7,15 +7,15 @@ ![GitHub Logo](../../figures/hiprofilercmd/systraceconfig.jpg) 说明: -- Record setting:设置 trace 的抓取模式,buffer size 大小,抓取时长。 -- Trace command:生成的抓取命令行。 -- Probes config:trace 的抓取参数配置。 -- Native Memory:NativeMemory 数据的抓取参数配置。 -- Hiperf:Hiperf 数据的抓取参数配置。 -- eBPF Config:ebpf 数据的抓取参数配置。 -- VM Tracker:smaps 数据的抓取参数配置。 -- HiSystemEvent:HiSystemEvent 数据抓取参数配置。 -- SDK Config:SDK 数据抓取参数配置。 +- Record setting: 设置 trace 的抓取模式,buffer size 大小,抓取时长。 +- Trace command: 生成的抓取命令行。 +- Probes config: trace 的抓取参数配置。 +- Native Memory: NativeMemory 数据的抓取参数配置。 +- Hiperf: Hiperf 数据的抓取参数配置。 +- eBPF Config: ebpf 数据的抓取参数配置。 +- VM Tracker: Smaps数据的抓取参数配置。 +- HiSystemEvent: HiSystemEvent 数据抓取参数配置。 +- SDK Config: SDK 数据抓取参数配置。 ## 命令行的生成和 trace 文件的抓取 @@ -27,12 +27,12 @@ ![GitHub Logo](../../figures/hiprofilercmd/command.jpg) 命令参数说明: -- -o:文件的输入路径和名称。 -- -t:抓取的时长。 -- buffer pages:buffer size 大小。 -- sample_duration:数据采集的时间。 -- sample_interval:主动获取插件数据的间隔时间(ms,只针对轮询插件,例如 memory 插件,cpu 插件,dikio 插件等,对流式插件和独立插件无效)。 -- trace_period_ms:ftrace 插件读取内核缓冲区数据的间隔时间(ms)。 +- -o: 文件的输入路径和名称。 +- -t: 抓取的时长。 +- buffer pages: buffer size 大小。 +- sample_duration: 数据采集的时间。 +- sample_interval: 主动获取插件数据的间隔时间(ms,只针对轮询插件,例如 memory 插件,cpu 插件,dikio 插件等,对流式插件和独立插件无效)。 +- trace_period_ms: ftrace 插件读取内核缓冲区数据的间隔时间(ms)。 - hitrace_time:hitrace 命令行抓取时间,与 hiprofiler_cmd 下发的-t 配置联动。 输入 hdc_std shell,进入设备,执行命令。 diff --git a/ide/src/doc/md/quickstart_filesystem.md b/ide/src/doc/md/quickstart_filesystem.md index 425d2c88db84f939649357bf5ee56f6997086167..72fd4f6b220fe3b227a935dab20a60e92c97232d 100644 --- a/ide/src/doc/md/quickstart_filesystem.md +++ b/ide/src/doc/md/quickstart_filesystem.md @@ -35,14 +35,14 @@ FileSystem 分析文件系统的信息和活动,比如读和写操作等。 ### FileSystem 泳道图展示 -FileSystem 泳道图按照读操作和写操作展示,鼠标移动都泳道图上,悬浮框会以 10ms 为周期展示读,写类型系统调用的次数。 +FileSystem 泳道图按照读操作和写操作展示,鼠标移动到泳道图上,悬浮框会以 10ms 为周期展示读,写类型系统调用的次数。 ![GitHub Logo](../../figures/FileSystem/FileSystemchart.jpg) 按住 w 键放大界面,悬浮框会显示当前时刻的文件读写次数。 ![GitHub Logo](../../figures/FileSystem/FileSystemcount.jpg) ### FileSystem 泳道图的框选功能 -可以对读写操作泳道图进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有五个 tab 页。 +可以对读写操作泳道图进行框选,框选后展示框选数据的统计表格,总共有六个 tab 页。 FileSystem statistics 的 Tab 页如图: ![GitHub Logo](../../figures/FileSystem/FileSystemstatistics.jpg) @@ -55,7 +55,7 @@ FileSystem statistics 的 Tab 页如图: - Min Duration:最小时长。 - Avg Duration: 平均时长。 - Max Duration:最大时长。 - FileSystem Calltree 的 Tab 页如图: + FileSystem CallTree 的 Tab 页如图: ![GitHub Logo](../../figures/FileSystem/FileSystemCalltree.jpg) - Call Stack:为经过符号解析后的Callstack,并且给出动态链接库或者进程名的信息。 - Local:为该调用方法自身占用的CPU时间。 @@ -66,6 +66,9 @@ FileSystem statistics 的 Tab 页如图: - Duration:时长。 - Process:进程名。 - Thread:线程名。 +- Type:操作类型。 +- File Descriptor:fd。 +- File Path:文件路径。 - First Argument:系统调用的第一个参数。 - Second Argument:系统调用的第二个参数。 - Third Argument:系统调用的第三个参数。 @@ -80,6 +83,7 @@ FileSystem statistics 的 Tab 页如图: - Process:进程名。 - Type:操作类型。 - File Descriptor:fd。 +- Path:文件路径。 - Backtrace:调用栈顶部函数,并显示调用栈深度。 File Descriptor Time Slice 的 Tab 页如图: ![GitHub Logo](../../figures/FileSystem/FileSystemtimeslice.jpg) @@ -87,19 +91,22 @@ FileSystem statistics 的 Tab 页如图: - Open Duration:打开的时长。 - Process:进程名。 - File Descriptor:fd。 +- Path:文件路径。 - Backtrace:调用栈顶部函数,并显示调用栈深度。 ### FileSystem 支持多种 Options 展示风格 -点击 FileSystem Calltree 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 +点击 FileSystem CallTree 的 Tab 页底部的 Options,会有四个 CheckBox 复选框。 ![GitHub Logo](../../figures/FileSystem/FileSystemOptions.jpg) - Invert:反向输出调用树。 - Hide System so:隐藏系统库文件。 +- Hide Event:隐藏事件。 +- Hide Thread:隐藏线程。 ### FileSystem 支持过滤调用栈调用次数的展示风格 -点击 FileSystem Calltree 的 Tab 页底部的 Sample Counter Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 +点击 FileSystem CallTree 的 Tab 页底部的 Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 ![GitHub Logo](../../figures/FileSystem/FileSystemsamplecounter.jpg) ### FileSystem 功能的调用栈 Group 展示-数据分析支持剪裁功能 @@ -128,7 +135,7 @@ FileSystem statistics 的 Tab 页如图: ### FileSystem 的火焰图功能 -点击 FileSystem Calltre 左下角的柱状图的图标,会切换到火焰图页面。 +点击 FileSystem CallTree 左下角的柱状图的图标,会切换到火焰图页面。 ![GitHub Logo](../../figures/FileSystem/FileSystemflame.jpg) 进入到火焰图页面,火焰图的展示跟 Callinfo 的 tab 页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称和 Duration 时长。 ![GitHub Logo](../../figures/FileSystem/FileSystemflameshow.jpg) diff --git a/ide/src/doc/md/quickstart_hiperf.md b/ide/src/doc/md/quickstart_hiperf.md index e4da5784ff531aebc27820122bb50922d021be20..224570c6819bd4624ab744906fca5227cc6c1b4a 100644 --- a/ide/src/doc/md/quickstart_hiperf.md +++ b/ide/src/doc/md/quickstart_hiperf.md @@ -10,7 +10,7 @@ HiPerf 工具是对系统性能数据进行采样记录,并将采样数据保 配置项说明: - Start Hiperf Sampling:配置项的总开关。 -- Process:离线模式下配置的是整个系统的。 +- Process:离线模式下配置的是整个系统的进程。 - Frequency:配置抓取的频率。 - Call Stack:配置抓取的堆栈类型。 - Advance Options:更多的抓取配置项。 @@ -18,7 +18,7 @@ HiPerf 工具是对系统性能数据进行采样记录,并将采样数据保 ![GitHub Logo](../../figures/perf/perfset.jpg) 点击 Trace command,就会根据上面的配置生成抓取命令,点击复制按钮,会将命令行复制。 ![GitHub Logo](../../figures/perf/perfcommand.jpg) - 输入 hdc_shell,进入设备,执行命令。 + 输入 hdc shell,进入设备,执行命令。 ![GitHub Logo](../../figures/perf/perfexcutecommand.jpg) 执行完成后,进入指定目录查看,在/data/local/tmp 下就会生成 trace 文件。 ![GitHub Logo](../../figures/perf/perffile.jpg) @@ -45,13 +45,14 @@ Perf 泳道图上浅色表示无效调用栈的采样点,抓取时由于设备 ### HiPerf 泳道图的框选功能 -可以对 CPU 使用量区,线程和进程区数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有两个 tab 页。 +可以对 CPU 使用量的线程和进程区数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有四个 tab 页。 Perf Profile 的 Tab 页如图: ![GitHub Logo](../../figures/perf/PerfProfile.jpg) - Call Stack:为经过符号解析后的Callstack,并且给出动态链接库或者进程名的信息。 - Local:为该调用方法自身占用的CPU时间。 -- Weight:调用方法的执行次数和占比。 +- Sample Count:采样数量。 +- Event Count:事件数量。 Sample List 的 Tab 页如图: ![GitHub Logo](../../figures/perf/Samplelist.jpg) - Sample Time:采样的时间戳信息。 @@ -63,15 +64,17 @@ Perf Profile 的 Tab 页如图: ### HiPerf 支持多种 Options 展示风格 -点击 Perf Profile 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 +点击 Perf Profile 的 Tab 页底部的 Options,会有四个 CheckBox 复选框。 ![GitHub Logo](../../figures/perf/Options.jpg) - Invert:反向输出调用树。 - Hide System so:隐藏系统库文件。 +- Hide Thread:隐藏线程。 +- Hide Thread State:隐藏线程状态。 ### HiPerf 支持过滤调用栈调用次数的展示风格 -点击 Perf Profile 的 Tab 页底部的 Sample Counter Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 +点击 Perf Profile 的 Tab 页底部的 Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 ![GitHub Logo](../../figures/perf/samplecounter.jpg) ### HiPerf 功能的调用栈 Group 展示-数据分析支持剪裁功能 diff --git a/ide/src/doc/md/quickstart_hisystemevent.md b/ide/src/doc/md/quickstart_hisystemevent.md index 8e8d80e9d3345830a9e28b7445dc61855aa318f1..cd3269ead56c7acbe68068fc0fa895391731ecd4 100644 --- a/ide/src/doc/md/quickstart_hisystemevent.md +++ b/ide/src/doc/md/quickstart_hisystemevent.md @@ -27,7 +27,7 @@ HiSystemEvent 应用功耗模块主要是展示应用的各个子类别功耗占 - Anomaly Event泳道: 显示系统异常和应用异常的ToolTip。 - System Event泳道: 以条状图显示,红色代表后台任务(WORKSCHEDULER),黄色代表应用锁(POWER),蓝色代表GPS定位(LOCATION)。 -- Power泳道:应用各个子类的功耗柱状图、折现图以及应用各个子类绘制的图例,鼠标的悬浮可以显示出各个子类功耗的具体值。 +- Power泳道:应用各个子类的功耗柱状图、折线图以及应用各个子类绘制的图例,鼠标的悬浮可以显示出各个子类功耗的具体值。 - Brightness Nit泳道:鼠标悬浮可以显示屏幕亮度值。 - Wifi Event Received泳道:鼠标悬浮可以显示WiFi信号强度值。 - Audio Stream Change泳道:鼠标悬浮可以显示Audio状态(AUDIO_STREAM_CHANGE事件)。 diff --git a/ide/src/doc/md/quickstart_native_memory.md b/ide/src/doc/md/quickstart_native_memory.md index d6474b1be6240268a195864031e1fc36c26b37d5..ac216a72389fd3ef992bbbd9dc295112045d8572 100644 --- a/ide/src/doc/md/quickstart_native_memory.md +++ b/ide/src/doc/md/quickstart_native_memory.md @@ -17,7 +17,7 @@ Native Memory 是查看内存的分配和释放等情况。 - Use Record Accurately:不过滤数据,上报全量的。 - Use Offline Symbolization:离线符号化。 - Use Record Statistics:统计数据上报时间间隔设置。 -- Use Startup Mode :抓取应用启动阶段的内存(默认是关闭,需要抓取应用启阶段内存可开启)。 +- Use Startup Mode: 抓取应用启动阶段的内存(默认是关闭,需要抓取应用启阶段内存可开启)。 再点击 Record setting,在 output file path 输入文件名 hiprofiler_data_nativememory.htrace,拖动滚动条设置 buffer size 大小是 64M,抓取时长是 50s。 ![GitHub Logo](../../figures/NativeMemory/nativememoryset.jpg) @@ -141,9 +141,10 @@ Call Info 的 Tab 页,主要显示了调用树详细类型。 ### 搜索框支持表达式输入 -调用栈默认显示火焰图,新增搜索框表达式输入。表达式作用范围为 nativehook 统计与非统计模式。其中处理的均为 Responsible Library 与 Responsible Caller,其中 Responsible Library,Responsible Caller 表示从下往上非 libc++ musl 的第一条调用栈的 lib 跟 symbol,如下图所示,由于最后一条 [ operator new(unsigned long) ] libc++.so 为 libc++.so 的函数,固跳过,所以该条调用栈的 Responsible Library 为 libhilog.so,Responsible Caller 为 OHOS::HiviewDFX::GetDomainLevel(unsigned int) 。 +调用栈默认会显示火焰图,新增搜索框表达式输入。表达式作用范围为 nativehook 的统计与非统计模式。其中处理的为 Responsible Library 与 Responsible Caller,其中 Responsible Library 和Responsible Caller 表示从下往上非 libc++ musl 的第一条调用栈的 lib 跟 symbol,如下图所示,由于最后一条 [ operator new(unsigned long) ] libc++.so 为 libc++.so 的函数,故跳过,所以该条调用栈的 Responsible Library 为 libhilog.so,Responsible Caller 为 OHOS::HiviewDFX::GetDomainLevel(unsigned int) 。 ![GitHub Logo](../../figures/NativeMemory/framecaller.jpg) -表达式说明:在 InputFilter 输入框可以进行搜索过滤和表达式过滤,其中表达式必须以@开头,英文括号包起所需要过滤的内容,每个括号必须包括 (Responsible Library,Responsible Caller)匹配全量以\*表示,否则认为该输入为搜索过滤。 + +表达式说明: 在 InputFilter 输入框可以进行搜索过滤和表达式过滤,其中表达式必须以@开头,英文括号包起所需要过滤的内容,每个括号必须包括 (Responsible Library,Responsible Caller)匹配全量以\*表示,否则认为该输入为搜索过滤。 | 表达式 | 含义 | | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | diff --git a/ide/src/doc/md/quickstart_page_fault.md b/ide/src/doc/md/quickstart_page_fault.md index b3968ce99df1f1928053d3f49e0631b87e249a6c..c5b0957033eb8074632b2fbb0d13287791df5e87 100644 --- a/ide/src/doc/md/quickstart_page_fault.md +++ b/ide/src/doc/md/quickstart_page_fault.md @@ -50,7 +50,7 @@ Page Fault Statistics 的 Tab 页如图: - Max Duration:最大时长。 点击下方的 Statistics by Thread,可以切换到按照 Thread 为基点显示数据。 ![GitHub Logo](../../figures/EBPF/ebpf_bythread.jpg) - Page Fault Calltree 的 Tab 页如图: + Page Fault CallTree 的 Tab 页如图: ![GitHub Logo](../../figures/EBPF/VMCalltree.jpg) - Call Stack:为经过符号解析后的Callstack,并且给出动态链接库或者进程名的信息。 - Local:为该调用方法自身占用的CPU时间。 @@ -66,7 +66,7 @@ Page Fault Statistics 的 Tab 页如图: ### 页内存支持多种 Options 展示风格 -点击 Page Fault Calltree 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 +点击 Page Fault CallTree 的 Tab 页底部的 Options,会有两个 CheckBox 复选框。 ![GitHub Logo](../../figures/EBPF/vmOptions.jpg) - Invert:反向输出调用树。 @@ -74,7 +74,7 @@ Page Fault Statistics 的 Tab 页如图: ### 页内存支持过滤调用栈调用次数的展示风格 -点击 Page Fault Calltree 的 Tab 页底部的 Sample Counter Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 +点击 Page Fault CallTree 的 Tab 页底部的 Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。 ![GitHub Logo](../../figures/EBPF/vmcounter.jpg) ### 页内存功能的调用栈 Group 展示-数据分析支持剪裁功能 @@ -97,12 +97,12 @@ Page Fault Statistics 的 Tab 页如图: ### 页内存的事件类型的过滤 -通过选择可以过滤是 File Backed In 类型,还是 Copy On Write 类型事件。 +通过选择类型事件进行过滤。 ![GitHub Logo](../../figures/EBPF/VMfilter.jpg) ### 页内存的火焰图功能 -点击 Page Fault Calltree 左下角的柱状图的图标,会切换到火焰图页面。 +点击 Page Fault CallTree 左下角的柱状图的图标,会切换到火焰图页面。 ![GitHub Logo](../../figures/EBPF/vmflame.jpg) 进入到火焰图页面,火焰图的展示跟 Callinfo 的 tab 页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称和 Duration 时长。 ![GitHub Logo](../../figures/EBPF/vmflameshow.jpg) diff --git a/ide/src/doc/md/quickstart_parsing_ability.md b/ide/src/doc/md/quickstart_parsing_ability.md index b3bb85846c32d62de582a1e1046ac10017a74c40..e39a320ae1e2f1c9f7db19136e18cfda8fd13c53 100644 --- a/ide/src/doc/md/quickstart_parsing_ability.md +++ b/ide/src/doc/md/quickstart_parsing_ability.md @@ -28,7 +28,7 @@ Trace 解析能力增强主要是提高 Trace 的解析能力。 ##### 配置完成后, 查看【用户配置路径】是否是配置的路径 - edge浏览器: edge://version/ + edge浏览器: edge://version/ chrome浏览器: chrome://version/ #### 超大 trace 抓取配置说明 diff --git a/ide/src/doc/md/quickstart_sql_metrics.md b/ide/src/doc/md/quickstart_sql_metrics.md index f06ba59ce47e773f347f99af9dc6c3ff674b62d7..dcfe181f3cf33a1e90a3a9beb2a88830d4268663 100644 --- a/ide/src/doc/md/quickstart_sql_metrics.md +++ b/ide/src/doc/md/quickstart_sql_metrics.md @@ -9,7 +9,7 @@ Sql 功能是方便使用者查询 sql 语句查看相关业务,Metrics 是更 ## Metrics 功能介绍 -Metrics 是更高级别的查询接口,无需手动键入任何 SQL 语句,只需要选择定制好的查询接口,就能获得想要跟踪的结果。 +Metrics 是更高级别的查询接口,无需手动输入任何 SQL 语句,只需要选择定制好的查询接口,就能获得想要跟踪的结果。 ### Metrics 查询接口展示 diff --git a/ide/src/doc/md/quickstart_systemtrace.md b/ide/src/doc/md/quickstart_systemtrace.md index 4802cbbdbc98c49c2f0abd25a218579f394fb948..b4f52d8d64e0334fd672388cb56b34d0438c94cf 100644 --- a/ide/src/doc/md/quickstart_systemtrace.md +++ b/ide/src/doc/md/quickstart_systemtrace.md @@ -12,7 +12,7 @@ - Open trace file:导入离线 trace 文件入口。 - Open long trace file:导入大文件入口。 - Record new trace:抓取新的 trace 文件入口。 -- Record template:抓取指定模块的 trace 入口。 +- Record template:抓取指定模块的 trace 文件入口。 ## 导入 trace 文件后显示页面 @@ -128,7 +128,7 @@ Thread States、Thread Switches 的 2 个 Tab 页,点击移动到某一行, ### Tab 页信息和泳道图可跳转(点击和框选场景,框选类似搜索) -泳道图高亮场景:框选 Cpu Frequency 或者 Cpu State 泳道图后,弹出 Cpu Frequency 或 Cpu State Tab 页,在点击 Tab 页表格的行时,框选范围泳道图的当前行的 Value 值一样的部分上方会出现一条以圆点开头颜色比趋势图颜色同色但稍深的粗线条,如下图: +泳道图高亮场景:框选 Cpu Frequency 或者 Cpu State 泳道图后,弹出 Cpu Frequency 或 Cpu State Tab 页,点击 Tab 页表格中行某一行数据时,会在框选范围泳道内出现一个以圆形开头的图标,表示当前所点击的数据,如下图: ![GitHub Logo](../../figures/Web/Tabskill.jpg) 搜索场景:框选函数调用栈的泳道图,弹出 Slices Tab 页,点击表格行,会跳转到框选范围内的第一条调用栈的位置,点击下图 Slices Tab 页的 Background concurrent copying GC 调用栈。 ![GitHub Logo](../../figures/Web/Tabskillcalltack.jpg) diff --git a/ide/src/doc/md/quickstart_web_record.md b/ide/src/doc/md/quickstart_web_record.md index efcf14b6d7d95497fcf8e62ef92bc1da3452a125..a6f0e3db4178c6d7b8fec3af86ad55e8c8aaff54 100644 --- a/ide/src/doc/md/quickstart_web_record.md +++ b/ide/src/doc/md/quickstart_web_record.md @@ -5,10 +5,11 @@ ## 界面配置说明 ![GitHub Logo](../../figures/hdc/hdc.jpg) + 说明: -- Record:trace 抓取按钮。 -- Add HDC Device:连接设备。 +- Record: trace 抓取按钮。 +- Add HDC Device: 连接设备。 ## trace 文件的在线抓取 @@ -18,13 +19,13 @@ ![GitHub Logo](../../figures/hdc/Schedulingdetails.jpg) 抓取项说明: -- Scheduling details:线程切换事件,暂停恢复方法,线程唤醒事件,进程退出和销毁处理,新建线程处理方法,线程重命名处理方法。 -- CPU Frequency and idle states:CPU 频率信息和 CPU 空闲状态。 -- Advanced ftrace config:线程切换事件,暂停恢复方法,线程唤醒事件,进程退出和销毁处理,新建线程处理方法,线程重命名处理方法,IRQ 事件,时钟频率处理方法,Binder 事件,线程调用堆栈开始和结束的处理。 -- AbilityMonitor:进程的 CPU,内存,磁盘,网络使用情况。 -- Kernel meminfo:内核内存。 -- Virtual memory stats:系统虚拟内存。 -- Hitrace categories:Bytrace 的抓取项,各解释项说明如下图: +- Scheduling details: 线程切换事件,暂停恢复方法,线程唤醒事件,进程退出和销毁处理,新建线程处理方法,线程重命名处理方法。 +- CPU Frequency and idle states: CPU 频率信息和 CPU 空闲状态。 +- Advanced ftrace config: 线程切换事件,暂停恢复方法,线程唤醒事件,进程退出和销毁处理,新建线程处理方法,线程重命名处理方法,IRQ 事件,时钟频率处理方法,Binder 事件,线程调用堆栈开始和结束的处理。 +- AbilityMonitor: 进程的 CPU,内存,磁盘,网络使用情况。 +- Kernel meminfo: 内核内存。 +- Virtual memory stats: 系统虚拟内存。 +- Hitrace categories: Bytrace 的抓取项,各解释项说明如下图: ![GitHub Logo](../../figures/hdc/bytacedescription.jpg) 再点击 Record setting,在 output file path 输入文件名 hiprofiler_data_example.htrace,拖动滚动条设置 buffer size 大小是 64M,抓取时长是 50s。 diff --git a/ide/src/doc/quickstart_bio.html b/ide/src/doc/quickstart_bio.html index b1fa979c52bf810125b3352055d300269fd33539..6ed54a19f91a4113082c819fd32f067fb2ab7374 100644 --- a/ide/src/doc/quickstart_bio.html +++ b/ide/src/doc/quickstart_bio.html @@ -908,7 +908,7 @@ Max Total Latency:最大延迟时间。

- Disk I/O Latency Calltree的Tab页如图:
+ Disk I/O Latency CallTree的Tab页如图:
GitHub Logo

    @@ -1006,7 +1006,7 @@ BackTrace:调用栈顶部函数,并显示调用栈深度。

    Bio支持多种Options展示风格

    - 点击Disk I/O Latency Calltree的Tab页底部的Options,会有两个CheckBox复选框。
    + 点击Disk I/O Latency CallTree的Tab页底部的Options,会有两个CheckBox复选框。
    GitHub Logo

      @@ -1026,7 +1026,7 @@ Hide System so:隐藏系统库文件 。

      Bio支持过滤调用栈调用次数的展示风格

      - 点击Disk I/O Latency Calltree的Tab页底部的Sample Counter + 点击Disk I/O Latency CallTree的Tab页底部的Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。
      GitHub Logo

      @@ -1068,9 +1068,9 @@ Hide System so:隐藏系统库文件 。

      Bio的火焰图功能

      - 点击Disk I/O Latency Calltree左下角的柱状图的图标,会切换到火焰图页面。
      + 点击Disk I/O Latency CallTree左下角的柱状图的图标,会切换到火焰图页面。
      GitHub Logo
      - 进入到火焰图页面,火焰图的展示跟 Disk I/O Latency Calltree 的tab页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称和Duration时长。
      + 进入到火焰图页面,火焰图的展示跟 Disk I/O Latency CallTree 的tab页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称和Duration时长。
      GitHub Logo
      鼠标点击火焰图,会进入下一级界面,点击上级则返回上一级界面。
      GitHub Logo diff --git a/ide/src/doc/quickstart_device_record.html b/ide/src/doc/quickstart_device_record.html index df214c61e896bcc2b0fe1e2f32486ae7e81b948c..5e2b90e0175b13a6a1d834fabf1365b0acb0ecf6 100644 --- a/ide/src/doc/quickstart_device_record.html +++ b/ide/src/doc/quickstart_device_record.html @@ -804,9 +804,9 @@

    • Record setting:设置trace的抓取模式,buffer size大小,抓取时长。
    • Trace command:生成的抓取命令行。
    • Probes config:trace的抓取参数配置。
    • -
    • Native Memory:NativeMemory数据的抓取参数配置。
    • +
    • Native Memory:Native Memory数据的抓取参数配置。
    • Hiperf:Hiperf数据的抓取参数配置。
    • -
    • eBPF Config:ebpf数据的抓取参数配置。
    • +
    • eBPF Config:eBPF数据的抓取参数配置。
    • VM Tracker:smaps数据的抓取参数配置。
    • HiSystemEvent:HiSystemEvent数据抓取参数配置。
    • SDK Config:SDK数据抓取参数配置。
    • diff --git a/ide/src/doc/quickstart_filesystem.html b/ide/src/doc/quickstart_filesystem.html index 15a8f8b984008939cff0fb4d26833cf99ff823aa..e85cb2dd484769ec34fce50891d654958560e8e3 100644 --- a/ide/src/doc/quickstart_filesystem.html +++ b/ide/src/doc/quickstart_filesystem.html @@ -981,6 +981,24 @@ Process:进程名。
    •  Thread:线程名。
      +
      +
    • +
    • +
      +Type:操作类型。
      +
      +
    • +
    • +
      +File Descriptor:fd。
      +
      +
    • +
    • +
      +File Path:文件路径。
       
    • @@ -1128,7 +1146,7 @@ Hide System so:隐藏系统库文件。

      FileSystem支持过滤调用栈调用次数的展示风格

      - 点击FileSystem Calltree的Tab页底部的Sample Counter + 点击FileSystem Calltree的Tab页底部的Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。
      GitHub Logo

      diff --git a/ide/src/doc/quickstart_hiperf.html b/ide/src/doc/quickstart_hiperf.html index f371d3ccda468581101a095bebe850b5f5bdd25c..0dcaf7d9633b17d3680c02aa4c4a13843ef40437 100644 --- a/ide/src/doc/quickstart_hiperf.html +++ b/ide/src/doc/quickstart_hiperf.html @@ -885,7 +885,7 @@ Advance Options:更多的抓取配置项。

      HiPerf泳道图的框选功能

      - 可以对CPU使用量区,线程和进程区数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有两个tab页。
      + 可以对CPU使用量区,线程和进程区数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有四个tab页。
      Perf Profile的Tab页如图:
      GitHub Logo

      @@ -904,7 +904,13 @@ Local:为该调用方法自身占用的CPU时间。
    • -Weight:调用方法的执行次数和占比。
      +Sample Count:采样数量。
      +
      +
    • +
    • +
      +Event Count:事件数量。
       
    • @@ -954,7 +960,7 @@ Backtrace:栈顶的调用栈名称。

      HiPerf支持多种Options展示风格

      - 点击Perf Profile的Tab页底部的Options,会有两个CheckBox复选框。
      + 点击Perf Profile的Tab页底部的Options,会有四个CheckBox复选框。
      GitHub Logo

        @@ -967,6 +973,18 @@ Invert:反向输出调用树。
      •  Hide System so:隐藏系统库文件。
        +
        +
      • +
      • +
        +Hide Thread:隐藏线程。
        +
        +
      • +
      • +
        +Hide Thread State:隐藏线程状态。
         
      • @@ -974,7 +992,7 @@ Hide System so:隐藏系统库文件。

        HiPerf支持过滤调用栈调用次数的展示风格

        - 点击Perf Profile的Tab页底部的Sample Counter Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。
        + 点击Perf Profile的Tab页底部的Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。
        GitHub Logo

        HiPerf功能的调用栈Group展示-数据分析支持剪裁功能

        diff --git a/ide/src/doc/quickstart_page_fault.html b/ide/src/doc/quickstart_page_fault.html index 5ed0a8c7061251609a49716ec9b1b1b93b1a5713..bfaa5e4ddace5daac4263a04d50d984d60ede445 100644 --- a/ide/src/doc/quickstart_page_fault.html +++ b/ide/src/doc/quickstart_page_fault.html @@ -1000,7 +1000,7 @@ Hide System so:隐藏系统库文件。

        页内存支持过滤调用栈调用次数的展示风格

        - 点击Page Fault Calltree的Tab页底部的Sample Counter + 点击Page Fault Calltree的Tab页底部的Sample Count Filter,可以填上区间值。过滤出符合该区间值调用次数的调用栈信息。
        GitHub Logo

        @@ -1030,7 +1030,7 @@ Hide System so:隐藏系统库文件。

        页内存的事件类型的过滤

        - 通过选择可以过滤是File Backed In类型,还是Copy On Write类型事件。
        + 通过选择类型事件进行过滤。
        GitHub Logo

        页内存的火焰图功能

        diff --git a/ide/src/figures/FileSystem/FileSystemOptions.jpg b/ide/src/figures/FileSystem/FileSystemOptions.jpg index b5ce7a6a6816502550c40d7e5237a8bd088233d0..fe5e05fa20619685933f723ed3333a7db947601d 100644 Binary files a/ide/src/figures/FileSystem/FileSystemOptions.jpg and b/ide/src/figures/FileSystem/FileSystemOptions.jpg differ diff --git a/ide/src/figures/FileSystem/FileSystemstatistics.jpg b/ide/src/figures/FileSystem/FileSystemstatistics.jpg index 86e2838c35e8c44dd740ce0c3847ab8aea873bac..8bbef983384008bb2c1f79f057b7552450d2379b 100644 Binary files a/ide/src/figures/FileSystem/FileSystemstatistics.jpg and b/ide/src/figures/FileSystem/FileSystemstatistics.jpg differ diff --git a/ide/src/figures/hdc/hdc.jpg b/ide/src/figures/hdc/hdc.jpg index bf8c0e8bfd2ac208214203dd972f3b3821b06d5d..68920afca2ae0b4452174c06367d94daa5fd929d 100644 Binary files a/ide/src/figures/hdc/hdc.jpg and b/ide/src/figures/hdc/hdc.jpg differ diff --git a/ide/src/figures/perf/Options.jpg b/ide/src/figures/perf/Options.jpg index 465b4cf6a06057fbe7e116c8bc72e967b94b59ec..5af18c3ec43c67b590da4523cb5dd6bab8f69825 100644 Binary files a/ide/src/figures/perf/Options.jpg and b/ide/src/figures/perf/Options.jpg differ diff --git a/ide/src/figures/perf/PerfProfile.jpg b/ide/src/figures/perf/PerfProfile.jpg index 2732b9541a582b0fcd91836cf34a7ada08e336cd..2baef6afffc3ba6b1901deb066115c7613bb4bb0 100644 Binary files a/ide/src/figures/perf/PerfProfile.jpg and b/ide/src/figures/perf/PerfProfile.jpg differ diff --git a/ide/src/figures/perf/Samplelist.jpg b/ide/src/figures/perf/Samplelist.jpg index f161a6c5a40405149ae296df339b43c154c2f81d..6931c510d32f203f4206855947d2e5b2be46de01 100644 Binary files a/ide/src/figures/perf/Samplelist.jpg and b/ide/src/figures/perf/Samplelist.jpg differ diff --git a/ide/src/figures/perf/datamining.jpg b/ide/src/figures/perf/datamining.jpg index bcc45679dba8ad79e227314b853a54d76f8ab3e2..20d73817c0e33b2ea80960d79903c84c9baa498c 100644 Binary files a/ide/src/figures/perf/datamining.jpg and b/ide/src/figures/perf/datamining.jpg differ diff --git a/ide/src/figures/perf/flame.jpg b/ide/src/figures/perf/flame.jpg index a188dcef2e8d44d2819f25e7c3599298900d7080..0a270ec83a9918a2286183210821460f0455ded8 100644 Binary files a/ide/src/figures/perf/flame.jpg and b/ide/src/figures/perf/flame.jpg differ diff --git a/ide/src/figures/perf/flameshow.jpg b/ide/src/figures/perf/flameshow.jpg index 618a552a8a43811c92979d512c647ffc9915f331..cc80933cbe5c11b5f667c4aece7d2c0cbb7b4942 100644 Binary files a/ide/src/figures/perf/flameshow.jpg and b/ide/src/figures/perf/flameshow.jpg differ diff --git a/ide/src/figures/perf/heaviesttrace1.jpg b/ide/src/figures/perf/heaviesttrace1.jpg index de01d6767b988bc99b02d92869d2e9e66b0d6d30..d390a8531441fd474bd09226820e1c56ed87e36a 100644 Binary files a/ide/src/figures/perf/heaviesttrace1.jpg and b/ide/src/figures/perf/heaviesttrace1.jpg differ diff --git a/ide/src/figures/perf/inputfilter.jpg b/ide/src/figures/perf/inputfilter.jpg index 0beea5695a229a7527812634aaefdd2316074331..a923053749c182d66b27047add93e18f18318cf7 100644 Binary files a/ide/src/figures/perf/inputfilter.jpg and b/ide/src/figures/perf/inputfilter.jpg differ diff --git a/ide/src/figures/perf/samplecounter.jpg b/ide/src/figures/perf/samplecounter.jpg index b7e92468b8b1ce414a831dd8134f3d6c5baa163e..3a32db0363da5cb6f6e3eca97e70f781f55e7069 100644 Binary files a/ide/src/figures/perf/samplecounter.jpg and b/ide/src/figures/perf/samplecounter.jpg differ diff --git a/ide/src/figures/perf/summary.jpg b/ide/src/figures/perf/summary.jpg index a8c01ad4ffec6b75b5efcae534084b53ce7370de..594d28fba25ab4f038a194d1804292fb9cb40c86 100644 Binary files a/ide/src/figures/perf/summary.jpg and b/ide/src/figures/perf/summary.jpg differ diff --git a/ide/src/statistics/util/SpStatisticsHttpUtil.ts b/ide/src/statistics/util/SpStatisticsHttpUtil.ts index c92138028301feed7e028109b71ccbdbe6515554..e89088f488d3d83d6a47206296c91f79a90e8245 100644 --- a/ide/src/statistics/util/SpStatisticsHttpUtil.ts +++ b/ide/src/statistics/util/SpStatisticsHttpUtil.ts @@ -37,6 +37,14 @@ export class SpStatisticsHttpUtil { static getRequestServerInfo(): string { try { let req = new XMLHttpRequest(); + req.onreadystatechange = () => { + if (req.readyState === 4 && req.status === 200) { + let requestInfo = req.getResponseHeader('request_info'); + if (requestInfo && requestInfo.length > 0) { + SpStatisticsHttpUtil.requestServerInfo = requestInfo; + } + } + } req.open( 'GET', `${window.location.protocol}//${window.location.host.split(':')[0]}:${ @@ -45,16 +53,9 @@ export class SpStatisticsHttpUtil { true ); req.send(null); - if (req.status == 200) { - let requestInfo = req.getResponseHeader('request_info'); - if (requestInfo && requestInfo.length > 0) { - return requestInfo; - } - } } catch { warn('Connect Server Failed') } - return ''; } diff --git a/ide/src/trace/SpApplication.ts b/ide/src/trace/SpApplication.ts index 3f7cbad4afb5713f1dee29a06b28a7096346e0e3..9ec7d62731c914194996830f3bf7cbae1870cdbc 100644 --- a/ide/src/trace/SpApplication.ts +++ b/ide/src/trace/SpApplication.ts @@ -67,6 +67,9 @@ import { readTraceFileBuffer, } from './SpApplicationPublicFunc'; import { queryExistFtrace } from './database/sql/SqlLite.sql'; +import '../base-ui/chart/scatter/LitChartScatter'; +import { SpThirdParty } from './component/SpThirdParty'; +import './component/SpThirdParty'; @element('sp-application') export class SpApplication extends BaseElement { @@ -124,6 +127,7 @@ export class SpApplication extends BaseElement { private customColor: CustomThemeColor | undefined | null; private filterConfig: LitIcon | undefined | null; private configClose: LitIcon | undefined | null; + private spThirdParty: SpThirdParty | undefined | null; // 关键路径标识 private importConfigDiv: HTMLInputElement | undefined | null; private closeKeyPath: HTMLDivElement | undefined | null; @@ -268,6 +272,7 @@ export class SpApplication extends BaseElement { this.longTracePage = this.shadowRoot!.querySelector('.long_trace_page') as HTMLDivElement; this.customColor = this.shadowRoot?.querySelector('.custom-color') as CustomThemeColor; this.filterConfig = this.shadowRoot?.querySelector('.filter-config') as LitIcon; + this.spThirdParty = this.shadowRoot!.querySelector('#sp-third-party') as SpThirdParty; this.configClose = this.shadowRoot ?.querySelector('.chart-filter')! .shadowRoot?.querySelector('.config-close'); @@ -310,6 +315,7 @@ export class SpApplication extends BaseElement { this.spRecordTemplate, this.spFlags, this.spKeyboard, + this.spThirdParty, ]; } @@ -648,6 +654,12 @@ export class SpApplication extends BaseElement { } private initDocumentListener(): void { + document.addEventListener('file-error', () => { + this.litSearch!.setPercent('This File is Error!', -1); + }); + document.addEventListener('file-correct', () => { + this.litSearch!.setPercent('', 101); + }); document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') { this.validateFileCacheLost(); @@ -773,17 +785,24 @@ export class SpApplication extends BaseElement { }, }, { - title: 'Keyboard shortcuts', + title: 'Keyboard Shortcuts', icon: 'smart-help', clickHandler: (item: MenuItem): void => { - this.search = false; - this.showContent(this.spKeyboard!); + document.querySelector('body > sp-application')!.shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'visible'; SpStatisticsHttpUtil.addOrdinaryVisitAction({ - event: 'Keyboard shortcuts', - action: 'Keyboard shortcuts', + event: 'Keyboard Shortcuts', + action: 'Keyboard Shortcuts', }); }, }, + { + title: '第三方文件', + icon: 'file-fill', + clickHandler: (item: MenuItem): void => { + this.search = false; + this.showContent(this.spThirdParty!); + }, + }, ], }, ]; @@ -828,33 +847,44 @@ export class SpApplication extends BaseElement { private handleWasmMode(ev: any, showFileName: string, fileSize: number, fileName: string): void { let that = this; - let fileSizeStr = (fileSize / 1048576).toFixed(1); - postLog(fileName, fileSizeStr); - document.title = `${showFileName} (${fileSizeStr}M)`; - info('Parse trace using wasm mode '); this.litSearch!.setPercent('', 1); - let completeHandler = async (res: any): Promise => { - await this.traceLoadCompleteHandler(res, fileSizeStr, showFileName, fileName); - }; - threadPool.init('wasm').then((res) => { - let reader: FileReader | null = new FileReader(); - reader.readAsArrayBuffer(ev as any); - reader.onloadend = function (ev): void { - info('read file onloadend'); - that.litSearch!.setPercent('ArrayBuffer loaded ', 2); - let wasmUrl = `https://${window.location.host.split(':')[0]}:${window.location.port}/application/wasm.json`; - SpApplication.loadingProgress = 0; - SpApplication.progressStep = 3; - let data = this.result as ArrayBuffer; - info('initData start Parse Data'); - that.spSystemTrace!.loadDatabaseArrayBuffer( - data, - wasmUrl, - (command: string, _: number) => that.setProgress(command), - completeHandler - ); + if (fileName.endsWith('.json')) { + that.progressEL!.loading = true; + that.spSystemTrace!.loadSample(ev).then(() => { + that.showContent(that.spSystemTrace!); + that.litSearch!.setPercent('', 101); + that.freshMenuDisable(false); + that.chartFilter!.setAttribute('mode', ''); + that.progressEL!.loading = false; + }) + } else { + let fileSizeStr = (fileSize / 1048576).toFixed(1); + postLog(fileName, fileSizeStr); + document.title = `${showFileName} (${fileSizeStr}M)`; + info('Parse trace using wasm mode '); + let completeHandler = async (res: any): Promise => { + await this.traceLoadCompleteHandler(res, fileSizeStr, showFileName, fileName); }; - }); + threadPool.init('wasm').then((res) => { + let reader: FileReader | null = new FileReader(); + reader.readAsArrayBuffer(ev as any); + reader.onloadend = function (ev): void { + info('read file onloadend'); + that.litSearch!.setPercent('ArrayBuffer loaded ', 2); + let wasmUrl = `https://${window.location.host.split(':')[0]}:${window.location.port}/application/wasm.json`; + SpApplication.loadingProgress = 0; + SpApplication.progressStep = 3; + let data = this.result as ArrayBuffer; + info('initData start Parse Data'); + that.spSystemTrace!.loadDatabaseArrayBuffer( + data, + wasmUrl, + (command: string, _: number) => that.setProgress(command), + completeHandler + ); + }; + }); + } } private async traceLoadCompleteHandler( @@ -960,15 +990,14 @@ export class SpApplication extends BaseElement { }, }, { - title: 'Keyboard shortcuts', + title: 'Keyboard Shortcuts', icon: 'smart-help', clickHandler: function (item: MenuItem): void { + document.querySelector('body > sp-application')!.shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'visible'; SpStatisticsHttpUtil.addOrdinaryVisitAction({ - event: 'Keyboard shortcuts', - action: 'Keyboard shortcuts', + event: 'Keyboard Shortcuts', + action: 'Keyboard Shortcuts', }); - that.search = false; - that.showContent(that.spKeyboard!); }, }, ], @@ -1929,6 +1958,12 @@ export class SpApplication extends BaseElement { if (cutIndex !== -1) { traceName = traceName.substring(0, cutIndex); } + if (cutBuffer !== undefined && cutBuffer.byteLength <= 12) { + this.litSearch!.setPercent('The cut is empty data. Select a time range for valid data!', -1); + this.progressEL!.loading = false; + this.freshMenuDisable(false); + return; + } let blobUrl = URL.createObjectURL(new Blob([cutBuffer!])); window.open( `index.html?link=true&local=true&traceName=${traceName}_cut_${cutLeftTs}${fileType}&trace=${encodeURIComponent( diff --git a/ide/src/trace/SpApplicationPublicFunc.ts b/ide/src/trace/SpApplicationPublicFunc.ts index fd6dd3571a1819069b83066aeaf6bf6a4696e89d..2fd388f8170040f494803a75fc2b5883af726f7b 100644 --- a/ide/src/trace/SpApplicationPublicFunc.ts +++ b/ide/src/trace/SpApplicationPublicFunc.ts @@ -360,25 +360,27 @@ export const applicationHtml: string = `
        - + -
        diff --git a/ide/src/trace/bean/BinderProcessThread.ts b/ide/src/trace/bean/BinderProcessThread.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce0c0bda7f613015f77151814bdbdfff6861c702 --- /dev/null +++ b/ide/src/trace/bean/BinderProcessThread.ts @@ -0,0 +1,103 @@ + +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface BinderGroup { + title: string | null | undefined ; + totalCount: number; + binderAsyncRcvCount?: number; + binderReplyCount?: number; + binderTransactionAsyncCount?: number; + binderTransactionCount?: number; + tid: number; + pid: number; + children?: Array; + status?: boolean; +} + +export class CycleBinderItem { + title: string = ''; + tid: number = 0; + pid: number = 0; + durNs: number = 0; + tsNs: number = 0; + cycleDur: number = 0; + cycleStartTime: number = 0; + totalCount: number = 0; + binderTransactionCount: number = 0; + binderAsyncRcvCount: number = 0; + binderReplyCount: number = 0; + binderTransactionAsyncCount: number = 0; + idx: number = -1; + type: string = 'Cycle'; +} + +export interface ThreadBinderItem { + title: string ; + tid: number; + pid: number; + totalCount: number; + type: string; + children: Array; +} + +export interface ProcessBinderItem { + title: string ; + pid: number; + totalCount: number; + type: string; + children: Array; +} + +export interface DataSource { + xName: string ; + yAverage: number; +} + +export interface FunctionItem { + cycleStartTime: number; + cycleDur: number; + dur: number; + id: number; + tid: number; + pid: number; +} + +export class FuncNameCycle { + funcName: string = ''; + cycleStartTime: number = 0; + cycleDur: number = 0; + startTime: number = 0; + endTime: number = 0; + id: number = 0; + tid: number = 0; + pid: number = 0; +} + +export interface BinderDataStruct { + name: string ; + value: number; + dur: number; + startNS: number; + cycle: number; + depth?: number; +} + +export interface BinderItem { + name: string ; + ts: number; + dur: number; + tid: number; + pid: number; +} diff --git a/ide/src/trace/bean/BoxSelection.ts b/ide/src/trace/bean/BoxSelection.ts index 59ec215b7d5c3e3df9d6d78c29f048226f7d44bd..d47b699afd612e2ddd04589addf0f5be11937bbe 100644 --- a/ide/src/trace/bean/BoxSelection.ts +++ b/ide/src/trace/bean/BoxSelection.ts @@ -33,6 +33,7 @@ import { HeapDataInterface } from '../../js-heap/HeapDataInterface'; import { LitTabs } from '../../base-ui/tabs/lit-tabs'; import { TabPaneSummary } from '../component/trace/sheet/ark-ts/TabPaneSummary'; import { JsCpuProfilerStruct } from '../database/ui-worker/ProcedureWorkerCpuProfiler'; +import { SampleStruct } from '../database/ui-worker/ProcedureWorkerSample'; export class SelectionParam { recordStartNs: number = 0; @@ -129,6 +130,26 @@ export class SelectionParam { sysAllEventsData: Array = []; sysAlllogsData: Array = []; hiSysEvents: Array = []; + sampleData: Array = []; + + pushSampleData(it: TraceRow) { + if (it.rowType == TraceRow.ROW_TYPE_SAMPLE) { + let dataList: SampleStruct[] = JSON.parse(JSON.stringify(it.dataList)); + if (dataList.length > 0) { + dataList.forEach( + SampleStruct => { + SampleStruct.property = SampleStruct.property!.filter((i : any) => + ((i.begin! - i.startTs!) ?? 0) >= TraceRow.rangeSelectObject!.startNS! && + ((i.end! - i.startTs!) ?? 0) <= TraceRow.rangeSelectObject!.endNS!) + } + ) + if (dataList[0].property!.length !== 0) { + this.sampleData.push(...dataList); + } + } + } + } + pushCpus(it: TraceRow) { if (it.rowType == TraceRow.ROW_TYPE_CPU) { this.cpus.push(parseInt(it.rowId!)); @@ -137,15 +158,29 @@ export class SelectionParam { } pushCpuStateFilterIds(it: TraceRow) { + if (it.rowType === TraceRow.ROW_TYPE_CPU_STATE_ALL) { + it.childrenList.forEach(child => { + child.rangeSelect = true; + child.checkType = '2'; + this.pushCpuStateFilterIds(child); + }); + } if (it.rowType == TraceRow.ROW_TYPE_CPU_STATE) { let filterId = parseInt(it.rowId!); - if (this.cpuStateFilterIds.indexOf(filterId) == -1) { + if (this.cpuStateFilterIds.indexOf(filterId) === -1) { this.cpuStateFilterIds.push(filterId); } } } pushCpuFreqFilter(it: TraceRow) { + if (it.rowType === TraceRow.ROW_TYPE_CPU_FREQ_ALL) { + it.childrenList.forEach(child => { + child.rangeSelect = true; + child.checkType = '2'; + this.pushCpuFreqFilter(child); + }); + } if (it.rowType == TraceRow.ROW_TYPE_CPU_FREQ) { let filterId = parseInt(it.rowId!); let filterName = it.name!; @@ -159,13 +194,22 @@ export class SelectionParam { } pushCpuFreqLimit(it: TraceRow) { - if (it.rowType == TraceRow.ROW_TYPE_CPU_FREQ_LIMIT) { - this.cpuFreqLimit.push({ - maxFilterId: it.getAttribute('maxFilterId'), - minFilterId: it.getAttribute('minFilterId'), - cpu: it.getAttribute('cpu'), + if (it.rowType === TraceRow.ROW_TYPE_CPU_FREQ_LIMITALL) { + it.childrenList.forEach(child => { + child.rangeSelect = true; + child.checkType = '2'; + this.pushCpuFreqLimit(child); }); } + if (it.rowType == TraceRow.ROW_TYPE_CPU_FREQ_LIMIT) { + if (!this.cpuFreqLimit.includes((item: any) => item.cpu === it.getAttribute('cpu'))) { + this.cpuFreqLimit.push({ + maxFilterId: it.getAttribute('maxFilterId'), + minFilterId: it.getAttribute('minFilterId'), + cpu: it.getAttribute('cpu'), + }); + } + } } pushProcess(it: TraceRow, sp: SpSystemTrace) { @@ -509,8 +553,8 @@ export class SelectionParam { this.jankFramesData = []; it.childrenList.forEach((child) => { if (child.rowType == TraceRow.ROW_TYPE_JANK && child.name == 'Actual Timeline') { - if (it.rowParentId === 'frameTime') { - it.dataListCache.forEach((jankData: any) => { + if (child.rowParentId === 'frameTime') { + child.dataListCache.forEach((jankData: any) => { if (isIntersect(jankData, TraceRow.rangeSelectObject!)) { this.jankFramesData.push(jankData); } @@ -527,8 +571,8 @@ export class SelectionParam { pushHeapTimeline(it: TraceRow, sp: SpSystemTrace) { if (it.rowType == TraceRow.ROW_TYPE_HEAP_TIMELINE) { const [rangeStart, rangeEnd] = [TraceRow.range?.startNS, TraceRow.range?.endNS]; - const endNS = TraceRow.rangeSelectObject?.endNS || rangeStart; - const startNS = TraceRow.rangeSelectObject?.startNS || rangeEnd; + const startNS = TraceRow.rangeSelectObject?.startNS || rangeStart; + const endNS = TraceRow.rangeSelectObject?.endNS || rangeEnd; let minNodeId, maxNodeId; if (!it.dataListCache || it.dataListCache.length === 0) { return; @@ -679,12 +723,24 @@ export class SelectionParam { } } - pushIrq(it: TraceRow, sp: SpSystemTrace) { + pushIrq(it: TraceRow) { + if (it.rowType === TraceRow.ROW_TYPE_IRQ_GROUP) { + it.childrenList.forEach(child => { + child.rangeSelect = true; + child.checkType = '2'; + this.pushIrq(child); + }); + } if (it.rowType == TraceRow.ROW_TYPE_IRQ) { + let filterId = parseInt(it.getAttribute('callId') || '-1'); if (it.getAttribute('cat') === 'irq') { - this.irqCallIds.push(parseInt(it.getAttribute('callId') || '-1')); + if (this.irqCallIds.indexOf(filterId) === -1) { + this.irqCallIds.push(filterId); + } } else { - this.softIrqCallIds.push(parseInt(it.getAttribute('callId') || '-1')); + if (this.softIrqCallIds.indexOf(filterId) === -1) { + this.softIrqCallIds.push(filterId); + } } } } @@ -885,6 +941,13 @@ export class SelectionParam { } pushClock(it: TraceRow, sp: SpSystemTrace) { + if (it.rowType === TraceRow.ROW_TYPE_CLOCK_GROUP) { + it.childrenList.forEach(it => { + it.rangeSelect = true; + it.checkType = '2'; + this.clockMapData.set(it.rowId || '', it.getCacheData); + }); + } if (it.rowType == TraceRow.ROW_TYPE_CLOCK) { this.clockMapData.set(it.rowId || '', it.getCacheData); } @@ -965,7 +1028,7 @@ export class SelectionParam { this.pushSysMemoryGpu(it, sp); this.pushSDK(it, sp); this.pushVmTrackerSmaps(it, sp); - this.pushIrq(it, sp); + this.pushIrq(it); this.pushSysMemoryGpuGl(it, sp); this.pushFrameDynamic(it, sp); this.pushFrameSpacing(it); @@ -995,6 +1058,7 @@ export class SelectionParam { this.pushPugreable(it, sp); this.pushLogs(it, sp); this.pushHiSysEvent(it, sp); + this.pushSampleData(it); } } diff --git a/ide/src/trace/bean/FuncStruct.ts b/ide/src/trace/bean/FuncStruct.ts index b1da74e036f8368cab71210e2f72402038da9e46..d77ead187124e078c85461e2e20080f3a561e570 100644 --- a/ide/src/trace/bean/FuncStruct.ts +++ b/ide/src/trace/bean/FuncStruct.ts @@ -36,6 +36,7 @@ export class FuncStruct extends BaseStruct { ipid: number | undefined; identify: number | undefined; track_id: number | undefined; + nofinish: boolean = false; static draw(funcBeanStructCanvasCtx: CanvasRenderingContext2D, funcBeanStruct: FuncStruct) { if (funcBeanStruct.frame) { diff --git a/ide/src/trace/bean/GpufreqBean.ts b/ide/src/trace/bean/GpufreqBean.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ba1ecfedd72654e198f9ba47a684fe72d61b03a --- /dev/null +++ b/ide/src/trace/bean/GpufreqBean.ts @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export class GpuCountBean { + freq: number = 0; + val: number = 0; + value: number = 0; + startNS: number = 0; + dur: number = 0; + endTime: number = 0; + thread: string = ''; + parentIndex: number = 0; + level?: number = 0; + constructor( + freq: number, + value: number, + val: number, + dur: number, + startNS: number, + endTime: number, + thread: string, + parentIndex: number + ) { + this.freq = freq; + this.value = value; + this.val = val; + this.dur = dur; + this.startNS = startNS; + this.endTime = endTime; + this.thread = thread; + this.parentIndex = parentIndex; + } +} +export class SearchGpuFuncBean { + funName: string | undefined; + startTime: number = 0; + dur: number | undefined; + endTime: number = 0; + threadName: string | undefined; + pid: number | undefined; +} +export class TreeDataBean { + thread?: string = ''; + val?: number = 0; + freq?: number = 0; + gpufreq?: number = 0; + dur: number = 0; + value: number = 0; + percent?: number = 0; + children: TreeDataBean[] = []; + ts?: number = 0; + startTime?: number = 0; + startNS?: number = 0; + level?: number; + cycle?: number; +} + +export class CycleDataBean { + colorIndex: number = 0; + dur: number = 0; + value: number = 0; + startNS: number = 0; + cycle: number = 0; + name: string = ''; + depth: number = 1 + constructor( + colorIndex: number, + dur: number, + value: number, + startNS: number, + cycle: number, + name: string, + depth: number) { + this.colorIndex = colorIndex; + this.dur = dur; + this.value = value; + this.startNS = startNS; + this.cycle = cycle; + this.name = name; + this.depth = this.depth + } +} + +export class TreeDataStringBean { + thread: string = ''; + value: string = ''; + dur: string = ''; + percent: string = ''; + level?: string = ''; + cycle?: number = 0; + startNS?: string = ''; + freq?: string = ''; + children?: TreeDataStringBean[] = []; + status?: boolean = false; + constructor( + thread: string, + value: string, + dur: string, + percent: string, + level?: string, + freq?: string, + cycle?: number, + children?: TreeDataStringBean[], + startNS?: string, + status?: boolean + ) { + this.thread = thread; + this.value = value; + this.dur = dur; + this.percent = percent; + this.level = level; + this.freq = freq; + this.cycle = cycle; + this.children = children; + this.startNS = startNS; + this.status = status + } +} \ No newline at end of file diff --git a/ide/src/trace/bean/ProcessStruct.ts b/ide/src/trace/bean/ProcessStruct.ts index 94a36c613c342af1acd7727c44983c0eeb9321a7..04ff2d1babf518524d05fe5c4d02643c194d7d23 100644 --- a/ide/src/trace/bean/ProcessStruct.ts +++ b/ide/src/trace/bean/ProcessStruct.ts @@ -15,7 +15,7 @@ import { ColorUtils } from '../component/trace/base/ColorUtils'; import { BaseStruct } from './BaseStruct'; -import { CpuStruct } from '../database/ui-worker/ProcedureWorkerCPU'; +import { CpuStruct } from '../database/ui-worker/cpu/ProcedureWorkerCPU'; const padding = 1; diff --git a/ide/src/trace/bean/SchedSwitchStruct.ts b/ide/src/trace/bean/SchedSwitchStruct.ts index 80832a903460887a1c55a175e036d12ad77c3273..4da9824e8465e928256dbfed942a891d7ceeaaeb 100644 --- a/ide/src/trace/bean/SchedSwitchStruct.ts +++ b/ide/src/trace/bean/SchedSwitchStruct.ts @@ -13,9 +13,58 @@ * limitations under the License. */ +export class ThreadInitConfig { + endTs: number = 0; + pid: number = -1; + state: string = ''; + tid: number = -1; + ts: number = -1; + dur: number = -1; + duration: number = -1; + cycleStartTime: number = -1; + cycleEndTime: number = -1; +} +export class SchedSwitchCountBean { + nodeFlag: string | undefined; + startNS: number; + cycleStartTime: string = ''; + dur: number | string; + duration: number | string; + cycle: number = -1; + title: string = ''; + value: number = 0; + level: string = ''; + colorIndex: number = -1; + children: Array = []; + constructor( + nodeFlag: string | undefined, + startNS: number, + cycleStartTime: string, + dur: number | string, + duration: number | string, + cycle: number, + title: string, + value: number, + level: string, + colorIndex: number, + children: Array + ) { + this.nodeFlag = nodeFlag; + this.startNS = startNS; + this.cycleStartTime = cycleStartTime; + this.dur = dur; + this.duration = duration; + this.cycle = cycle; + this.title = title; + this.value = value; + this.level = level; + this.colorIndex = colorIndex; + this.children = children + } +} export class TreeSwitchConfig { - count: number = 0; - cycleNum: number = 1; + value: number = 0; + dur!: number | string | undefined; duration!: number | string | undefined; isHover?: boolean = false; isSelected?: boolean = false; @@ -23,47 +72,30 @@ export class TreeSwitchConfig { level: string = ''; pid: number = -1; process: string | undefined; - state?: string = ''; status?: boolean = false; thread: string | undefined; tid: number = -1; title: string = ''; - ts?: string = ''; cycleStartTime!: number | string | undefined; children: Array = []; } - export class HistogramSourceConfig { average: number = 0; color: string = ''; - count: number = 0; + value: number = 0; cycleNum: number = 0; isHover: boolean = false; size: string = ''; } - -export class ThreadInitConfig { - dur: number = 0; - endTs: number = 0; - id: number = 0; +export class CutDataObjConfig { + cyclesArr: Array = []; pid: number = -1; - state: string = ''; tid: number = -1; - ts: number = -1; - type: string = ''; + process: string | undefined; + thread: string | undefined; + processTitle: string = ''; + threadTitle: string = ''; + threadCountTotal: number = 0; + threadDurTotal!: number | string } -export class SchedThreadCutConfig { - cycleEndTime: number = 0; - cycleStartTime: number = 0; - funId: number = 0; - name: string = ''; - pid: number = -1; - runningCnt: number = 0; - state: string = ''; - tid: number = -1; - process?: string = ''; - thread?: string = ''; - dur?: number = 0; - leftNS?: number = 0; -} diff --git a/ide/src/trace/bean/SearchFuncBean.ts b/ide/src/trace/bean/SearchFuncBean.ts index 40bfb5baa53801a350efbc909a3b773a0031dc1f..f01d594d584c43dec47e264cd9903f41bab8761f 100644 --- a/ide/src/trace/bean/SearchFuncBean.ts +++ b/ide/src/trace/bean/SearchFuncBean.ts @@ -19,6 +19,7 @@ export class SearchFuncBean { funName: string | undefined; //"binder transaction" id: number | undefined; // 92749 startTime: number | undefined; // 9729867000 + endTime: number | undefined; tid: number | undefined; // pid: number | undefined; // 2785 type: string | undefined; diff --git a/ide/src/trace/bean/StateModle.ts b/ide/src/trace/bean/StateModle.ts new file mode 100644 index 0000000000000000000000000000000000000000..efd5e584be993a0db6928f7d367de7b15be1534c --- /dev/null +++ b/ide/src/trace/bean/StateModle.ts @@ -0,0 +1,35 @@ +export class StateGroup { + SleepingCount: number = 0; + RunningCount: number = 0; + RunnableCount: number = 0; + DCount: number = 0; + RunningDur: number = 0; + RunnableDur: number = 0; + SleepingDur: number = 0; + DDur: number = 0; + title?: string = ''; + pid: number = 0; + tid: number = 0; + ts: number = 0; + dur?: number = 0; + type: string = ''; + state?: string = ''; + children?: Array; + isSelected?: boolean = false; + totalCount?: number = 0; + cycleDur?: number; + cycle:number = 0; + id?:number; + cpu?:number = 0; +} + +export class FuncNameCycle { + funcName: string = ''; + cycleStartTime: number = 0; + cycleDur: number = 0; + startTime: number = 0; + endTime: number = 0; + id: number = 0; + tid: number = 0; + pid: number = 0; + } \ No newline at end of file diff --git a/ide/src/trace/component/SpFlags.ts b/ide/src/trace/component/SpFlags.ts index dd2332e39c3b64b907a8092d5bba6ab91300a374..6a37385ae73f3f89443bb060eb96273e1877da2f 100644 --- a/ide/src/trace/component/SpFlags.ts +++ b/ide/src/trace/component/SpFlags.ts @@ -258,6 +258,11 @@ export class FlagsConfig { switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], describeContent: 'Ffrt Convert templates', }, + { + title: 'HMKernel', + switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], + describeContent: '', + }, ]; static getAllFlagConfig(): Array { diff --git a/ide/src/trace/component/SpHelp.ts b/ide/src/trace/component/SpHelp.ts index 827319f3da0b555015d8b833023cd40e2e4eed94..a54d88af39d19505885ca1e5a34669cd306ed209 100644 --- a/ide/src/trace/component/SpHelp.ts +++ b/ide/src/trace/component/SpHelp.ts @@ -447,8 +447,6 @@ export class SpHelp extends BaseElement { .body{ width: 90%; margin-left: 3%; - margin-top: 2%; - margin-bottom: 2%; display: grid; grid-template-columns: min-content 1fr; background-color: var(--dark-background3,#FFFFFF); diff --git a/ide/src/trace/component/SpKeyboard.html.ts b/ide/src/trace/component/SpKeyboard.html.ts index 2f004d95408198e55f0247db162a39395a6a03d3..d2448b75fab69974c27f16f83f28e3949dcd9ac3 100644 --- a/ide/src/trace/component/SpKeyboard.html.ts +++ b/ide/src/trace/component/SpKeyboard.html.ts @@ -34,7 +34,7 @@ export const SpKeyboardHtml = ` .body{ width: 50%; background-color: #fff; - padding: 30px; + padding: 0 30px 30px; z-index: 9000; max-height: 600px; overflow-y: scroll; @@ -44,10 +44,11 @@ export const SpKeyboardHtml = ` position:absolute; } header { - position: relative; - width: 100%; - height: 31px; - line-height: 31px; + position: fixed; + width: 50%; + height: 50px; + line-height: 50px; + background-color: #fff; } .close-icon{ cursor: pointer; @@ -93,7 +94,7 @@ table{
        -

        SmartPerf help

        +

        SmartPerf Help

        diff --git a/ide/src/trace/component/SpKeyboard.ts b/ide/src/trace/component/SpKeyboard.ts index 154678278b8492af44b8959fef13823c3c23fd66..8f3990dbe1ecf3b2e67e4d60a75d08f09af240df 100644 --- a/ide/src/trace/component/SpKeyboard.ts +++ b/ide/src/trace/component/SpKeyboard.ts @@ -25,17 +25,12 @@ export class SpKeyboard extends BaseElement { let keyboardDiv = document .querySelector('body > sp-application')! .shadowRoot!.querySelector('#sp-keyboard')!; - let welcomeDiv = document - .querySelector('body > sp-application')! - .shadowRoot!.querySelector('#sp-welcome')!; let shadow_box = this.shadowRoot?.querySelector('.shadow-box')!; closeWindow!.addEventListener('click', () => { keyboardDiv.style.visibility = 'hidden'; - welcomeDiv.style.visibility = 'visible'; }); shadow_box!.addEventListener('click', () => { keyboardDiv.style.visibility = 'hidden'; - welcomeDiv.style.visibility = 'visible'; }); } diff --git a/ide/src/trace/component/SpRecordConfigModel.ts b/ide/src/trace/component/SpRecordConfigModel.ts index 7101db4151e667c25c03241d7201c426d100a2a8..f9b6dad8cc2245b7a64c6deb28a434eabdc5ee79 100644 --- a/ide/src/trace/component/SpRecordConfigModel.ts +++ b/ide/src/trace/component/SpRecordConfigModel.ts @@ -634,6 +634,9 @@ function initHiPerfConfig( if (perfConfig.isOffCpu) { recordArgs = `${recordArgs} --offcpu`; } + if (perfConfig?.isKernelChain) { + recordArgs = `${recordArgs} --kernel-chain`; + } if (perfConfig.noInherit) { recordArgs = `${recordArgs} --no-inherit`; } diff --git a/ide/src/trace/component/SpRecordTrace.ts b/ide/src/trace/component/SpRecordTrace.ts index 4dc2c5ad04daa58bbfb40f90bdbb1cd2fadbd661..d2f5481a48858148201a6990729d48e66cdf8393 100644 --- a/ide/src/trace/component/SpRecordTrace.ts +++ b/ide/src/trace/component/SpRecordTrace.ts @@ -66,6 +66,8 @@ import { } from './SpRecordConfigModel'; import { SpRecordTraceHtml } from './SpRecordTrace.html'; +const DEVICE_NOT_CONNECT = '设备未连接,请使用系统管理员权限打开cmd窗口,并执行hdc kill,然后重新添加设备。若还没有效果,请重新插拔一下手机。' + @element('sp-record-trace') export class SpRecordTrace extends BaseElement { public static serialNumber: string = ''; @@ -157,40 +159,63 @@ export class SpRecordTrace extends BaseElement { return clearFlag; } - private refreshDeviceList(): void { + private async refreshDeviceList(): Promise { if (this.vs) { this.refreshDeviceListByVs(); } else { this.deviceSelect!.innerHTML = ''; // @ts-ignore - HdcDeviceManager.getDevices().then((devs: USBDevice[]) => { + HdcDeviceManager.getDevices().then(async (devs: USBDevice[]) => { if (devs.length === 0) { this.recordButton!.hidden = true; this.disconnectButton!.hidden = true; this.devicePrompt!.innerText = 'Device not connected'; + this.hintEl!.textContent = DEVICE_NOT_CONNECT; + if (!this.showHint) { + this.showHint = true; + } } + let optionNum = 0; for (let len = 0; len < devs.length; len++) { let dev = devs[len]; let option = document.createElement('option'); option.className = 'select'; if (typeof dev.serialNumber === 'string') { - option.value = dev.serialNumber; + let res = await HdcDeviceManager.connect(dev.serialNumber); + if (res) { + optionNum++; + option.value = dev.serialNumber; + option.textContent = dev!.serialNumber ? dev!.serialNumber!.toString() : 'hdc Device'; + this.deviceSelect!.appendChild(option); + } + if (len === 0 && res) { + option.selected = true; + this.recordButton!.hidden = false; + this.disconnectButton!.hidden = false; + this.showHint = false; + this.devicePrompt!.innerText = ''; + this.hintEl!.textContent = ''; + SpRecordTrace.serialNumber = option.value; + this.refreshDeviceVersion(option); + } } - option.textContent = dev!.serialNumber ? dev!.serialNumber!.toString() : 'hdc Device'; - this.deviceSelect!.appendChild(option); - if (len === 0) { - option.selected = true; - this.recordButton!.hidden = false; - this.disconnectButton!.hidden = false; - this.devicePrompt!.innerText = ''; - SpRecordTrace.serialNumber = option.value; - this.refreshDeviceVersion(option); + }; + if(!optionNum){ + this.deviceSelect!.style!.border = '2px solid red'; + setTimeout(() => { + this.deviceSelect!.style!.border = '1px solid #4D4D4D'; + },3000); + this.recordButton!.hidden = true; + this.disconnectButton!.hidden = true; + this.devicePrompt!.innerText = 'Device not connected'; + this.hintEl!.textContent = DEVICE_NOT_CONNECT; + if (!this.showHint) { + this.showHint = true; } } }); } } - private refreshDeviceVersion(option: HTMLOptionElement): void { HdcDeviceManager.connect(option.value).then((result) => { if (result) { @@ -220,7 +245,6 @@ export class SpRecordTrace extends BaseElement { } }); } - private refreshDeviceListByVs(): void { Cmd.execHdcCmd(CmdConstant.CMD_HDC_DEVICES, (res: string) => { let devs: string[] = res.trim().replace(/\r\n/g, '\r').replace(/\n/g, '\r').split(/\r/); @@ -333,6 +357,7 @@ export class SpRecordTrace extends BaseElement { if (parentElement) { parentElement.style.overflow = 'hidden'; } + this.sp = document.querySelector('sp-application') as SpApplication; if (!this.shadowRoot || !this.sp){ return; } @@ -345,7 +370,6 @@ export class SpRecordTrace extends BaseElement { this.recordButton = this.shadowRoot.querySelector('.record') as LitButton; this.recordButtonText = this.shadowRoot.querySelector('.record_text') as HTMLSpanElement; this.cancelButton = this.shadowRoot.querySelector('.cancel') as LitButton; - this.sp = document.querySelector('sp-application') as SpApplication; this.progressEL = this.sp.shadowRoot?.querySelector('.progress') as LitProgressBar; this.litSearch = this.sp.shadowRoot?.querySelector('#lit-record-search') as LitSearch; this.menuGroup = this.shadowRoot.querySelector('#menu-group') as LitMainMenuGroup; @@ -360,11 +384,11 @@ export class SpRecordTrace extends BaseElement { if (this.deviceSelect.options && this.deviceSelect.options.length > 0) { this.disconnectButton!.hidden = false; this.recordButton.hidden = false; - this.devicePrompt.innerText = ''; + this.devicePrompt.innerText = ''; } else { this.disconnectButton!.hidden = true; this.recordButton.hidden = true; - this.devicePrompt.innerText = 'Device not connected'; + this.devicePrompt.innerText = 'Device not connected'; } } diff --git a/ide/src/trace/component/SpSystemTrace.event.ts b/ide/src/trace/component/SpSystemTrace.event.ts index b86eaa4ec08d693d80b6fdf6502490a26fdf768f..3e9b15b8fcb15fb5d9112f73be633633411ad328 100644 --- a/ide/src/trace/component/SpSystemTrace.event.ts +++ b/ide/src/trace/component/SpSystemTrace.event.ts @@ -13,32 +13,33 @@ * limitations under the License. */ -import {SpSystemTrace} from "./SpSystemTrace"; -import {ThreadStruct, ThreadStructOnClick} from "../database/ui-worker/ProcedureWorkerThread"; -import {TraceRow} from "./trace/base/TraceRow"; -import {JankStruct, JankStructOnClick} from "../database/ui-worker/ProcedureWorkerJank"; -import {HeapSnapshotStruct, HeapSnapshotStructOnClick} from "../database/ui-worker/ProcedureWorkerHeapSnapshot"; -import {FuncStructOnClick} from "../database/ui-worker/ProcedureWorkerFunc"; -import {CpuFreqStructOnClick} from "../database/ui-worker/ProcedureWorkerFreq"; -import {ClockStructOnClick} from "../database/ui-worker/ProcedureWorkerClock"; -import {SnapshotStructOnClick} from "../database/ui-worker/ProcedureWorkerSnapshot"; -import {IrqStructOnClick} from "../database/ui-worker/ProcedureWorkerIrq"; -import {HeapStructOnClick} from "../database/ui-worker/ProcedureWorkerHeap"; -import {JsCpuProfilerStructOnClick} from "../database/ui-worker/ProcedureWorkerCpuProfiler"; -import {AppStartupStructOnClick} from "../database/ui-worker/ProcedureWorkerAppStartup"; -import {SoStructOnClick} from "../database/ui-worker/ProcedureWorkerSoInit"; -import {FrameAnimationStructOnClick} from "../database/ui-worker/ProcedureWorkerFrameAnimation"; -import {FrameDynamicStructOnClick} from "../database/ui-worker/ProcedureWorkerFrameDynamic"; -import {FrameSpacingStructOnClick} from "../database/ui-worker/ProcedureWorkerFrameSpacing"; -import {SportRuler} from "./trace/timer-shaft/SportRuler"; -import {SpStatisticsHttpUtil} from "../../statistics/util/SpStatisticsHttpUtil"; -import {LitSearch} from "./trace/search/Search"; -import {TabPaneCurrent} from "./trace/sheet/TabPaneCurrent"; -import type {SpKeyboard} from "./SpKeyboard"; -import {enableVSync} from "./chart/VSync"; -import {CpuStruct, CpuStructOnClick} from "../database/ui-worker/cpu/ProcedureWorkerCPU"; -import {CpuStateStructOnClick} from "../database/ui-worker/cpu/ProcedureWorkerCpuState"; -import {CpuFreqLimitsStructOnClick} from "../database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits"; +import { SpSystemTrace } from "./SpSystemTrace"; +import { ThreadStruct, ThreadStructOnClick } from "../database/ui-worker/ProcedureWorkerThread"; +import { TraceRow } from "./trace/base/TraceRow"; +import { JankStruct, JankStructOnClick } from "../database/ui-worker/ProcedureWorkerJank"; +import { HeapSnapshotStruct, HeapSnapshotStructOnClick } from "../database/ui-worker/ProcedureWorkerHeapSnapshot"; +import { FuncStructOnClick } from "../database/ui-worker/ProcedureWorkerFunc"; +import { CpuFreqStructOnClick } from "../database/ui-worker/ProcedureWorkerFreq"; +import { ClockStructOnClick } from "../database/ui-worker/ProcedureWorkerClock"; +import { SnapshotStructOnClick } from "../database/ui-worker/ProcedureWorkerSnapshot"; +import { IrqStructOnClick } from "../database/ui-worker/ProcedureWorkerIrq"; +import { HeapStructOnClick } from "../database/ui-worker/ProcedureWorkerHeap"; +import { JsCpuProfilerStructOnClick } from "../database/ui-worker/ProcedureWorkerCpuProfiler"; +import { AppStartupStructOnClick } from "../database/ui-worker/ProcedureWorkerAppStartup"; +import { SoStructOnClick } from "../database/ui-worker/ProcedureWorkerSoInit"; +import { FrameAnimationStructOnClick } from "../database/ui-worker/ProcedureWorkerFrameAnimation"; +import { FrameDynamicStructOnClick } from "../database/ui-worker/ProcedureWorkerFrameDynamic"; +import { FrameSpacingStructOnClick } from "../database/ui-worker/ProcedureWorkerFrameSpacing"; +import { sampleStructOnClick } from "../database/ui-worker/ProcedureWorkerSample"; +import { SportRuler } from "./trace/timer-shaft/SportRuler"; +import { SpStatisticsHttpUtil } from "../../statistics/util/SpStatisticsHttpUtil"; +import { LitSearch } from "./trace/search/Search"; +import { TabPaneCurrent } from "./trace/sheet/TabPaneCurrent"; +import type { SpKeyboard } from "./SpKeyboard"; +import { enableVSync } from "./chart/VSync"; +import { CpuStruct, CpuStructOnClick } from "../database/ui-worker/cpu/ProcedureWorkerCPU"; +import { CpuStateStructOnClick } from "../database/ui-worker/cpu/ProcedureWorkerCpuState"; +import { CpuFreqLimitsStructOnClick } from "../database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits"; function timeoutJudge(sp: SpSystemTrace) { let timeoutJudge = setTimeout(() => { @@ -172,15 +173,15 @@ function jankClickHandlerFunc(sp: SpSystemTrace) { JankStruct.selectJankStruct = findJankEntry; sp.timerShaftEL?.drawTriangle(findJankEntry!.ts || 0, 'inverted'); sp.traceSheetEL?.displayJankData(JankStruct.selectJankStruct!, (datas) => { - sp.removeLinkLinesByBusinessType('janks'); - // 绘制跟自己关联的线 - datas.forEach((data) => { - let endParentRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='${data.pid}'][folder]` - ); - sp.drawJankLine(endParentRow, JankStruct.selectJankStruct!, data); - }); - }, + sp.removeLinkLinesByBusinessType('janks'); + // 绘制跟自己关联的线 + datas.forEach((data) => { + let endParentRow = sp.shadowRoot?.querySelector>( + `trace-row[row-id='${data.pid}'][folder]` + ); + sp.drawJankLine(endParentRow, JankStruct.selectJankStruct!, data); + }); + }, jankClickHandler ); } @@ -229,6 +230,7 @@ function cpuClickHandlerTask(threadRow: TraceRow, sp: SpSystemTrace, d: Cpu findEntry!.startTime! + findEntry!.dur! + findEntry!.dur! * 2 ); } + ThreadStruct.firstselectThreadStruct = ThreadStruct.selectThreadStruct; sp.hoverStructNull().selectStructNull().wakeupListNull(); ThreadStruct.hoverThreadStruct = findEntry; ThreadStruct.selectThreadStruct = findEntry; @@ -237,7 +239,18 @@ function cpuClickHandlerTask(threadRow: TraceRow, sp: SpSystemTrace, d: Cpu ThreadStruct.selectThreadStruct!, threadClickHandlerFunc(sp), cpuClickHandlerFunc(sp), - (datas) => sp.removeLinkLinesByBusinessType('thread') + (datas, str) => { + sp.removeLinkLinesByBusinessType('thread'); + if (str == 'wakeup tid') { + datas.forEach((data) => { + let endParentRow = sp.shadowRoot?.querySelector>( + `trace-row[row-id='${data.pid}'][folder]` + ); + sp.drawThreadLine(endParentRow, ThreadStruct.firstselectThreadStruct, data); + }); + } + sp.refreshCanvas(true); + } ); sp.scrollToProcess(`${d.tid}`, `${d.processId}`, 'thread', true); } @@ -281,7 +294,7 @@ function cpuClickHandlerFunc(sp: SpSystemTrace) { }; } -function AllStructOnClick(clickRowType:string,sp:SpSystemTrace,row?:TraceRow) { +function allStructOnClick(clickRowType: string, sp: SpSystemTrace, row?: TraceRow) { CpuStructOnClick(clickRowType, sp, cpuClickHandlerFunc(sp)) .then(() => ThreadStructOnClick(clickRowType, sp, threadClickHandlerFunc(sp), cpuClickHandlerFunc(sp))) .then(() => FuncStructOnClick(clickRowType, sp, row, scrollToFuncHandlerFunc(sp))) @@ -289,17 +302,18 @@ function AllStructOnClick(clickRowType:string,sp:SpSystemTrace,row?:TraceRow CpuStateStructOnClick(clickRowType, sp)) .then(() => CpuFreqLimitsStructOnClick(clickRowType, sp)) .then(() => ClockStructOnClick(clickRowType, sp)) - .then(() => SnapshotStructOnClick(clickRowType, sp)) + .then(() => SnapshotStructOnClick(clickRowType, sp, row!)) .then(() => IrqStructOnClick(clickRowType, sp)) .then(() => HeapStructOnClick(clickRowType, sp, row)) - .then(() => JankStructOnClick(clickRowType, sp, jankClickHandlerFunc(sp))) - .then(() => HeapSnapshotStructOnClick(clickRowType, sp, snapshotClickHandlerFunc(sp))) - .then(() => JsCpuProfilerStructOnClick(clickRowType, sp)) + .then(() => JankStructOnClick(clickRowType, sp, row!, jankClickHandlerFunc(sp))) + .then(() => HeapSnapshotStructOnClick(clickRowType, sp, row!, snapshotClickHandlerFunc(sp))) + .then(() => JsCpuProfilerStructOnClick(clickRowType, sp, row!)) .then(() => AppStartupStructOnClick(clickRowType, sp, scrollToFuncHandlerFunc(sp))) .then(() => SoStructOnClick(clickRowType, sp, scrollToFuncHandlerFunc(sp))) - .then(() => FrameAnimationStructOnClick(clickRowType, sp)) + .then(() => FrameAnimationStructOnClick(clickRowType, sp, row!)) .then(() => FrameDynamicStructOnClick(clickRowType, sp, row)) - .then(() => FrameSpacingStructOnClick(clickRowType, sp)) + .then(() => FrameSpacingStructOnClick(clickRowType, sp, row!)) + .then(() => sampleStructOnClick(clickRowType, sp)) .then(() => { if (!JankStruct.hoverJankStruct && JankStruct.delJankLineFlag) { sp.removeLinkLinesByBusinessType('janks'); @@ -308,10 +322,10 @@ function AllStructOnClick(clickRowType:string,sp:SpSystemTrace,row?:TraceRow {}); + }).catch(e => { }); } export default function spSystemTraceOnClickHandler(sp: SpSystemTrace, clickRowType: string, row?: TraceRow) { if (row) { @@ -325,7 +339,7 @@ export default function spSystemTraceOnClickHandler(sp: SpSystemTrace, clickRowT sp.selectStructNull(); // 判断点击的线程是否在唤醒树内 timeoutJudge(sp); - AllStructOnClick(clickRowType,sp,row); + allStructOnClick(clickRowType, sp, row); if (!JankStruct.selectJankStruct) { sp.removeLinkLinesByBusinessType('janks'); } @@ -410,7 +424,7 @@ function SpSystemTraceDocumentOnMouseMoveMouseDown(sp: SpSystemTrace, search: Li } function SpSystemTraceDocumentOnMouseMoveMouseUp(sp: SpSystemTrace, rows: Array>, ev: MouseEvent) { - if (!sp.rowsPaneEL!.containPoint(ev, {left: 248})) { + if (!sp.rowsPaneEL!.containPoint(ev, { left: 248 })) { sp.hoverStructNull(); } rows @@ -426,7 +440,6 @@ function SpSystemTraceDocumentOnMouseMoveMouseUp(sp: SpSystemTrace, rows: Array< } }) .forEach((tr) => { - sp.hoverStructNull(); if (sp.currentRowType != tr.rowType) { sp.currentRowType = tr.rowType || ''; } @@ -482,6 +495,9 @@ export function SpSystemTraceDocumentOnKeyPress(sp: SpSystemTrace, ev: KeyboardE let keyPressWASD = keyPress === 'w' || keyPress === 'a' || keyPress === 's' || keyPress === 'd'; if (keyPressWASD) { sp.keyPressMap.set(keyPress, true); + if (sp.rangeSelect.isMouseDown && sp.rangeSelect.drag) { + sp.rangeSelect.mouseUp(); + } sp.hoverFlag = null; } sp.timerShaftEL!.documentOnKeyPress(ev, sp.currentSlicesTime); @@ -521,13 +537,7 @@ export function spSystemTraceDocumentOnMouseDown(sp: SpSystemTrace, ev: MouseEve let x = ev.offsetX - sp.timerShaftEL!.canvas!.offsetLeft; let y = ev.offsetY; sp.timerShaftEL?.documentOnMouseDown(ev); - if ( - !( - sp.timerShaftEL!.sportRuler!.frame.contains(x, y) && - x > (TraceRow.rangeSelectObject?.startX || 0) && - x < (TraceRow.rangeSelectObject?.endX || 0) - ) - ) { + if (y > sp.timerShaftEL!.offsetHeight) { sp.rangeSelect.mouseDown(ev); sp.rangeSelect.drag = true; } @@ -667,7 +677,7 @@ function handleClickActions(sp: SpSystemTrace, x: number, y: number, ev: MouseEv if (JankStruct.delJankLineFlag) { sp.removeLinkLinesByBusinessType('janks'); } - if (rows && rows[0] && sp.traceRowClickJudgmentConditions.get(rows[0]!.rowType!)?.()) { + if (rows && rows[0] && rows[0].getHoverStruct()) { sp.onClickHandler(rows[0]!.rowType!, rows[0]); sp.documentOnMouseMove(ev); } else { diff --git a/ide/src/trace/component/SpSystemTrace.init.ts b/ide/src/trace/component/SpSystemTrace.init.ts index 3311ced0b4b36dbe025c6e5d352d99ddac9256b6..6dd4682679f83edae7def5f9eab9bc3b7e2d64ed 100644 --- a/ide/src/trace/component/SpSystemTrace.init.ts +++ b/ide/src/trace/component/SpSystemTrace.init.ts @@ -34,7 +34,6 @@ import { TraceSheet } from './trace/base/TraceSheet'; import { TimerShaftElement } from './trace/TimerShaftElement'; import { SpChartList } from './trace/SpChartList'; type HTMLElementAlias = HTMLElement | null | undefined; - function rightButtonOnClick(sp: SpSystemTrace,rightStar: HTMLElementAlias) { Object.assign(sp, { ext(): string { @@ -192,7 +191,7 @@ function flagChangeHandler(sp: SpSystemTrace) { showTab = showTab.filter((it) => it !== 'box-flag'); sp.traceSheetEL?.displayTab(...showTab); } else { - sp.traceSheetEL?.setAttribute('mode', 'hidden'); + sp.traceSheetEL?.setMode('hidden'); } } sp.refreshCanvas(true); @@ -210,7 +209,7 @@ function slicesChangeHandler(sp:SpSystemTrace) { showTab = showTab.filter((it) => it !== 'tabpane-current'); sp.traceSheetEL?.displayTab(...showTab); } else { - sp.traceSheetEL?.setAttribute('mode', 'hidden'); + sp.traceSheetEL?.setMode('hidden'); } } sp.refreshCanvas(true); @@ -391,15 +390,21 @@ function selectHandler(sp: SpSystemTrace) { } sp.refreshCanvas(true); if (!SportRuler.isMouseInSportRuler) { - sp.traceSheetEL?.setAttribute('mode', 'hidden'); + sp.traceSheetEL?.setMode('hidden'); } return; } - selectHandlerRefreshCheckBox(sp,rows, refreshCheckBox); + let checkRows = rows; + if (!refreshCheckBox) { + checkRows = [ + ...sp.shadowRoot!.querySelectorAll>("trace-row[check-type='2']"), + ...sp.favoriteChartListEL!.getAllSelectCollectRows()] + } + selectHandlerRefreshCheckBox(sp, checkRows, refreshCheckBox); if (!sp.isSelectClick) { sp.rangeTraceRow = []; } - selectHandlerRows(sp, rows); + selectHandlerRows(sp, checkRows); }; } function selectHandlerRefreshCheckBox(sp: SpSystemTrace, rows: Array>, refreshCheckBox: boolean) { @@ -486,7 +491,9 @@ function resizeObserverHandler(sp:SpSystemTrace) { if (sp.traceSheetEL!.getAttribute('mode') == 'hidden') { sp.timerShaftEL?.removeTriangle('triangle'); } - sp.refreshFavoriteCanvas(); + if(sp.favoriteChartListEL?.style.display === 'flex'){ + sp.refreshFavoriteCanvas(); + } sp.refreshCanvas(true); }).observe(sp.rowsPaneEL!); } @@ -531,10 +538,12 @@ function intersectionObserverHandler(sp: SpSystemTrace) { sp.visibleRows .filter((vr) => vr.expansion) .forEach((vr) => { - vr.sticky = sp.visibleRows.some((vro) => vr.childrenList.filter((it) => !it.collect).indexOf(vro) >= 0); + vr.sticky = sp.visibleRows.some((vro) =>{ + vr.childrenList.filter((it) => !it.collect).indexOf(vro) >= 0; + }); }); sp.visibleRows - .filter((vr) => !vr.folder && vr.parentRowEl && vr.parentRowEl.expansion) + .filter((vr) => !vr.folder && vr.parentRowEl && vr.parentRowEl.expansion && !vr.collect) .forEach((vr) => (vr.parentRowEl!.sticky = true)); if (sp.handler) { clearTimeout(sp.handler); @@ -560,7 +569,7 @@ function windowKeyDownHandler(sp: SpSystemTrace) { sp.rangeSelect.rangeTraceRow = []; sp.selectStructNull(); sp.timerShaftEL?.setSlicesMark(); - sp.traceSheetEL?.setAttribute('mode', 'hidden'); + sp.traceSheetEL?.setMode('hidden'); sp.removeLinkLinesByBusinessType('janks', 'task'); } } @@ -661,7 +670,9 @@ export function spSystemTraceInitElement(sp:SpSystemTrace){ } function moveRangeToCenterAndHighlight(sp: SpSystemTrace, findEntry: any) { - sp.moveRangeToCenter(findEntry.startTime!, findEntry.dur!); + if (findEntry.startTime > TraceRow.range!.endNS || (findEntry.startTime + findEntry.dur) < TraceRow.range!.startNS) { + sp.moveRangeToLeft(findEntry.startTime!, findEntry.dur!); + } sp.queryAllTraceRow().forEach((item) => { item.highlight = false; }); @@ -709,15 +720,21 @@ export function spSystemTraceShowStruct(sp:SpSystemTrace,previous: boolean, curr return findIndex; } function spSystemTraceShowStructFindIndex(sp: SpSystemTrace, previous: boolean, currentIndex: number, structs: Array, retargetIndex: number | undefined) { + if (TraceRow.range!.startNS > SpSystemTrace.currentStartTime && !retargetIndex) { + SpSystemTrace.currentStartTime = TraceRow.range!.startNS; + } let findIndex = -1; if (previous) { if (retargetIndex) { findIndex = retargetIndex - 1; + SpSystemTrace.retargetIndex = findIndex; } else { for (let i = structs.length - 1; i >= 0; i--) { let it = structs[i]; if ( - i < currentIndex + i < currentIndex && + it.startTime! >= TraceRow.range!.startNS && + it.startTime! + it.dur! <= TraceRow.range!.endNS ) { findIndex = i; break; @@ -725,15 +742,23 @@ function spSystemTraceShowStructFindIndex(sp: SpSystemTrace, previous: boolean, } } } else { - if (currentIndex == -1) { - findIndex = 0; - } else { - findIndex = structs.findIndex((it, idx) => { - return ( - idx > currentIndex - ); - }); + if (SpSystemTrace.currentStartTime > TraceRow.range!.startNS) { + SpSystemTrace.currentStartTime = TraceRow.range!.startNS; + if (structs[currentIndex].startTime < TraceRow.range!.startNS || structs[currentIndex].startTime! + structs[currentIndex].dur! > TraceRow.range!.endNS) { + currentIndex = -1; + } } + if (SpSystemTrace.currentStartTime !== 0 && SpSystemTrace.currentStartTime < TraceRow.range!.startNS) { + SpSystemTrace.currentStartTime = 0; + SpSystemTrace.retargetIndex = 0; + } + findIndex = structs.findIndex((it, idx) => { + return ( + idx > currentIndex && + it.startTime! >= TraceRow.range!.startNS && + it.startTime! + it.dur! <= TraceRow.range!.endNS + ); + }); } return findIndex; } @@ -756,7 +781,6 @@ function findEntryTypeCpu(sp: SpSystemTrace, findEntry: any) { } function findEntryTypeFunc(sp: SpSystemTrace, findEntry: any) { sp.observerScrollHeightEnable = true; - sp.moveRangeToCenter(findEntry.startTime!, findEntry.dur!); sp.scrollToActFunc( { startTs: findEntry.startTime, @@ -874,6 +898,7 @@ export async function spSystemTraceInit(sp:SpSystemTrace,param: { buf?: ArrayBuf } if (sp.loadTraceCompleted) { sp.traceSheetEL?.displaySystemLogsData(); + sp.traceSheetEL?.displaySystemStatesData(); } sp.intersectionObserver?.observe(it); }); diff --git a/ide/src/trace/component/SpSystemTrace.line.ts b/ide/src/trace/component/SpSystemTrace.line.ts index 02b9f4e1c13ff7dc1183bff555b3aa716d562669..d369a628bfc367b7253d64c69b22c41ab64fd611 100644 --- a/ide/src/trace/component/SpSystemTrace.line.ts +++ b/ide/src/trace/component/SpSystemTrace.line.ts @@ -274,7 +274,11 @@ function taskPoolOtherRelationData( relationDataList: FuncStruct[], res: any ): void { + sp.clearPointPair(); selectRow!.fixedList = relationDataList; + if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) { + return; + } relationDataList.forEach((value) => { TabPaneTaskFrames.TaskArray.push(value); // allocation to execute @@ -283,7 +287,6 @@ function taskPoolOtherRelationData( const selectRowY = selectRow?.translateY!; const selectStartTs = FuncStruct.selectFuncStruct!.startTs!; const selectDur = FuncStruct.selectFuncStruct!.dur!; - if (value.id === res[0].allocation_task_row) { sp.addPointPair( sp.makePoint(value.startTs!, 0, selectRowY, selectRow, offSetY, 'task', LineType.bezierCurve, true), @@ -306,6 +309,10 @@ function taskPoolRelationDataAllocation( relationDataList: FuncStruct[], res: any ): void { + sp.clearPointPair(); + if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) { + return; + } let executeStruct = relationDataList.filter((item) => item.id === res[0].execute_task_row)[0]; relationDataList.forEach((value) => { const selectY = (FuncStruct.selectFuncStruct!.depth! + 0.5) * 20; @@ -344,6 +351,10 @@ function taskPoolRelationDataPerformTask( relationDataList: FuncStruct[], res: any ): void { + sp.clearPointPair(); + if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) { + return; + } let executeStruct = relationDataList.filter((item) => item.id === res[0].execute_task_row)[0]; relationDataList.forEach((value) => { const executeRowY = executeRow?.translateY!; @@ -378,7 +389,11 @@ function taskPoolRelationDataPerformTask( function taskAllocationOrPerformTask(sp: SpSystemTrace, row: TraceRow, executeID: string): void { TabPaneTaskFrames.IsShowConcurrency = false; + sp.clearPointPair(); queryBySelectAllocationOrReturn(executeID, FuncStruct.selectFuncStruct!.itid!).then((res) => { + if (!FuncStruct.selectFuncStruct) { + return; + } if (FuncStruct.selectFuncStruct!.funName!.indexOf('H:Task Allocation:') >= 0 && res.length > 0) { let executeRow = sp.shadowRoot?.querySelector>( `trace-row[row-id='${res[0].tid}'][row-type='func']` @@ -422,14 +437,17 @@ function taskAllocationOrPerformTask(sp: SpSystemTrace, row: TraceRow, exec } export function spSystemTraceDrawTaskPollLine(sp: SpSystemTrace, row?: TraceRow): void { - let executeID = TabPaneTaskFrames.getExecuteId(FuncStruct.selectFuncStruct!.funName!); + if (FuncStruct.selectFuncStruct === undefined || FuncStruct.selectFuncStruct === null) { + return; + } + let relationId = TabPaneTaskFrames.getRelationId(FuncStruct.selectFuncStruct!.funName!); TabPaneTaskFrames.TaskArray.push(FuncStruct.selectFuncStruct!); if (!row) { return; } if (FuncStruct.selectFuncStruct!.funName!.indexOf('H:Task Perform:') >= 0) { TabPaneTaskFrames.IsShowConcurrency = true; - queryBySelectExecute(executeID, FuncStruct.selectFuncStruct!.itid!).then((res) => { + queryBySelectExecute(relationId, FuncStruct.selectFuncStruct!.itid!).then((res) => { if (res.length === 1) { let allocationRowId = res[0].tid; let selectRow = sp.shadowRoot?.querySelector>( @@ -457,51 +475,40 @@ export function spSystemTraceDrawTaskPollLine(sp: SpSystemTrace, row?: TraceRow< } }); } else { - taskAllocationOrPerformTask(sp, row, executeID); + taskAllocationOrPerformTask(sp, row, relationId); } } -function jankPoint( - endRowStruct: any, - data: any, - sp: SpSystemTrace, - selectThreadStruct: ThreadStruct, - startRow: any, - endParentRow: any -): void { - if (endRowStruct) { - let findJankEntry = endRowStruct!.dataListCache!.find( - (dat: any) => dat.startTime == data.startTime && dat.dur! > 0 + +function jankPoint(endRowStruct: any, selectThreadStruct: ThreadStruct, startRow: any, endParentRow: any, sp: SpSystemTrace) { + let findJankEntry = endRowStruct!.fixedList[0]; + let ts: number = 0; + if (findJankEntry) { + ts = selectThreadStruct.startTime! + selectThreadStruct.dur! / 2; + const [startY, startRowEl, startOffSetY] = sp.calculateStartY(startRow, selectThreadStruct); + const [endY, endRowEl, endOffSetY] = sp.calculateEndY(endParentRow, endRowStruct); + sp.addPointPair( + sp.makePoint( + ns2xByTimeShaft(ts, sp.timerShaftEL!), + ts, + startY, + startRowEl!, + startOffSetY, + 'thread', + LineType.straightLine, + selectThreadStruct.startTime == ts + ), + sp.makePoint( + ns2xByTimeShaft(findJankEntry.startTime!, sp.timerShaftEL!), + findJankEntry.startTime!, + endY, + endRowEl, + endOffSetY, + 'thread', + LineType.straightLine, + true + ) ); - let ts: number = 0; - if (findJankEntry) { - ts = selectThreadStruct.startTime! + selectThreadStruct.dur! / 2; - const [startY, startRowEl, startOffSetY] = sp.calculateStartY(startRow, selectThreadStruct); - const [endY, endRowEl, endOffSetY] = sp.calculateEndY(endParentRow, endRowStruct); - sp.addPointPair( - sp.makePoint( - ns2xByTimeShaft(ts, sp.timerShaftEL!), - ts, - startY, - startRowEl!, - startOffSetY, - 'thread', - LineType.straightLine, - selectThreadStruct.startTime == ts - ), - sp.makePoint( - ns2xByTimeShaft(findJankEntry.startTime!, sp.timerShaftEL!), - findJankEntry.startTime!, - endY, - endRowEl, - endOffSetY, - 'thread', - LineType.straightLine, - true - ) - ); - sp.refreshCanvas(true); - } } } @@ -511,22 +518,29 @@ export function spSystemTraceDrawThreadLine( selectThreadStruct: ThreadStruct | undefined, data: any ): void { - const collectList = sp.favoriteChartListEL!.getCollectRows(); - if (!selectThreadStruct) { + let collectList = sp.favoriteChartListEL!.getCollectRows(); + if (selectThreadStruct == undefined || selectThreadStruct == null) { return; } - const selectRowId = selectThreadStruct?.tid; + let selectRowId = selectThreadStruct?.tid; let startRow = sp.getStartRow(selectRowId, collectList); - if (!endParentRow) { - return; - } - let endRowStruct: any = sp.shadowRoot?.querySelector>( - `trace-row[row-id='${data.tid}'][row-type='thread']` - ); - if (!endRowStruct) { - endRowStruct = endParentRow.childrenList.find((item: TraceRow) => { - return item.rowId === `${data.tid}` && item.rowType === 'thread'; - }); + + if (endParentRow) { + endParentRow.expansion = true; + let endRowStruct: any = sp.shadowRoot?.querySelector>( + `trace-row[row-id='${data.tid}'][row-type='thread']` + ); + if (!endRowStruct) { + endRowStruct = endParentRow.childrenList.find((item: TraceRow) => { + return item.rowId === `${data.tid}` && item.rowType === 'thread'; + }); + } + if (endRowStruct) { + if (endRowStruct.isComplete) { + jankPoint(endRowStruct, selectThreadStruct, startRow, endParentRow, sp); + } + } } - jankPoint(endParentRow, data, sp, selectThreadStruct, startRow, endParentRow); } + + diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts index 8114d670297f87f5c817dd4ee90708eb0a0fa9ff..5695ff6110c42730eb958d39b566d660d6b84575 100644 --- a/ide/src/trace/component/SpSystemTrace.ts +++ b/ide/src/trace/component/SpSystemTrace.ts @@ -120,6 +120,7 @@ import spSystemTraceOnClickHandler, { spSystemTraceDocumentOnMouseOut, spSystemTraceDocumentOnMouseUp, } from './SpSystemTrace.event'; +import { SampleStruct } from '../database/ui-worker/ProcedureWorkerSample'; function dpr(): number { return window.devicePixelRatio || 1; @@ -204,6 +205,8 @@ export class SpSystemTrace extends BaseElement { expandRowList: Array> = []; _slicesList: Array = []; _flagList: Array = []; + static currentStartTime: number = 0; + static retargetIndex: number = 0; set snapshotFile(data: FileInfo) { this.snapshotFiles = data; @@ -752,6 +755,11 @@ export class SpSystemTrace extends BaseElement { this.currentSlicesTime.startTime = JankStruct.selectJankStruct.ts; this.currentSlicesTime.endTime = JankStruct.selectJankStruct.ts + JankStruct.selectJankStruct.dur; } + } else if (SampleStruct.selectSampleStruct) { + if (SampleStruct.selectSampleStruct.begin && SampleStruct.selectSampleStruct.end) { + this.currentSlicesTime.startTime = SampleStruct.selectSampleStruct.begin - SampleStruct.selectSampleStruct.startTs!; + this.currentSlicesTime.endTime = SampleStruct.selectSampleStruct.end - SampleStruct.selectSampleStruct.startTs!; + } } else { this.currentSlicesTime.startTime = 0; this.currentSlicesTime.endTime = 0; @@ -770,6 +778,7 @@ export class SpSystemTrace extends BaseElement { SoStruct.selectSoStruct || AllAppStartupStruct.selectStartupStruct || FrameAnimationStruct.selectFrameAnimationStruct || + SampleStruct.selectSampleStruct || JsCpuProfilerStruct.selectJsCpuProfilerStruct; this.calculateSlicesTime(selectedStruct, shiftKey); @@ -778,9 +787,16 @@ export class SpSystemTrace extends BaseElement { private calculateSlicesTime(selectedStruct: any, shiftKey: boolean): void { if (selectedStruct) { - const startTs = selectedStruct.startTs || selectedStruct.startTime || selectedStruct.startNS || 0; - const dur = selectedStruct.dur || selectedStruct.totalTime || selectedStruct.endNS || 0; - this.slicestime = this.timerShaftEL?.setSlicesMark(startTs, startTs + dur, shiftKey); + let startTs = 0; + if (selectedStruct.begin && selectedStruct.end) { + startTs = selectedStruct.begin - selectedStruct.startTs; + let end = selectedStruct.end - selectedStruct.startTs; + this.slicestime = this.timerShaftEL?.setSlicesMark(startTs, end, shiftKey); + } else { + startTs = selectedStruct.startTs || selectedStruct.startTime || selectedStruct.startNS || 0; + let dur = selectedStruct.dur || selectedStruct.totalTime || (selectedStruct.endNS - selectedStruct.startNS) || 0; + this.slicestime = this.timerShaftEL?.setSlicesMark(startTs, startTs + dur, shiftKey); + } } else { this.slicestime = this.timerShaftEL?.setSlicesMark(); } @@ -1007,6 +1023,7 @@ export class SpSystemTrace extends BaseElement { JsCpuProfilerStruct.hoverJsCpuProfilerStruct = undefined; SnapshotStruct.hoverSnapshotStruct = undefined; HiPerfCallChartStruct.hoverPerfCallCutStruct = undefined; + SampleStruct.hoverSampleStruct = undefined; this.tipEL!.style.display = 'none'; return this; } @@ -1036,6 +1053,7 @@ export class SpSystemTrace extends BaseElement { AllAppStartupStruct.selectStartupStruct = undefined; LtpoStruct.selectLtpoStruct = undefined; HitchTimeStruct.selectHitchTimeStruct = undefined; + SampleStruct.selectSampleStruct = undefined; return this; } @@ -1061,7 +1079,7 @@ export class SpSystemTrace extends BaseElement { this.timerShaftEL?.removeTriangle('inverted'); // 如果鼠标在SportRuler区域不隐藏tab页 if (!SportRuler.isMouseInSportRuler) { - this.traceSheetEL?.setAttribute('mode', 'hidden'); + this.traceSheetEL?.setMode('hidden'); } this.removeLinkLinesByBusinessType('task', 'thread'); this.refreshCanvas(true); @@ -1079,6 +1097,10 @@ export class SpSystemTrace extends BaseElement { TraceRow.ROW_TYPE_FUNC, (): boolean => FuncStruct.hoverFuncStruct !== null && FuncStruct.hoverFuncStruct !== undefined, ], + [ + TraceRow.ROW_TYPE_SAMPLE, + (): boolean => SampleStruct.hoverSampleStruct !== null && SampleStruct.hoverSampleStruct !== undefined + ], [ TraceRow.ROW_TYPE_CPU_FREQ, (): boolean => CpuFreqStruct.hoverCpuFreqStruct !== null && CpuFreqStruct.hoverCpuFreqStruct !== undefined, @@ -1090,8 +1112,8 @@ export class SpSystemTrace extends BaseElement { [ TraceRow.ROW_TYPE_CPU_FREQ_LIMIT, (): boolean => - CpuFreqLimitsStruct.selectCpuFreqLimitsStruct !== null && - CpuFreqLimitsStruct.selectCpuFreqLimitsStruct !== undefined, + CpuFreqLimitsStruct.hoverCpuFreqLimitsStruct !== null && + CpuFreqLimitsStruct.hoverCpuFreqLimitsStruct !== undefined, ], [ TraceRow.ROW_TYPE_CLOCK, @@ -1322,7 +1344,7 @@ export class SpSystemTrace extends BaseElement { this.addEventListener('click', this.documentOnClick); this.addEventListener('mousedown', this.documentOnMouseDown); this.addEventListener('mouseup', this.documentOnMouseUp); - this.addEventListener('mouseout', this.documentOnMouseOut); + this.addEventListener('mouseout', this.documentOnMouseOut); document.addEventListener('keydown', this.documentOnKeyDown); document.addEventListener('keypress', this.documentOnKeyPress); @@ -1412,6 +1434,23 @@ export class SpSystemTrace extends BaseElement { }); }); window.subscribe(window.SmartEvent.UI.HoverNull, () => this.hoverStructNull()); + this.subscribeBottomTabVisibleEvent(); + } + + private scrollH: number = 0; + + subscribeBottomTabVisibleEvent(): void { + window.subscribe(window.SmartEvent.UI.ShowBottomTab, (data: { show: number, delta: number}) => { + if (data.show === 1) { + //显示底部tab + this.scrollH = this.rowsEL!.scrollHeight; + } else { + // 底部 tab 为 最小化 或者隐藏 时候 + if (this.rowsEL!.scrollHeight > this.scrollH) { + this.rowsEL!.scrollTop = this.rowsEL!.scrollTop - data.delta; + } + } + }); } favoriteAreaSearchHandler(row: TraceRow): void { @@ -1457,11 +1496,11 @@ export class SpSystemTrace extends BaseElement { if (rootRow && rootRow!.collect) { this.favoriteAreaSearchHandler(rootRow); rootRow.expandFunc(); - this.favoriteChartListEL!.scroll({ - top: (rootRow?.offsetTop || 0) - this.favoriteChartListEL!.getCanvas()!.offsetHeight + (++depth * 20 || 0), - left: 0, - behavior: smooth ? 'smooth' : undefined, - }); + if (!this.isInViewport(rootRow)) { + setTimeout(() => { + rootRow!.scrollIntoView({ behavior: "smooth"}) + }, 500); + } } else { let row = this.rowsEL!.querySelector>(`trace-row[row-id='${rowParentId}'][folder]`); if (row && !row.expansion) { @@ -1471,16 +1510,28 @@ export class SpSystemTrace extends BaseElement { rootRow.expandFunc(); } if (rootRow && rootRow.offsetTop >= 0 && rootRow.offsetHeight >= 0) { - let top = (rootRow?.offsetTop || 0) - this.canvasPanel!.offsetHeight + (++depth * 20 || 0); - this.rowsPaneEL!.scroll({ - top: top, - left: 0, - behavior: smooth ? 'smooth' : undefined, - }); + if (!this.isInViewport(rootRow)) { + let top = (rootRow?.offsetTop || 0) - this.canvasPanel!.offsetHeight + rootRow.offsetHeight / 2 + (++depth * 20); + this.rowsPaneEL!.scrollTo({ + top: top, + left: 0, + behavior: smooth ? 'smooth' : undefined, + }); + } } } } + isInViewport(e: any) { + const rect = e.getBoundingClientRect(); + return ( + rect.top >=0 && + rect.left >=0 && + rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.right <= (window.innerWidth || document.documentElement.clientWidth) + ) + } + scrollToFunction(rowId: string, rowParentId: string, rowType: string, smooth: boolean = true) { let condition = `trace-row[row-id='${rowId}'][row-type='${rowType}'][row-parent-id='${rowParentId}']`; let rootRow = @@ -1548,7 +1599,7 @@ export class SpSystemTrace extends BaseElement { this.rangeSelect.rangeTraceRow = []; this.selectStructNull(); this.wakeupListNull(); - this.traceSheetEL?.setAttribute('mode', 'hidden'); + this.traceSheetEL?.setMode('hidden'); this.removeLinkLinesByBusinessType('janks'); TraceRow.range!.refresh = true; this.refreshCanvas(false); @@ -1588,6 +1639,28 @@ export class SpSystemTrace extends BaseElement { }); } + loadSample = async (ev: File) => { + this.observerScrollHeightEnable = false; + await this.initSample(ev); + this.rowsEL?.querySelectorAll('trace-row').forEach((it: any) => this.observer.observe(it)); + window.publish(window.SmartEvent.UI.MouseEventEnable, { + mouseEnable: true, + }); + } + + initSample = async (ev: File) => { + this.rowsPaneEL!.scroll({ + top: 0, + left: 0, + }); + this.chartManager?.initSample(ev).then(() => { + this.loadTraceCompleted = true; + this.rowsEL!.querySelectorAll>('trace-row').forEach((it) => { + this.intersectionObserver?.observe(it); + }) + }) + } + queryAllTraceRow(selectors?: string, filter?: (row: TraceRow) => boolean): TraceRow[] { return [ ...this.rowsEL!.querySelectorAll>(selectors ?? 'trace-row'), @@ -1705,9 +1778,9 @@ export class SpSystemTrace extends BaseElement { this.hoverStructNull(); this.selectStructNull(); this.wakeupListNull(); + this.onClickHandler(TraceRow.ROW_TYPE_FUNC); FuncStruct.hoverFuncStruct = entry; FuncStruct.selectFuncStruct = entry; - this.onClickHandler(TraceRow.ROW_TYPE_FUNC); this.scrollToDepth(`${funcRowID}`, `${funcStract.pid}`, 'func', true, entry.depth || 0); } }; @@ -1772,6 +1845,21 @@ export class SpSystemTrace extends BaseElement { }); } + moveRangeToLeft(startTime: number, dur: number) { + let startNS = this.timerShaftEL?.getRange()?.startNS || 0; + let endNS = this.timerShaftEL?.getRange()?.endNS || 0; + let harfDur = Math.trunc((endNS - startNS) - dur / 2); + let leftNs = startTime; + let rightNs = startTime + dur + harfDur; + if (startTime - harfDur < 0) { + leftNs = 0; + rightNs += harfDur - startTime; + } + this.timerShaftEL?.setRangeNS(leftNs, rightNs); + TraceRow.range!.refresh = true; + this.refreshCanvas(true); + } + moveRangeToCenter(startTime: number, dur: number) { let startNS = this.timerShaftEL?.getRange()?.startNS || 0; let endNS = this.timerShaftEL?.getRange()?.endNS || 0; @@ -1841,7 +1929,7 @@ export class SpSystemTrace extends BaseElement { this.selectStructNull(); this.hoverStructNull(); this.wakeupListNull(); - this.traceSheetEL?.setAttribute('mode', 'hidden'); + this.traceSheetEL?.setMode('hidden'); progress?.('rest timershaft', 8); this.timerShaftEL?.reset(); progress?.('clear cache', 10); @@ -1907,12 +1995,16 @@ export class SpSystemTrace extends BaseElement { } if (this.tipEL) { this.tipEL.innerHTML = html; - if (row.rowType === TraceRow.ROW_TYPE_JS_CPU_PROFILER || row.rowType === TraceRow.ROW_TYPE_PERF_CALLCHART) { + if (row.rowType === TraceRow.ROW_TYPE_JS_CPU_PROFILER || row.rowType === TraceRow.ROW_TYPE_PERF_CALLCHART || row.rowType === TraceRow.ROW_TYPE_BINDER_COUNT) { this.tipEL.style.maxWidth = row.clientWidth / 3 + 'px'; this.tipEL.style.wordBreak = ' break-all'; this.tipEL.style.height = 'unset'; this.tipEL.style.display = 'block'; y = y + struct.depth * 20; + if (row.rowType === TraceRow.ROW_TYPE_BINDER_COUNT) { + this.tipEL.style.height = '40px'; + y = row.hoverY + row.getBoundingClientRect().top - this.getBoundingClientRect().top; + } } else { this.tipEL.style.display = 'flex'; this.tipEL.style.height = row.style.height; diff --git a/ide/src/trace/component/SpThirdParty.ts b/ide/src/trace/component/SpThirdParty.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac645e564bf7927632c24085db17eb6314a0cf42 --- /dev/null +++ b/ide/src/trace/component/SpThirdParty.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. + */ + +import { BaseElement, element } from '../../base-ui/BaseElement'; +import { LitMainMenu, MenuItem } from '../../base-ui/menu/LitMainMenu'; +import { SpApplication } from '../SpApplication'; +@element('sp-third-party') +export class SpThirdParty extends BaseElement { + private bodyEl: HTMLElement | undefined | null; + private uploadEl: HTMLElement | undefined | null; + private inputEl: HTMLInputElement | undefined | null; + private sp: SpApplication | undefined; + + initElements(): void { + let parentElement = this.parentNode as HTMLElement; + parentElement.style.overflow = 'hidden'; + this.bodyEl = this.shadowRoot?.querySelector('.body'); + this.uploadEl = this.shadowRoot?.querySelector('.upload-btn')?.shadowRoot?.querySelector('#custom-button'); + this.inputEl = this.shadowRoot?.querySelector('#file'); + this.uploadEl?.addEventListener('click', () => { + this.inputEl?.click(); + }) + this.inputEl!.addEventListener('change', () => { + let files = this.inputEl!.files; + if (files && files.length > 0) { + let main = this.parentNode!.parentNode!.querySelector('lit-main-menu') as LitMainMenu; + let children = main.menus!; + let child = children[0].children as Array; + let fileHandler = child[0].fileHandler!; + fileHandler({ + detail: files[0] + }) + } + if (this.inputEl) this.inputEl.value = ''; + }) + } + + initHtml(): string { + return ` + ${this.initHtmlStyle()} +
        +
        + + + Open bpftrace file + +
        +
        + `; + } + + private initHtmlStyle(): string { + return ` + + `; + } + +} + + diff --git a/ide/src/trace/component/Utils.ts b/ide/src/trace/component/Utils.ts index 60880a902adf16e3bee776bf3ff312ec07ab5f45..7fe99515374b8a7093c22bb76a6f2f5ea01d464c 100644 --- a/ide/src/trace/component/Utils.ts +++ b/ide/src/trace/component/Utils.ts @@ -95,3 +95,13 @@ export function parseKeyPathJson(content: string): Array { } return parseResult; } + +export function debounce(func: any, delay: number) { + let timer: any = null; + return function() { + clearTimeout(timer); + timer = setTimeout(() => { + func(); + }, delay) + } +} \ No newline at end of file diff --git a/ide/src/trace/component/chart/FrameChart.ts b/ide/src/trace/component/chart/FrameChart.ts index f9b652fd83fac991918c6cb7194e03e230985df7..b5b93e3fee376c42f6e45217b97dc30e82c4f95d 100644 --- a/ide/src/trace/component/chart/FrameChart.ts +++ b/ide/src/trace/component/chart/FrameChart.ts @@ -185,6 +185,21 @@ export class FrameChart extends BaseElement { this.setParentDisplayInfo(node, module, true); this.setChildrenDisplayInfo(node); + this.clearOtherDisplayInfo(this.rootNode); + } + } + + private clearOtherDisplayInfo(node: ChartStruct): void{ + for(const children of node.children){ + if (children.isChartSelect){ + this.clearOtherDisplayInfo(children); + continue; + } + children.drawCount = 0; + children.drawEventCount = 0; + children.drawSize = 0; + children.drawDur = 0; + this.clearOtherDisplayInfo(children); } } diff --git a/ide/src/trace/component/chart/SpAllAppStartups.ts b/ide/src/trace/component/chart/SpAllAppStartups.ts index faf9f5ea812ce5de20d898237c3fa97d1d9a982e..d29f356ca132c2c436a0ba5d8a351a5683c99487 100644 --- a/ide/src/trace/component/chart/SpAllAppStartups.ts +++ b/ide/src/trace/component/chart/SpAllAppStartups.ts @@ -61,6 +61,7 @@ export class SpAllAppStartupsChart { row.folder = false; row.style.height = '40px'; row.name = `All App Startups`; + row.addTemplateTypes('AppStartup'); row.selectChangeHandler = SpAllAppStartupsChart.trace.selectChangeHandler; row.favoriteChangeHandler = SpAllAppStartupsChart.trace.favoriteChangeHandler; row.supplier = async (): Promise> => { diff --git a/ide/src/trace/component/chart/SpChartManager.ts b/ide/src/trace/component/chart/SpChartManager.ts index ea86c2eff93663635a059c4610753c16fbf38503..0c5258e9fb6024c430389a7d705aa131a61e8d79 100644 --- a/ide/src/trace/component/chart/SpChartManager.ts +++ b/ide/src/trace/component/chart/SpChartManager.ts @@ -41,15 +41,18 @@ import { FlagsConfig } from '../SpFlags'; import { SpLogChart } from './SpLogChart'; import { SpHiSysEventChart } from './SpHiSysEventChart'; import { SpAllAppStartupsChart } from './SpAllAppStartups'; -import {procedurePool} from "../../database/Procedure"; +import { procedurePool } from '../../database/Procedure'; +import { SpSegmentationChart } from './SpSegmentationChart'; import { queryAppStartupProcessIds, queryDataDICT, queryThreadAndProcessName -} from "../../database/sql/ProcessThread.sql"; -import {queryTaskPoolCallStack, queryTotalTime} from "../../database/sql/SqlLite.sql"; -import {getCpuUtilizationRate} from "../../database/sql/Cpu.sql"; -import {queryMemoryConfig} from "../../database/sql/Memory.sql"; +} from '../../database/sql/ProcessThread.sql'; +import { queryTaskPoolCallStack, queryTotalTime } from '../../database/sql/SqlLite.sql'; +import { getCpuUtilizationRate } from '../../database/sql/Cpu.sql'; +import { queryMemoryConfig } from '../../database/sql/Memory.sql'; +import { SpLtpoChart } from './SpLTPO'; +import { SpSampleChart } from './SpSampleChart'; export class SpChartManager { static APP_STARTUP_PID_ARR: Array = []; @@ -70,10 +73,13 @@ export class SpChartManager { private clockChart: SpClockChart; private irqChart: SpIrqChart; private spAllAppStartupsChart!: SpAllAppStartupsChart; + private SpLtpoChart!: SpLtpoChart; frameTimeChart: SpFrameTimeChart; public arkTsChart: SpArkTsChart; private logChart: SpLogChart; private spHiSysEvent: SpHiSysEventChart; + private spSegmentationChart: SpSegmentationChart; + private spSampleChart: SpSampleChart; constructor(trace: SpSystemTrace) { this.trace = trace; @@ -96,6 +102,9 @@ export class SpChartManager { this.logChart = new SpLogChart(trace); this.spHiSysEvent = new SpHiSysEventChart(trace); this.spAllAppStartupsChart = new SpAllAppStartupsChart(trace); + this.SpLtpoChart = new SpLtpoChart(trace); + this.spSegmentationChart = new SpSegmentationChart(trace); + this.spSampleChart = new SpSampleChart(trace); } async init(progress: Function) { @@ -122,6 +131,7 @@ export class SpChartManager { progress('cpu', 70); await this.cpu.init(); info('initData cpu Data initialized'); + await this.spSampleChart.init(null); progress('process/thread state', 73); await this.cpu.initProcessThreadStateData(progress); if (FlagsConfig.getFlagsConfigEnableStatus('SchedulingAnalysis')) { @@ -146,6 +156,9 @@ export class SpChartManager { progress('Irq init', 84); await this.irqChart.init(); info('initData Irq Data initialized'); + progress('SpSegmentationChart inin', 84.5); + await this.spSegmentationChart.init(); + info('initData Segmentation initialized'); await this.virtualMemChart.init(); info('initData virtualMemChart initialized'); progress('fps', 85); @@ -176,9 +189,10 @@ export class SpChartManager { progress('ark ts', 90); await this.arkTsChart.initFolder(); info('initData ark ts initialized'); + await this.spAllAppStartupsChart.init(); + await this.SpLtpoChart.init(); await this.frameTimeChart.init(); info('initData frameTimeLine initialized'); - await this.spAllAppStartupsChart.init(); progress('process', 92); await this.process.initAsyncFuncData(); await this.process.initDeliverInputEvent(); @@ -187,6 +201,11 @@ export class SpChartManager { progress('display', 95); } + async initSample(ev: File) { + await this.initSampleTime(); + await this.spSampleChart.init(ev); + } + async importSoFileUpdate() { SpSystemTrace.DATA_DICT.clear(); let dict = await queryDataDICT(); @@ -230,6 +249,21 @@ export class SpChartManager { } }; + initSampleTime = async () => { + if (this.trace.timerShaftEL) { + let total = 30_000_000_000; + let startNS = 0; + let endNS = 30_000_000_000; + this.trace.timerShaftEL.totalNS = total; + this.trace.timerShaftEL.getRangeRuler()!.drawMark = true; + this.trace.timerShaftEL.setRangeNS(0, total); + (window as any).recordStartNS = startNS; + (window as any).recordEndNS = endNS; + (window as any).totalNS = total; + this.trace.timerShaftEL.loadComplete = true; + } + }; + initCpuRate = async () => { let rates = await getCpuUtilizationRate(0, this.trace.timerShaftEL?.totalNS || 0); if (this.trace.timerShaftEL) this.trace.timerShaftEL.cpuUsage = rates; @@ -246,11 +280,11 @@ export class SpChartManager { }; async cacheDataDictToWorker(): Promise { - return new Promise((resolve) => { + return new Promise((resolve) => { procedurePool.submitWithName( 'logic0', 'cache-data-dict', - { dataDict: SpSystemTrace.DATA_DICT }, + {dataDict: SpSystemTrace.DATA_DICT}, undefined, (res: any) => { resolve(); diff --git a/ide/src/trace/component/chart/SpFrameTimeChart.ts b/ide/src/trace/component/chart/SpFrameTimeChart.ts index 4d9375ce122112474911980e0a8de4f7efc442a9..680f8a958fe06109351cae725bd6938521f789bb 100644 --- a/ide/src/trace/component/chart/SpFrameTimeChart.ts +++ b/ide/src/trace/component/chart/SpFrameTimeChart.ts @@ -226,25 +226,29 @@ export class SpFrameTimeChart { async initAnimatedScenesChart( processRow: TraceRow, process: { pid: number | null; processName: string | null }, - firstRow: TraceRow + firstRow: TraceRow, + secondRow: TraceRow ): Promise { this.flagConfig = FlagsConfig.getFlagsConfig('AnimationAnalysis'); let appNameMap: Map = new Map(); if (this.flagConfig?.AnimationAnalysis === 'Enabled') { if (process.processName?.startsWith('render_service')) { - let targetRowList = processRow.childrenList.filter( - (childRow) => childRow.rowType === 'thread' && childRow.name.startsWith('render_service') - ); let nameArr: { name: string }[] = await queryFrameApp(); if (nameArr && nameArr.length > 0) { let currentName = nameArr[0].name; let frameChart = await this.initFrameChart(processRow, nameArr); - processRow.addChildTraceRowAfter(frameChart, targetRowList[0]); + if (secondRow !== null) { + processRow.addChildTraceRowAfter(frameChart, secondRow); + } else if (firstRow !== null) { + processRow.addChildTraceRowAfter(frameChart, firstRow) + } else { + processRow.addChildTraceRowSpecifyLocation(frameChart, 0) + } let appNameList = await queryDynamicIdAndNameData(); appNameList.forEach((item) => { appNameMap.set(item.id, item.appName); }); - let animationRanges = await this.initAnimationChart(processRow, firstRow); + let animationRanges = await this.initAnimationChart(processRow, firstRow, secondRow); await this.initDynamicCurveChart(appNameMap, frameChart, currentName, animationRanges); await this.initFrameSpacing(appNameMap, nameArr, frameChart, currentName, animationRanges); } @@ -296,7 +300,8 @@ export class SpFrameTimeChart { async initAnimationChart( processRow: TraceRow, - firstRow: TraceRow + firstRow: TraceRow, + secondRow: TraceRow ): Promise { let animationRanges: AnimationRanges[] = []; let frameAnimationRow = TraceRow.skeleton(); @@ -366,7 +371,13 @@ export class SpFrameTimeChart { ); frameAnimationRow!.canvasRestore(context, this.trace); }; - processRow.addChildTraceRowBefore(frameAnimationRow, firstRow); + if (firstRow !== null) { + processRow.addChildTraceRowBefore(frameAnimationRow, firstRow); + } else if (secondRow !== null) { + processRow.addChildTraceRowBefore(frameAnimationRow, secondRow) + } else { + processRow.addChildTraceRowSpecifyLocation(frameAnimationRow, 0) + } return animationRanges; } diff --git a/ide/src/trace/component/chart/SpHiPerf.ts b/ide/src/trace/component/chart/SpHiPerf.ts index 84de69d29de516986083ed37e1361a606d13258a..86381388810c5c28f6ebe1704180fe09e97dae7c 100644 --- a/ide/src/trace/component/chart/SpHiPerf.ts +++ b/ide/src/trace/component/chart/SpHiPerf.ts @@ -22,10 +22,8 @@ import { HiPerfCallChartRender, HiPerfCallChartStruct, } from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfCallChart'; -import { HiPerfThreadStruct } from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfThread2'; -import { - HiPerfProcessStruct, -} from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfProcess2'; +import { HiPerfThreadStruct } from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfThread2'; +import { HiPerfProcessStruct } from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfProcess2'; import { info } from '../../../log/Log'; import { HiPerfEventStruct } from '../../database/ui-worker/hiperf/ProcedureWorkerHiPerfEvent'; import { perfDataQuery } from './PerfDataQuery'; @@ -501,6 +499,7 @@ export class SpHiPerf { return hiperfProcessDataSender( process.pid, row.drawType, + this.maxCpuId + 1, SpHiPerf.stringResult?.fValue || 1, TraceRow.range?.scale || 50, row @@ -556,6 +555,7 @@ export class SpHiPerf { return hiperfThreadDataSender( thObj.tid, thread.drawType, + this.maxCpuId + 1, SpHiPerf.stringResult?.fValue || 1, TraceRow.range?.scale || 50, thread @@ -661,22 +661,24 @@ export class SpHiPerf { if (struct) { if (groupBy10MS) { if (row.drawType === -2) { - let num = 0; + let num: number | string = 0; if (struct instanceof HiPerfEventStruct) { num = Math.trunc(((struct.sum || 0) / (struct.max || 0)) * 100); } else { - num = Math.trunc(((struct.height || 0) / 40) * 100); - } - if (num > 0) { - tip = `${num * (this.maxCpuId + 1)}% (10.00ms)`; + let interval = SpHiPerf.stringResult?.fValue || 1; + num = ((struct.sampleCount! / (10 / interval)) * 100).toFixed(2); } + tip = `${num}% (10.00ms)`; } else { tip = `${struct.event_count || struct.eventCount} (10.00ms)`; } } else { let perfCall = perfDataQuery.callChainMap.get(struct.callchain_id || 0); if (perfCall) { - let perfName = SpSystemTrace.DATA_DICT.get(parseInt(perfCall.name)); + let perfName; + typeof perfCall.name === 'number' + ? (perfName = SpSystemTrace.DATA_DICT.get(parseInt(perfCall.name))) + : (perfName = perfCall.name); tip = `${perfCall ? perfName : ''} (${perfCall ? perfCall.depth : '0'} other frames)`; } } diff --git a/ide/src/trace/component/chart/SpLTPO.ts b/ide/src/trace/component/chart/SpLTPO.ts new file mode 100644 index 0000000000000000000000000000000000000000..b56b60313d0f64ca51f35cad0846525228d62fa9 --- /dev/null +++ b/ide/src/trace/component/chart/SpLTPO.ts @@ -0,0 +1,359 @@ +/* + * 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 { SpSystemTrace } from '../SpSystemTrace'; +import { TraceRow } from '../trace/base/TraceRow'; +import { renders } from '../../database/ui-worker/ProcedureWorker'; +import { CpuFreqStruct } from '../../database/ui-worker/ProcedureWorkerFreq'; +import { + queryFanceNameList, + queryFpsNameList, + queryRealFpsList +} from '../../database/sql/Ltpo.sql'; +import { LtpoRender, LtpoStruct } from '../../database/ui-worker/ProcedureWorkerLTPO' +import { HitchTimeStruct, hitchTimeRender } from '../../database/ui-worker/ProcedureWorkerHitchTime'; +import { lostFrameSender } from '../../database/data-trafic/LostFrameSender'; + +export class SpLtpoChart { + private readonly trace: SpSystemTrace | undefined; + static APP_STARTUP_PID_ARR: Array = []; + static jsonRow: TraceRow | undefined; + static trace: SpSystemTrace; + static presentArr: Array = []; + static fanceNameList: Array = []; + static fpsnameList: Array = []; + static realFpsList: Array = []; + static ltpoDataArr: Array = []; + static sendLTPODataArr: Array = []; + static sendHitchDataArr: Array = []; + static signaledFence: Array = []; + static threadName: String = 'Present%'; + static funName: String = 'H:Waiting for Present Fence%'; + constructor(trace: SpSystemTrace) { + SpLtpoChart.trace = trace; + } + + async init() { + SpLtpoChart.ltpoDataArr = []; + SpLtpoChart.fanceNameList = await queryFanceNameList(); + SpLtpoChart.fpsnameList = await queryFpsNameList(); + SpLtpoChart.realFpsList = await queryRealFpsList(); + SpLtpoChart.fanceNameList.map((item) => { + let cutFanceNameArr = item.name!.split(" "); + if (cutFanceNameArr[cutFanceNameArr.length - 1] === 'signaled') { + item.fanceId = Number(cutFanceNameArr[2]); + item.signaled = 1; + SpLtpoChart.signaledFence.push(item); + } else { + item.fanceId = Number(cutFanceNameArr[cutFanceNameArr.length - 1]); + } + }); + SpLtpoChart.fpsnameList.map((item) => { + let cutFpsNameArr = item.name!.split(",")[0].split(":"); + item.fps = Number(cutFpsNameArr[cutFpsNameArr.length - 1]); + }); + if (SpLtpoChart.realFpsList.length > 0) { + SpLtpoChart.realFpsList.map((item) => { + let cutRealFpsArr = item.name!.split(' '); + item.fps = Number(cutRealFpsArr[cutRealFpsArr.length - 1]); + }); + this.setRealFps(); + }; + //特殊情况:当前trace的RSHardwareThrea泳道最前面多一个单独的fence + if (SpLtpoChart.fpsnameList.length > 0 && SpLtpoChart.fanceNameList.length - SpLtpoChart.fpsnameList.length === 1) { + if (Number(SpLtpoChart.fanceNameList[0].ts) < Number(SpLtpoChart.fpsnameList[0].ts)) { + SpLtpoChart.fanceNameList.splice(0, 1); + } + } + if (SpLtpoChart.fanceNameList!.length && SpLtpoChart.fpsnameList.length === SpLtpoChart.fanceNameList.length) { + for (let i = 0; i < SpLtpoChart.fanceNameList.length; i++) { + let tmpFps = SpLtpoChart.fpsnameList[i]!.fps ? Number(SpLtpoChart.fpsnameList[i]!.fps) : 60; + let signaled = Number(SpLtpoChart.fanceNameList[i]!.signaled); + let startTime = Number(SpLtpoChart.fanceNameList[i]!.ts); + let durtaion = Number(SpLtpoChart.fanceNameList[i]!.dur); + if (SpLtpoChart.fanceNameList[i]!.signaled) { + this.pushLtpoData(SpLtpoChart.ltpoDataArr, SpLtpoChart.fanceNameList[i]!.fanceId!, tmpFps, signaled, startTime, durtaion, 0, 0); + } else { + this.pushLtpoData(SpLtpoChart.ltpoDataArr, SpLtpoChart.fanceNameList[i]!.fanceId!, tmpFps, 0, 0, 0, 0, 0); + } + } + } else { + return; + } + if (SpLtpoChart.fanceNameList && SpLtpoChart.fanceNameList.length) { + await this.initFolder(); + await this.initHitchTime(); + } + } + //处理fps + setRealFps(): void { + let moreIndex = 0; + let reallIndex = 0; + while (moreIndex < SpLtpoChart.fpsnameList.length) { + let itemMoreEndTs = Number(SpLtpoChart.fpsnameList[moreIndex].ts) + Number(SpLtpoChart.fpsnameList[moreIndex].dur); + if (Number(SpLtpoChart.realFpsList[reallIndex].ts) < itemMoreEndTs) {//此时这一帧包含了两个fps,将真实的fps赋给SpLtpoChart.fpsnameList + SpLtpoChart.fpsnameList[moreIndex].fps = SpLtpoChart.realFpsList[reallIndex].fps; + moreIndex++; + if (reallIndex < SpLtpoChart.realFpsList.length - 1) {//判断SpLtpoChart.realFpsList有没有遍历完,没有就继续 + reallIndex++; + } else {//否则跳出 + return; + } + } else {//如果不满足的话,SpLtpoChart.fpsnameList数组往下走,而reallIndex不变 + moreIndex++; + } + } + } + pushLtpoData( + lptoArr: any[] | undefined, + fanceId: Number, + fps: Number, + signaled: Number, + startTs: Number, + dur: Number, + nextStartTs: Number, + nextDur: number + ): void { + lptoArr?.push( + { + fanceId: fanceId, + fps: fps, + signaled: signaled, + startTs: startTs, + dur: dur, + nextStartTs: nextStartTs, + nextDur: nextDur + } + ); + } + sendDataHandle(presentArr: LtpoStruct[], ltpoDataArr: LtpoStruct[]): Array { + let sendDataArr: LtpoStruct[] = []; + //当有present缺失时: + this.deleteUselessFence(presentArr, ltpoDataArr); + if (presentArr!.length && presentArr!.length === ltpoDataArr!.length) { + for (let i = 0; i < presentArr!.length; i++) { + ltpoDataArr[i].startTs = Number(presentArr[i].startTime) - (window as any).recordStartNS; + ltpoDataArr[i].dur = presentArr[i].dur; + ltpoDataArr[i].nextStartTs = presentArr[i + 1] ? Number(presentArr[i + 1].startTime) - (window as any).recordStartNS : ''; + ltpoDataArr[i].nextDur = presentArr[i + 1] ? presentArr[i + 1].dur : 0; + } + } else { + return sendDataArr; + } + for (let i = 0; i < ltpoDataArr.length; i++) { + if (ltpoDataArr[i].fanceId !== -1 && ltpoDataArr[i].nextDur) { + let sendStartTs: number | undefined = 0; + let sendDur: number | undefined = 0; + sendStartTs = Number(ltpoDataArr[i].startTs) + Number(ltpoDataArr[i].dur); + sendDur = Number(ltpoDataArr[i].nextStartTs) + Number(ltpoDataArr[i].nextDur) - sendStartTs; + let tmpDur = (Math.ceil(sendDur / 100000)) / 10; + if (tmpDur < 170) { + sendDataArr.push( + { + dur: sendDur, + value: 0, + startTs: sendStartTs, + pid: ltpoDataArr[i].fanceId, + itid: ltpoDataArr[i].fanceId, + name: undefined, + presentId: ltpoDataArr[i].fanceId, + ts: undefined, + fanceId: ltpoDataArr[i].fanceId, + fps: ltpoDataArr[i].fps, + nextStartTs: ltpoDataArr[i].nextStartTs, + nextDur: ltpoDataArr[i].nextDur, + translateY: undefined, + frame: undefined, + isHover: false, + startTime: undefined, + signaled: undefined + } + ); + } + } + } + return sendDataArr; + } + deleteUselessFence(presentArr: LtpoStruct[], ltpoDataArr: LtpoStruct[]) { + //当有present缺失时: + let presentIndex = 0; + let fpsIndex = 0; + while (presentIndex < presentArr.length) {//遍历present,把ltpoDataArr中不包含present中presentFance的item舍弃掉 + if (Number(presentArr[presentIndex].presentId) < Number(ltpoDataArr[fpsIndex].fanceId)) { + presentArr.splice(presentIndex, 1); + } else if (Number(presentArr[presentIndex].presentId) > Number(ltpoDataArr[fpsIndex].fanceId)) { + ltpoDataArr.splice(fpsIndex, 1); + } else { + if (presentIndex === presentArr.length - 1 && fpsIndex < ltpoDataArr.length - 1) {//此时present已经遍历到最后一项,如果ltpoDataArr还没有遍历到最后一项,就把后面的舍弃掉 + ltpoDataArr.splice(fpsIndex); + } + presentIndex++; + fpsIndex++; + } + }; + } + //六舍七入 + specialValue(num: number) { + if (num < 0) { + return 0; + } else { + let tempNum = Number(num.toString().split('.')[1].charAt(0)); + if (tempNum > 6) { + return Math.ceil(num); + } else { + return Math.floor(num); + } + } + + } + //补齐present中已上屏的部分 + supPresent(presentArr: LtpoStruct[], signaledFence: LtpoStruct[]) { + let presIndex = 0; + let signaleIndex = 0; + while (presIndex < presentArr.length && signaleIndex < signaledFence.length) { + if (Number(presentArr[presIndex].presentId) > Number(signaledFence[signaleIndex].fanceId) && presIndex > 0 && + Number(presentArr[presIndex - 1].presentId) < Number(signaledFence[signaleIndex].fanceId)) { + presentArr.splice(presIndex, 0, { + dur: signaledFence[signaleIndex].dur, + presentId: Number(signaledFence[signaleIndex].fanceId), + startTime: signaledFence[signaleIndex].ts, + name: undefined, + ts: undefined, + fanceId: undefined, + fps: undefined, + startTs: undefined, + nextStartTs: undefined, + nextDur: undefined, + value: undefined, + pid: undefined, + itid: undefined, + signaled: undefined, + translateY: undefined, + frame: undefined, + isHover: false + }); + presIndex++; + signaleIndex++; + } else { + presIndex++; + } + } + } + + async initFolder() { + SpLtpoChart.presentArr = []; + let row: TraceRow = TraceRow.skeleton(); + row.rowId = SpLtpoChart.fanceNameList!.length ? `LTPO ${SpLtpoChart.fanceNameList[0].fanceId}` : ''; + row.rowParentId = ''; + row.rowType = TraceRow.ROW_TYPE_LTPO; + row.folder = false; + row.style.height = '40px'; + row.name = `Lost Frames`; + row.favoriteChangeHandler = SpLtpoChart.trace.favoriteChangeHandler; + row.selectChangeHandler = SpLtpoChart.trace.selectChangeHandler; + row.supplierFrame = () => { + return lostFrameSender(SpLtpoChart.threadName, SpLtpoChart.funName, row).then((res) => { + SpLtpoChart.presentArr = res; + if (SpLtpoChart.signaledFence.length) { + this.supPresent(SpLtpoChart.presentArr, SpLtpoChart.signaledFence); + } + SpLtpoChart.sendLTPODataArr = this.sendDataHandle(SpLtpoChart.presentArr, SpLtpoChart.ltpoDataArr); + for (let i = 0; i < SpLtpoChart.sendLTPODataArr.length; i++) { + let tmpDur = SpLtpoChart.sendLTPODataArr[i].dur! / 1000000; + let mathValue = tmpDur * Number(SpLtpoChart.sendLTPODataArr[i].fps) / 1000 - 1; + SpLtpoChart.sendLTPODataArr[i].value = this.specialValue(mathValue); + } + return SpLtpoChart.sendLTPODataArr; + }) + } + row.focusHandler = () => { + SpLtpoChart.trace?.displayTip(row!, LtpoStruct.hoverLtpoStruct, `${(LtpoStruct.hoverLtpoStruct?.value!)}`) + }; + row.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (row.currentContext) { + context = row.currentContext; + } else { + context = row.collect ? SpLtpoChart.trace.canvasFavoritePanelCtx! : SpLtpoChart.trace.canvasPanelCtx!; + } + row.canvasSave(context); + (renders['ltpo-present'] as LtpoRender).renderMainThread( + { + appStartupContext: context, + useCache: useCache, + type: `ltpo-present ${row.rowId}`, + }, row); + row.canvasRestore(context); + }; + SpLtpoChart.trace.rowsEL?.appendChild(row); + } + async initHitchTime() { + SpLtpoChart.presentArr = []; + let row: TraceRow = TraceRow.skeleton(); + this.takeStaticArg(row); + row.supplierFrame = () => { + return lostFrameSender(SpLtpoChart.threadName, SpLtpoChart.funName, row).then((res) => { + SpLtpoChart.presentArr = res + if (SpLtpoChart.signaledFence.length) { + this.supPresent(SpLtpoChart.presentArr, SpLtpoChart.signaledFence); + } + SpLtpoChart.sendHitchDataArr = this.sendDataHandle(SpLtpoChart.presentArr, SpLtpoChart.ltpoDataArr); + for (let i = 0; i < SpLtpoChart.sendHitchDataArr.length; i++) { + let tmpVale = (Math.ceil(((SpLtpoChart.sendHitchDataArr[i].dur! / 1000000) - (1000 / SpLtpoChart.sendHitchDataArr[i].fps!)) * 10)) / 10; + let tmpDur = SpLtpoChart.sendLTPODataArr[i].dur! / 1000000; + let mathValue = tmpDur * Number(SpLtpoChart.sendLTPODataArr[i].fps) / 1000 - 1; + SpLtpoChart.sendHitchDataArr[i].value = tmpVale! < 0 ? 0 : tmpVale; + SpLtpoChart.sendHitchDataArr[i].name = this.specialValue(mathValue).toString(); + } + return SpLtpoChart.sendHitchDataArr; + }) + } + row.focusHandler = () => { + let viewValue = (HitchTimeStruct.hoverHitchTimeStruct?.value!)!+''; + let rep = /[\.]/; + if(!rep.test(viewValue) && viewValue !== '0') { + viewValue += '.0'; + } + SpLtpoChart.trace?.displayTip(row!, HitchTimeStruct.hoverHitchTimeStruct, `${viewValue}`) + }; + row.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (row.currentContext) { + context = row.currentContext; + } else { + context = row.collect ? SpLtpoChart.trace.canvasFavoritePanelCtx! : SpLtpoChart.trace.canvasPanelCtx!; + } + row.canvasSave(context); + (renders['hitch'] as hitchTimeRender).renderMainThread( + { + appStartupContext: context, + useCache: useCache, + type: `hitch ${row.rowId}`, + }, row); + row.canvasRestore(context); + }; + SpLtpoChart.trace.rowsEL?.appendChild(row); + } + takeStaticArg(row: TraceRow) { + row.rowId = SpLtpoChart.fanceNameList!.length ? `hitch-time ${SpLtpoChart.fanceNameList[0].fanceId}` : ''; + row.rowParentId = ''; + row.rowType = TraceRow.ROW_TYPE_HITCH_TIME; + row.folder = false; + row.style.height = '40px'; + row.name = `Hitch Time`; + row.favoriteChangeHandler = SpLtpoChart.trace.favoriteChangeHandler; + row.selectChangeHandler = SpLtpoChart.trace.selectChangeHandler; + } +} diff --git a/ide/src/trace/component/chart/SpProcessChart.ts b/ide/src/trace/component/chart/SpProcessChart.ts index 260661911ae00ccdb6931244d2cd25d39e039b83..ace08eea549d4906230c72f4dd327926533d1911 100644 --- a/ide/src/trace/component/chart/SpProcessChart.ts +++ b/ide/src/trace/component/chart/SpProcessChart.ts @@ -24,7 +24,7 @@ import { FuncRender, FuncStruct } from '../../database/ui-worker/ProcedureWorker import { MemRender, ProcessMemStruct } from '../../database/ui-worker/ProcedureWorkerMem'; import { FolderSupplier, FolderThreadHandler, SpChartManager } from './SpChartManager'; import { JankRender, JankStruct } from '../../database/ui-worker/ProcedureWorkerJank'; -import { ns2xByTimeShaft } from '../../database/ui-worker/ProcedureWorkerCommon'; +import { isFrameContainPoint, ns2xByTimeShaft } from '../../database/ui-worker/ProcedureWorkerCommon'; import { AppStartupRender, AppStartupStruct } from '../../database/ui-worker/ProcedureWorkerAppStartup'; import { SoRender, SoStruct } from '../../database/ui-worker/ProcedureWorkerSoInit'; import { FlagsConfig } from '../SpFlags'; @@ -55,6 +55,7 @@ import { queryTaskPoolProcessIds, } from '../../database/sql/ProcessThread.sql'; import { queryAllJankProcess } from '../../database/sql/Janks.sql'; +import { BaseStruct } from '../../bean/BaseStruct'; export class SpProcessChart { private readonly trace: SpSystemTrace; @@ -76,6 +77,7 @@ export class SpProcessChart { private processNameMap: Map = new Map(); private threadNameMap: Map = new Map(); private processSrcSliceMap: Map = new Map(); + private renderRow: TraceRow | null = null; constructor(trace: SpSystemTrace) { this.trace = trace; } @@ -138,7 +140,7 @@ export class SpProcessChart { res.forEach((it, i) => { res[i].funName = this.funcNameMap.get(res[i].id!); res[i].threadName = this.threadNameMap.get(res[i].tid!); - if (it.dur == -1) { + if (it.dur == -1 || it.dur === null || it.dur === undefined) { it.dur = (TraceRow.range?.endNS || 0) - it.startTs; it.flag = 'Did not end'; } @@ -153,6 +155,9 @@ export class SpProcessChart { return res; }); }; + funcRow.findHoverStruct = (): void => { + FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); + } funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; funcRow.selectChangeHandler = this.trace.selectChangeHandler; funcRow.onThreadHandler = (useCache): void => { @@ -580,17 +585,22 @@ export class SpProcessChart { } linkProcessItem[1].y = linkProcessItem[1].rowEL!.translateY + linkProcessItem[1].offsetY; if (linkProcessItem[0].rowEL.rowParentId == e.detail.rowId) { - linkProcessItem[0].x = ns2xByTimeShaft(linkProcessItem[0].ns, this.trace.timerShaftEL!); - linkProcessItem[0].y = processRow!.translateY! + linkProcessItem[0].offsetY / 2; - linkProcessItem[0].offsetY = linkProcessItem[0].offsetY / 2; - linkProcessItem[0].rowEL = processRow!; + if (!linkProcessItem[0].rowEL.collect) { + linkProcessItem[0].x = ns2xByTimeShaft(linkProcessItem[0].ns, this.trace.timerShaftEL!); + linkProcessItem[0].y = processRow!.translateY! + linkProcessItem[0].offsetY / 2; + linkProcessItem[0].offsetY = linkProcessItem[0].offsetY / 2; + linkProcessItem[0].rowEL = processRow!; + } } if (linkProcessItem[1].rowEL.rowParentId == e.detail.rowId) { - linkProcessItem[1].x = ns2xByTimeShaft(linkProcessItem[1].ns, this.trace.timerShaftEL!); - linkProcessItem[1].y = processRow!.translateY! + linkProcessItem[1].offsetY / 2; - linkProcessItem[1].offsetY = linkProcessItem[1].offsetY / 2; - linkProcessItem[1].rowEL = processRow!; + if (!linkProcessItem[1].rowEL.collect) { + linkProcessItem[1].x = ns2xByTimeShaft(linkProcessItem[1].ns, this.trace.timerShaftEL!); + linkProcessItem[1].y = processRow!.translateY! + linkProcessItem[1].offsetY / 2; + linkProcessItem[1].offsetY = linkProcessItem[1].offsetY / 2; + linkProcessItem[1].rowEL = processRow!; + } } + JankStruct.selectJankStructList = []; }); }, 300); } @@ -600,273 +610,17 @@ export class SpProcessChart { clearTimeout(refreshTimeOut); }, 360); }); - /** - * Async Function - */ - let asyncFuncList = this.processAsyncFuncMap[it.pid] || []; - let asyncFuncGroup = Utils.groupBy(asyncFuncList, 'funName'); - Reflect.ownKeys(asyncFuncGroup).map((key: any) => { - let asyncFunctions: Array = asyncFuncGroup[key]; - if (asyncFunctions.length > 0) { - let isIntersect = (a: any, b: any): boolean => - Math.max(a.startTs + a.dur, b.startTs + b.dur) - Math.min(a.startTs, b.startTs) < a.dur + b.dur; - let depthArray: any = []; - asyncFunctions.forEach((it, i) => { - if (it.dur === -1) { - it.dur = (TraceRow.range?.endNS || 0) - it.startTs; - it.flag = 'Did not end'; - } - let currentDepth = 0; - let index = i; - while ( - depthArray[currentDepth] !== undefined && - isIntersect(depthArray[currentDepth], asyncFunctions[index]) - ) { - currentDepth++; - } - asyncFunctions[index].depth = currentDepth; - depthArray[currentDepth] = asyncFunctions[index]; - }); - let max = Math.max(...asyncFunctions.map((it) => it.depth || 0)) + 1; - let maxHeight = max * 20; - let funcRow = TraceRow.skeleton(); - funcRow.rowId = `${asyncFunctions[0].funName}-${it.pid}`; - funcRow.asyncFuncName = asyncFunctions[0].funName; - funcRow.asyncFuncNamePID = it.pid; - funcRow.rowType = TraceRow.ROW_TYPE_FUNC; - funcRow.enableCollapseChart(); //允许折叠泳道图 - funcRow.rowParentId = `${it.pid}`; - funcRow.rowHidden = !processRow.expansion; - funcRow.style.width = '100%'; - funcRow.style.height = `${maxHeight}px`; - funcRow.setAttribute('height', `${maxHeight}`); - funcRow.name = `${asyncFunctions[0].funName}`; - funcRow.setAttribute('children', ''); - funcRow.supplier = (): Promise => new Promise((resolve) => resolve(asyncFunctions)); - funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; - funcRow.selectChangeHandler = this.trace.selectChangeHandler; - funcRow.onThreadHandler = (cacheFlag): void => { - let context: CanvasRenderingContext2D; - if (funcRow.currentContext) { - context = funcRow.currentContext; - } else { - context = funcRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; - } - funcRow.canvasSave(context); - (renders.func as FuncRender).renderMainThread( - { - context: context, - useCache: cacheFlag, - type: `func-${asyncFunctions[0].funName}-${it.pid}`, - }, - funcRow - ); - funcRow.canvasRestore(context, this.trace); - }; - processRow.addChildTraceRow(funcRow); - } - }); - - /** - * 添加进程内存信息 - */ - let processMem = this.processMem.filter((mem) => mem.pid === it.pid); - processMem.forEach((mem) => { - let row = TraceRow.skeleton(); - row.rowId = `${mem.trackId}`; - row.rowType = TraceRow.ROW_TYPE_MEM; - row.rowParentId = `${it.pid}`; - row.rowHidden = !processRow.expansion; - row.style.height = '40px'; - row.style.width = '100%'; - row.name = `${mem.trackName}`; - row.setAttribute('children', ''); - row.favoriteChangeHandler = this.trace.favoriteChangeHandler; - row.selectChangeHandler = this.trace.selectChangeHandler; - row.focusHandler = (): void => { - this.trace.displayTip( - row, - ProcessMemStruct.hoverProcessMemStruct, - `${ProcessMemStruct.hoverProcessMemStruct?.value || '0'}` - ); - }; - row.findHoverStruct = (): void => { - ProcessMemStruct.hoverProcessMemStruct = row.getHoverStruct(false); - }; - row.supplierFrame = (): Promise> => - processMemDataSender(mem.trackId, row).then((resultProcess) => { - let maxValue = this.filterIdMaxValue.get(mem.trackId) || 0; - for (let j = 0; j < resultProcess.length; j++) { - resultProcess[j].maxValue = maxValue; - if (j === resultProcess.length - 1) { - resultProcess[j].duration = (TraceRow.range?.totalNS || 0) - (resultProcess[j].startTime || 0); - } else { - resultProcess[j].duration = (resultProcess[j + 1].startTime || 0) - (resultProcess[j].startTime || 0); - } - if (j > 0) { - resultProcess[j].delta = (resultProcess[j].value || 0) - (resultProcess[j - 1].value || 0); - } else { - resultProcess[j].delta = 0; - } - } - return resultProcess; - }); - row.onThreadHandler = (useCache): void => { - let context: CanvasRenderingContext2D; - if (row.currentContext) { - context = row.currentContext; - } else { - context = row.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; - } - row.canvasSave(context); - (renders.mem as MemRender).renderMainThread( - { - context: context, - useCache: useCache, - type: `mem ${mem.trackId} ${mem.trackName}`, - }, - row - ); - row.canvasRestore(context, this.trace); - }; - processRow.addChildTraceRow(row); - }); - /** - * add thread list - */ - let threads = this.processThreads.filter((thread) => thread.pid === it.pid && thread.tid != 0); - for (let j = 0; j < threads.length; j++) { - let thread = threads[j]; - let threadRow = TraceRow.skeleton(); - threadRow.rowId = `${thread.tid}`; - threadRow.rowType = TraceRow.ROW_TYPE_THREAD; - threadRow.rowParentId = `${it.pid}`; - threadRow.rowHidden = !processRow.expansion; - threadRow.index = j; - threadRow.style.height = '30px'; - threadRow.style.width = '100%'; - threadRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; - threadRow.setAttribute('children', ''); - threadRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; - threadRow.selectChangeHandler = this.trace.selectChangeHandler; - threadRow.supplierFrame = (): Promise> => { - return threadDataSender(thread.tid || 0, it.pid || 0, threadRow).then((res) => { - if (res === true) { - // threadRow.rowDiscard = true; - return []; - } else { - let rs = res as ThreadStruct[]; - if (rs.length <= 0 && !threadRow.isComplete) { - this.trace.refreshCanvas(true); - } - return rs; - } - }); - }; - threadRow.onThreadHandler = (useCache): void => { - let context: CanvasRenderingContext2D; - if (threadRow.currentContext) { - context = threadRow.currentContext; - } else { - context = threadRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; - } - threadRow.canvasSave(context); - (renders['thread'] as ThreadRender).renderMainThread( - { - context: context, - useCache: useCache, - type: `thread ${thread.tid} ${thread.threadName}`, - translateY: threadRow.translateY, - }, - threadRow - ); - threadRow.canvasRestore(context, this.trace); - }; - if (threadRow.rowId === threadRow.rowParentId) { - if (actualRow !== null) { - processRow.addChildTraceRowAfter(threadRow, actualRow); - } else if (expectedRow !== null) { - processRow.addChildTraceRowAfter(threadRow, expectedRow); - } else if (soRow) { - processRow.addChildTraceRowAfter(threadRow, soRow); - } else if (startupRow) { - processRow.addChildTraceRowAfter(threadRow, startupRow); - } else { - processRow.addChildTraceRowSpecifyLocation(threadRow, 0); - } - } else { - processRow.addChildTraceRow(threadRow); - } - if (this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) != undefined) { - let max = this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) || 1; - let maxHeight = max * 20; - let funcRow = TraceRow.skeleton(); - funcRow.rowId = `${thread.tid}`; - funcRow.rowType = TraceRow.ROW_TYPE_FUNC; - funcRow.enableCollapseChart(); //允许折叠泳道图 - funcRow.rowParentId = `${it.pid}`; - funcRow.rowHidden = !processRow.expansion; - funcRow.checkType = threadRow.checkType; - funcRow.style.width = '100%'; - funcRow.style.height = `${maxHeight}px`; - funcRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; - funcRow.setAttribute('children', ''); - funcRow.supplierFrame = (): Promise> => { - return funcDataSender(thread.tid || 0, thread.upid || 0, funcRow).then( - (rs: Array | boolean) => { - if (rs === true) { - funcRow.rowDiscard = true; - return []; - } else { - let funs = rs as FuncStruct[]; - if (funs.length > 0) { - funs.forEach((fun, index) => { - funs[index].itid = thread.utid; - funs[index].ipid = thread.upid; - funs[index].funName = this.funcNameMap.get(funs[index].id!); - if (Utils.isBinder(fun)) { - } else { - if (fun.dur === -1) { - fun.dur = (TraceRow.range?.totalNS || 0) - (fun.startTs || 0); - fun.flag = 'Did not end'; - } - } - }); - } else { - this.trace.refreshCanvas(true); - } - return funs; - } - } - ); - }; - funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; - funcRow.selectChangeHandler = this.trace.selectChangeHandler; - funcRow.onThreadHandler = (useCache): void => { - let context: CanvasRenderingContext2D; - if (funcRow.currentContext) { - context = funcRow.currentContext; - } else { - context = funcRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; - } - funcRow.canvasSave(context); - (renders.func as FuncRender).renderMainThread( - { - context: context, - useCache: useCache, - type: `func${thread.tid}${thread.threadName}`, - }, - funcRow - ); - funcRow.canvasRestore(context, this.trace); - }; - processRow.addChildTraceRowAfter(funcRow, threadRow); - } - if ((thread.switchCount || 0) === 0) { - threadRow.rowDiscard = true; - } + this.renderRow = null; + if (it.processName === 'render_service') { + this.addThreadList(it, processRow, expectedRow, actualRow, soRow, startupRow); + this.addProcessMemInfo(it, processRow); + this.addAsyncFunction(it, processRow); + } else { + this.addAsyncFunction(it, processRow); + this.addProcessMemInfo(it, processRow); + this.addThreadList(it, processRow, expectedRow, actualRow, soRow, startupRow); } - await this.trace.chartManager?.frameTimeChart.initAnimatedScenesChart(processRow, it, expectedRow!); + await this.trace.chartManager?.frameTimeChart.initAnimatedScenesChart(processRow, it, expectedRow!, actualRow!); } let durTime = new Date().getTime() - time; info('The time to load the Process data is: ', durTime); @@ -883,6 +637,9 @@ export class SpProcessChart { startupRow.style.height = '30px'; startupRow.style.width = `100%`; startupRow.name = `App Startups`; + startupRow.findHoverStruct = (): void => { + AppStartupStruct.hoverStartupStruct = startupRow.getHoverStruct(); + } startupRow.setAttribute('children', ''); startupRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; startupRow.selectChangeHandler = this.trace.selectChangeHandler; @@ -935,6 +692,9 @@ export class SpProcessChart { soRow.setAttribute('children', ''); soRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; soRow.selectChangeHandler = this.trace.selectChangeHandler; + soRow.findHoverStruct = (): void => { + SoStruct.hoverSoStruct = soRow.getHoverStruct(); + } soRow.supplierFrame = (): Promise> => processSoInitDataSender(parseInt(processRow.rowId!), soRow).then((res) => { if (res.length <= 0) { @@ -978,4 +738,323 @@ export class SpProcessChart { parentEl!.insertBefore(newEl, targetEl.nextSibling); } } + + //add thread list + addThreadList( + it: { pid: number | null; processName: string | null }, + processRow: TraceRow, + expectedRow: TraceRow | null, + actualRow: TraceRow | null, + soRow: TraceRow | undefined, + startupRow: TraceRow | undefined, + ) { + let threads = this.processThreads.filter((thread) => thread.pid === it.pid && thread.tid != 0); + let threadRowArr: Array> = []; + for (let j = 0; j < threads.length; j++) { + let thread = threads[j]; + let threadRow = TraceRow.skeleton(); + threadRow.rowId = `${thread.tid}`; + threadRow.rowType = TraceRow.ROW_TYPE_THREAD; + threadRow.rowParentId = `${it.pid}`; + threadRow.rowHidden = !processRow.expansion; + threadRow.index = j; + threadRow.style.height = '30px'; + threadRow.style.width = '100%'; + threadRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; + threadRow.namePrefix = `${thread.threadName || 'Thread'}`; + threadRow.setAttribute('children', ''); + threadRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; + threadRow.selectChangeHandler = this.trace.selectChangeHandler; + threadRow.findHoverStruct = (): void => { + let arr = threadRow.dataListCache.filter( + (re) => re.frame && isFrameContainPoint(re.frame, threadRow.hoverX, threadRow.hoverY, true, false) + ); + let runItem = arr.find(it => it.state === 'Running'); + if (runItem) { + ThreadStruct.hoverThreadStruct = runItem; + } else { + let otherItem = arr.find(it => it.state !== 'S'); + if (otherItem) { + ThreadStruct.hoverThreadStruct = otherItem; + } else { + ThreadStruct.hoverThreadStruct = arr[0]; + } + } + } + threadRow.supplierFrame = (): Promise> => { + return threadDataSender(thread.tid || 0, it.pid || 0, threadRow).then((res) => { + if (res === true) { + // threadRow.rowDiscard = true; + return []; + } else { + let rs = res as ThreadStruct[]; + if (rs.length <= 0 && !threadRow.isComplete) { + this.trace.refreshCanvas(true); + } + return rs; + } + }); + }; + threadRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (threadRow.currentContext) { + context = threadRow.currentContext; + } else { + context = threadRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + threadRow.canvasSave(context); + (renders['thread'] as ThreadRender).renderMainThread( + { + context: context, + useCache: useCache, + type: `thread ${thread.tid} ${thread.threadName}`, + translateY: threadRow.translateY, + }, + threadRow + ); + threadRow.canvasRestore(context, this.trace); + }; + if (it.processName === 'render_service') { + if (threadRow.name === `${it.processName} ${it.pid}`) { + this.renderRow = threadRow; + } + let flag = threads.length === j + 1 && !this.threadFuncMaxDepthMap.has(`${thread.upid}-${thread.tid}`); + processRow.sortRenderServiceData(threadRow, threadRow, threadRowArr, flag); + } else { + if (threadRow.rowId === threadRow.rowParentId) { + if (actualRow !== null) { + processRow.addChildTraceRowAfter(threadRow, actualRow); + } else if (expectedRow !== null) { + processRow.addChildTraceRowAfter(threadRow, expectedRow); + } else if (soRow) { + processRow.addChildTraceRowAfter(threadRow, soRow); + } else if (startupRow) { + processRow.addChildTraceRowAfter(threadRow, startupRow); + } else { + processRow.addChildTraceRowSpecifyLocation(threadRow, 0); + } + } else { + processRow.addChildTraceRow(threadRow); + } + } + if (this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) != undefined) { + let max = this.threadFuncMaxDepthMap.get(`${thread.upid}-${thread.tid}`) || 1; + let maxHeight = max * 20; + let funcRow = TraceRow.skeleton(); + funcRow.rowId = `${thread.tid}`; + funcRow.rowType = TraceRow.ROW_TYPE_FUNC; + funcRow.enableCollapseChart(); //允许折叠泳道图 + funcRow.rowParentId = `${it.pid}`; + funcRow.rowHidden = !processRow.expansion; + funcRow.checkType = threadRow.checkType; + funcRow.style.width = '100%'; + funcRow.style.height = `${maxHeight}px`; + funcRow.name = `${thread.threadName || 'Thread'} ${thread.tid}`; + funcRow.namePrefix = `${thread.threadName || 'Thread'}`; + funcRow.setAttribute('children', ''); + funcRow.supplierFrame = (): Promise> => { + return funcDataSender(thread.tid || 0, thread.upid || 0, funcRow).then( + (rs: Array | boolean) => { + if (rs === true) { + funcRow.rowDiscard = true; + return []; + } else { + let funs = rs as FuncStruct[]; + if (funs.length > 0) { + funs.forEach((fun, index) => { + funs[index].itid = thread.utid; + funs[index].ipid = thread.upid; + funs[index].funName = this.funcNameMap.get(funs[index].id!); + if (Utils.isBinder(fun)) { + } else { + if (fun.nofinish) { + fun.flag = 'Did not end'; + } + } + }); + } else { + this.trace.refreshCanvas(true); + } + return funs; + } + } + ); + }; + funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; + funcRow.selectChangeHandler = this.trace.selectChangeHandler; + funcRow.findHoverStruct = (): void => { + FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); + } + funcRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (funcRow.currentContext) { + context = funcRow.currentContext; + } else { + context = funcRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + funcRow.canvasSave(context); + (renders.func as FuncRender).renderMainThread( + { + context: context, + useCache: useCache, + type: `func${thread.tid}${thread.threadName}`, + }, + funcRow + ); + funcRow.canvasRestore(context, this.trace); + }; + if (it.processName === 'render_service') { + let flag = threads.length === j + 1; + processRow.sortRenderServiceData(funcRow, threadRow, threadRowArr, flag); + } else { + processRow.addChildTraceRowAfter(funcRow, threadRow); + } + } + if ((thread.switchCount || 0) === 0) { + threadRow.rowDiscard = true; + } + } + } + + //进程内存信息 + addProcessMemInfo( + it: { pid: number | null; processName: string | null }, + processRow: TraceRow, + ) { + let processMem = this.processMem.filter((mem) => mem.pid === it.pid); + processMem.forEach((mem) => { + let row = TraceRow.skeleton(); + row.rowId = `${mem.trackId}`; + row.rowType = TraceRow.ROW_TYPE_MEM; + row.rowParentId = `${it.pid}`; + row.rowHidden = !processRow.expansion; + row.style.height = '40px'; + row.style.width = '100%'; + row.name = `${mem.trackName}`; + row.setAttribute('children', ''); + row.favoriteChangeHandler = this.trace.favoriteChangeHandler; + row.selectChangeHandler = this.trace.selectChangeHandler; + row.focusHandler = (): void => { + this.trace.displayTip( + row, + ProcessMemStruct.hoverProcessMemStruct, + `${ProcessMemStruct.hoverProcessMemStruct?.value || '0'}` + ); + }; + row.findHoverStruct = (): void => { + ProcessMemStruct.hoverProcessMemStruct = row.getHoverStruct(false); + }; + row.supplierFrame = (): Promise> => + processMemDataSender(mem.trackId, row).then((resultProcess) => { + let maxValue = this.filterIdMaxValue.get(mem.trackId) || 0; + for (let j = 0; j < resultProcess.length; j++) { + resultProcess[j].maxValue = maxValue; + if (j === resultProcess.length - 1) { + resultProcess[j].duration = (TraceRow.range?.totalNS || 0) - (resultProcess[j].startTime || 0); + } else { + resultProcess[j].duration = (resultProcess[j + 1].startTime || 0) - (resultProcess[j].startTime || 0); + } + if (j > 0) { + resultProcess[j].delta = (resultProcess[j].value || 0) - (resultProcess[j - 1].value || 0); + } else { + resultProcess[j].delta = 0; + } + } + return resultProcess; + }); + row.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (row.currentContext) { + context = row.currentContext; + } else { + context = row.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + row.canvasSave(context); + (renders.mem as MemRender).renderMainThread( + { + context: context, + useCache: useCache, + type: `mem ${mem.trackId} ${mem.trackName}`, + }, + row + ); + row.canvasRestore(context, this.trace); + }; + if (this.renderRow && row.name === 'H:PreferredFrameRate') { + processRow.addChildTraceRowBefore(row, this.renderRow); + } else { + processRow.addChildTraceRow(row); + } + }); + } + + //Async Function + addAsyncFunction(it: { pid: number; processName: string | null }, processRow: TraceRow) { + let asyncFuncList = this.processAsyncFuncMap[it.pid] || []; + let asyncFuncGroup = Utils.groupBy(asyncFuncList, 'funName'); + Reflect.ownKeys(asyncFuncGroup).map((key: any) => { + let asyncFunctions: Array = asyncFuncGroup[key]; + if (asyncFunctions.length > 0) { + let isIntersect = (a: any, b: any): boolean => + Math.max(a.startTs + a.dur, b.startTs + b.dur) - Math.min(a.startTs, b.startTs) < a.dur + b.dur; + let depthArray: any = []; + asyncFunctions.forEach((it, i) => { + if (it.dur === -1 || it.dur === null || it.dur === undefined) { + it.dur = (TraceRow.range?.endNS || 0) - it.startTs; + it.flag = 'Did not end'; + } + let currentDepth = 0; + let index = i; + while ( + depthArray[currentDepth] !== undefined && + isIntersect(depthArray[currentDepth], asyncFunctions[index]) + ) { + currentDepth++; + } + asyncFunctions[index].depth = currentDepth; + depthArray[currentDepth] = asyncFunctions[index]; + }); + let max = Math.max(...asyncFunctions.map((it) => it.depth || 0)) + 1; + let maxHeight = max * 20; + let funcRow = TraceRow.skeleton(); + funcRow.rowId = `${asyncFunctions[0].funName}-${it.pid}`; + funcRow.asyncFuncName = asyncFunctions[0].funName; + funcRow.asyncFuncNamePID = it.pid; + funcRow.rowType = TraceRow.ROW_TYPE_FUNC; + funcRow.enableCollapseChart(); //允许折叠泳道图 + funcRow.rowParentId = `${it.pid}`; + funcRow.rowHidden = !processRow.expansion; + funcRow.style.width = '100%'; + funcRow.style.height = `${maxHeight}px`; + funcRow.setAttribute('height', `${maxHeight}`); + funcRow.name = `${asyncFunctions[0].funName}`; + funcRow.setAttribute('children', ''); + funcRow.findHoverStruct = (): void => { + FuncStruct.hoverFuncStruct = funcRow.getHoverStruct(); + } + funcRow.supplier = (): Promise => new Promise((resolve) => resolve(asyncFunctions)); + funcRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; + funcRow.selectChangeHandler = this.trace.selectChangeHandler; + funcRow.onThreadHandler = (cacheFlag): void => { + let context: CanvasRenderingContext2D; + if (funcRow.currentContext) { + context = funcRow.currentContext; + } else { + context = funcRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + funcRow.canvasSave(context); + (renders.func as FuncRender).renderMainThread( + { + context: context, + useCache: cacheFlag, + type: `func-${asyncFunctions[0].funName}-${it.pid}`, + }, + funcRow + ); + funcRow.canvasRestore(context, this.trace); + }; + processRow.addChildTraceRow(funcRow); + } + }); + } } diff --git a/ide/src/trace/component/chart/SpSampleChart.ts b/ide/src/trace/component/chart/SpSampleChart.ts new file mode 100644 index 0000000000000000000000000000000000000000..463f9e63c6b8c9a6d1ee5fc8a7c2260e87420c32 --- /dev/null +++ b/ide/src/trace/component/chart/SpSampleChart.ts @@ -0,0 +1,313 @@ +/* + * 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 { SpSystemTrace } from '../SpSystemTrace'; +import { TraceRow } from '../trace/base/TraceRow'; +import { renders } from '../../database/ui-worker/ProcedureWorker'; +import { SampleStruct, SampleRender } from '../../database/ui-worker/ProcedureWorkerSample'; +import { queryStartTime } from '../../database/sql/SqlLite.sql'; + +export class SpSampleChart { + private trace: SpSystemTrace; + + constructor(trace: SpSystemTrace) { + this.trace = trace; + } + + async init(file: File | null) { + if (!file) { + let startTime = await queryStartTime(); + let folder = await this.initSample(startTime[0].start_ts, file); + this.trace.rowsEL?.appendChild(folder); + } else { + let folder = await this.initSample(-1, file); + this.trace.rowsEL?.appendChild(folder); + } + } + + async initSample(start_ts: number, file: any): Promise> { + let traceRow = TraceRow.skeleton(); + traceRow.rowId = 'Sample'; + traceRow.index = 0; + traceRow.rowType = TraceRow.ROW_TYPE_SAMPLE; + traceRow.rowParentId = ''; + traceRow.folder = false; + traceRow.style.height = '40px'; + traceRow.name = 'Sample'; + traceRow.selectChangeHandler = this.trace.selectChangeHandler; + traceRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; + traceRow.findHoverStruct = () => { + SampleStruct.hoverSampleStruct = traceRow.getHoverStruct(); + }; + //添加上传按钮 + traceRow.addRowSampleUpload(); + this.addTraceRowEventListener(traceRow, start_ts); + //单独上传 + if (file) { + this.getJsonData(file).then((res: any) => { + const propertyData = res.data; + const treeNodes = res.relation.children || [res.relation.RS.children[0]]; + const uniqueProperty = this.removeDuplicates(propertyData); + const flattenTreeArray = this.getFlattenTreeData(treeNodes); + const height = (Math.max(...flattenTreeArray.map((obj: any) => obj.depth)) + 1) * 20; + const sampleProperty = this.setRelationDataProperty(flattenTreeArray, uniqueProperty); + const startTS = flattenTreeArray[0].property[0].begin; + traceRow.supplier = () => + new Promise((resolve): void => { + resolve(sampleProperty) + }) + traceRow.onThreadHandler = (useCache) => { + let context: CanvasRenderingContext2D; + if (traceRow.currentContext) { + context = traceRow.currentContext; + } else { + context = traceRow.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + traceRow.canvasSave(context); + (renders.sample as SampleRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'sample', + start_ts: startTS, + uniqueProperty: uniqueProperty, + flattenTreeArray: flattenTreeArray + }, + traceRow + ); + traceRow.canvasRestore(context) + }; + traceRow.style.height = `${ height }px`; + }) + } + return traceRow; + } + + /** + * 监听文件上传事件 + * @param row + * @param start_ts + */ + addTraceRowEventListener(row: TraceRow, start_ts: number) { + row.uploadEl?.addEventListener('sample-file-change', (e: any) => { + this.resetChartData(row); + this.getJsonData(e).then((res: any) => { + const propertyData = res.data; + const treeNodes = res.relation.children || [res.relation.RS.children[0]]; + const uniqueProperty = this.removeDuplicates(propertyData); + const flattenTreeArray = this.getFlattenTreeData(treeNodes); + const height = (Math.max(...flattenTreeArray.map((obj: any) => obj.depth)) + 1) * 20; + const sampleProperty = this.setRelationDataProperty(flattenTreeArray, uniqueProperty); + const startTS = start_ts > 0 ? start_ts : flattenTreeArray[0].property[0].begin; + row.supplier = () => + new Promise((resolve): void => { + resolve(sampleProperty) + }) + row.onThreadHandler = (useCache) => { + let context: CanvasRenderingContext2D; + if (row.currentContext) { + context = row.currentContext; + } else { + context = row.collect ? this.trace.canvasFavoritePanelCtx! : this.trace.canvasPanelCtx!; + } + row.canvasSave(context); + (renders.sample as SampleRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'sample', + start_ts: startTS, + uniqueProperty: uniqueProperty, + flattenTreeArray: flattenTreeArray + }, + row + ); + row.canvasRestore(context) + }; + row.style.height = `${ height }px`; + }) + }) + } + + /** + * 清空缓存 + * @param row + */ + resetChartData(row: TraceRow) { + row.dataList = []; + row.dataList2 = []; + row.dataListCache = []; + row.isComplete = false; + } + + /** + * 获取上传的文件内容 转为json格式 + * @param file + * @returns + */ + getJsonData(file: any): Promise { + return new Promise((resolve, reject) => { + let reader = new FileReader(); + reader.readAsText(file.detail || file); + reader.onloadend = (e: any) => { + const fileContent = e.target?.result; + try { + resolve(JSON.parse(fileContent)); + document.dispatchEvent( + new CustomEvent('file-correct') + ) + } catch (error) { + document.dispatchEvent( + new CustomEvent('file-error') + ) + } + } + }) + } + + /** + * 树结构扁平化 + * @param treeData + * @param depth + * @param parentName + * @returns + */ + getFlattenTreeData(treeData: Array, depth: number = 0, parentName: string = ''): Array { + let result: Array = []; + treeData.forEach(node => { + const name: string = node['function_name']; + const newNode: any = {}; + if (name.indexOf('unknown') > -1) { + newNode['children'] = this.getUnknownAllChildrenNames(node); + } + newNode['detail'] = node['detail']; + newNode['depth'] = depth; + newNode['name'] = name; + newNode['parentName'] = parentName; + newNode['property'] = []; + result.push(newNode); + if (node.children) { + result = result.concat(this.getFlattenTreeData(node.children, depth + 1, node['function_name'])) + } + }) + return result + } + + /** + * 查找重复项 + * @param propertyData + * @returns + */ + removeDuplicates(propertyData: Array): Array { + const result: Array = []; + propertyData.forEach(propertyGroup => { + const groups: Array = []; + propertyGroup.forEach((property: any) => { + const duplicateObj = groups.find(group => group['func_name'] === property['func_name']); + if (duplicateObj) { + duplicateObj['begin'] = Math.min(duplicateObj['begin'], property['begin']); + duplicateObj['end'] = Math.max(duplicateObj['end'], property['end']); + } else { + groups.push(property) + } + }) + result.push(groups); + }) + return result + } + + /** + * 关系树赋值 + * @param relationData + * @param propertyData + */ + setRelationDataProperty(relationData: Array, propertyData: Array): Array { + const sampleProperty = relationData; + //数组每一项进行比对 + propertyData.forEach(propertyGroup => { + propertyGroup.forEach((property: any) => { + const relation = sampleProperty.find(relation => relation['name'] === property['func_name']); + //property属性存储每帧数据 + relation?.property.push({ + name: property['func_name'], + detail: relation['detail'], + end: property['end'], + begin: property['begin'], + depth: relation['depth'], + instructions: property['instructions'], + cycles: property['cycles'] + }) + }) + }) + + //获取所有名字为unknown的数据 + const unknownRelation = sampleProperty.filter(relation => relation['name'].indexOf('unknown') > -1); + //二维数组 用于存放unknown下所有子节点的数据 + let twoDimensionalArray: Array = []; + let result: Array = []; + unknownRelation.forEach(unknownItem => { + result = []; + twoDimensionalArray = []; + const children = unknownItem['children']; + //先获取到unknwon节点下每个子节点的property + Object.keys(children).forEach(key => { + unknownItem.children[key] = (sampleProperty.find(relation => relation['name'] === key)).property; + }) + //将每个子节点的property加到二维数组中 + Object.values(children).forEach((value: any) => { + if (value.length > 0) { + twoDimensionalArray.push(value) + } + }) + if (twoDimensionalArray.length > 0) { + //取每列的最大值和最小值 + for (let i = 0; i < twoDimensionalArray[0].length; i++) { + const data = { + name: unknownItem['name'], + detail: unknownItem['detail'], + begin: (twoDimensionalArray[0][i]).begin, + end: 0, + depth: unknownItem['depth'] + } + for (let j = 0; j < twoDimensionalArray.length; j++) { + data['end'] = Math.max((twoDimensionalArray[j][i])['end'], data['end']); + data['begin'] = Math.min((twoDimensionalArray[j][i])['begin'], data['begin']); + } + result.push(data); + } + unknownItem.property = result; + } + }) + return sampleProperty; + } + + /** + * 获取unknown节点下所有孩子节点的名称 + * @param node + * @param names + */ + getUnknownAllChildrenNames(node: any, names: any = {}): object { + if (node['children']) { + node['children'].forEach((child: any) => { + if (child['function_name'].indexOf('unknown') < 0) { + names[child['function_name']] = [] + } else { + this.getUnknownAllChildrenNames(child, names) + } + }) + } + return names + } +} diff --git a/ide/src/trace/component/chart/SpSegmentationChart.ts b/ide/src/trace/component/chart/SpSegmentationChart.ts new file mode 100644 index 0000000000000000000000000000000000000000..311651cf7f0a8084d27794f2d0c103dd2d529c9d --- /dev/null +++ b/ide/src/trace/component/chart/SpSegmentationChart.ts @@ -0,0 +1,577 @@ + +/* + * 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 { type SpSystemTrace } from '../SpSystemTrace'; +import { TraceRow } from '../trace/base/TraceRow'; +import { renders } from '../../database/ui-worker/ProcedureWorker'; +import { type EmptyRender } from '../../database/ui-worker/cpu/ProcedureWorkerCPU'; +import { type FreqExtendRender, CpuFreqExtendStruct } from '../../database/ui-worker/ProcedureWorkerFreqExtend'; +import { type BinderRender, BinderStruct } from '../../database/ui-worker/procedureWorkerBinder'; +import { queryIrqList } from '../../database/sql/Irq.sql'; +import { type BaseStruct } from '../../bean/BaseStruct'; +import { type ThreadRender, ThreadStruct } from '../../database/ui-worker/ProcedureWorkerThread'; +import { StateGroup } from '../../bean/StateModle'; +const UNIT_HEIGHT: number = 20; +const MS_TO_US: number = 1000000; +const MIN_HEIGHT: number = 2; +export class SpSegmentationChart { + static trace: SpSystemTrace; + static cpuRow: TraceRow | undefined; + static GpuRow: TraceRow | undefined; + static binderRow: TraceRow | undefined; + static schedRow: TraceRow | undefined; + static freqInfoMapData = new Map>(); + private rowFolder!: TraceRow; + static chartData: Array = []; + static statesRow: TraceRow | undefined; + // 数据切割联动 + static setChartData(type: string, data: Array): void { + if (type === 'CPU-FREQ') { + setCpuData(data); + } else if (type === 'GPU-FREQ') { + setGpuData(data); + } else { + setSchedData(data); + } + SpSegmentationChart.trace.refreshCanvas(false); + } + + // state泳道联动 + static setStateChartData(data: Array) { + let stateChartData = new Array(); + stateChartData = data.map(v => { + return { + dur: v.dur, + pid: v.pid, + tid: v.tid, + end_ts: v.ts + v.dur!, + id: v.id, + name: 'all-state', + startTime: v.ts, + start_ts: v.ts, + state: v.state, + type: v.type, + cpu: v.cpu, + cycle: v.cycle, + }; + }); + SpSegmentationChart.statesRow!.dataList = []; + SpSegmentationChart.statesRow!.dataListCache = []; + SpSegmentationChart.statesRow!.isComplete = false; + // @ts-ignore + SpSegmentationChart.statesRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve(stateChartData)); + SpSegmentationChart.trace.refreshCanvas(false); + }; + + // binder联动调用 + static setBinderChartData(data: Array>): void { + BinderStruct.maxHeight = 0; + SpSegmentationChart.binderRow!.dataList = []; + SpSegmentationChart.binderRow!.dataListCache = []; + SpSegmentationChart.binderRow!.isComplete = false; + if (data.length === 0) { + SpSegmentationChart.binderRow!.style.height = `40px`; + // @ts-ignore + SpSegmentationChart.binderRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + } else { + let binderList: Array = []; + let chartData: Array = []; + setBinderData(data, binderList); + chartData = binderList.map((v: FreqChartDataStruct) => { + return { + cpu: + v.name === 'binder transaction' + ? 0 + : v.name === 'binder transaction async' + ? 1 + : v.name === 'binder reply' + ? MS_TO_US + : 3, + startNS: v.startNS, + dur: v.dur, + name: `${v.name}`, + value: v.value, + depth: v.depth, + cycle: v.cycle, + }; + }); + SpSegmentationChart.binderRow!.style.height = `${BinderStruct.maxHeight > MIN_HEIGHT ? BinderStruct.maxHeight * UNIT_HEIGHT + UNIT_HEIGHT : 40}px`; + // @ts-ignore + SpSegmentationChart.binderRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve(chartData)); + } + + SpSegmentationChart.trace.refreshCanvas(false); + } + // 悬浮联动 + static tabHover(type: string, tableIsHover: boolean = false, cycle: number = -1): void { + CpuFreqExtendStruct.isTabHover = tableIsHover; + if (type === 'CPU-FREQ' || type === 'GPU-FREQ' || type === 'SCHED-SWITCH') { + CpuFreqExtendStruct.hoverType = type + if (tableIsHover) { + if (type === 'CPU-FREQ') { + CpuFreqExtendStruct.cpuCycle = cycle; + SpSegmentationChart.cpuRow!.isHover = false; + CpuFreqExtendStruct.gpuCycle = -1; + CpuFreqExtendStruct.schedCycle = -1; + } else if (type === 'GPU-FREQ') { + CpuFreqExtendStruct.gpuCycle = cycle; + SpSegmentationChart.GpuRow!.isHover = false; + CpuFreqExtendStruct.cpuCycle = -1; + CpuFreqExtendStruct.schedCycle = -1; + } else { + CpuFreqExtendStruct.schedCycle = cycle; + SpSegmentationChart.schedRow!.isHover = false; + CpuFreqExtendStruct.gpuCycle = -1; + CpuFreqExtendStruct.cpuCycle = -1; + } + } else { + if (type === 'CPU-FREQ') { + CpuFreqExtendStruct.cpuCycle = -1; + } else if (type === 'GPU-FREQ') { + CpuFreqExtendStruct.gpuCycle = -1; + } else { + CpuFreqExtendStruct.schedCycle = -1; + } + CpuFreqExtendStruct.hoverCpuFreqStruct = undefined; + } + } else if (type === 'BINDER') { + if (tableIsHover) { + BinderStruct.hoverCycle = cycle; + } else { + BinderStruct.hoverCycle = -1; + } + } + SpSegmentationChart.trace.refreshCanvas(true, 'flagChange'); + } + constructor(trace: SpSystemTrace) { + SpSegmentationChart.trace = trace; + } + async init() { + await this.initFolder(); + await this.initCpuFreq(); + await this.initGpuTrace(); + await this.initSchedTrace(); + await this.initAllStates(); + await this.initBinderTrace(); + } + async initFolder() { + let row = TraceRow.skeleton(); + row.setAttribute('disabled-check', ''); + row.rowId = 'segmentation'; + row.index = 0; + row.rowType = TraceRow.ROW_TYPE_SPSEGNENTATION; + row.rowParentId = ''; + row.folder = true; + row.style.height = '40px'; + row.name = 'Segmentation'; + row.supplier = (): Promise> => new Promise>((resolve) => resolve([])); + row.onThreadHandler = (useCache): void => { + row.canvasSave(SpSegmentationChart.trace.canvasPanelCtx!); + if (row.expansion) { + SpSegmentationChart.trace.canvasPanelCtx?.clearRect(0, 0, row.frame.width, row.frame.height); + } else { + (renders['empty'] as EmptyRender).renderMainThread( + { + context: SpSegmentationChart.trace.canvasPanelCtx, + useCache: useCache, + type: '', + }, + row + ); + } + row.canvasRestore(SpSegmentationChart.trace.canvasPanelCtx!); + }; + this.rowFolder = row; + SpSegmentationChart.trace.rowsEL?.appendChild(row); + } + async initCpuFreq() { + // json文件泳道 + SpSegmentationChart.cpuRow = TraceRow.skeleton(); + SpSegmentationChart.cpuRow.rowId = 'cpu-freq'; + SpSegmentationChart.cpuRow.rowType = TraceRow.ROW_TYPE_CPU_COMPUTILITY; + SpSegmentationChart.cpuRow.rowParentId = ''; + SpSegmentationChart.cpuRow.style.height = '40px'; + SpSegmentationChart.cpuRow.name = 'Cpu Computility'; + SpSegmentationChart.cpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; + SpSegmentationChart.cpuRow.addRowCheckFilePop(); + SpSegmentationChart.cpuRow.rowSetting = 'checkFile'; + // 拿到了用户传递的数据 + SpSegmentationChart.cpuRow.onRowCheckFileChangeHandler = (e: string | ArrayBuffer | null): void => { + // @ts-ignore + let chartData = JSON.parse(e); + let mapData = new Map(); + // @ts-ignore + chartData.map((v) => { + for (let key in v.freqInfo) { + mapData.set(Number(key), Number(v.freqInfo[key])); + } + SpSegmentationChart.freqInfoMapData.set(v.cpuId, mapData); + mapData = new Map(); + }); + }; + SpSegmentationChart.cpuRow.focusHandler = (ev): void => { + SpSegmentationChart.trace?.displayTip( + SpSegmentationChart.cpuRow!, + CpuFreqExtendStruct.hoverCpuFreqStruct, + `${CpuFreqExtendStruct.hoverCpuFreqStruct === undefined ? 0 : CpuFreqExtendStruct.hoverCpuFreqStruct.value! + }` + ); + }; + SpSegmentationChart.cpuRow.findHoverStruct = (): void => { + CpuFreqExtendStruct.hoverCpuFreqStruct = SpSegmentationChart.cpuRow!.getHoverStruct(); + }; + // @ts-ignore + SpSegmentationChart.cpuRow.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + SpSegmentationChart.cpuRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (SpSegmentationChart.cpuRow!.currentContext) { + context = SpSegmentationChart.cpuRow!.currentContext; + } else { + context = SpSegmentationChart.cpuRow!.collect + ? SpSegmentationChart.trace.canvasFavoritePanelCtx! + : SpSegmentationChart.trace.canvasPanelCtx!; + } + SpSegmentationChart.cpuRow!.canvasSave(context); + (renders['freq-extend'] as FreqExtendRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'CPU-FREQ', + }, + SpSegmentationChart.cpuRow! + ); + SpSegmentationChart.cpuRow!.canvasRestore(context); + }; + SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.cpuRow); + this.rowFolder!.addChildTraceRow(SpSegmentationChart.cpuRow); + } + async initGpuTrace() { + SpSegmentationChart.GpuRow = TraceRow.skeleton(); + SpSegmentationChart.GpuRow.rowId = 'gpurow'; + SpSegmentationChart.GpuRow.rowType = TraceRow.ROW_TYPE_GPU_COMPUTILITY; + SpSegmentationChart.GpuRow.rowParentId = ''; + SpSegmentationChart.GpuRow.style.height = '40px'; + SpSegmentationChart.GpuRow.name = 'Gpu Computility'; + SpSegmentationChart.GpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; + SpSegmentationChart.GpuRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; + // @ts-ignore + SpSegmentationChart.GpuRow.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + SpSegmentationChart.GpuRow.focusHandler = (ev): void => { + SpSegmentationChart.trace?.displayTip( + SpSegmentationChart.GpuRow!, + CpuFreqExtendStruct.hoverCpuFreqStruct, + `${CpuFreqExtendStruct.hoverCpuFreqStruct === undefined ? 0 : CpuFreqExtendStruct.hoverCpuFreqStruct.value! + }` + ); + }; + SpSegmentationChart.GpuRow.findHoverStruct = (): void => { + CpuFreqExtendStruct.hoverCpuFreqStruct = SpSegmentationChart.GpuRow!.getHoverStruct(); + }; + SpSegmentationChart.GpuRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (SpSegmentationChart.GpuRow!.currentContext) { + context = SpSegmentationChart.GpuRow!.currentContext; + } else { + context = SpSegmentationChart.GpuRow!.collect + ? SpSegmentationChart.trace.canvasFavoritePanelCtx! + : SpSegmentationChart.trace.canvasPanelCtx!; + } + SpSegmentationChart.GpuRow!.canvasSave(context); + (renders['freq-extend'] as FreqExtendRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'GPU-FREQ', + }, + SpSegmentationChart.GpuRow! + ); + SpSegmentationChart.GpuRow!.canvasRestore(context); + }; + SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.GpuRow); + this.rowFolder!.addChildTraceRow(SpSegmentationChart.GpuRow); + } + async initSchedTrace() { + SpSegmentationChart.schedRow = TraceRow.skeleton(); + SpSegmentationChart.schedRow.rowId = 'sched_switch Count'; + SpSegmentationChart.schedRow.rowType = TraceRow.ROW_TYPE_SCHED_SWITCH; + SpSegmentationChart.schedRow.rowParentId = ''; + SpSegmentationChart.schedRow.style.height = '40px'; + SpSegmentationChart.schedRow.name = 'Sched_switch Count'; + SpSegmentationChart.schedRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; + SpSegmentationChart.schedRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; + SpSegmentationChart.schedRow.focusHandler = (ev): void => { + SpSegmentationChart.trace?.displayTip( + SpSegmentationChart.schedRow!, + CpuFreqExtendStruct.hoverCpuFreqStruct, + `${CpuFreqExtendStruct.hoverCpuFreqStruct?.value!}` + ); + }; + SpSegmentationChart.schedRow.findHoverStruct = (): void => { + CpuFreqExtendStruct.hoverCpuFreqStruct = SpSegmentationChart.schedRow!.getHoverStruct(); + }; + // @ts-ignore + SpSegmentationChart.schedRow.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + SpSegmentationChart.schedRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (SpSegmentationChart.schedRow!.currentContext) { + context = SpSegmentationChart.schedRow!.currentContext; + } else { + context = SpSegmentationChart.schedRow!.collect + ? SpSegmentationChart.trace.canvasFavoritePanelCtx! + : SpSegmentationChart.trace.canvasPanelCtx!; + } + SpSegmentationChart.schedRow!.canvasSave(context); + (renders['freq-extend'] as FreqExtendRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'SCHED-SWITCH', + }, + SpSegmentationChart.schedRow! + ); + SpSegmentationChart.schedRow!.canvasRestore(context); + }; + SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.schedRow); + this.rowFolder!.addChildTraceRow(SpSegmentationChart.schedRow); + } + + async initAllStates() { + SpSegmentationChart.statesRow = TraceRow.skeleton(); + SpSegmentationChart.statesRow.rowId = `statesrow`; + SpSegmentationChart.statesRow.rowType = TraceRow.ROW_TYPE_THREAD; + SpSegmentationChart.statesRow.rowParentId = ''; + SpSegmentationChart.statesRow.style.height = '30px'; + SpSegmentationChart.statesRow.name = `All States`; + SpSegmentationChart.statesRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; + SpSegmentationChart.statesRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; + // @ts-ignore + SpSegmentationChart.statesRow.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + SpSegmentationChart.statesRow.onThreadHandler = (useCache) => { + let context: CanvasRenderingContext2D; + if (SpSegmentationChart.statesRow!.currentContext) { + context = SpSegmentationChart.statesRow!.currentContext; + } else { + context = SpSegmentationChart.statesRow!.collect ? SpSegmentationChart.trace.canvasFavoritePanelCtx! : SpSegmentationChart.trace.canvasPanelCtx!; + } + SpSegmentationChart.statesRow!.canvasSave(context); + (renders['thread'] as ThreadRender).renderMainThread( + { + context: context, + useCache: useCache, + type: ``, + translateY: SpSegmentationChart.statesRow!.translateY, + }, + SpSegmentationChart.statesRow! + ); + SpSegmentationChart.statesRow!.canvasRestore(context); + }; + SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.statesRow); + this.rowFolder!.addChildTraceRow(SpSegmentationChart.statesRow); + } + + async initBinderTrace() { + SpSegmentationChart.binderRow = TraceRow.skeleton(); + SpSegmentationChart.binderRow.rowId = 'binderrow'; + SpSegmentationChart.binderRow.rowType = TraceRow.ROW_TYPE_BINDER_COUNT; + SpSegmentationChart.binderRow.rowParentId = ''; + SpSegmentationChart.binderRow.name = 'Binder Count'; + SpSegmentationChart.binderRow.style.height = '40px'; + SpSegmentationChart.binderRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; + SpSegmentationChart.binderRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; + SpSegmentationChart.binderRow.findHoverStruct = () => { + BinderStruct.hoverCpuFreqStruct = SpSegmentationChart.binderRow!.dataListCache.find((v: BinderStruct) => { + if (SpSegmentationChart.binderRow!.isHover) { + if (v.frame!.x < SpSegmentationChart.binderRow!.hoverX + && v.frame!.x + v.frame!.width > SpSegmentationChart.binderRow!.hoverX + && (BinderStruct.maxHeight * 20 - v.depth * 20 + 20) < SpSegmentationChart.binderRow!.hoverY + && BinderStruct.maxHeight * 20 - v.depth * 20 + v.value * 20 + 20 > SpSegmentationChart.binderRow!.hoverY) { + return v; + } + } + }) + }; + SpSegmentationChart.binderRow.supplier = (): Promise> => + new Promise>((resolve) => resolve([])); + SpSegmentationChart.binderRow.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (SpSegmentationChart.binderRow!.currentContext) { + context = SpSegmentationChart.binderRow!.currentContext; + } else { + context = SpSegmentationChart.binderRow!.collect + ? SpSegmentationChart.trace.canvasFavoritePanelCtx! + : SpSegmentationChart.trace.canvasPanelCtx!; + } + SpSegmentationChart.binderRow!.canvasSave(context); + (renders.binder as BinderRender).renderMainThread( + { + context: context, + useCache: useCache, + type: 'binder', + }, + SpSegmentationChart.binderRow! + ); + SpSegmentationChart.binderRow!.canvasRestore(context); + }; + SpSegmentationChart.binderRow.focusHandler = (ev): void => { + SpSegmentationChart.trace!.displayTip( + SpSegmentationChart.binderRow!, + BinderStruct.hoverCpuFreqStruct, + `Cycle: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.cycle : 0 + }
        + Name: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.name : '' + }
        + Count: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.value : 0 + }` + ); + }; + SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.binderRow); + this.rowFolder!.addChildTraceRow(SpSegmentationChart.binderRow); + } +} +class FreqChartDataStruct { + colorIndex?: number = 0; + dur: number = 0; + value: number = 0; + startNS: number = 0; + cycle: number = 0; + depth?: number = 1; + name?: string = ''; +} + +function setCpuData(data: Array) { + let currentMaxValue = 0; + data.map((v: FreqChartDataStruct) => { + if (v.value > currentMaxValue) { + currentMaxValue = v.value; + } + }); + CpuFreqExtendStruct.hoverType = 'CPU-FREQ'; + CpuFreqExtendStruct.cpuMaxValue = currentMaxValue; + SpSegmentationChart.cpuRow!.dataList = []; + SpSegmentationChart.cpuRow!.dataListCache = []; + SpSegmentationChart.cpuRow!.isComplete = false; + // @ts-ignore + SpSegmentationChart.cpuRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve(data)); +} +function setGpuData(data: Array): void { + let currentMaxValue = 0; + data.map((v: FreqChartDataStruct) => { + if (v.value && v.value > currentMaxValue!) { + currentMaxValue = v.value; + } + }); + CpuFreqExtendStruct.hoverType = 'GPU-FREQ'; + CpuFreqExtendStruct.gpuMaxValue = currentMaxValue; + SpSegmentationChart.GpuRow!.dataList = []; + SpSegmentationChart.GpuRow!.dataListCache = []; + SpSegmentationChart.GpuRow!.isComplete = false; + // @ts-ignore + SpSegmentationChart.GpuRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve(data)); +} +function setSchedData(data: Array): void { + let currentMaxValue = 0; + data.map((v: FreqChartDataStruct) => { + if (v.value && v.value > currentMaxValue!) { + currentMaxValue = v.value; + } + }); + CpuFreqExtendStruct.hoverType = 'SCHED-SWITCH'; + CpuFreqExtendStruct.schedMaxValue = currentMaxValue!; + SpSegmentationChart.schedRow!.dataList = []; + SpSegmentationChart.schedRow!.dataListCache = []; + SpSegmentationChart.schedRow!.isComplete = false; + // @ts-ignore + SpSegmentationChart.schedRow!.supplier = (): Promise> => + new Promise>((resolve) => resolve(data)); +} +function setBinderData(data: Array>, binderList: Array): void { + data.map((v: Array) => { + // 统计每一竖列的最大count + let listCount = 0; + v.map((t: FreqChartDataStruct) => { + listCount += t.value; + if (t.name === 'binder transaction') { + t.depth = t.value; + } + if (t.name === 'binder transaction async') { + t.depth = + t.value + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + })[0].value + : 0); + } + if (t.name === 'binder reply') { + t.depth = + t.value + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + })[0].value + : 0) + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction async'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction async'; + })[0].value + : 0); + } + if (t.name === 'binder async rcv') { + t.depth = + t.value + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction'; + })[0].value + : 0) + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction async'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder transaction async'; + })[0].value + : 0) + + (v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder reply'; + }).length > 0 + ? v.filter((i: FreqChartDataStruct) => { + return i.name === 'binder reply'; + })[0].value + : 0); + } + binderList.push(t); + }); + BinderStruct.maxHeight = + BinderStruct.maxHeight > listCount ? BinderStruct.maxHeight : JSON.parse(JSON.stringify(listCount)); + listCount = 0; + }); +} diff --git a/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.html.ts b/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.html.ts index 8877f47e47eb6156d02dc18123495e163162c3a6..23562fe01796068b32e23707a1ea2ac625364e5c 100644 --- a/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.html.ts +++ b/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.html.ts @@ -79,7 +79,7 @@ export const TabCpuAnalysisHtml = `
        - + `; \ No newline at end of file diff --git a/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.ts b/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.ts index 56008c3cdeca9c933e651f8e632ef65f0a763f1b..fbea0476612d7ab59c187119e37f0cccdf9a88a8 100644 --- a/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.ts +++ b/ide/src/trace/component/schedulingAnalysis/TabCpuAnalysis.ts @@ -178,7 +178,7 @@ export class TabCpuAnalysis extends BaseElement { if (this.loadingUsage || this.loadingPieData) { return; } - this.drawer!.title = `CPU: ${cpu}`; + this.drawer!.drawerTitle = `CPU: ${cpu}`; this.drawer!.visible = true; this.drawerCpuTabs!.init(cpu, this.schedulingSelect!.value); }); diff --git a/ide/src/trace/component/setting/SpRecordPerf.ts b/ide/src/trace/component/setting/SpRecordPerf.ts index 6a6448d9cc2f8bf395f48c06485b6e5b2d46a7e6..24ff7b8c8d1506cd6baf3d304b514f8e75f2739c 100644 --- a/ide/src/trace/component/setting/SpRecordPerf.ts +++ b/ide/src/trace/component/setting/SpRecordPerf.ts @@ -42,6 +42,7 @@ export class SpRecordPerf extends BaseElement { private frequencySetInput: HTMLInputElement | undefined | null; private recordProcessInput: HTMLInputElement | undefined | null; private offCPUSwitch: LitSwitch | undefined | null; + private kernelChainSwitch: LitSwitch | undefined | null; private callSelect: LitSelect | undefined | null; private sp: SpApplication | undefined; private recordPerfSearch: LitSearch | undefined; @@ -87,6 +88,7 @@ export class SpRecordPerf extends BaseElement { period: 1, isOffCpu: true, noInherit: false, + isKernelChain: true, callStack: 'dwarf', branch: 'none', mmap: 256, @@ -127,6 +129,9 @@ export class SpRecordPerf extends BaseElement { case 'Off CPU': perfConfig.isOffCpu = (value as LitSwitch).checked; break; + case 'Kernel Chain': + perfConfig.isKernelChain = (value as LitSwitch).checked; + break; case 'No Inherit': perfConfig.noInherit = (value as LitSwitch).checked; break; @@ -346,7 +351,7 @@ export class SpRecordPerf extends BaseElement { eventSelectClickHandler = (): void => { let that = this; if (SpRecordTrace.serialNumber === '') { - this.eventSelect?.dataSource(eventSelect,''); + this.eventSelect?.dataSource(eventSelect, ''); } else { if (this.sp!.search) { this.sp!.search = false; @@ -411,6 +416,7 @@ export class SpRecordPerf extends BaseElement { } }; this.offCPUSwitch = this.shadowRoot?.querySelector('lit-switch[title=\'Off CPU\']'); + this.kernelChainSwitch = this.shadowRoot?.querySelector("lit-switch[title='Kernel Chain']"); this.callSelect = this.shadowRoot?.querySelector('lit-select[title=\'Call Stack\']'); this.addOptionButton!.addEventListener('click', () => { if (!this.startSamp) { @@ -488,7 +494,7 @@ type="text" value = ' ${defaultValue} ${config.litSliderStyle.resultUnit}' >< maplitSlider!.sliderStyle = config.litSliderStyle; } - private configTypeByLitSlider(config: any, recordPerfDiv: HTMLDivElement): void{ + private configTypeByLitSlider(config: any, recordPerfDiv: HTMLDivElement): void { let sliderEl = `
        = []; - if (this.rangeTraceRow) { - this.rangeTraceRow.forEach((row) => { - row.docompositionList = []; - }); - docompositionData = []; + //查询render_service数据 + if (this.rangeTraceRow?.length) { + // 如果框选的第一行和最后一行的父节点名称都以render_service开头 if ( - this.rangeTraceRow.length === 1 && - this.rangeTraceRow[0]?.getAttribute('row-type') === 'func' && - this.rangeTraceRow[0]?.getAttribute('name')?.startsWith('render_service') + this.rangeTraceRow[0]!.parentRowEl?.getAttribute('name')?.startsWith('render_service') && + this.rangeTraceRow[this.rangeTraceRow.length - 1].parentRowEl?.getAttribute('name')?.startsWith('render_service') ) { - querySearchRowFuncData( - 'H:RSMainThread::DoComposition', - Number(this.rangeTraceRow[0]?.getAttribute('row-id')), + this.handleFrameRateData(this.rangeTraceRow!, 'render_service', 'H:RSMainThread::DoComposition'); + this.handleFrameRateData(this.rangeTraceRow!, 'RSHardwareThrea', 'H:Repaint'); + this.handleFrameRateData(this.rangeTraceRow!, 'Present', 'H:Waiting for Present Fence'); + } + } + } + this.isMouseDown = false; + } + + // 根据框选行和方法名查询数据 + handleFrameRateData(rowList: Array>, rowName: string, funcName: string): void { + let dataList: Array = []; + for (let i = 0; i < rowList.length; i++) { + if (rowList[i].getAttribute('row-type') === 'func') { + if (rowList[i]?.getAttribute('name')?.startsWith(rowName)) { + queryFuncRowData( + funcName, + Number(rowList[i]?.getAttribute('row-id')), TraceRow.rangeSelectObject!.startNS!, - TraceRow.rangeSelectObject!.endNS! + TraceRow.rangeSelectObject!.endNS!, ).then((res) => { - res.forEach((item) => { - docompositionData.push(item.startTime!); - }); - this.rangeTraceRow![0].docompositionList = docompositionData; + if (res.length >= 2) { + res.forEach((item) => { + dataList.push(item.startTime!); + }); + rowList[i].frameRateList = dataList; + } }); } + if (rowName === 'Present' && rowList[i]?.getAttribute('name')?.startsWith(rowName)) { + this.handlePresentData(rowList[i], funcName); + } + if (dataList.length) { + break; + } } } - this.isMouseDown = false; + } + + // 处理框选时Present Fence线程的数据 + handlePresentData(currentRow: TraceRow, funcName: string): void { + let dataList: Array = []; + fuzzyQueryFuncRowData( + funcName, + Number(currentRow?.getAttribute('row-id')), + TraceRow.rangeSelectObject!.startNS!, + TraceRow.rangeSelectObject!.endNS!, + ).then((res) => { + if (res.length >= 2) { + res.forEach((item) => { + dataList.push(item.endTime!); + }); + currentRow.frameRateList = dataList; + if (currentRow.frameRateList.length >= 2) { + let hitchTimeList: Array = []; + for (let i = 0; i < SpLtpoChart.sendHitchDataArr.length; i++) { + if (SpLtpoChart.sendHitchDataArr[i].startTs! >= dataList[0] + && + SpLtpoChart.sendHitchDataArr[i].startTs! < dataList[dataList.length - 1]) { + hitchTimeList.push(SpLtpoChart.sendHitchDataArr[i].value!); + } else if ( + SpLtpoChart.sendHitchDataArr[i].startTs! >= dataList[dataList.length - 1] + ) { + break; + } + } + currentRow.hitchTimeData = hitchTimeList; + } + } + }); } isDrag(): boolean { @@ -161,7 +214,7 @@ export class RangeSelect { let favoriteLimit = favoriteRect!.top + favoriteRect!.height; this.rangeTraceRow = rows.filter((it) => { let domRect = it.getBoundingClientRect(); - let itRect = {x: domRect.x, y: domRect.y, width: domRect.width, height: domRect.height}; + let itRect = { x: domRect.x, y: domRect.y, width: domRect.width, height: domRect.height }; if (itRect.y < favoriteLimit && !it.collect) { let offset = favoriteLimit - itRect.y; itRect.y = itRect.y + offset; @@ -200,9 +253,12 @@ export class RangeSelect { } }); if (this.rangeTraceRow && this.rangeTraceRow.length) { - this.rangeTraceRow!.forEach((row) => { - row.docompositionList = []; - }); + if (this.rangeTraceRow[0].parentRowEl) { + for (let i = 0; i < this.rangeTraceRow[0].parentRowEl.childrenList.length; i++) { + this.rangeTraceRow[0].parentRowEl.childrenList[i].frameRateList = []; + this.rangeTraceRow[0].parentRowEl.childrenList[i].hitchTimeData = []; + } + } } } @@ -258,7 +314,7 @@ export class RangeSelect { ((TraceRow.rangeSelectObject!.endNS! - TraceRow.range!.startNS) * (this.timerShaftEL?.canvas?.clientWidth || 0)) / (TraceRow.range!.endNS - TraceRow.range!.startNS); - this.mark = {startMark: x1, endMark: x2}; + this.mark = { startMark: x1, endMark: x2 }; let mouseX = ev.pageX - this.rowsPaneEL!.getBoundingClientRect().left - 248; if (mouseX > x1 - 5 && mouseX < x1 + 5) { this.isHover = true; diff --git a/ide/src/trace/component/trace/base/TraceRow.html.ts b/ide/src/trace/component/trace/base/TraceRow.html.ts index 5ef5ba458bdb6be6b0af300f38bfce969aa952b2..4abec2c0053c8843dc876a5723199182c442f4db 100644 --- a/ide/src/trace/component/trace/base/TraceRow.html.ts +++ b/ide/src/trace/component/trace/base/TraceRow.html.ts @@ -118,7 +118,7 @@ export const TraceRowHtml = ` :host([sticky]) { position: sticky; top: 0; - z-index: 1000; + z-index: 1; } :host([expansion]) { background-color: var(--bark-expansion,#0C65D1); @@ -174,12 +174,12 @@ export const TraceRowHtml = ` } :host([collect-type][row-setting='enable']:not([row-type='hiperf-callchart'])) .setting{ position:fixed; - z-index:1003; + z-index:0; left: 473px; } :host([collect-type][row-setting='enable'][row-type='hiperf-callchart'][func-expand='false']) .setting{ position:fixed; - z-index:1003; + z-index:0; left: 473px; } :host(:not([collect-type])) { @@ -243,7 +243,7 @@ export const TraceRowHtml = ` color: #00a3f5; } .lit-check-box{ - margin-right: 15px; + margin-right: 25px; } :host([row-setting='enable'][check-type]) .lit-check-box{ margin-right: 25px; @@ -263,12 +263,18 @@ export const TraceRowHtml = ` :host([row-setting='checkFile']) #myfolder{ color:#4b5766; } + .upload { + position: absolute; + color: var(--dark-icon,#333333); + right: 5px; + margin-top: 4px; + }
        -
        +
        - `; \ No newline at end of file + `; diff --git a/ide/src/trace/component/trace/base/TraceRow.ts b/ide/src/trace/component/trace/base/TraceRow.ts index aea7575819bc1f4298a9cdd87f01a533d45e2a68..95363ab690e815e7a65251f54ddb9953fd651fc6 100644 --- a/ide/src/trace/component/trace/base/TraceRow.ts +++ b/ide/src/trace/component/trace/base/TraceRow.ts @@ -27,7 +27,10 @@ import '../../../../base-ui/tree/LitTree'; import { LitPopover } from '../../../../base-ui/popover/LitPopoverV'; import { info } from '../../../../log/Log'; import { ColorUtils } from './ColorUtils'; -import { drawSelectionRange, isFrameContainPoint } from '../../../database/ui-worker/ProcedureWorkerCommon'; +import { + drawSelectionRange, + isFrameContainPoint +} from '../../../database/ui-worker/ProcedureWorkerCommon'; import { TraceRowConfig } from './TraceRowConfig'; import { type TreeItemData, LitTree } from '../../../../base-ui/tree/LitTree'; import { SpSystemTrace } from '../../SpSystemTrace'; @@ -126,6 +129,7 @@ export class TraceRow extends HTMLElement { static ROW_TYPE_PURGEABLE_TOTAL_VM = 'purgeable-total-vm'; static ROW_TYPE_PURGEABLE_PIN_VM = 'purgeable-pin-vm'; static ROW_TYPE_LOGS = 'logs'; + static ROW_TYPE_SAMPLE = 'sample'; static ROW_TYPE_ALL_APPSTARTUPS = 'all-appstartups'; static FRAME_WIDTH: number = 0; static range: TimeRange | undefined | null; @@ -189,13 +193,18 @@ export class TraceRow extends HTMLElement { public getCacheData: ((arg: any) => Promise> | undefined) | undefined; //实时查询 public loadingFrame: boolean = false; //实时查询,正在查询中 public needRefresh: boolean = true; - _docompositionList: Array | undefined; + _frameRateList: Array | undefined; //存储平均帧率数据 + _hitchTimeData: Array | undefined;//存储hitch time public folderIcon: LitIcon | null | undefined; + private sampleUploadEl: HTMLDivElement | null | undefined; + private jsonFileEl: HTMLInputElement | null | undefined; focusHandler?: (ev: MouseEvent) => void | undefined; findHoverStruct?: () => void | undefined; public funcMaxHeight: number = 0; currentContext: CanvasRenderingContext2D | undefined | null; + static ROW_TYPE_LTPO: string | null | undefined; + static ROW_TYPE_HITCH_TIME: string | null | undefined; constructor( args: { @@ -214,7 +223,7 @@ export class TraceRow extends HTMLElement { ) { super(); this.args = args; - this.attachShadow({ mode: 'open' }).innerHTML = this.initHtml(); + this.attachShadow({mode: 'open'}).innerHTML = this.initHtml(); this.initElements(); } @@ -253,12 +262,25 @@ export class TraceRow extends HTMLElement { 'row-setting-popover-direction', ]; } - get docompositionList(): Array | undefined { - return this._docompositionList; + + get uploadEl() { + return this.sampleUploadEl; + } + + get frameRateList(): Array | undefined { + return this._frameRateList; + } + + set frameRateList(value: Array | undefined) { + this._frameRateList = value; + } + + get hitchTimeData(): Array | undefined { + return this._hitchTimeData; } - set docompositionList(value: Array | undefined) { - this._docompositionList = value; + set hitchTimeData(value: Array | undefined) { + this._hitchTimeData = value; } get funcExpand(): boolean { @@ -268,9 +290,11 @@ export class TraceRow extends HTMLElement { set funcExpand(b: boolean) { this.setAttribute('func-expand', b ? 'true' : 'false'); } + get sticky(): boolean { return this.hasAttribute('sticky'); } + set sticky(fixed: boolean) { if (fixed) { this.setAttribute('sticky', ''); @@ -278,6 +302,7 @@ export class TraceRow extends HTMLElement { this.removeAttribute('sticky'); } } + get hasParentRowEl(): boolean { return this.parentRowEl !== undefined; } @@ -392,6 +417,14 @@ export class TraceRow extends HTMLElement { this.setAttribute('row-parent-id', val || ''); } + get namePrefix(): string | undefined | null { + return this.getAttribute('name-prefix'); + } + + set namePrefix(val) { + this.setAttribute('name-prefix', val || ''); + } + set rowHidden(val: boolean) { let height = 0; if (val) { @@ -528,7 +561,7 @@ export class TraceRow extends HTMLElement { getHoverStruct(strict: boolean = true, offset: boolean = false, maxKey: string | undefined = undefined): T | undefined { if (this.isHover) { if (maxKey) { - let arr = this.dataListCache.filter( + let arr = this.dataListCache.filter( (re) => re.frame && isFrameContainPoint(re.frame, this.hoverX, this.hoverY, strict, offset) ).sort((targetA, targetB) => (targetB as any)[maxKey] - (targetA as any)[maxKey]); return arr[0]; @@ -584,6 +617,33 @@ export class TraceRow extends HTMLElement { } } + addRowSampleUpload(): void { + this.sampleUploadEl = document.createElement('div'); + this.sampleUploadEl!.className = 'upload'; + this.sampleUploadEl!.innerHTML = ` + + + ` + this.jsonFileEl = this.sampleUploadEl!.querySelector('.file') as HTMLInputElement; + this.sampleUploadEl!.addEventListener('change', () => { + let files = this.jsonFileEl!.files; + if (files && files.length > 0) { + this.sampleUploadEl!.dispatchEvent( + new CustomEvent('sample-file-change', { + detail: files[0] + }) + ) + if (this.jsonFileEl) this.jsonFileEl.value = ''; + } + }) + this.sampleUploadEl!.addEventListener('click', (e) => { + e.stopPropagation(); + }) + this.describeEl?.appendChild(this.sampleUploadEl!); + } + addChildTraceRowSpecifyLocation(child: TraceRow, index: number) { TraceRowConfig.allTraceRowList.push(child); child.parentRowEl = this; @@ -604,6 +664,40 @@ export class TraceRow extends HTMLElement { } } + sortRenderServiceData(child: TraceRow, targetRow: TraceRow, threadRowArr: Array>, flag: boolean) { + if (child.rowType === 'thread') { + threadRowArr.push(child); + } else { + let index: number = threadRowArr.indexOf(targetRow); + if (index !== -1) { + threadRowArr.splice(index + 1, 0, child); + } else { + threadRowArr.push(child); + } + } + if (flag) { + let order: string[] = ['VSyncGenerator', 'VSync-rs', 'VSync-app', 'render_service', 'Acquire Fence', 'RSHardwareThrea', 'Present Fence']; + let filterOrderArr: Array> = []; + let filterNotOrderArr: Array> = []; + for (let i = 0; i < threadRowArr.length; i++) { + const element: TraceRow = threadRowArr[i]; + let renderFlag: boolean = element.name.startsWith('render_service') && element.rowId === element.rowParentId ? true : false; + if (renderFlag) { + filterOrderArr.push(element); + } else if (order.includes(element.namePrefix!) && !(element.name.startsWith('render_service'))) { + filterOrderArr.push(element); + } else if (!(order.includes(element.namePrefix!)) || !renderFlag) { + filterNotOrderArr.push(element); + } + } + filterOrderArr.sort((star, next) => { + return order.indexOf(star.namePrefix!) - order.indexOf(next.namePrefix!); + }); + let combinedArr = [...filterOrderArr, ...filterNotOrderArr]; + combinedArr.forEach((item) => { this.addChildTraceRow(item) }) + } + } + set tip(value: string) { if (this.tipEL) { this.tipEL.innerHTML = value; @@ -881,7 +975,7 @@ export class TraceRow extends HTMLElement { initCanvas(list: Array): void { let timerShaftEL = document! - .querySelector('body > sp-application')! + .querySelector('body > sp-application')! .shadowRoot!.querySelector('#sp-system-trace')! .shadowRoot!.querySelector('div > timer-shaft-element'); let timerShaftCanvas = timerShaftEL!.shadowRoot!.querySelector('canvas'); @@ -1089,7 +1183,8 @@ export class TraceRow extends HTMLElement { loadingPin1: number = 0; loadingPin2: number = 0; - static currentActiveRows:Array = []; + static currentActiveRows: Array = []; + drawFrame(): void { if (!this.hasAttribute('row-hidden')) { if (!this.loadingFrame || window.isLastFrame || !this.isComplete) { @@ -1108,16 +1203,16 @@ export class TraceRow extends HTMLElement { this.dataListCache.push(...this.fixedList); this.isComplete = true; this.loadingFrame = false; - let idx = TraceRow.currentActiveRows.findIndex(it=> it === `${ this.rowType }-${ this.rowId }`) - if (idx!=-1){ + let idx = TraceRow.currentActiveRows.findIndex(it => it === `${this.rowType}-${this.rowId}`); + if (idx != -1) { TraceRow.currentActiveRows.splice(idx, 1); } requestAnimationFrame(() => { this.onThreadHandler?.(true, null); - if (TraceRow.currentActiveRows.isEmpty()){ - window.publish(window.SmartEvent.UI.LoadFinish,""); + if (TraceRow.currentActiveRows.isEmpty()) { + window.publish(window.SmartEvent.UI.LoadFinish, ''); } - window.publish(window.SmartEvent.UI.LoadFinishFrame,""); + window.publish(window.SmartEvent.UI.LoadFinishFrame, ''); }); }); } else if (this.fixedList.length > 0 && !this.dataListCache.includes(this.fixedList[0])) { @@ -1127,6 +1222,7 @@ export class TraceRow extends HTMLElement { this.onThreadHandler?.(true, null); } } + draw(useCache: boolean = false) { this.dpr = window.devicePixelRatio || 1; if (this.sleeping) { diff --git a/ide/src/trace/component/trace/base/TraceRowConfig.ts b/ide/src/trace/component/trace/base/TraceRowConfig.ts index 5c0a431c903718fb350acb6b9696feccd65ad37e..9c0bd200f1d81439f4411fed3ce850954caec034 100644 --- a/ide/src/trace/component/trace/base/TraceRowConfig.ts +++ b/ide/src/trace/component/trace/base/TraceRowConfig.ts @@ -383,7 +383,7 @@ export class TraceRowConfig extends BaseElement { clearSearchAndFlag(): void { let traceSheet = this.spSystemTrace!.shadowRoot?.querySelector('.trace-sheet') as TraceSheet; if (traceSheet) { - traceSheet!.setAttribute('mode', 'hidden'); + traceSheet!.setMode('hidden'); } let search = document.querySelector('sp-application')!.shadowRoot?.querySelector('#lit-search') as LitSearch; if (search) { @@ -521,7 +521,6 @@ export class TraceRowConfig extends BaseElement { let subsystemsKey: string = 'subsystems'; if (configJson[subsystemsKey]) { isTrulyJson = true; - window.localStorage.setItem(LOCAL_STORAGE_JSON, text); this.tempString = text; this.openFileIcon!.style.display = 'block'; } @@ -532,7 +531,13 @@ export class TraceRowConfig extends BaseElement { return; } let id = 0; - this.treeNodes = this.buildSubSystemTreeData(id, configJson); + try { + this.treeNodes = this.buildSubSystemTreeData(id, configJson); + } catch (e) { + this.loadTempConfig(window.localStorage.getItem(LOCAL_STORAGE_JSON)!); + return; + } + window.localStorage.setItem(LOCAL_STORAGE_JSON, text); this.buildTempOtherList(id); this.setAttribute('temp_config', ''); this.expandedNodeList.clear(); @@ -558,7 +563,7 @@ export class TraceRowConfig extends BaseElement { } for (let subIndex = 0; subIndex < subsystemsData.length; subIndex++) { let currentSystemData = subsystemsData[subIndex]; - if(!currentSystemData.hasOwnProperty('subsystem')) { + if(!currentSystemData.hasOwnProperty('subsystem') || Array.isArray(currentSystemData.subsystem)) { continue; } let currentSubName = currentSystemData.subsystem; @@ -573,7 +578,7 @@ export class TraceRowConfig extends BaseElement { }; if (subSystems.indexOf(subsystemStruct) < 0) { let currentCompDates = currentSystemData.components; - if (!currentCompDates) { + if (!currentCompDates || !Array.isArray(currentCompDates)) { continue; } for (let compIndex = 0; compIndex < currentCompDates.length; compIndex++) { @@ -595,10 +600,11 @@ export class TraceRowConfig extends BaseElement { }; for (let chartIndex = 0; chartIndex < currentChartDates.length; chartIndex++) { let currentChartDate = currentChartDates[chartIndex]; - if(!currentChartDate.hasOwnProperty('chartName') && !currentChartDate.hasOwnProperty('chartId')) { + if((!currentChartDate.hasOwnProperty('chartName') && !currentChartDate.hasOwnProperty('chartId')) + || Array.isArray(currentChartDate.chartName)) { continue; } - let currentChartName = currentChartDate.chartName; + let currentChartName = `${ currentChartDate.chartName}`; let currentChartId = currentChartDate.chartId; let findChartNames: Array | undefined = []; let scene: string[] = []; diff --git a/ide/src/trace/component/trace/base/TraceSheet.ts b/ide/src/trace/component/trace/base/TraceSheet.ts index ad608a40a6150792bea7fd8caa215c854ab6d799..8efd91ff0a81e6c156a08a28d6245eeb970b260f 100644 --- a/ide/src/trace/component/trace/base/TraceSheet.ts +++ b/ide/src/trace/component/trace/base/TraceSheet.ts @@ -82,6 +82,9 @@ import { type LitPageTable } from '../../../../base-ui/table/LitPageTable'; import '../../../../base-ui/popover/LitPopoverV'; import { LitPopover } from '../../../../base-ui/popover/LitPopoverV'; import { LitTree, TreeItemData } from '../../../../base-ui/tree/LitTree'; +import { SampleStruct } from '../../../database/ui-worker/ProcedureWorkerSample'; +import { TabPaneSampleInstruction } from '../sheet/sample/TabPaneSampleInstruction'; +import { TabPaneFreqStatesDataCut } from '../sheet/states/TabPaneFreqStatesDataCut'; @element('trace-sheet') export class TraceSheet extends BaseElement { @@ -103,6 +106,8 @@ export class TraceSheet extends BaseElement { private fragment: DocumentFragment | undefined; private lastSelectIPid: number = -1; private lastProcessSet: Set = new Set(); + private optionsDiv: LitPopover | undefined | null; + private optionsSettingTree: LitTree | undefined | null; static get observedAttributes(): string[] { return ['mode']; @@ -126,9 +131,15 @@ export class TraceSheet extends BaseElement { } displayTab(...names: string[]): T { - this.setAttribute('mode', 'max'); - this.showUploadSoBt(null); - this.showSwitchProcessBt(null); + this.setMode('max'); + if (names.includes('box-flag') || names.includes('tabpane-current')) { + this.showUploadSoBt(this.selection); + this.showSwitchProcessBt(this.selection); + } else { + this.showOptionsBt(null); + this.showUploadSoBt(null); + this.showSwitchProcessBt(null); + } this.shadowRoot ?.querySelectorAll('#tabs lit-tabpane') .forEach((it) => (it.hidden = !names.some((k) => k === it.id))); @@ -158,6 +169,18 @@ export class TraceSheet extends BaseElement { this.importDiv = this.shadowRoot?.querySelector('#import_div'); this.switchDiv = this.shadowRoot?.querySelector('#select-process'); this.processTree = this.shadowRoot?.querySelector('#processTree'); + this.optionsDiv = this.shadowRoot?.querySelector('#options'); + this.optionsSettingTree = this.shadowRoot?.querySelector('#optionsSettingTree'); + this.optionsSettingTree!.onChange = (e: any): void => { + const select = this.optionsSettingTree!.getCheckdKeys(); + document.dispatchEvent( + new CustomEvent('sample-popver-change', { + detail: { + select: select[0] + } + }) + ) + } this.processTree!.onChange = (e: any): void => { const select = this.processTree!.getCheckdKeys(); const selectIPid = Number(select[0]); @@ -332,7 +355,9 @@ export class TraceSheet extends BaseElement { let litTabpane: NodeListOf | undefined | null = this.shadowRoot?.querySelectorAll('#tabs > lit-tabpane'); if (tabsPackUp!.name == 'down') { + let beforeHeight = this.clientHeight; this.tabs!.style.height = this.navRoot!.offsetHeight + 'px'; + window.publish(window.SmartEvent.UI.ShowBottomTab, { show: 2 , delta: beforeHeight - this.clientHeight }) litTabpane!.forEach((node: HTMLDivElement) => (node!.style.height = '0px')); tabsPackUp!.name = 'up'; tabsPackUp!.title = 'Reset Tab'; @@ -375,6 +400,9 @@ export class TraceSheet extends BaseElement { that: this, tabsPackUp: LitIcon, borderTop: number): void { let preY = event.pageY; let preHeight = this.tabs!.offsetHeight; + let scrollH = that.rowsPaneEL!.scrollHeight; + let scrollT = that.rowsPaneEL!.scrollTop; + let ch = that.clientHeight; document.onmousemove = function (event): void { let moveY: number = preHeight - (event.pageY - preY); litTabpane!.forEach((node: HTMLDivElement) => { @@ -416,6 +444,10 @@ export class TraceSheet extends BaseElement { tabsPackUp!.name = 'down'; } }); + let currentSH = that.rowsPaneEL!.scrollHeight; + if (currentSH > scrollH && currentSH > that.rowsPaneEL!.scrollTop + that.clientHeight) { + that.rowsPaneEL!.scrollTop = scrollT - (ch - that.clientHeight); + } }; } @@ -505,10 +537,23 @@ export class TraceSheet extends BaseElement { align-items: center; margin-right: 10px; z-index: 2; - } + } + .option { + display: flex; + margin-right: 10px; + cursor: pointer; + }
        +
        + +
        + +
        + +
        +
        @@ -539,7 +584,7 @@ export class TraceSheet extends BaseElement { data: ThreadStruct, scrollCallback: ((e: ThreadStruct) => void) | undefined, scrollWakeUp: (d: any) => void | undefined, - callback: ((data: Array) => void) | undefined = undefined + callback?: ((data: Array, str:string) => void) ) => this.displayTab('current-selection').setThreadData( data, @@ -762,12 +807,27 @@ export class TraceSheet extends BaseElement { } } }; + displaySampleData = (data: SampleStruct, reqProperty: any): void => { + this.displayTab('box-sample-instruction').setSampleInstructionData(data, reqProperty); + this.optionsDiv!.style.display = "flex"; + const select = this.optionsSettingTree!.getCheckdKeys().length === 0 ? ['0'] : this.optionsSettingTree!.getCheckdKeys(); + this.optionsSettingTree!.treeData = [{key: '0', title: 'instruction', checked: select[0] === '0'}, {key: '1', title: 'cycles', checked: select[0] === '1'}]; + } + + displaySystemStatesData = (): void => { + let tblStatesPanel = this.shadowRoot?.querySelector("tabpane-states-datacut"); + if (tblStatesPanel) { + tblStatesPanel.initTabSheetEl(this); + + } + }; rangeSelect(selection: SelectionParam, restore = false): boolean { this.selection = selection; this.exportBt!.style.display = 'flex'; this.showUploadSoBt(selection); this.showSwitchProcessBt(selection); + this.showOptionsBt(selection); Reflect.ownKeys(tabConfig) .reverse() .forEach((id) => { @@ -780,10 +840,10 @@ export class TraceSheet extends BaseElement { if (restore) { if (this.litTabs?.activekey) { this.loadTabPaneData(this.litTabs?.activekey); - this.setAttribute('mode', 'max'); + this.setMode('max'); return true; } else { - this.setAttribute('mode', 'hidden'); + this.setMode('hidden'); return false; } } else { @@ -791,15 +851,25 @@ export class TraceSheet extends BaseElement { if (firstPane) { this.litTabs?.activeByKey(firstPane.key); this.loadTabPaneData(firstPane.key); - this.setAttribute('mode', 'max'); + this.setMode('max'); return true; } else { - this.setAttribute('mode', 'hidden'); + this.setMode('hidden'); return false; } } } + showOptionsBt(selection: SelectionParam | null | undefined): void { + if (selection && selection.sampleData.length > 0) { + this.optionsDiv!.style.display = 'flex'; + const select = this.optionsSettingTree!.getCheckdKeys().length === 0 ? ['0'] : this.optionsSettingTree!.getCheckdKeys(); + this.optionsSettingTree!.treeData = [{key: '0', title: 'instruction', checked: select[0] === '0'}, {key: '1', title: 'cycles', checked: select[0] === '1'}]; + } else { + this.optionsDiv!.style.display = 'none'; + } + } + updateRangeSelect(ipid?: number): boolean { if ( this.selection && @@ -911,6 +981,16 @@ export class TraceSheet extends BaseElement { } } + setMode(mode: string): void { + let delta = this.clientHeight; + let show = mode === 'max' ? 1 : -1; + this.setAttribute('mode', mode); + if (mode === 'hidden') { + this.selection = undefined; + } + window.publish(window.SmartEvent.UI.ShowBottomTab, { show: show , delta: delta}); + } + rowClickHandler(e: any): void { this.currentPaneID = e.target.parentElement.id; this.shadowRoot!.querySelectorAll(`lit-tabpane`).forEach((it) => diff --git a/ide/src/trace/component/trace/base/TraceSheetConfig.ts b/ide/src/trace/component/trace/base/TraceSheetConfig.ts index d4e76e6507fadd9451579fd079a1b5c897e47217..3ee495c3581df1c2dd9fd90bd6acf69deaeb7be5 100644 --- a/ide/src/trace/component/trace/base/TraceSheetConfig.ts +++ b/ide/src/trace/component/trace/base/TraceSheetConfig.ts @@ -121,6 +121,18 @@ import { TabPaneGpuGraph } from '../sheet/gpu/TabPaneGraph'; import { TabPaneFreqUsage } from '../sheet/frequsage/TabPaneFreqUsage'; import { TabPaneHisysEvents } from '../sheet/hisysevent/TabPaneHisysEvents'; import { TabPaneHiSysEventSummary } from '../sheet/hisysevent/TabPaneHiSysEventSummary'; +import { TabPaneFreqDataCut } from '../sheet/frequsage/TabPaneFreqDataCut'; +import { TabPaneSchedSwitch } from '../sheet/schedswitch/TabPaneSchedSwitch'; +import { TabPaneBinderDataCut } from '../sheet/binder/TabPaneBinderDataCut'; +import { TabPaneBinders } from '../sheet/binder/TabPaneBinders'; +import { TabPaneGpufreq } from '../sheet/gpufreq/TabPaneGpufreqUsage'; +import { TabPaneGpufreqDataCut } from '../sheet/gpufreq/TabPaneGpufreqDataCut'; +import { TabPaneFreqStatesDataCut } from '../sheet/states/TabPaneFreqStatesDataCut'; +import { TabPaneSampleInstruction } from '../sheet/sample/TabPaneSampleInstruction'; +import { TabPaneSampleInstructionDistributions } from '../sheet/sample/TabPaneSampleInstructionDistributions'; +import { TabPaneSampleInstructionTotalTime } from '../sheet/sample/TabPaneSampleInstructionSelectionTotalTime'; +import { TabPaneSampleInstructionSelection } from '../sheet/sample/TabPaneSampleInstructionSelection'; + export let tabConfig: any = { 'current-selection': { @@ -170,7 +182,7 @@ export let tabConfig: any = { require: (param: SelectionParam) => param.cpus.length > 0, }, 'box-thread-states': { - title: 'Thread States', + title: 'Thread by State', type: TabPaneThreadStates, require: (param: SelectionParam) => param.threadIds.length > 0, }, @@ -634,6 +646,11 @@ export let tabConfig: any = { type: TabPaneFreqUsage, require: (param: SelectionParam) => param.threadIds.length > 0, }, + 'tabpane-freqdatacut': { + title: 'Freq DataCut', + type: TabPaneFreqDataCut, + require: (param: SelectionParam) => param.threadIds.length > 0, + }, 'tab-hisysevents': { title: 'HiSysevents', type: TabPaneHisysEvents, @@ -644,4 +661,53 @@ export let tabConfig: any = { type: TabPaneHiSysEventSummary, require: (param: SelectionParam) => param.hiSysEvents.length > 0, }, + 'tabpane-schedswitch': { + title: 'Sched Switch', + type: TabPaneSchedSwitch, + require: (param: SelectionParam) => param.threadIds.length > 0, + }, + 'tabpane-binders': { + title: 'Thread Binders', + type: TabPaneBinders, + require: (param: SelectionParam) => param.threadIds.length > 0, + }, + 'tabpane-binder-datacut': { + title: 'Binder DataCut', + type: TabPaneBinderDataCut, + require: (param: SelectionParam) => param.threadIds.length > 0, + }, + 'tabpane-gpufreq': { + title: 'Gpufreq Usage', + type: TabPaneGpufreq, + require: (param: SelectionParam) => param.clockMapData.size === 1 && param.clockMapData.has('gpufreq Frequency') === true, + }, + 'tabpane-freqDataCut': { + title: 'Gpufreq DataCut', + type: TabPaneGpufreqDataCut, + require: (param: SelectionParam) => param.clockMapData.size === 1 && param.clockMapData.has('gpufreq Frequency') === true, + }, + 'tabpane-states-datacut': { + title: 'Freq StatesDataCut', + type: TabPaneFreqStatesDataCut, + require: (param: SelectionParam) => param.threadIds.length > 0, + }, + 'box-sample-instruction-selection': { + title: 'Data Selection', + type: TabPaneSampleInstructionSelection, + require: (param: SelectionParam) => param.sampleData.length > 0 + }, + 'box-sample-instruction-distribution-selection': { + title: 'Data Distribution', + type: TabPaneSampleInstructionDistributions, + require: (param: SelectionParam) => param.sampleData.length > 0 + }, + 'box-sample-instruction-totaltime-selection': { + title: 'Total Duration', + type: TabPaneSampleInstructionTotalTime, + require: (param: SelectionParam) => param.sampleData.length > 0 + }, + 'box-sample-instruction': { + title: 'Data Flow', + type: TabPaneSampleInstruction, + }, }; diff --git a/ide/src/trace/component/trace/base/Utils.ts b/ide/src/trace/component/trace/base/Utils.ts index d085a0a6f9450f3280c65028db2dcbfe5e3848ad..2633a95ee4625644b9ba3e2d8e02f94449fc6cc7 100644 --- a/ide/src/trace/component/trace/base/Utils.ts +++ b/ide/src/trace/component/trace/base/Utils.ts @@ -250,11 +250,11 @@ export class Utils { let gb1 = ((1 << 10) << 10) << 10; // 1 gb let res = ''; if (currentByte > gb1) { - res += (currentByte / gb1).toFixed(2) + ' Gb'; + res += (currentByte / gb1).toFixed(2) + ' GB'; } else if (currentByte > mb1) { - res += (currentByte / mb1).toFixed(2) + ' Mb'; + res += (currentByte / mb1).toFixed(2) + ' MB'; } else if (currentByte > kb1) { - res += (currentByte / kb1).toFixed(2) + ' Kb'; + res += (currentByte / kb1).toFixed(2) + ' KB'; } else { res += Math.round(currentByte) + ' byte'; } diff --git a/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts b/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts index d5775e8250bcdb80e7006fcacfbdfcee5537538e..3d68d17b711ef9007375a82083706724b9695de4 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneCurrent.ts @@ -103,7 +103,7 @@ export class TabPaneCurrent extends BaseElement { } event.stopPropagation(); }, - {capture: true} + { capture: true } ); } @@ -184,9 +184,7 @@ export class TabPaneCurrent extends BaseElement { */ private eventHandler(): void { let tr = this.panelTable!.shadowRoot!.querySelectorAll('.tr') as NodeListOf; - tr[0].querySelector('#text-input')!.disabled = true; this.trClickEvent(tr); - this.panelTableClick(tr); // 第一个tr是移除全部,所以跳过,从第二个tr开始,和this.slicesTimeList数组的第一个对应……,所以i从1开始,在this.slicesTimeList数组中取值时用i-1 for (let i = 1; i < tr.length; i++) { @@ -245,7 +243,7 @@ export class TabPaneCurrent extends BaseElement { ) { this.systemTrace!.slicesList = this.slicesTimeList || []; this.slicesTimeList[i - 1].color = event?.target.value; - document.dispatchEvent(new CustomEvent('slices-change', {detail: this.slicesTimeList[i - 1]})); + document.dispatchEvent(new CustomEvent('slices-change', { detail: this.slicesTimeList[i - 1] })); // 卡尺颜色改变时,重绘泳道图 this.systemTrace?.refreshCanvas(true); } @@ -273,7 +271,7 @@ export class TabPaneCurrent extends BaseElement { let slicesTimeList = [...this.slicesTimeList]; for (let i = 0; i < slicesTimeList.length; i++) { slicesTimeList[i].hidden = true; - document.dispatchEvent(new CustomEvent('slices-change', {detail: slicesTimeList[i]})); + document.dispatchEvent(new CustomEvent('slices-change', { detail: slicesTimeList[i] })); } this.slicesTimeList = []; return; @@ -289,7 +287,7 @@ export class TabPaneCurrent extends BaseElement { ) { this.slicesTimeList[i - 1].hidden = true; this.systemTrace!.slicesList = this.slicesTimeList || []; - document.dispatchEvent(new CustomEvent('slices-change', {detail: this.slicesTimeList[i - 1]})); + document.dispatchEvent(new CustomEvent('slices-change', { detail: this.slicesTimeList[i - 1] })); // 移除时更新表格内容 this.setTableData(); } @@ -297,27 +295,6 @@ export class TabPaneCurrent extends BaseElement { }); } - private panelTableClick(tr: NodeListOf): void { - // 更新备注信息 - this.panelTable!.addEventListener('click', (event: any) => { - if (this.slicesTimeList.length === 0) { - return; - } - for (let i = 1; i < tr.length; i++) { - let inputValue = tr[i].querySelector('#text-input')!.value; - if ( - this.tableDataSource[i].startTime === this.slicesTimeList[i - 1].startTime && - this.tableDataSource[i].endTime === this.slicesTimeList[i - 1].endTime - ) { - this.slicesTimeList[i - 1].text = inputValue; - document.dispatchEvent(new CustomEvent('slices-change', {detail: this.slicesTimeList[i - 1]})); - // 旗子颜色改变时,重绘泳道图 - this.systemTrace?.refreshCanvas(true); - } - } - }); - } - /** * 修改表格指定行数的背景颜色 * @param line 要改变的表格行数 diff --git a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts index 00ac8ac550c93e5ac39bdd73711e9b5b4ff89ac7..0b2943da66952967f511065ba27fba3c9363eef7 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts @@ -109,6 +109,7 @@ export class TabPaneCurrentSelection extends BaseElement { private scrollView: HTMLDivElement | null | undefined; // @ts-ignore private dpr: any = window.devicePixelRatio || window.webkitDevicePixelRatio || window.mozDevicePixelRatio || 1; + private wakeUp: string = ''; set data(currentSelectionValue: any) { if ( @@ -140,15 +141,15 @@ export class TabPaneCurrentSelection extends BaseElement { } if (args.length > 0) { args.forEach((arg) => { - list.push({name: arg.keyName, value: arg.strValue}); + list.push({ name: arg.keyName, value: arg.strValue }); }); } this.currentSelectionTbl!.dataSource = list; let rightArea: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#table-right'); let rightTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightTitle'); let rightButton: HTMLElement | null | undefined = this?.shadowRoot - ?.querySelector('#rightButton') - ?.shadowRoot?.querySelector('#custom-button'); + ?.querySelector('#rightButton') + ?.shadowRoot?.querySelector('#custom-button'); let rightStar: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#right-star'); this.threadClickEvent(scrollCallback, data); let canvas = this.initCanvas(); @@ -183,7 +184,7 @@ export class TabPaneCurrentSelection extends BaseElement { } private updateRightTitleUI(rightArea: HTMLElement, rightTitle: HTMLElement, rightButton: HTMLElement, - rightStar: HTMLElement) { + rightStar: HTMLElement) { if (rightArea !== null && rightArea) { rightArea.style.visibility = 'visible'; } @@ -196,7 +197,7 @@ export class TabPaneCurrentSelection extends BaseElement { } private handleNullBeanUI(rightArea: HTMLElement, rightTitle: HTMLElement, rightButton: HTMLElement, - rightStar: HTMLElement) { + rightStar: HTMLElement) { this.weakUpBean = null; if (rightArea !== null && rightArea) { rightArea.style.visibility = 'hidden'; @@ -240,14 +241,14 @@ export class TabPaneCurrentSelection extends BaseElement {
        `, }); } - list.push({name: 'StartTime(Relative)', value: getTimeString(data.startTime || 0),}); + list.push({ name: 'StartTime(Relative)', value: getTimeString(data.startTime || 0), }); list.push({ name: 'StartTime(Absolute)', value: ((data.startTime || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); - list.push({name: 'Prio', value: data.priority || 0}); - list.push({name: 'End State', value: state}); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); + list.push({ name: 'Prio', value: data.priority || 0 }); + list.push({ name: 'End State', value: state }); } setFunctionData(data: FuncStruct, scrollCallback: Function): void { @@ -268,7 +269,7 @@ export class TabPaneCurrentSelection extends BaseElement { } } else { this.setTableHeight('auto'); - list.push({name: 'Name', value: name}); + list.push({ name: 'Name', value: name }); list.push({ name: 'StartTime(Relative)', value: getTimeString(data.startTs || 0), @@ -281,16 +282,16 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'Duration', value: getTimeString(data.dur || 0), }); - list.push({name: 'depth', value: data.depth}); + list.push({ name: 'depth', value: data.depth }); this.currentSelectionTbl!.dataSource = list; } } private handleNonBinder(data: FuncStruct, list: any[], name: string): void { queryBinderArgsByArgset(data.argsetid!).then((argset) => { - list.push({name: 'Name', value: name}); + list.push({ name: 'Name', value: name }); argset.forEach((item) => { - list.push({name: item.keyName, value: item.strValue}); + list.push({ name: item.keyName, value: item.strValue }); }); this.addTabPanelContent(list, data); this.currentSelectionTbl!.dataSource = list; @@ -311,10 +312,10 @@ export class TabPaneCurrentSelection extends BaseElement {
        `, }); } - list.push({name: item.keyName, value: item.strValue}); + list.push({ name: item.keyName, value: item.strValue }); }); if (binderSliceId === -1) { - list.unshift({name: 'Name', value: name}); + list.unshift({ name: 'Name', value: name }); } this.addTabPanelContent(list, data); this.currentSelectionTbl!.dataSource = list; @@ -361,7 +362,7 @@ export class TabPaneCurrentSelection extends BaseElement {
        `, }); } else { - list.unshift({name: 'Name', value: name}); + list.unshift({ name: 'Name', value: name }); } this.addTabPanelContent(list, data); this.currentSelectionTbl!.dataSource = list; @@ -385,9 +386,9 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'Duration', value: getTimeString(data.dur || 0), }); - contentList.push({name: 'depth', value: data.depth}); + contentList.push({ name: 'depth', value: data.depth }); if (data.argsetid && data.argsetid > -1) { - contentList.push({name: 'arg_set_id', value: data.argsetid}); + contentList.push({ name: 'arg_set_id', value: data.argsetid }); } } @@ -403,8 +404,8 @@ export class TabPaneCurrentSelection extends BaseElement { private setTitleAndButtonStyle(): void { let rightTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightTitle'); let rightButton: HTMLElement | null | undefined = this?.shadowRoot - ?.querySelector('#rightButton') - ?.shadowRoot?.querySelector('#custom-button'); + ?.querySelector('#rightButton') + ?.shadowRoot?.querySelector('#custom-button'); let rightStar: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#right-star'); if (rightTitle) { rightTitle.style.visibility = 'hidden'; @@ -430,7 +431,7 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'Value', value: ColorUtils.formatNumberComma(data.value || 0), }); - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); this.currentSelectionTbl!.dataSource = list; } @@ -451,8 +452,8 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'StartTime(Absolute)', value: ((data.startTime || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Value', value: data.value}); - list.push({name: 'Delta', value: data.delta}); + list.push({ name: 'Value', value: data.value }); + list.push({ name: 'Delta', value: data.delta }); list.push({ name: 'Duration', value: getTimeString(data.duration || 0), @@ -477,12 +478,12 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'StartTime(Absolute)', value: ((data.startNS || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Name', value: data.name}); - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); + list.push({ name: 'Name', value: data.name }); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); queryBinderArgsByArgset(data.argSetId || 0).then((argsBinderRes) => { if (argsBinderRes.length > 0) { argsBinderRes.forEach((item) => { - list.push({name: item.keyName, value: item.strValue}); + list.push({ name: item.keyName, value: item.strValue }); }); } this.currentSelectionTbl!.dataSource = list; @@ -493,7 +494,7 @@ export class TabPaneCurrentSelection extends BaseElement { data: ThreadStruct, scrollCallback: ((d: any) => void) | undefined, scrollWakeUp: (d: any) => void | undefined, - callback: ((data: Array) => void) | undefined = undefined + callback?: ((data: Array, str: string) => void) ): void { //线程信息 this.setTableHeight('550px'); @@ -570,7 +571,7 @@ export class TabPaneCurrentSelection extends BaseElement { data: ThreadStruct, list: any[], jankJumperList: ThreadTreeNode[], - callback: ((data: Array) => void) | undefined, + callback: ((data: Array, str: string) => void) | undefined, scrollWakeUp: (d: any) => (void | undefined), scrollCallback: ((d: any) => void) | undefined ): void { @@ -585,16 +586,17 @@ export class TabPaneCurrentSelection extends BaseElement { let args = result[2]; let [preData, nextData] = this.sortByNearData(result[3], data, list); this.setWakeupData(fromBean, wakeUps, list); - let timeLineNode = new ThreadTreeNode(data.tid!, data.pid!, data.startTime!); - jankJumperList.push(timeLineNode); if (args.length > 0) { args.forEach((arg) => { - list.push({name: arg.keyName, value: arg.strValue}); + list.push({ name: arg.keyName, value: arg.strValue }); }); } this.currentSelectionTbl!.dataSource = list; + let timeLineNode = new ThreadTreeNode(data.tid!, data.pid!, data.startTime!); + jankJumperList.push(timeLineNode); if (callback) { - callback(jankJumperList); + callback(jankJumperList, this.wakeUp); + this.wakeUp = ''; } this.stateClickHandler(preData, nextData, data, scrollWakeUp, scrollCallback); this.wakeupClickHandler(wakeUps, fromBean, scrollWakeUp); @@ -620,6 +622,7 @@ export class TabPaneCurrentSelection extends BaseElement { argSetID: fromBean.argSetID, }); } + this.wakeUp = 'wakeup tid'; }); if (wakeUps) { wakeUps.map((up) => { @@ -637,6 +640,7 @@ export class TabPaneCurrentSelection extends BaseElement { argSetID: up.argSetID, }); } + this.wakeUp = 'wakeup tid'; }); }); } @@ -696,7 +700,7 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'StartTime(Absolute)', value: ((data.startTime || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); let state; if (data.state) { state = Utils.getEndState(data.state); @@ -715,11 +719,11 @@ export class TabPaneCurrentSelection extends BaseElement {
        `, }); } else { - list.push({name: 'State', value: `${state}`}); + list.push({ name: 'State', value: `${state}` }); } let slice = Utils.SCHED_SLICE_MAP.get(`${data.id}-${data.startTime}`); if (slice) { - list.push({name: 'Prio', value: `${slice.priority}`}); + list.push({ name: 'Prio', value: `${slice.priority}` }); } let processName = Utils.PROCESS_MAP.get(data.pid!); if ( @@ -754,13 +758,13 @@ export class TabPaneCurrentSelection extends BaseElement { } private handleTypeJank(data: JankStruct, list: any[], scrollCallback: ((d: any) => void) | undefined, - callback: ((data: Array) => void) | undefined): void { + callback: ((data: Array) => void) | undefined): void { this.setJankType(data, list); let jankJumperList = new Array(); if (data.frame_type === 'render_service') { queryGpuDur(data.id!).then((it) => { if (it.length > 0) { - list.push({name: 'Gpu Duration', value: getTimeString(it[0].gpu_dur)}); + list.push({ name: 'Gpu Duration', value: getTimeString(it[0].gpu_dur) }); } }); this.handleRenderServiceJank(data, list, jankJumperList, scrollCallback, callback); @@ -772,7 +776,7 @@ export class TabPaneCurrentSelection extends BaseElement { } private handleFrameTimeJank(data: JankStruct, list: any[], jankJumperList: JankTreeNode[], - scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { + scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { queryGpuDur(data.id!).then((it) => { if (it.length > 0) { list.push({ @@ -859,7 +863,7 @@ export class TabPaneCurrentSelection extends BaseElement { } private handleAppJank(list: any[], data: JankStruct, jankJumperList: JankTreeNode[], - scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { + scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { list.push({ name: 'FrameTimeLine flows', value: '', @@ -906,7 +910,7 @@ export class TabPaneCurrentSelection extends BaseElement { } private handleRenderServiceJank(data: JankStruct, list: any[], jankJumperList: JankTreeNode[], - scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { + scrollCallback: ((d: any) => void) | undefined, callback: ((data: Array) => void) | undefined): void { if (data.src_slice) { queryFlowsData(data.src_slice!.split(',')).then((it) => { if (it.length > 0) { @@ -964,7 +968,7 @@ export class TabPaneCurrentSelection extends BaseElement { allStartUpLeftTitle.innerText = 'Details'; } let list: any[] = []; - list.push({name: 'Name', value: data.stepName!}); + list.push({ name: 'Name', value: data.stepName! }); list.push({ name: 'StartTime(Relative)', value: getTimeString(data.startTs || 0), @@ -993,7 +997,7 @@ export class TabPaneCurrentSelection extends BaseElement { this.initCanvas(); this.setStartUpStyle(); let list: any[] = []; - list.push({name: 'Name', value: AppStartupStruct.getStartupName(data.startName)}); + list.push({ name: 'Name', value: AppStartupStruct.getStartupName(data.startName) }); list.push({ name: 'StartTime(Relative)', value: ` @@ -1028,15 +1032,15 @@ export class TabPaneCurrentSelection extends BaseElement { value: 'Unknown Time', }); } - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); this.currentSelectionTbl!.dataSource = list; this.attachScrollHandlers(data, scrollCallback); } private setStartUpStyle() { let rightButton: HTMLElement | null | undefined = this?.shadowRoot - ?.querySelector('#rightButton') - ?.shadowRoot?.querySelector('#custom-button'); + ?.querySelector('#rightButton') + ?.shadowRoot?.querySelector('#custom-button'); let startUpRightTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightTitle'); if (startUpRightTitle) { startUpRightTitle.style.visibility = 'hidden'; @@ -1092,7 +1096,7 @@ export class TabPaneCurrentSelection extends BaseElement { this.initCanvas(); this.setStaticInitStyle(); let list: any[] = []; - list.push({name: 'Name', value: data.soName}); + list.push({ name: 'Name', value: data.soName }); list.push({ name: 'StartTime(Relative)', value: `
        @@ -1104,7 +1108,7 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'StartTime(Absolute)', value: ((data.startTs || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Duration', value: getTimeString(data.dur || 0)}); + list.push({ name: 'Duration', value: getTimeString(data.dur || 0) }); this.currentSelectionTbl!.dataSource = list; this.startIconClickEvent(data, scrollCallback); } @@ -1112,8 +1116,8 @@ export class TabPaneCurrentSelection extends BaseElement { private setStaticInitStyle(): void { let rightTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightTitle'); let rightButton: HTMLElement | null | undefined = this?.shadowRoot - ?.querySelector('#rightButton') - ?.shadowRoot?.querySelector('#custom-button'); + ?.querySelector('#rightButton') + ?.shadowRoot?.querySelector('#custom-button'); if (rightTitle) { rightTitle.style.visibility = 'hidden'; rightButton!.style.visibility = 'hidden'; @@ -1159,8 +1163,8 @@ export class TabPaneCurrentSelection extends BaseElement { this.tabCurrentSelectionInit('Animation Details'); let list = []; let dataTs: number = data.startTs < 0 ? 0 : data.startTs; - list.push({name: 'Name', value: data.name}); - list.push({name: 'Start time(Relative)', value: `${Utils.getTimeString(dataTs)}`}); + list.push({ name: 'Name', value: data.name }); + list.push({ name: 'Start time(Relative)', value: `${Utils.getTimeString(dataTs)}` }); list.push({ name: 'Start time(Absolute)', value: ((dataTs || 0) + (window as any).recordStartNS) / 1000000000 + 's', @@ -1173,16 +1177,16 @@ export class TabPaneCurrentSelection extends BaseElement { name: 'End time(Absolute)', value: (dataTs + (data.dur || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Duration', value: `${Utils.getTimeString(data.dur || 0)}`}); + list.push({ name: 'Duration', value: `${Utils.getTimeString(data.dur || 0)}` }); if (data.status === 'Completion delay') { let frameFpsMessage = data.frameInfo?.split(':'); if (frameFpsMessage) { if (frameFpsMessage[1] !== '0') { - list.push({name: 'FPS', value: `${frameFpsMessage[1]}`}); + list.push({ name: 'FPS', value: `${frameFpsMessage[1]}` }); } else { let fixedNumber: number = 2; let fpsValue: number = Number(frameFpsMessage[0]) / (data.dur / 1000_000_000); - list.push({name: 'FPS', value: `${fpsValue.toFixed(fixedNumber) || 0}`}); + list.push({ name: 'FPS', value: `${fpsValue.toFixed(fixedNumber) || 0}` }); } } } @@ -1192,29 +1196,29 @@ export class TabPaneCurrentSelection extends BaseElement { private setJankType(data: JankStruct, list: any[]): void { if (data.jank_tag === 1) { if (data.frame_type === 'render_service') { - list.push({name: 'Jank Type', value: 'RenderService Deadline Missed'}); + list.push({ name: 'Jank Type', value: 'RenderService Deadline Missed' }); } else if (data.frame_type === 'app') { - list.push({name: 'Jank Type', value: 'APP Deadline Missed'}); + list.push({ name: 'Jank Type', value: 'APP Deadline Missed' }); } else if (data.frame_type === 'frameTime') { - list.push({name: 'Jank Type', value: 'Deadline Missed'}); + list.push({ name: 'Jank Type', value: 'Deadline Missed' }); } } else if (data.jank_tag === 3) { - list.push({name: 'Jank Type', value: 'Deadline Missed'}); + list.push({ name: 'Jank Type', value: 'Deadline Missed' }); } else { - list.push({name: 'Jank Type', value: 'NONE'}); + list.push({ name: 'Jank Type', value: 'NONE' }); } } private setJankCommonMessage(list: any[], data: JankStruct): void { - list.push({name: 'Name', value: data.name}); - list.push({name: 'StartTime(Relative)', value: getTimeString(data.ts || 0)}); + list.push({ name: 'Name', value: data.name }); + list.push({ name: 'StartTime(Relative)', value: getTimeString(data.ts || 0) }); list.push({ name: 'StartTime(Absolute)', value: ((data.ts || 0) + (window as any).recordStartNS) / 1000000000 + 's', }); - list.push({name: 'Duration', value: data.dur ? getTimeString(data.dur) : ' '}); + list.push({ name: 'Duration', value: data.dur ? getTimeString(data.dur) : ' ' }); if (data.frame_type !== 'frameTime') { - list.push({name: 'Process', value: data.cmdline + ' ' + data.pid}); + list.push({ name: 'Process', value: data.cmdline + ' ' + data.pid }); } } diff --git a/ide/src/trace/component/trace/sheet/TabPaneFilter.html.ts b/ide/src/trace/component/trace/sheet/TabPaneFilter.html.ts index 355c184f5f90dd6047337c78359861887a9c0cdc..ce4dc3658a3352b1820105a1fffd873b9c2a9d9a 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneFilter.html.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneFilter.html.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -let inputPlace = ''; +import { replacePlaceholders } from '../../../../base-ui/utils/Template'; let html = ` Input Filter - +
        @@ -323,6 +323,5 @@ margin-left: 15px;
        ` export const TabPaneFilterHtml = (input: string): string => { - inputPlace = input; - return html; + return replacePlaceholders(html, input); } diff --git a/ide/src/trace/component/trace/sheet/TabPaneFilter.ts b/ide/src/trace/component/trace/sheet/TabPaneFilter.ts index dd0521e9c51fa06d0f35d29642fde9b4b4112047..b585ce23306df004f83d46b6e46bc0f1ec74d594 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneFilter.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneFilter.ts @@ -443,13 +443,13 @@ export class TabPaneFilter extends BaseElement { let checkList = []; for (let index = 0; index < 5; index++) { if (idx === index) { - checkList.push(row[index].querySelector('lit-check-box')!.checked) - } else { checkList.push(check); + } else { + checkList.push(row[index].querySelector('lit-check-box')!.checked) } } this.getCallTree!({ - checks: [checkList[0], checkList[1], checkList[2], checkList[3], checkList[4]], + checks: checkList, value: idx, }); } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneMemoryAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneMemoryAbility.ts index 66551491598046c79a8fe10b6f8cad706206c898..a833e173b36dd87e44aa88fac58e84067c1eb2b9 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneMemoryAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneMemoryAbility.ts @@ -33,7 +33,7 @@ export class TabPaneMemoryAbility extends BaseElement { set data(memoryAbilityValue: SelectionParam | any) { if (this.memoryAbilityTbl) { // @ts-ignore - this.memoryAbilityTbl.shadowRoot.querySelector('.table').style.height = + this.memoryAbilityTbl.shadowRoot?.querySelector('.table').style.height = this.parentElement!.clientHeight - 45 + 'px'; } this.queryDataByDB(memoryAbilityValue); diff --git a/ide/src/trace/component/trace/sheet/ability/TabPaneNetworkAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPaneNetworkAbility.ts index 0e7c7de9e37676f0dca92d96da7c55907e6aa680..b310757b88f7ab67ce4e949dffa41839080dcb33 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPaneNetworkAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPaneNetworkAbility.ts @@ -34,7 +34,7 @@ export class TabPaneNetworkAbility extends BaseElement { set data(networkAbilityValue: SelectionParam | any) { if (this.networkAbilityTbl) { // @ts-ignore - this.networkAbilityTbl.shadowRoot.querySelector('.table').style.height = + this.networkAbilityTbl.shadowRoot?.querySelector('.table').style.height = this.parentElement!.clientHeight - 45 + 'px'; } this.queryDataByDB(networkAbilityValue); diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPin.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPin.ts index 13ad5b68d84e7bd308b40b7a303349d877fbe1e1..007b056195fc3e55d87a52d0f38d8bf03bd46b92 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPin.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPin.ts @@ -35,7 +35,7 @@ export class TabPanePurgPin extends BaseElement { set data(selection: SelectionParam) { if (this.purgeablePinTable) { //@ts-ignore - this.purgeablePinTable.shadowRoot.querySelector('.table').style.height = `${ + this.purgeablePinTable.shadowRoot?.querySelector('.table').style.height = `${ this.parentElement!.clientHeight - 45 }px`; } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts index 91d72107e667333bc3ad2a9cd2cc57211ad564ad..6bfdf9608f6d24f7f77a4f0293fb4c665a6d96af 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.ts @@ -38,7 +38,7 @@ export class TabPanePurgPinComparisonAbility extends BaseElement { public totalData(purgePinComParam: SelectionParam | any, dataList: any): void { if (this.purgeablePinTable) { //@ts-ignore - this.purgeablePinTable.shadowRoot.querySelector('.table').style.height = `${ + this.purgeablePinTable.shadowRoot?.querySelector('.table').style.height = `${ this.parentElement!.clientHeight - 45 }px`; } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotal.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotal.ts index e99d23a557eab71c2b92ec6ba7b4664071ea50b7..a62e13cd14c793ed7be738e0e1e431f6af043aef 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotal.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotal.ts @@ -34,7 +34,7 @@ export class TabPanePurgTotal extends BaseElement { set data(selection: SelectionParam) { if (this.purgeableTotalTable) { //@ts-ignore - this.purgeableTotalTable.shadowRoot.querySelector('.table').style.height = `${ + this.purgeableTotalTable.shadowRoot?.querySelector('.table').style.height = `${ this.parentElement!.clientHeight - 45 }px`; } diff --git a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts index 13afc6101dbde804d50ea7036a052e40bafa8cab..8a4c991b3849c115c6608dbaef6c128b612e2509 100644 --- a/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts +++ b/ide/src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.ts @@ -38,7 +38,7 @@ export class TabPanePurgTotalComparisonAbility extends BaseElement { public totalData(purgeTotalComParam: SelectionParam | any, dataList: any): void { if (this.purgeableTotalTable) { //@ts-ignore - this.purgeableTotalTable.shadowRoot.querySelector('.table').style.height = `${ + this.purgeableTotalTable.shadowRoot?.querySelector('.table').style.height = `${ this.parentElement!.clientHeight - 45 }px`; } 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 95bc5a305c4384153085916f6504187a2e523eee..73de618801243a3e88ef919b33b414de1a928ae8 100644 --- a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts +++ b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneJsCpu.ts @@ -87,7 +87,7 @@ export class TabPaneJsCpuCallTree extends BaseElement { } private setCallTreeTableData(results: Array): void { - this.clearTab(); + this.stackTable!.recycleDataSource = []; const callTreeMap = new Map(); const setTabData = (data: Array): void => { data.forEach((item) => { @@ -98,13 +98,15 @@ export class TabPaneJsCpuCallTree extends BaseElement { } item.name = SpSystemTrace.DATA_DICT.get(item.nameId) || ''; callTreeMap.set(item.id, item); - if (item.scriptName === 'unknown') { - item.symbolName = item.name; - } else { - item.symbolName = `${item.name } ${item.scriptName}`; + if (item.symbolName.length < 0) { + if (item.scriptName === 'unknown') { + item.symbolName = item.name; + } else { + item.symbolName = `${item.name} ${item.scriptName}`; + } } - item.totalTimePercent = `${((item.totalTime / this.totalNs) * 100).toFixed(1) }%`; - item.selfTimePercent = `${((item.selfTime / this.totalNs) * 100).toFixed(1) }%`; + item.totalTimePercent = `${((item.totalTime / this.totalNs) * 100).toFixed(1)}%`; + item.selfTimePercent = `${((item.selfTime / this.totalNs) * 100).toFixed(1)}%`; item.selfTimeStr = ns2s(item.selfTime); item.totalTimeStr = ns2s(item.totalTime); item.parent = callTreeMap.get(item.parentId!); @@ -196,12 +198,14 @@ export class TabPaneJsCpuCallTree extends BaseElement { super.connectedCallback(); new ResizeObserver(() => { // @ts-ignore - this.callTreeTable?.shadowRoot.querySelector('.table').style.height = - `${this.parentElement!.clientHeight - 32 }px`; + this.callTreeTable?.shadowRoot.querySelector('.table').style.height = `${ + this.parentElement!.clientHeight - 32 + }px`; this.callTreeTable?.reMeauseHeight(); // @ts-ignore - this.stackTable?.shadowRoot.querySelector('.table').style.height = - `${this.parentElement!.clientHeight - 32 - 22 }px`; + this.stackTable?.shadowRoot.querySelector('.table').style.height = `${ + this.parentElement!.clientHeight - 32 - 22 + }px`; this.stackTable?.reMeauseHeight(); }).observe(this.parentElement!); } @@ -228,9 +232,9 @@ export class TabPaneJsCpuCallTree extends BaseElement { if (this.sortType === 0) { return defaultSort(callTreeLeftData, callTreeRightData); } else if (this.sortType === 1) { - return (`${callTreeLeftData.symbolName }`).localeCompare(`${callTreeRightData.symbolName }`); + return `${callTreeLeftData.symbolName}`.localeCompare(`${callTreeRightData.symbolName}`); } else { - return (`${callTreeRightData.symbolName }`).localeCompare(`${callTreeLeftData.symbolName }`); + return `${callTreeRightData.symbolName}`.localeCompare(`${callTreeLeftData.symbolName}`); } } else { if (this.sortType === 0) { 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 b6ec743a20ab5cbf88dbdc79ed8119bd49e21ccd..a168b4fe84d93c6b77e224b0709e41e06b2aa264 100644 --- a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts +++ b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneSummary.ts @@ -617,7 +617,8 @@ export class TabPaneSummary extends BaseElement { } else { this.tbs!.snapshotDataSource = []; } - this.tblSummaryRowClickExtend(data); + //@ts-ignore + this.tblSummaryRowClickExtend(evt.detail); }; private initRetainsData(data: ConstructorItem): void { @@ -637,9 +638,9 @@ export class TabPaneSummary extends BaseElement { }); } - private tblSummaryRowClickExtend(data: ConstructorItem): void { + private tblSummaryRowClickExtend(detail: any): void { if (this.file!.name.includes('Timeline')) { - this.stackData = HeapDataInterface.getInstance().getAllocationStackData(data); + this.stackData = HeapDataInterface.getInstance().getAllocationStackData(detail.data); if (this.stackData.length > 0) { this.stackTable!.recycleDataSource = this.stackData; this.stackText!.textContent = ''; @@ -670,10 +671,8 @@ export class TabPaneSummary extends BaseElement { this.stackTable!.style.height = 'calc(100% - 30px)'; this.stackTable!.reMeauseHeight(); }).observe(this.parentElement!); - // @ts-ignore - if ((evt.detail as any).callBack) { - // @ts-ignore - (evt.detail as any).callBack(true); + if (detail.callBack) { + detail.callBack(true); } } diff --git a/ide/src/trace/component/trace/sheet/binder/TabPaneBinderDataCut.ts b/ide/src/trace/component/trace/sheet/binder/TabPaneBinderDataCut.ts new file mode 100644 index 0000000000000000000000000000000000000000..cabd62850be831666638a142c5053a0e16eb4b97 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/binder/TabPaneBinderDataCut.ts @@ -0,0 +1,756 @@ + +/* + * 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'; +import { type LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { Utils } from '../../base/Utils'; +import { type SelectionParam } from '../../../../bean/BoxSelection'; +import { + type BinderItem, + type ProcessBinderItem, + type ThreadBinderItem, + type DataSource, + type FunctionItem, + type BinderDataStruct, + CycleBinderItem, +} from '../../../../bean/BinderProcessThread'; +import { queryFuncNameCycle } from '../../../../../trace/database/sql/Func.sql'; +import { queryBinderByThreadId } from '../../../../../trace/database/sql/ProcessThread.sql'; +import { resizeObserver } from '../SheetUtils'; +import { type LitChartColumn } from '../../../../../base-ui/chart/column/LitChartColumn'; +import '../../../../../base-ui/chart/column/LitChartColumn'; +import { SpSegmentationChart } from '../../../chart/SpSegmentationChart'; +import { SliceGroup } from '../../../../bean/StateProcessThread'; + +const MILLIONS: number = 1000000; +const THREE: number = 3; +@element('tabpane-binder-datacut') +export class TabPaneBinderDataCut extends BaseElement { + private threadBindersTbl: LitTable | null | undefined; + private currentSelectionParam: SelectionParam | any; + private threadStatesDIV: Element | null | undefined; + private cycleColumnDiv: HTMLDivElement | null | undefined; + private cycleARangeArr: CycleBinderItem[] = []; + private cycleBRangeArr: CycleBinderItem[] = []; + private cycleAStartRangeDIV: HTMLInputElement | null | undefined; + private cycleAEndRangeDIV: HTMLInputElement | null | undefined; + private cycleBStartRangeDIV: HTMLInputElement | null | undefined; + private cycleBEndRangeDIV: HTMLInputElement | null | undefined; + private chartTotal: LitChartColumn | null | undefined; + private dataSource: DataSource[] = []; + private rowCycleData: CycleBinderItem[] = []; + private currentThreadId: string = ''; + private threadArr: Array = []; + private threadBinderMap: Map> = new Map(); + private processIds: Array = []; + private isQueryDataFromDb: boolean = false; + private funcCycleArr: Array = []; + + set data(threadStatesParam: SelectionParam) { + if (this.currentSelectionParam === threadStatesParam) { + return; + } + this.currentSelectionParam = threadStatesParam; + SpSegmentationChart.setBinderChartData([]); + SpSegmentationChart.tabHover('BINDER', false, -1); + // @ts-ignore + this.processIds = [...new Set(this.currentSelectionParam.processIds)]; + this.threadArr = []; + this.threadBinderMap.clear(); + this.hideQueryArea(true); + this.clickLoop(false); + this.clickSingle(false); + this.isQueryDataFromDb = false; + this.threadBindersTbl!.recycleDataSource = []; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + this.parentElement!.style.overflow = 'hidden'; + new ResizeObserver(() => { + // @ts-ignore + let lastHeight: number = this.threadBindersTbl.tableElement!.offsetHeight; + this.cycleColumnDiv!.style.height = lastHeight + 'px'; + }).observe(this.parentElement!); + } + + hideQueryArea(b: boolean): void { + if (b) { + this.setAttribute('hideQueryArea', ''); + } else { + this.removeAttribute('hideQueryArea'); + } + } + + clickSingle(b: boolean): void { + if (b) { + this.setAttribute('clickSingle', ''); + } else { + this.removeAttribute('clickSingle'); + } + } + + clickLoop(b: boolean): void { + if (b) { + this.setAttribute('clickLoop', ''); + } else { + this.removeAttribute('clickLoop'); + } + } + + // 查询数据库,binder和Function查询 + async queryDataFromDb( + threadIdValue: string, + threadFuncName: string, + threadIds: Array, + leftNS: number, + rightNS: number + ): Promise { + let binderArr: Array = await queryBinderByThreadId(this.processIds, threadIds, leftNS, rightNS); + if (binderArr.length > 0) { + this.structureThreadBinderMap(binderArr); + } + this.funcCycleArr = await queryFuncNameCycle(threadFuncName, threadIdValue, leftNS, rightNS); + } + + //点击single loop 切割按钮方法 + async dataCutFunc( + threadId: HTMLInputElement, + threadFunc: HTMLInputElement, + type: string, + ): Promise { + this.currentThreadId = ''; + let threadIdValue = threadId.value.trim(); + let threadFuncName = threadFunc.value.trim(); + this.clickLoop(type === 'loop' ? true : false); + this.clickSingle(type === 'loop' ? false : true); + //清空泳道图 + SpSegmentationChart.setBinderChartData([]); + SpSegmentationChart.tabHover('BINDER', false, -1); + if (threadIdValue !== '' && threadFuncName !== '') { + this.threadBindersTbl!.loading = true; + threadId.style.border = '1px solid rgb(151,151,151)'; + threadFunc.style.border = '1px solid rgb(151,151,151)'; + if (!this.isQueryDataFromDb) { + let threadIds = this.currentSelectionParam.threadIds; + let leftNS = this.currentSelectionParam.leftNs; + let rightNS = this.currentSelectionParam.rightNs; + await this.queryDataFromDb(threadIdValue, threadFuncName, threadIds, leftNS, rightNS); + this.isQueryDataFromDb = true; + } + if (this.funcCycleArr.length !== 0) { + let cycleMap: Map> = type === 'loop' ? + this.loopDataCutCycleMap(this.funcCycleArr) : this.singleDataCutCycleMap(this.funcCycleArr); + this.threadBindersTbl!.recycleDataSource = this.mergeData(cycleMap); + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } else { + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } + } else { + this.verifyInputIsEmpty(threadIdValue, threadFuncName, threadId, threadFunc); + } + } + + verifyInputIsEmpty( + threadIdValue: string, + threadFuncName: string, + threadId: HTMLInputElement, + threadFunc: HTMLInputElement + ): void { + if (threadIdValue === '') { + threadId.style.border = '1px solid rgb(255,0,0)'; + threadId.setAttribute('placeholder', 'Please input thread id'); + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } else { + threadId.style.border = '1px solid rgb(151,151,151)'; + } + if (threadFuncName === '') { + threadFunc.style.border = '1px solid rgb(255,0,0)'; + threadFunc.setAttribute('placeholder', 'Please input function name'); + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } else { + threadFunc.style.border = '1px solid rgb(151,151,151)'; + } + } + + // 构建线程 binder Map数据 + structureThreadBinderMap(binderArr: Array): void { + for (let b of binderArr) { + if (!this.threadBinderMap.has(b.pid + '_' + b.tid)) { + this.threadArr.push({ + title: Utils.THREAD_MAP.get(b.tid) === null ? 'Thread' + ' ' + '[' + b.tid + ']' : Utils.THREAD_MAP.get(b.tid) + ' ' + '[' + b.tid + ']', + totalCount: 0, + tid: b.tid, + pid: b.pid, + children: [], + type: 'Thread', + }); + this.threadBinderMap.set(b.pid + '_' + b.tid, new Array()); + } + let arr: Array | undefined = this.threadBinderMap.get(b.pid + '_' + b.tid); + arr?.push(b); + } + } + + deepCloneThreadBinderMap(threadBinderMap: Map>): Map> { + let cloneThreadBinderMap: Map> = new Map(); + if (cloneThreadBinderMap instanceof Map) { + threadBinderMap.forEach((val, key) => { + const k = key; + const v = JSON.parse(JSON.stringify(val)); + cloneThreadBinderMap.set(k, v) + }) + } + return cloneThreadBinderMap; + } + + // 构建single切割cycle Map数据 + singleDataCutCycleMap(funcNameArr: Array): Map> { + let cloneThreadBinderMap: Map> = this.deepCloneThreadBinderMap(this.threadBinderMap); + let cycleMap: Map> = new Map(); + cloneThreadBinderMap.forEach((tBinder: Array) => { + funcNameArr.forEach((func, idx) => { + let cycleArr: Array | undefined = []; + let countBinder: CycleBinderItem = new CycleBinderItem(); + let cid = func.id; + for (let j: number = 0; j < tBinder.length; j++) { + if (!cycleMap.has(tBinder[j].tid + '_' + cid)) { + cycleMap.set(tBinder[j].tid + '_' + cid, new Array()); + } + cycleArr = cycleMap.get(tBinder[j].tid + '_' + cid); + let thread: string = Utils.THREAD_MAP.get(tBinder[j].tid) || 'Thread'; + countBinder.title = 'cycle ' + (idx + 1) + '_' + thread; + countBinder.tid = tBinder[j].tid; + countBinder.pid = tBinder[j].pid; + countBinder.durNs = func.dur; + countBinder.tsNs = func.cycleStartTime; + countBinder.cycleDur = Number((func.dur / MILLIONS).toFixed(THREE)); + countBinder.cycleStartTime = Number((func.cycleStartTime / MILLIONS).toFixed(THREE)); + if (tBinder[j].ts + tBinder[j].dur > func.cycleStartTime && tBinder[j].ts + tBinder[j].dur < func.cycleStartTime + func!.dur) { + countBinder.totalCount += 1; + countBinder.binderTransactionCount += tBinder[j].name === 'binder transaction' ? 1 : 0; + countBinder.binderAsyncRcvCount += tBinder[j].name === 'binder async rcv' ? 1 : 0; + countBinder.binderReplyCount += tBinder[j].name === 'binder reply' ? 1 : 0; + countBinder.binderTransactionAsyncCount += tBinder[j].name === 'binder transaction async' ? 1 : 0; + countBinder.idx = idx + 1; + tBinder.splice(j, 1); + j--; + } + } + cycleArr?.push(countBinder); + }); + }); + return cycleMap; + } + + // 构建loop切割cycle Map数据 + loopDataCutCycleMap(funcNameArr: Array): Map> { + let cloneThreadBinderMap: Map> = this.deepCloneThreadBinderMap(this.threadBinderMap); + let cycleMap: Map> = new Map(); + cloneThreadBinderMap.forEach((tBinder: Array) => { + for (let i: number = 0; i < funcNameArr.length - 1; i++) { + let cycleArr: Array | undefined = []; + let countBinder: CycleBinderItem = new CycleBinderItem(); + let cid: number = funcNameArr[i].id; + for (let j: number = 0; j < tBinder.length; j++) { + if (!cycleMap.has(tBinder[j].tid + '_' + cid)) { + cycleMap.set(tBinder[j].tid + '_' + cid, new Array()); + } + cycleArr = cycleMap.get(tBinder[j].tid + '_' + cid); + let thread: string = Utils.THREAD_MAP.get(tBinder[j].tid) || 'Thread'; + countBinder.title = 'cycle ' + (i + 1) + '_' + thread; + countBinder.tid = tBinder[j].tid; + countBinder.pid = tBinder[j].pid; + countBinder.durNs = funcNameArr[i + 1].cycleStartTime - funcNameArr[i].cycleStartTime; + countBinder.tsNs = funcNameArr[i].cycleStartTime; + countBinder.cycleDur = Number(((funcNameArr[i + 1].cycleStartTime - funcNameArr[i].cycleStartTime) / MILLIONS).toFixed(THREE)); + countBinder.cycleStartTime = Number((funcNameArr[i].cycleStartTime / MILLIONS).toFixed(THREE)); + if (tBinder[j].ts + tBinder[j].dur > funcNameArr[i].cycleStartTime && tBinder[j].ts + tBinder[j].dur < funcNameArr[i + 1].cycleStartTime) { + countBinder.totalCount += 1; + countBinder!.binderTransactionCount += tBinder[j].name === 'binder transaction' ? 1 : 0; + countBinder!.binderAsyncRcvCount += tBinder[j].name === 'binder async rcv' ? 1 : 0; + countBinder.binderReplyCount += tBinder[j].name === 'binder reply' ? 1 : 0; + countBinder.binderTransactionAsyncCount += tBinder[j].name === 'binder transaction async' ? 1 : 0; + countBinder.idx = i + 1; + tBinder.splice(j, 1); + j--; + } + } + cycleArr?.push(countBinder); + } + }); + return cycleMap; + } + + //组成树结构数据 + mergeData(cycleMap: Map>): Array { + let processArr: Array = []; + let processIds: Array = []; + // 将thread级下的周期数据放入对应的thread下。树结构的第二层thread数据 + for (let thread of this.threadArr) { + if (!processIds.includes(thread.pid)) { + processIds.push(thread.pid); + } + thread.totalCount = 0; + thread.children = []; + for (let key of cycleMap!.keys()) { + let cycle: Array | undefined = cycleMap.get(key); + if (key.split('_')[0] === thread.tid + '') { + thread.totalCount += cycle![0].totalCount; + thread.children.push(cycle![0]); + } + } + } + // process级的数组数据,也就是树结构的根数据层 + processIds.forEach(pid => { + processArr.push( + { + pid: pid, + title: Utils.PROCESS_MAP.get(pid) === null ? 'Process' + ' ' + '[' + pid + ']' : Utils.PROCESS_MAP.get(pid) + ' ' + '[' + pid + ']', + totalCount: 0, + type: 'Process', + children: [], + } + ); + }) + // 将process级下的thread数据放入对应的process下 + for (let process of processArr) { + for (let thread of this.threadArr) { + if (thread.pid === process.pid) { + process.totalCount += thread.totalCount; + process.children.push(thread); + } + } + } + return processArr; + } + + // 构建画泳道图的数据 + structuredLaneChartData(rowCycleData: CycleBinderItem[]): Array { + let laneChartData: Array = []; + rowCycleData.forEach((it) => { + if (it.totalCount !== 0) { + let cycleDataArr: BinderDataStruct[] = []; + if (it.binderTransactionCount !== 0) { + cycleDataArr.push({ + name: 'binder transaction', + value: it.binderTransactionCount!, + dur: it.durNs, + startNS: it.tsNs, + cycle: it.idx, + }); + } + if (it.binderTransactionAsyncCount !== 0) { + cycleDataArr.push({ + name: 'binder transaction async', + value: it.binderTransactionAsyncCount!, + dur: it.durNs, + startNS: it.tsNs, + cycle: it.idx, + }); + } + if (it.binderReplyCount !== 0) { + cycleDataArr.push({ + name: 'binder reply', + value: it.binderReplyCount!, + dur: it.durNs, + startNS: it.tsNs, + cycle: it.idx, + }); + } + if (it.binderAsyncRcvCount !== 0) { + cycleDataArr.push({ + name: 'binder async rcv', + value: it.binderAsyncRcvCount!, + dur: it.durNs, + startNS: it.tsNs, + cycle: it.idx, + }); + } + laneChartData.push(cycleDataArr); + } + }); + return laneChartData; + } + + clearCycleRange(): void { + this.cycleAStartRangeDIV!.value = ''; + this.cycleAEndRangeDIV!.value = ''; + this.cycleBStartRangeDIV!.value = ''; + this.cycleBEndRangeDIV!.value = ''; + } + + drawColumn(): void { + this.chartTotal!.dataSource = this.dataSource!; + this.chartTotal!.config = { + data: this.dataSource!, + appendPadding: 10, + xField: 'xName', + yField: 'yAverage', + seriesField: '', + removeUnit: true, + notSort: true, + color: (a) => { + if (a.xName === 'Total') { + return '#2f72f8'; + } else if (a.xName === 'cycleA') { + return '#ffab67'; + } else if (a.xName === 'cycleB') { + return '#a285d2'; + } else { + return '#0a59f7'; + } + }, + tip: (a) => { + if (a && a[0]) { + let tip: string = ''; + tip = `
        +
        Average count: ${a[0].obj.yAverage}
        +
        `; + return tip; + } else { + return ''; + } + }, + label: null, + }; + } + + tHeadClick(data: Array): void { + let labels = this.threadBindersTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Process')) { + this.threadBindersTbl!.setStatus(data, false); + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement( + data, + RedrawTreeForm.Retract + ); + } else if (label.includes('Thread')) { + for (let item of data) { + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.threadBindersTbl!.setStatus(item.children, false); + } + } + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement( + data, + RedrawTreeForm.Retract + ); + } else if (label.includes('Cycle')) { + this.threadBindersTbl!.setStatus(data, true); + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + } + }); + } + } + } + + //点击Thread行表格数据时 + tableRowClickFunc(): void { + this.threadBindersTbl!.addEventListener('row-click', (evt: any) => { + let currentData = evt.detail.data; + if (currentData.type === 'Process') { + currentData.isSelected = true; + this.threadBindersTbl!.clearAllSelection(currentData); + this.threadBindersTbl!.setCurrentSelection(currentData); + this.hideQueryArea(true); + SpSegmentationChart.setBinderChartData([]); + SpSegmentationChart.tabHover('BINDER', false, -1); + } + if (currentData.type === 'Thread') { + SpSegmentationChart.tabHover('BINDER', false, -1); + this.currentThreadId = currentData.tid + '' + currentData.pid; + this.clearCycleRange(); + currentData.isSelected = true; + this.threadBindersTbl!.clearAllSelection(currentData); + this.threadBindersTbl!.setCurrentSelection(currentData); + this.rowCycleData = currentData.children; + this.hideQueryArea(false); + let totalCount = currentData.totalCount; + this.dataSource = []; + this.dataSource.push({ + xName: 'Total', + yAverage: totalCount > 0 ? Math.ceil(totalCount / this.rowCycleData!.length) : 0, + }); + //绘制柱状图 + this.drawColumn(); + let laneChartData: Array = this.structuredLaneChartData(currentData.children!); + //绘制泳道图 + SpSegmentationChart.setBinderChartData(laneChartData); + } + + if (currentData.type === 'Cycle' && currentData.tid + '' + currentData.pid === this.currentThreadId) { + currentData.isSelected = true; + this.threadBindersTbl!.clearAllSelection(currentData); + this.threadBindersTbl!.setCurrentSelection(currentData); + //泳道图的鼠标悬浮 + SpSegmentationChart.tabHover('BINDER', true, currentData.idx); + } + }); + } + + //点击query按钮绘制柱状图 + queryBtnClick(): void { + this.shadowRoot?.querySelector('#query-btn')?.addEventListener('click', () => { + this.cycleARangeArr = this.rowCycleData?.filter((it: CycleBinderItem) => { + return (it.cycleDur >= Number(this.cycleAStartRangeDIV!.value) && it.cycleDur < Number(this.cycleAEndRangeDIV!.value)); + }); + this.cycleBRangeArr = this.rowCycleData?.filter((it: CycleBinderItem) => { + return (it.cycleDur >= Number(this.cycleBStartRangeDIV!.value) && it.cycleDur < Number(this.cycleBEndRangeDIV!.value)); + }); + let cycleACount: number = 0; + this.cycleARangeArr?.forEach((it: CycleBinderItem) => { + cycleACount += it.totalCount; + }); + let cycleBCount: number = 0; + this.cycleBRangeArr?.forEach((it: CycleBinderItem) => { + cycleBCount += it.totalCount; + }); + this.dataSource!.length > 1 && this.dataSource?.splice(1); + this.dataSource!.push({ + xName: 'cycleA', + yAverage: cycleACount !== 0 ? Math.ceil(cycleACount / this.cycleARangeArr!.length) : 0, + }); + this.dataSource!.push({ + xName: 'cycleB', + yAverage: cycleBCount !== 0 ? Math.ceil(cycleBCount / this.cycleBRangeArr!.length) : 0, + }); + this.drawColumn(); + }); + } + + initElements(): void { + this.threadBindersTbl = this.shadowRoot?.querySelector('#tb-binder-count'); + this.chartTotal = this.shadowRoot!.querySelector('#chart_cycle'); + this.cycleAStartRangeDIV = this.shadowRoot?.querySelector('#cycle-a-start-range'); + this.cycleAEndRangeDIV = this.shadowRoot?.querySelector('#cycle-a-end-range'); + this.cycleBStartRangeDIV = this.shadowRoot?.querySelector('#cycle-b-start-range'); + this.cycleBEndRangeDIV = this.shadowRoot?.querySelector('#cycle-b-end-range'); + this.cycleColumnDiv = this.shadowRoot?.querySelector('#cycleColumn'); + this.threadStatesDIV = this.shadowRoot!.querySelector('#dataCut'); + this.threadStatesDIV?.children[2].children[0].addEventListener('click', (e) => { + this.hideQueryArea(true); + this.dataSource = []; + // @ts-ignore + this.dataCutFunc(this.threadStatesDIV!.children[0], this.threadStatesDIV?.children[1], 'single'); + }); + this.threadStatesDIV?.children[2].children[1].addEventListener('click', (e) => { + this.hideQueryArea(true); + this.dataSource = []; + // @ts-ignore + this.dataCutFunc(this.threadStatesDIV?.children[0], this.threadStatesDIV?.children[1], 'loop'); + }); + this.tableRowClickFunc(); + this.queryBtnClick(); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadBindersTbl!); + } + + initHtml(): string { + return ` + +
        + + +
        + + +
        +
        +
        + +
        + + + + + + + + + + + + + + + + + + +
        + +
        +
        + Cycle A: + + ~ + +
        +
        +
        + Cycle B: + + ~ + +
        +
        + +
        +
        +
        +
        Average Binder Count
        + +
        +
        Total
        +
        Cycle A
        +
        Cycle B
        +
        +
        +
        +
        +
        + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/binder/TabPaneBinders.ts b/ide/src/trace/component/trace/sheet/binder/TabPaneBinders.ts new file mode 100644 index 0000000000000000000000000000000000000000..dcc8ddd288e8fca4969ae6168ab5d1c8088ae4d4 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/binder/TabPaneBinders.ts @@ -0,0 +1,182 @@ + +/* + * Copyright (C) 2023 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'; +import { type LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { SelectionData, SelectionParam } from '../../../../bean/BoxSelection'; +import '../../../StackBar'; +import { queryBinderByThreadId } from '../../../../database/sql/ProcessThread.sql'; +import { Utils } from '../../base/Utils'; +import { resizeObserver } from '../SheetUtils'; +import { type BinderGroup, type BinderItem } from '../../../../bean/BinderProcessThread'; +import { SliceGroup } from '../../../../bean/StateProcessThread'; + +@element('tabpane-binders') +export class TabPaneBinders extends BaseElement { + private threadBindersTbl: LitTable | null | undefined; + private threadBindersTblSource: Array = []; + private currentSelectionParam: Selection | undefined; + + set data(threadStatesParam: SelectionParam | any) { + if (this.currentSelectionParam === threadStatesParam) { + return; + } + this.currentSelectionParam = threadStatesParam; + this.initBinderData(threadStatesParam); + } + + initBinderData(threadStatesParam: SelectionParam): void { + this.threadBindersTbl!.loading = true; + this.threadBindersTbl!.recycleDataSource = []; + let binderList: BinderItem[] = []; + let threadIds = threadStatesParam.threadIds; + let processIds: number[] = [...new Set(threadStatesParam.processIds)]; + queryBinderByThreadId(processIds, threadIds, threadStatesParam.leftNs, threadStatesParam.rightNs).then((result) => { + if (result !== null && result.length > 0) { + binderList = result; + } + if (binderList.length > 0) { + this.threadBindersTbl!.recycleDataSource = this.transferToTreeData(binderList); + this.threadBindersTblSource = this.threadBindersTbl!.recycleDataSource; + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } else if (binderList.length === 0) { + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTblSource = []; + this.threadBindersTbl!.loading = false; + this.tHeadClick(this.threadBindersTbl!.recycleDataSource); + } + }); + } + + transferToTreeData(binderList: BinderItem[]): BinderGroup[] { + let group: any = {}; + binderList.forEach((it: BinderItem) => { + if (group[`${it.pid}`]) { + let process = group[`${it.pid}`]; + process.totalCount += 1; + let thread = process.children.find((child: BinderGroup) => child.title === `T-${it.tid}`); + if (thread) { + thread.totalCount += 1; + thread.binderTransactionCount += it.name === 'binder transaction' ? 1 : 0; + thread.binderAsyncRcvCount += it.name === 'binder async rcv' ? 1 : 0; + thread.binderReplyCount += it.name === 'binder reply' ? 1 : 0; + thread.binderTransactionAsyncCount += it.name === 'binder transaction async' ? 1 : 0; + } else { + process.children.push({ + title: `T-${it.tid}`, + totalCount: 1, + binderTransactionCount: it.name === 'binder transaction' ? 1 : 0, + binderAsyncRcvCount: it.name === 'binder async rcv' ? 1 : 0, + binderReplyCount: it.name === 'binder reply' ? 1 : 0, + binderTransactionAsyncCount: it.name === 'binder transaction async' ? 1 : 0, + tid: it.tid, + pid: it.pid, + }); + } + } else { + group[`${it.pid}`] = { + title: `P-${it.pid}`, + totalCount: 1, + tid: it.tid, + pid: it.pid, + children: [ + { + title: `T-${it.tid}`, + totalCount: 1, + binderTransactionCount: it.name === 'binder transaction' ? 1 : 0, + binderAsyncRcvCount: it.name === 'binder async rcv' ? 1 : 0, + binderReplyCount: it.name === 'binder reply' ? 1 : 0, + binderTransactionAsyncCount: it.name === 'binder transaction async' ? 1 : 0, + tid: it.tid, + pid: it.pid, + }, + ], + }; + } + }); + return Object.values(group); + } + + private tHeadClick(data: Array): void { + let labels = this.threadBindersTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', () => { + if (label.includes('Process') && i === 0) { + this.threadBindersTbl!.setStatus(data, false); + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement( + data, + RedrawTreeForm.Retract + ); + } else if (label.includes('Thread') && i === 1) { + for (let item of data) { + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.threadBindersTbl!.setStatus(item.children, false); + } + } + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement( + data, + RedrawTreeForm.Retract + ); + } + }); + } + } + } + + initElements(): void { + this.threadBindersTbl = this.shadowRoot?.querySelector('#tb-binder-count'); + this.threadBindersTbl!.itemTextHandleMap.set('title', Utils.transferBinderTitle); + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadBindersTbl!); + } + + initHtml(): string { + return ` + + + + + + + + + + + + + + + + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/clock/TabPaneClockCounter.ts b/ide/src/trace/component/trace/sheet/clock/TabPaneClockCounter.ts index 6527b429c55666724f456f91917614c5386c95ea..3182b0f7137c21d0d809ca1eb2120f812772fa1f 100644 --- a/ide/src/trace/component/trace/sheet/clock/TabPaneClockCounter.ts +++ b/ide/src/trace/component/trace/sheet/clock/TabPaneClockCounter.ts @@ -39,6 +39,7 @@ export class TabPaneClockCounter extends BaseElement { let dataSource: Array = []; let collect = clockCounterValue.clockMapData; let sumCount = 0; + this.clockCounterTbl!.loading = true; for (let key of collect.keys()) { let counters = collect.get(key); let res = await counters?.({ startNS: clockCounterValue.leftNs, endNS: clockCounterValue.rightNs, queryAll: true }); @@ -50,6 +51,7 @@ export class TabPaneClockCounter extends BaseElement { sumData.count = sumCount.toString(); sumData.process = ' '; dataSource.splice(0, 0, sumData); + this.clockCounterTbl!.loading = false; this.clockCounterSource = dataSource; this.clockCounterTbl!.recycleDataSource = dataSource; } diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneBoxChild.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneBoxChild.ts index 1f10c3c5b79c9852f08eab80760fd00d59874379..0e8281ab6099c684b34de8b1a78e488c58e6d442 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneBoxChild.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneBoxChild.ts @@ -30,7 +30,7 @@ export class TabPaneBoxChild extends BaseElement { set data(boxChildValue: BoxJumpParam) { if (this.boxChildTbl) { // @ts-ignore - this.boxChildTbl.shadowRoot.querySelector('.table').style.height = this.parentElement!.clientHeight - 45 + 'px'; + this.boxChildTbl.shadowRoot?.querySelector('.table').style.height = this.parentElement!.clientHeight - 45 + 'px'; } this.boxChildRange!.textContent = 'Selected range: ' + parseFloat(((boxChildValue.rightNs - boxChildValue.leftNs) / 1000000.0).toFixed(5)) + ' ms'; diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuByThread.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuByThread.ts index 5c07ba2faf0586382b97be1747c48661f98637d2..e17b74227c6dbf6d2e8c4a4d0459dcde5ec12c81 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuByThread.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuByThread.ts @@ -128,10 +128,14 @@ export class TabPaneCpuByThread extends BaseElement { private updateCpuValues(e: any, cpuByThreadValue: any, cpuByThreadObject: any): void { cpuByThreadObject[`cpu${e.cpu}`] = e.wallDuration || 0; cpuByThreadObject[`cpu${e.cpu}TimeStr`] = getProbablyTime(e.wallDuration || 0); - cpuByThreadObject[`cpu${e.cpu}Ratio`] = ( + let ratio = ( (100.0 * (e.wallDuration || 0)) / (cpuByThreadValue.rightNs - cpuByThreadValue.leftNs) ).toFixed(2); + if (ratio === '0.00') { + ratio = '0'; + } + cpuByThreadObject[`cpu${e.cpu}Ratio`] = ratio; } private calculateCount(map: Map, sumWall: number, sumOcc: number): void { diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuUsage.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuUsage.ts index 7dc39f7ad48a85405ea40f13bb3503df5364c892..ee6d1cf28c173acd43abed02fd47e2ef63402cde 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuUsage.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneCpuUsage.ts @@ -193,15 +193,15 @@ export class TabPaneCpuUsage extends BaseElement { - + - + - + diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneFrequencySample.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneFrequencySample.ts index f12c6c564ea98ebb626ea2495b638d27a7f9aa1f..5c2dced6467dd2dc8f11a40dff4d3040188fe1b8 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneFrequencySample.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneFrequencySample.ts @@ -201,7 +201,7 @@ export class TabPaneFrequencySample extends BaseElement { stateFiliterIds ); let msg = { - frqSampleParam, + timeParam: { leftNs: frqSampleParam.leftNs, rightNs: frqSampleParam.rightNs, recordStartNs: frqSampleParam.recordStartNs }, result, sampleMap, res, diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPanePTS.ts b/ide/src/trace/component/trace/sheet/cpu/TabPanePTS.ts index 2df4b261331e7f573448178bc859e8de1e8b3077..574a13b5602e7e9d8628cc76e666c8d5fc707722 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPanePTS.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPanePTS.ts @@ -67,12 +67,7 @@ export class TabPanePTS extends BaseElement { this.ptsTbl!.setStatus(data, false); this.ptsTbl!.recycleDs = this.ptsTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if (label.includes('Thread') && i === 1) { - for (let item of data) { - item.status = true; - if (item.children != undefined && item.children.length > 0) { - this.ptsTbl!.setStatus(item.children, false); - } - } + this.ptsTbl!.setStatus(data, false, 0, 1); this.ptsTbl!.recycleDs = this.ptsTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if (label.includes('State') && i === 2) { this.ptsTbl!.setStatus(data, true); diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneSPT.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneSPT.ts index 89530f8331902fdc0408a088fbb4b17c2417dbcd..c70c1091f5962c26ce91ff96e6ac81b0aed1dda0 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneSPT.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneSPT.ts @@ -77,12 +77,7 @@ export class TabPaneSPT extends BaseElement { this.sptTbl!.setStatus(data, false); this.sptTbl!.recycleDs = this.sptTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if (label.includes('Process') && i === 1) { - for (let item of data) { - item.status = true; - if (item.children != undefined && item.children.length > 0) { - this.sptTbl!.setStatus(item.children, false); - } - } + this.sptTbl!.setStatus(data, false, 0, 1); this.sptTbl!.recycleDs = this.sptTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if (label.includes('Thread') && i === 2) { this.sptTbl!.setStatus(data, true); diff --git a/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts b/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts index bee85024041ce9c97e6ca3f508c3d09422fa1bb5..93a750f793e43e5edbbdd6acce2536601c93c3c5 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts @@ -20,7 +20,7 @@ import { resizeObserver } from '../SheetUtils'; import { procedurePool } from '../../../../database/Procedure'; import { Utils } from '../../base/Utils'; import { Priority } from '../../../../bean/StateProcessThread'; -import {queryThreadStateArgsByName} from "../../../../database/sql/ProcessThread.sql"; +import { queryThreadStateArgsByName } from '../../../../database/sql/ProcessThread.sql'; @element('tabpane-sched-priority') export class TabPaneSchedPriority extends BaseElement { @@ -97,8 +97,12 @@ export class TabPaneSchedPriority extends BaseElement { ); } - private fetchData(item: any, setPriority: (item: Priority, strArg: string[]) => void, - resultData: Array, runnableMap: Map) { + private fetchData( + item: any, + setPriority: (item: Priority, strArg: string[]) => void, + resultData: Array, + runnableMap: Map + ) { let strArg: string[] = []; const args = this.strValueMap.get(item.argSetID); if (args) { diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneCallTree.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneCallTree.ts index cfa07b6903c2163c777b70d2cadf59369702a36e..7bcc472a3371576ec40b5ad0ac93283d630d007d 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneCallTree.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneCallTree.ts @@ -322,16 +322,20 @@ export class TabPaneCallTree extends BaseElement { this.frameChart?.updateCanvas(false, entries[0].contentRect.width); this.frameChart?.calculateChartData(); } + let headLineHeight = 0; + if (this.callTreeHeadLine?.isShow) { + headLineHeight = this.callTreeHeadLine!.clientHeight; + } if (this.callTreeTbl) { // @ts-ignore this.callTreeTbl.shadowRoot.querySelector('.table').style.height = - this.parentElement!.clientHeight - 10 - 35 + 'px'; + this.parentElement!.clientHeight - 10 - 35 - headLineHeight + 'px'; this.callTreeTbl.reMeauseHeight(); } if (this.callTreeTbr) { // @ts-ignore this.callTreeTbr.shadowRoot.querySelector('.table').style.height = - this.parentElement!.clientHeight - 45 - 21 + 'px'; + this.parentElement!.clientHeight - 45 - 21 - headLineHeight + 'px'; this.callTreeTbr.reMeauseHeight(); } this.loadingPage.style.height = this.parentElement!.clientHeight - 24 + 'px'; @@ -460,7 +464,12 @@ export class TabPaneCallTree extends BaseElement { private handleFilterData(): void { this.callTreeFilter!.getFilterData((callTreeFilterData: FilterData) => { - if (this.searchValue !== this.callTreeFilter!.filterValue) { + if ( + (this.isChartShow && callTreeFilterData.icon === 'tree') || + (!this.isChartShow && callTreeFilterData.icon === 'block') + ) { + this.switchFlameChart(callTreeFilterData); + } else if (this.searchValue !== this.callTreeFilter!.filterValue) { this.searchValue = this.callTreeFilter!.filterValue; let callTreeArgs = [ { diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.ts index 7870387210aa8124d916e63a9f23edf836780905..8e47b5b9da782f90036228e8ffcb1c2098610dc6 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemCalltree.ts @@ -332,10 +332,10 @@ export class TabpaneFilesystemCalltree extends BaseElement { } } this.performDataProcessing(fsCallTreeFuncArgs); - }; + } private handleSymbolCase(data: any, fsCallTreeFuncArgs: any[]): void { - this.fsCallTreeFilter!.addDataMining({name: this.fsCallTreeCurrentSelectedData.symbolName}, data.item); + this.fsCallTreeFilter!.addDataMining({ name: this.fsCallTreeCurrentSelectedData.symbolName }, data.item); fsCallTreeFuncArgs.push({ funcName: 'splitTree', funcArgs: [this.fsCallTreeCurrentSelectedData.symbolName, false, true], @@ -343,7 +343,7 @@ export class TabpaneFilesystemCalltree extends BaseElement { } private handleLibraryCase(data: any, fsCallTreeFuncArgs: any[]): void { - this.fsCallTreeFilter!.addDataMining({name: this.fsCallTreeCurrentSelectedData.libName}, data.item); + this.fsCallTreeFilter!.addDataMining({ name: this.fsCallTreeCurrentSelectedData.libName }, data.item); fsCallTreeFuncArgs.push({ funcName: 'splitTree', funcArgs: [this.fsCallTreeCurrentSelectedData.libName, false, false], @@ -364,7 +364,9 @@ export class TabpaneFilesystemCalltree extends BaseElement { private handleFilterData(): void { this.fsCallTreeFilter!.getFilterData((data: FilterData): void => { - if (this.searchValue != this.fsCallTreeFilter!.filterValue) { + if ((this.isChartShow && data.icon === 'tree') || (!this.isChartShow && data.icon === 'block')) { + this.switchFlameChart(data); + } else if (this.searchValue != this.fsCallTreeFilter!.filterValue) { this.searchValue = this.fsCallTreeFilter!.filterValue; let fileArgs = [ { @@ -557,7 +559,7 @@ export class TabpaneFilesystemCalltree extends BaseElement { let data = evt.detail.data as FileMerageBean; document.dispatchEvent( new CustomEvent('number_calibration', { - detail: {time: data.tsArray, durations: data.durArray}, + detail: { time: data.tsArray, durations: data.durArray }, }) ); this.setRightTableData(data); @@ -592,18 +594,22 @@ export class TabpaneFilesystemCalltree extends BaseElement { this.frameChart?.updateCanvas(false, entries[0].contentRect.width); this.frameChart?.calculateChartData(); } + let headLineHeight = 0; + if (this.fileSystemHeadLine?.isShow) { + headLineHeight = this.fileSystemHeadLine!.clientHeight; + } if (this.fsCallTreeTbl) { // @ts-ignore this.fsCallTreeTbl.shadowRoot.querySelector('.table').style.height = - this.parentElement!.clientHeight - 10 - 35 + 'px'; + this.parentElement!.clientHeight - 10 - 35 - headLineHeight + 'px'; this.fsCallTreeTbl.reMeauseHeight(); } - if (this.fsCallTreeTbr) { - // @ts-ignore - this.fsCallTreeTbr.shadowRoot.querySelector('.table').style.height = - this.parentElement!.clientHeight - 45 - 21 + 'px'; - this.fsCallTreeTbr.reMeauseHeight(); - } + if (this.fsCallTreeTbr) { + // @ts-ignore + this.fsCallTreeTbr.shadowRoot.querySelector('.table').style.height = + this.parentElement!.clientHeight - 45 - 21 - headLineHeight + 'px'; + this.fsCallTreeTbr.reMeauseHeight(); + } this.loadingPage.style.height = this.parentElement!.clientHeight - 24 + 'px'; } }).observe(this.parentElement!); @@ -640,12 +646,12 @@ export class TabpaneFilesystemCalltree extends BaseElement { let isHideEvent: boolean = filterData.callTree[2]; let isHideThread: boolean = filterData.callTree[3]; let list = filterData.dataMining.concat(filterData.dataLibrary); - fileSysCallTreeArgs.push({funcName: 'hideThread', funcArgs: [isHideThread],}); - fileSysCallTreeArgs.push({funcName: 'hideEvent', funcArgs: [isHideEvent],}); - fileSysCallTreeArgs.push({funcName: 'getCallChainsBySampleIds', funcArgs: [isTopDown, 'fileSystem'],}); + fileSysCallTreeArgs.push({ funcName: 'hideThread', funcArgs: [isHideThread] }); + fileSysCallTreeArgs.push({ funcName: 'hideEvent', funcArgs: [isHideEvent] }); + fileSysCallTreeArgs.push({ funcName: 'getCallChainsBySampleIds', funcArgs: [isTopDown, 'fileSystem'] }); this.fsCallTreeTbr!.recycleDataSource = []; if (isHideSystemLibrary) { - fileSysCallTreeArgs.push({funcName: 'hideSystemLibrary', funcArgs: [],}); + fileSysCallTreeArgs.push({ funcName: 'hideSystemLibrary', funcArgs: [] }); } if (filterData.callTreeConstraints.checked) { fileSysCallTreeArgs.push({ @@ -653,8 +659,8 @@ export class TabpaneFilesystemCalltree extends BaseElement { funcArgs: [parseInt(filterData.callTreeConstraints.inputs[0]), filterData.callTreeConstraints.inputs[1]], }); } - fileSysCallTreeArgs.push({funcName: 'splitAllProcess', funcArgs: [list],}); - fileSysCallTreeArgs.push({funcName: 'resetAllNode', funcArgs: [],}); + fileSysCallTreeArgs.push({ funcName: 'splitAllProcess', funcArgs: [list] }); + fileSysCallTreeArgs.push({ funcName: 'resetAllNode', funcArgs: [] }); if (this._fsRowClickData && this._fsRowClickData.libId !== undefined && this._currentFsCallTreeLevel === 3) { fileSysCallTreeArgs.push({ funcName: 'showLibLevelData', diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.ts index 2fa252f902e798fd821bd73749dd36168bc9b042..b6f4d80fb481e2ec636a111705f3a5c1063d4c00 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatistics.ts @@ -14,11 +14,11 @@ */ import { BaseElement, element } from '../../../../../base-ui/BaseElement'; -import { LitTable } from '../../../../../base-ui/table/lit-table'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; import { SelectionParam } from '../../../../bean/BoxSelection'; import { Utils } from '../../base/Utils'; import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar'; -import {getTabPaneFilesystemStatistics} from "../../../../database/sql/SqlLite.sql"; +import { getTabPaneFilesystemStatistics } from '../../../../database/sql/SqlLite.sql'; @element('tabpane-file-statistics') export class TabPaneFileStatistics extends BaseElement { @@ -54,11 +54,9 @@ export class TabPaneFileStatistics extends BaseElement { this.fileStatisticsSortKey = evt.detail.key; // @ts-ignore this.fileStatisticsSortType = evt.detail.sort; - - let newSource = JSON.parse(JSON.stringify(this.fileStatisticsSource)); - if (this.fileStatisticsSortType != 0 && newSource.length > 0) - this.sortTable(newSource[0], this.fileStatisticsSortKey); - this.fileStatisticsTbl!.recycleDataSource = newSource; + if (this.fileStatisticsSortType != 0 && this.fileStatisticsSource.length > 0) + this.sortTable(this.fileStatisticsSource[0], this.fileStatisticsSortKey); + this.fileStatisticsTbl!.recycleDataSource = this.fileStatisticsSource; }); } @@ -132,12 +130,35 @@ export class TabPaneFileStatistics extends BaseElement { fileStatisticsAllNode = this.getInitData(fileStatisticsAllNode); fileStatisticsAllNode.title = 'All'; this.fileStatisticsSource = result.length > 0 ? [fileStatisticsAllNode] : []; - let newSource = JSON.parse(JSON.stringify(this.fileStatisticsSource)); if (this.fileStatisticsSortType != 0 && result.length > 0) - this.sortTable(newSource[0], this.fileStatisticsSortKey); - this.fileStatisticsTbl!.recycleDataSource = newSource; + this.sortTable(this.fileStatisticsSource[0], this.fileStatisticsSortKey); + this.theadClick(this.fileStatisticsSource); + this.fileStatisticsTbl!.recycleDataSource = this.fileStatisticsSource; }); } + private theadClick(res: Array): void { + let labels = this.fileStatisticsTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Syscall') && i === 0) { + this.fileStatisticsTbl!.setStatus(res, false, 0, 1); + this.fileStatisticsTbl!.recycleDs = this.fileStatisticsTbl!.meauseTreeRowElement( + res, + RedrawTreeForm.Retract + ); + } else if (label.includes('Process') && i === 1) { + this.fileStatisticsTbl!.setStatus(res, true); + this.fileStatisticsTbl!.recycleDs = this.fileStatisticsTbl!.meauseTreeRowElement( + res, + RedrawTreeForm.Retract + ); + } + }); + } + } + } private handleResult(result: Array, fileStatisticsFatherMap: Map, fileStatisticsAllNode: any): void { result.forEach((item, idx) => { @@ -170,9 +191,7 @@ export class TabPaneFileStatistics extends BaseElement { fileStatisticsAllNode.minDuration = item.minDuration; } else { fileStatisticsAllNode.minDuration = - fileStatisticsAllNode.minDuration <= item.minDuration - ? fileStatisticsAllNode.minDuration - : item.minDuration; + fileStatisticsAllNode.minDuration <= item.minDuration ? fileStatisticsAllNode.minDuration : item.minDuration; } fileStatisticsAllNode.count += item.count; fileStatisticsAllNode.logicalReads += item.logicalReads; diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.ts index 404060dd5db1bcd1980e1857045501a4243173f6..30662708e75573f0d1bf66a4a6dbffde3093fa06 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneFilesystemStatisticsAnalysis.ts @@ -97,10 +97,11 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { }, { funcName: 'getCurrentDataFromDb', - funcArgs: [{queryFuncName: 'fileSystem', ...val}], + funcArgs: [{ queryFuncName: 'fileSystem', ...val }], }, ], (results: any[]) => { + this.disableCheckBox(results); this.getFilesystemProcess(results); } ); @@ -151,6 +152,15 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { addRowClickEventListener(this.fileStatisticsAnalysisTableThread!, this.fileThreadLevelClickEvent.bind(this)); addRowClickEventListener(this.fileStatisticsAnalysisTableSo!, this.fileSoLevelClickEvent.bind(this)); } + private disableCheckBox(results: Array): void { + if (results.length === 0) { + this.hideProcessCheckBox?.setAttribute('disabled', 'disabled'); + this.hideThreadCheckBox?.setAttribute('disabled', 'disabled'); + } else { + this.hideProcessCheckBox?.removeAttribute('disabled'); + this.hideThreadCheckBox?.removeAttribute('disabled'); + } + } private checkBoxListener(box: LitCheckBox): void { box!.addEventListener('change', () => { @@ -880,7 +890,11 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { this.threadPieChart(); } - private updateThreadData(threadMap: Map>, fileSysStatThreadItem: any, allDur: number): void { + private updateThreadData( + threadMap: Map>, + fileSysStatThreadItem: any, + allDur: number + ): void { this.fileStatisticsAnalysisThreadData = []; threadMap.forEach((value: Array, key: string) => { let dur = 0; @@ -890,7 +904,7 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { tName = fileSysStatThreadItem.threadName = fileSysStatThreadItem.threadName === null || fileSysStatThreadItem.threadName === undefined ? `Thread(${fileSysStatThreadItem.tid})` - : `${fileSysStatThreadItem.threadName}`; + : `${fileSysStatThreadItem.threadName}(${fileSysStatThreadItem.tid})`; } const threadData = { tableName: tName, @@ -942,16 +956,16 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { return false; } if (!this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return (itemData.pid !== item.pid || itemData.tid !== item.tid || itemData.type !== item.type); + return itemData.pid !== item.pid || itemData.tid !== item.tid || itemData.type !== item.type; } if (!this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { - return (itemData.pid !== item.pid || itemData.type !== item.type); + return itemData.pid !== item.pid || itemData.type !== item.type; } if (this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return (itemData.tid !== item.tid || itemData.type !== item.type); + return itemData.tid !== item.tid || itemData.type !== item.type; } if (this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { - return (itemData.type !== item.type); + return itemData.type !== item.type; } return false; } @@ -1013,16 +1027,21 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { return false; } if (!this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return (fsProcessData.pid !== pid || fsProcessData.tid !== tid || fsProcessData.type !== type || fsProcessData.libId !== libId); + return ( + fsProcessData.pid !== pid || + fsProcessData.tid !== tid || + fsProcessData.type !== type || + fsProcessData.libId !== libId + ); } if (!this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { - return (fsProcessData.pid !== pid || fsProcessData.type !== type || fsProcessData.libId !== libId); + return fsProcessData.pid !== pid || fsProcessData.type !== type || fsProcessData.libId !== libId; } if (this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return (fsProcessData.tid !== tid || fsProcessData.type !== type || fsProcessData.libId !== libId); + return fsProcessData.tid !== tid || fsProcessData.type !== type || fsProcessData.libId !== libId; } if (this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { - return (fsProcessData.type !== type || fsProcessData.libId !== libId); + return fsProcessData.type !== type || fsProcessData.libId !== libId; } return false; } @@ -1112,7 +1131,7 @@ export class TabPaneFilesystemStatisticsAnalysis extends BaseElement { procedurePool.submitWithName( 'logic0', 'fileSystem-action', - {args, callType: 'fileSystem', isAnalysis: true}, + { args, callType: 'fileSystem', isAnalysis: true }, undefined, (results: any) => { handler(results); diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.ts index 38b4d17ab17413e768405cdd9a7ecea83b8a3e5e..1cba252e8f6c3fc3769ceff3b6e27bab5d17ab45 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics.ts @@ -14,12 +14,12 @@ */ import { BaseElement, element } from '../../../../../base-ui/BaseElement'; -import { LitTable } from '../../../../../base-ui/table/lit-table'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; import { SelectionParam } from '../../../../bean/BoxSelection'; import { Utils } from '../../base/Utils'; import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar'; import { SpSystemTrace } from '../../../SpSystemTrace'; -import { getTabPaneIOTierStatisticsData } from "../../../../database/sql/SqlLite.sql"; +import { getTabPaneIOTierStatisticsData } from '../../../../database/sql/SqlLite.sql'; @element('tabpane-io-tier-statistics') export class TabPaneIOTierStatistics extends BaseElement { @@ -31,7 +31,6 @@ export class TabPaneIOTierStatistics extends BaseElement { private ioTierStatisticsSource: Array = []; private ioTierStatisticsSortKey: string = ''; private ioTierStatisticsSortType: number = 0; - private ioTierStatisticsResultData: Array = []; set data(ioTierStatisticsSelection: SelectionParam | any) { if (ioTierStatisticsSelection == this.ioTierStatisticsSelectionParam) { @@ -55,11 +54,9 @@ export class TabPaneIOTierStatistics extends BaseElement { this.ioTierStatisticsSortKey = evt.detail.key; // @ts-ignore this.ioTierStatisticsSortType = evt.detail.sort; - - let newSource = JSON.parse(JSON.stringify(this.ioTierStatisticsSource)); - if (this.ioTierStatisticsSortType != 0 && newSource.length > 0) - this.sortTable(newSource[0], this.ioTierStatisticsSortKey); - this.ioTierStatisticsTbl!.recycleDataSource = newSource; + if (this.ioTierStatisticsSortType != 0 && this.ioTierStatisticsSource.length > 0) + this.sortTable(this.ioTierStatisticsSource[0], this.ioTierStatisticsSortKey); + this.ioTierStatisticsTbl!.recycleDataSource = this.ioTierStatisticsSource; }); } @@ -106,10 +103,38 @@ export class TabPaneIOTierStatistics extends BaseElement { this.ioTierStatisticsProgressEL!.loading = false; this.loadingPage.style.visibility = 'hidden'; } - this.ioTierStatisticsResultData = JSON.parse(JSON.stringify(result)); this.sortioTierStatisticsStatus(result, 'tier', 'ipid'); }); } + private theadClick(res: Array): void { + let labels = this.ioTierStatisticsTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Tier') && i === 0) { + this.ioTierStatisticsTbl!.setStatus(res, false, 0, 1); + this.ioTierStatisticsTbl!.recycleDs = this.ioTierStatisticsTbl!.meauseTreeRowElement( + res, + RedrawTreeForm.Retract + ); + } else if (label.includes('Process') && i === 1) { + this.ioTierStatisticsTbl!.setStatus(res, false, 0, 2); + this.ioTierStatisticsTbl!.recycleDs = this.ioTierStatisticsTbl!.meauseTreeRowElement( + res, + RedrawTreeForm.Retract + ); + } else if (label.includes('Path') && i === 2) { + this.ioTierStatisticsTbl!.setStatus(res, true); + this.ioTierStatisticsTbl!.recycleDs = this.ioTierStatisticsTbl!.meauseTreeRowElement( + res, + RedrawTreeForm.Expand + ); + } + }); + } + } + } sortioTierStatisticsStatus(result: Array, firstLevel: string, secondLevel: string) { let ioTierFatherMap = new Map(); @@ -140,12 +165,12 @@ export class TabPaneIOTierStatistics extends BaseElement { this.calculateAvgDuration(ioTierFatherMap, ioTierChildMap, ioTierAllNode); ioTierAllNode = this.getInitData(ioTierAllNode); ioTierAllNode.title = 'All'; - ioTierAllNode.path = {tier: null, pid: null, path: null, value: 'All'}; + ioTierAllNode.path = { tier: null, pid: null, path: null, value: 'All' }; this.ioTierStatisticsSource = result.length > 0 ? [ioTierAllNode] : []; - let newSource = JSON.parse(JSON.stringify(this.ioTierStatisticsSource)); if (this.ioTierStatisticsSortType != 0 && result.length > 0) - this.sortTable(newSource[0], this.ioTierStatisticsSortKey); - this.ioTierStatisticsTbl!.recycleDataSource = newSource; + this.sortTable(this.ioTierStatisticsSource[0], this.ioTierStatisticsSortKey); + this.theadClick(this.ioTierStatisticsSource); + this.ioTierStatisticsTbl!.recycleDataSource = this.ioTierStatisticsSource; } private updateIoTierFatherMap(ioTierFatherMap: Map, resultItem: any, firstLevel: string): void { @@ -170,8 +195,12 @@ export class TabPaneIOTierStatistics extends BaseElement { } } - private updateIoTierChildMap(ioTierChildMap: Map, resultItem: any, firstLevel: string, - secondLevel: string): void { + private updateIoTierChildMap( + ioTierChildMap: Map, + resultItem: any, + firstLevel: string, + secondLevel: string + ): void { if (ioTierChildMap.has(resultItem[firstLevel] + '_' + resultItem[secondLevel])) { let currentChildObject = ioTierChildMap.get(resultItem[firstLevel] + '_' + resultItem[secondLevel]); currentChildObject.count += resultItem.count; @@ -193,7 +222,11 @@ export class TabPaneIOTierStatistics extends BaseElement { } } - private calculateAvgDuration(ioTierFatherMap: Map, ioTierChildMap: Map, ioTierAllNode: any): void { + private calculateAvgDuration( + ioTierFatherMap: Map, + ioTierChildMap: Map, + ioTierAllNode: any + ): void { for (let ks of ioTierFatherMap.keys()) { let sp = ioTierFatherMap.get(ks); sp!.children = []; @@ -208,6 +241,7 @@ export class TabPaneIOTierStatistics extends BaseElement { for (let kst of ioTierChildMap.keys()) { if (kst.startsWith(ks + '_')) { let spt = ioTierChildMap.get(kst); + spt.avgDuration = spt.allDuration / spt.count; let data = this.getInitData(spt!, 'pname', 'pid'); data.path = { tier: ioTierNode.tier, diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatisticsAnalysis.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatisticsAnalysis.ts index e09a35f44bd0e86f8998a4bad71fa4cf373854e6..5fccecc81bf82c8bdd997710ce29b0852ea5206d 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatisticsAnalysis.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneIOTierStatisticsAnalysis.ts @@ -78,7 +78,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { for (let ioTable of this.ioTableArray) { initSort(ioTable!, this.ioSortColumn, this.ioSortType); } - } + } this.reset(this.ioTierTableProcess!, false); this.hideProcessCheckBox!.checked = false; this.hideThreadCheckBox!.checked = false; @@ -100,14 +100,15 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { }, { funcName: 'getCurrentDataFromDb', - funcArgs: [{queryFuncName: 'io', ...ioTierStatisticsAnalysisSelection}], + funcArgs: [{ queryFuncName: 'io', ...ioTierStatisticsAnalysisSelection }], }, ], (results: any[]) => { this.processData = JSON.parse(JSON.stringify(results)); + this.disableCheckBox(); this.getIOTierProcess(this.processData); } - ); + ); } initElements(): void { @@ -155,6 +156,15 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { addRowClickEventListener(this.ioTierTableThread!, this.ioTierThreadLevelClickEvent.bind(this)); addRowClickEventListener(this.ioTierTableSo!, this.ioTierSoLevelClickEvent.bind(this)); } + private disableCheckBox(): void { + if (this.processData.length === 0) { + this.hideProcessCheckBox?.setAttribute('disabled', 'disabled'); + this.hideThreadCheckBox?.setAttribute('disabled', 'disabled'); + } else { + this.hideProcessCheckBox?.removeAttribute('disabled'); + this.hideThreadCheckBox?.removeAttribute('disabled'); + } + } private columnClickEvent(ioTable: LitTable): void { ioTable!.addEventListener('column-click', (evt) => { @@ -178,6 +188,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { this.hideProcess(); } else { this.reset(this.ioTierTableProcess!, false); + this.showAssignLevel(this.ioTierTableProcess!, this.ioTierTableThread!, 1, this.tierTableType!.recycleDataSource); this.getIOTierProcess(this.processData); } }); @@ -245,10 +256,10 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { if (tierTable === showTable) { initSort(tierTable!, this.ioSortColumn, this.ioSortType); tierTable.style.display = 'grid'; - tierTable.setAttribute('hideDownload', ''); - } else { - tierTable!.style.display = 'none'; tierTable!.removeAttribute('hideDownload'); + } else { + tierTable!.style.display = 'none'; + tierTable.setAttribute('hideDownload', ''); } } } @@ -263,19 +274,20 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { this.tableFunction!.recycleDataSource = []; } - private showAssignLevel(showIoTable: LitTable, hideIoTable: LitTable, currentLevel: number): void { + private showAssignLevel(showIoTable: LitTable, hideIoTable: LitTable, currentLevel: number,currentLevelData: Array): void { showIoTable!.style.display = 'grid'; hideIoTable!.style.display = 'none'; hideIoTable.setAttribute('hideDownload', ''); showIoTable?.removeAttribute('hideDownload'); this.currentLevel = currentLevel; + this.currentLevelData = currentLevelData; } private goBack(): void { this.iOTierStatisticsAnalysisBack!.addEventListener('click', () => { if (this.tabName!.textContent === 'Statistic By type AllDuration') { this.iOTierStatisticsAnalysisBack!.style.visibility = 'hidden'; - this.showAssignLevel(this.ioTierTableProcess!, this.tierTableType!, 0); + this.showAssignLevel(this.ioTierTableProcess!, this.tierTableType!, 0, this.ioTierTableProcess!.recycleDataSource); this.processPieChart(); } else if (this.tabName!.textContent === 'Statistic By Thread AllDuration') { if (this.hideProcessCheckBox?.checked) { @@ -283,21 +295,21 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { } else { this.iOTierStatisticsAnalysisBack!.style.visibility = 'visible'; } - this.showAssignLevel(this.tierTableType!, this.ioTierTableThread!, 1); + this.showAssignLevel(this.tierTableType!, this.ioTierTableThread!, 1, this.tierTableType!.recycleDataSource); this.typePieChart(); } else if (this.tabName!.textContent === 'Statistic By Library AllDuration') { if (this.hideThreadCheckBox?.checked) { if (this.hideProcessCheckBox?.checked) { this.iOTierStatisticsAnalysisBack!.style.visibility = 'hidden'; } - this.showAssignLevel(this.tierTableType!, this.ioTierTableSo!, 1); + this.showAssignLevel(this.tierTableType!, this.ioTierTableSo!, 1, this.tierTableType!.recycleDataSource); this.typePieChart(); } else { - this.showAssignLevel(this.ioTierTableThread!, this.ioTierTableSo!, 2); + this.showAssignLevel(this.ioTierTableThread!, this.ioTierTableSo!, 2, this.ioTierTableThread!.recycleDataSource); this.threadPieChart(); } } else if (this.tabName!.textContent === 'Statistic By Function AllDuration') { - this.showAssignLevel(this.ioTierTableSo!, this.tableFunction!, 3); + this.showAssignLevel(this.ioTierTableSo!, this.tableFunction!, 3, this.ioTierTableSo!.recycleDataSource); this.libraryPieChart(); } }); @@ -305,12 +317,14 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private hideProcess(): void { this.reset(this.tierTableType!, false); + this.showAssignLevel(this.tierTableType!, this.ioTierTableProcess!, 1, this.tierTableType!.recycleDataSource); this.processName = ''; this.getIOTierType(null); } private hideThread(it?: any): void { this.reset(this.tierTableType!, true); + this.showAssignLevel(this.tierTableType!, this.ioTierTableThread!, 1, this.tierTableType!.recycleDataSource); this.processName = ''; this.threadName = ''; if (it) { @@ -364,6 +378,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private ioTierProcessLevelClickEvent(it: any): void { this.reset(this.tierTableType!, true); + this.showAssignLevel(this.tierTableType!, this.ioTierTableProcess!, 1, this.tierTableType!.recycleDataSource); this.getIOTierType(it); this.processName = it.tableName; this.ioPieChart?.hideTip(); @@ -412,9 +427,11 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private ioTierTypeLevelClickEvent(it: any): void { if (this.hideThreadCheckBox!.checked) { this.reset(this.ioTierTableSo!, true); + this.showAssignLevel(this.ioTierTableSo!, this.tierTableType!, 2, this.ioTierTableThread!.recycleDataSource); this.getIOTierSo(it); } else { this.reset(this.ioTierTableThread!, true); + this.showAssignLevel(this.ioTierTableThread!, this.tierTableType!, 2, this.ioTierTableThread!.recycleDataSource); this.getIOTierThread(it); } this.typeName = it.tableName; @@ -491,6 +508,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private ioTierThreadLevelClickEvent(it: any): void { this.reset(this.ioTierTableSo!, true); + this.showAssignLevel(this.ioTierTableSo!, this.ioTierTableThread!, 3, this.ioTierTableSo!.recycleDataSource); this.getIOTierSo(it); this.threadName = it.tableName; this.ioPieChart?.hideTip(); @@ -576,6 +594,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private ioTierSoLevelClickEvent(it: any): void { this.reset(this.tableFunction!, true); + this.showAssignLevel(this.tableFunction!, this.ioTierTableSo!, 4, this.tableFunction!.recycleDataSource); this.getIOTierFunction(it); this.ioPieChart?.hideTip(); let title = ''; @@ -827,7 +846,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { for (let item of value) { dur += item.dur; tName = item.threadName = - item.threadName === null || item.threadName === undefined ? `Thread(${item.tid})` : `${item.threadName}`; + item.threadName === null || item.threadName === undefined ? `Thread(${item.tid})` : `${item.threadName}(${item.tid})`; } const threadData = { tableName: tName, @@ -871,8 +890,10 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { private tierSoIsAccumulationData(item: any, processItemData: any): boolean { if (!this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return item && - (processItemData.pid !== item.pid || processItemData.tid !== item.tid || processItemData.type !== item.type); + return ( + item && + (processItemData.pid !== item.pid || processItemData.tid !== item.tid || processItemData.type !== item.type) + ); } else if (!this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { return item && (processItemData.pid !== item.pid || processItemData.type !== item.type); } else if (this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { @@ -986,8 +1007,9 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { return false; } if (!this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return processData.pid !== pid || processData.tid !== tid || - processData.type !== type || processData.libId !== libId; + return ( + processData.pid !== pid || processData.tid !== tid || processData.type !== type || processData.libId !== libId + ); } else if (!this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { return processData.pid !== pid || processData.type !== type || processData.libId !== libId; } else if (this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { @@ -1099,7 +1121,7 @@ export class TabPaneIOTierStatisticsAnalysis extends BaseElement { procedurePool.submitWithName( 'logic0', 'fileSystem-action', - {args, callType: 'io', isAnalysis: true}, + { args, callType: 'io', isAnalysis: true }, undefined, (results: any) => { handler(results); diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.ts index ee14617ed34912cfd5f5ec86de4a7cfbd5d9cfb2..3c8a7f988be765e23581c933c4c46fc1b4bbd140 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics.ts @@ -14,14 +14,14 @@ */ import { BaseElement, element } from '../../../../../base-ui/BaseElement'; -import { LitTable } from '../../../../../base-ui/table/lit-table'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; import { SelectionParam } from '../../../../bean/BoxSelection'; import { Utils } from '../../base/Utils'; import { LitProgressBar } from '../../../../../base-ui/progress-bar/LitProgressBar'; import { TabPaneFilter } from '../TabPaneFilter'; import '../TabPaneFilter'; import { VM_TYPE_MAP } from '../../../../database/logic-worker/ProcedureLogicWorkerFileSystem'; -import {getTabPaneVirtualMemoryStatisticsData} from "../../../../database/sql/Memory.sql"; +import { getTabPaneVirtualMemoryStatisticsData } from '../../../../database/sql/Memory.sql'; @element('tabpane-virtual-memory-statistics') export class TabPaneVirtualMemoryStatistics extends BaseElement { @@ -58,11 +58,9 @@ export class TabPaneVirtualMemoryStatistics extends BaseElement { this.vmStatisticsSortKey = evt.detail.key; // @ts-ignore this.vmStatisticsSortType = evt.detail.sort; - - let newSource = JSON.parse(JSON.stringify(this.vmStatisticsSource)); - if (this.vmStatisticsSortType != 0 && newSource.length > 0) - this.sortVmStatisticsTable(newSource[0], this.vmStatisticsSortKey); - this.vmStatisticsTbl!.recycleDataSource = newSource; + if (this.vmStatisticsSortType != 0 && this.vmStatisticsSource.length > 0) + this.sortVmStatisticsTable(this.vmStatisticsSource[0], this.vmStatisticsSortKey); + this.vmStatisticsTbl!.recycleDataSource = this.vmStatisticsSource; }); this.vmStatisticsFilter = this.shadowRoot!.querySelector('#filter'); this.vmStatisticsFilter!.getStatisticsTypeData((type) => { @@ -154,13 +152,37 @@ export class TabPaneVirtualMemoryStatistics extends BaseElement { vmMemoryStatAllNode.title = 'All'; vmMemoryStatAllNode.path = { type: null, tid: null, pid: null, value: 'All' }; this.vmStatisticsSource = result.length > 0 ? [vmMemoryStatAllNode] : []; - let newSource = JSON.parse(JSON.stringify(this.vmStatisticsSource)); if (this.vmStatisticsSortType != 0 && result.length > 0) - this.sortVmStatisticsTable(newSource[0], this.vmStatisticsSortKey); - this.vmStatisticsTbl!.recycleDataSource = newSource; + this.sortVmStatisticsTable(this.vmStatisticsSource[0], this.vmStatisticsSortKey); + this.theadClick(this.vmStatisticsSource); + this.vmStatisticsTbl!.recycleDataSource = this.vmStatisticsSource; } - - private handleFatherMap(vmMemoryStatFatherMap: Map, firstLevel: string, vmMemoryStatChildMap: Map, vmMemoryStatAllNode: any): void { + private theadClick(res: Array): void { + let labels = this.vmStatisticsTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Operation') && i === 0) { + this.vmStatisticsTbl!.setStatus(res, false, 0, 1); + this.vmStatisticsTbl!.recycleDs = this.vmStatisticsTbl!.meauseTreeRowElement(res, RedrawTreeForm.Retract); + } else if (label.includes('Process') && i === 1) { + this.vmStatisticsTbl!.setStatus(res, false, 0, 2); + this.vmStatisticsTbl!.recycleDs = this.vmStatisticsTbl!.meauseTreeRowElement(res, RedrawTreeForm.Retract); + } else if (label.includes('Thread') && i === 2) { + this.vmStatisticsTbl!.setStatus(res, true); + this.vmStatisticsTbl!.recycleDs = this.vmStatisticsTbl!.meauseTreeRowElement(res, RedrawTreeForm.Expand); + } + }); + } + } + } + private handleFatherMap( + vmMemoryStatFatherMap: Map, + firstLevel: string, + vmMemoryStatChildMap: Map, + vmMemoryStatAllNode: any + ): void { for (let ks of vmMemoryStatFatherMap.keys()) { let sp = vmMemoryStatFatherMap.get(ks); sp!.children = []; @@ -178,7 +200,13 @@ export class TabPaneVirtualMemoryStatistics extends BaseElement { } } - private handleChildMap(vmMemoryStatChildMap: Map, ks: any, firstLevel: string, vmMemoryStatNode: any, sp: any): void { + private handleChildMap( + vmMemoryStatChildMap: Map, + ks: any, + firstLevel: string, + vmMemoryStatNode: any, + sp: any + ): void { for (let kst of vmMemoryStatChildMap.keys()) { if (kst.startsWith(ks + '_')) { let spt = vmMemoryStatChildMap.get(kst); @@ -233,7 +261,12 @@ export class TabPaneVirtualMemoryStatistics extends BaseElement { } } - private processChildMap(vmMemoryStatChildMap: Map, item: any, firstLevel: string, secondLevel: string): void { + private processChildMap( + vmMemoryStatChildMap: Map, + item: any, + firstLevel: string, + secondLevel: string + ): void { if (vmMemoryStatChildMap.has(item[firstLevel] + '_' + item[secondLevel])) { let vmMemoryStatChildObj = vmMemoryStatChildMap.get(item[firstLevel] + '_' + item[secondLevel]); vmMemoryStatChildObj.count += item.count; diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.html.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.html.ts index d70db43feaed862d8b88eaa00777d901050d6c7b..b80386019fb8bdc33b8cccfccabf595bc13ec77e 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.html.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.html.ts @@ -56,6 +56,10 @@ export const TabPaneVirtualMemoryStatisticsAnalysisHtml = ` left: 0; position: absolute; } + #filter{ + position: absolute; + bottom: 0px; + }
        diff --git a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.ts b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.ts index 8614a06013ac637f345e55660d452a67fded15b4..6438a1ebcbe2ca31c3690c3e48209a08dfd10223 100644 --- a/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.ts +++ b/ide/src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatisticsAnalysis.ts @@ -100,10 +100,11 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { }, { funcName: 'getCurrentDataFromDb', - funcArgs: [{queryFuncName: 'virtualMemory', ...vmStatisticsAnalysisSelection}], + funcArgs: [{ queryFuncName: 'virtualMemory', ...vmStatisticsAnalysisSelection }], }, ], (results: any[]) => { + this.disableCheckBox(results); this.getVirtualMemoryProcess(results); } ); @@ -155,6 +156,15 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { addRowClickEventListener(this.vmStatisticsAnalysisTableThread!, this.vmThreadLevelClickEvent.bind(this)); addRowClickEventListener(this.vmStatisticsAnalysisTableSo!, this.vmSoLevelClickEvent.bind(this)); } + private disableCheckBox(results: Array): void { + if (results.length === 0) { + this.hideProcessCheckBox?.setAttribute('disabled', 'disabled'); + this.hideThreadCheckBox?.setAttribute('disabled', 'disabled'); + } else { + this.hideProcessCheckBox?.removeAttribute('disabled'); + this.hideThreadCheckBox?.removeAttribute('disabled'); + } + } private columnClickEvent(vmTable: LitTable): void { vmTable!.addEventListener('column-click', (evt) => { @@ -531,7 +541,7 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { private setVmPieChartConfig(): void { this.vmPieChart!.config = { appendPadding: 0, - data: this.getVmPieChartData(this.vmStatisticsAnalysisSoData), + data: this.getVmPieChartData(this.vmStatisticsAnalysisFunctionData), angleField: 'duration', colorField: 'tableName', radius: 1, @@ -820,7 +830,9 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { for (let item of value) { vmThreadDur += item.dur; tName = item.threadName = - item.threadName === null || item.threadName === undefined ? `Thread(${item.tid})` : `${item.threadName}`; + item.threadName === null || item.threadName === undefined + ? `Thread(${item.tid})` + : `${item.threadName}(${item.tid})`; } const threadData = { tableName: tName, @@ -950,7 +962,7 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { private setVmPieConfig() { this.vmPieChart!.config = { appendPadding: 0, - data: this.getVmPieChartData(this.vmStatisticsAnalysisFunctionData), + data: this.getVmPieChartData(this.vmStatisticsAnalysisSoData), angleField: 'duration', colorField: 'tableName', radius: 1, @@ -982,8 +994,12 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { private vmFunctionIsAccumulationData(vmProcessData: any, tid: number, pid: number, type: string, libId: number) { if (!this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { - return vmProcessData.pid !== pid || vmProcessData.tid !== tid || vmProcessData.type !== type || - vmProcessData.libId !== libId; + return ( + vmProcessData.pid !== pid || + vmProcessData.tid !== tid || + vmProcessData.type !== type || + vmProcessData.libId !== libId + ); } else if (!this.hideProcessCheckBox?.checked && this.hideThreadCheckBox?.checked) { return vmProcessData.pid !== pid || vmProcessData.type !== type || vmProcessData.libId !== libId; } else if (this.hideProcessCheckBox?.checked && !this.hideThreadCheckBox?.checked) { @@ -1076,7 +1092,7 @@ export class TabPaneVirtualMemoryStatisticsAnalysis extends BaseElement { procedurePool.submitWithName( 'logic0', 'fileSystem-action', - {args, callType: 'virtualMemory', isAnalysis: true}, + { args, callType: 'virtualMemory', isAnalysis: true }, undefined, (results: any) => { handler(results); diff --git a/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.ts b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4559346ab99d8ff874dba47f0ba450d8b755eeb --- /dev/null +++ b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.ts @@ -0,0 +1,1266 @@ + +/* + * Copyright (C) 2023 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'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import '../../../StackBar'; +import { getTabRunningPercent } from '../../../../database/sql/ProcessThread.sql'; +import { queryCpuFreqUsageData, queryCpuFreqFilterId } from '../../../../database/sql/Cpu.sql'; +import { querySearchFuncData } from '../../../../database/sql/Func.sql'; +import { Utils } from '../../base/Utils'; +import { resizeObserver } from '../SheetUtils'; +import { LitChartScatter } from '../../../../../base-ui/chart/scatter/LitChartScatter'; +import { SpSegmentationChart } from '../../../chart/SpSegmentationChart'; +import { TabPaneFreqUsageConfig, type TabPaneRunningConfig, TabPaneCpuFreqConfig} from './TabPaneFreqUsageConfig'; +@element('tabpane-freqdatacut') +export class TabPaneFreqDataCut extends BaseElement { + private threadStatesTbl: LitTable | null | undefined; + private threadStatesTblSource: Array = []; + private currentSelectionParam: SelectionParam | any; + private threadStatesDIV: HTMLDivElement | null | undefined; + private scatterInput: HTMLInputElement | null | undefined; + private initData: Map> = new Map(); + private processArr: Array = []; + private threadArr: Array = []; + private statisticsScatter: LitChartScatter | null | undefined; + set data(threadStatesParam: SelectionParam) { + if (this.currentSelectionParam === threadStatesParam) { + return; + } + this.currentSelectionParam = threadStatesParam; + this.initData = new Map(); + this.threadArr = []; + this.initUI(); + this.init(threadStatesParam); + let pidArr: Array = []; + // 整理进程级的数组信息 + let processArr: Array = + threadStatesParam.processIds.length > 1 + ? [...new Set(threadStatesParam.processIds)] + : threadStatesParam.processIds; + for (let i of processArr) { + pidArr.push( + new TabPaneFreqUsageConfig( + Utils.PROCESS_MAP.get(i) === null ? 'Process ' + i : Utils.PROCESS_MAP.get(i) + ' ' + i, + '', i, '', 0, '', '', 0, '', 0, 'process', -1, []) + ); + } + // 拷贝给私有属性,以便后续进行数据切割时免除整理进程层级数据 + this.processArr = pidArr; + } + /** + * 初始化数据 + */ + async init(threadStatesParam: SelectionParam): Promise { + let {runningMap, sum}: { + runningMap: Map>, + sum: number + } + = await this.queryRunningData(threadStatesParam); + let cpuFreqData: Array = await this.queryCpuFreqData( + threadStatesParam + ); + if (runningMap.size > 0) { + // 将cpu频点数据与running状态数据整合,保证其上该段时长内有对应的cpu频点数据 + this.mergeFreqData(runningMap, cpuFreqData, sum); + this.threadStatesTbl!.loading = false; + } else { + this.threadStatesTblSource = []; + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = false; + } + } + /** + * 重置UI输入框等组件为默认状态 + */ + initUI(): void { + this.threadStatesTblSource = []; + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = true; + // @ts-ignore + this.threadStatesTbl.value = []; + // @ts-ignore + this.shadowRoot?.querySelector('#dataCutThreadId').style.border = '1px solid rgb(151,151,151)'; + // @ts-ignore + this.shadowRoot?.querySelector('#dataCutThreadFunc').style.border = '1px solid rgb(151,151,151)'; + // @ts-ignore + this.shadowRoot?.querySelector('#maxFreq').style.border = '1px solid rgb(151,151,151)'; + // @ts-ignore + this.shadowRoot?.querySelector('#maxHz').style.border = '1px solid rgb(151,151,151)'; + // @ts-ignore + this.shadowRoot?.querySelector('#cycle-a-start-range').value = ''; + // @ts-ignore + this.shadowRoot?.querySelector('#cycle-a-end-range').value = ''; + // @ts-ignore + this.shadowRoot?.querySelector('#cycle-b-start-range').value = ''; + // @ts-ignore + this.shadowRoot?.querySelector('#cycle-b-end-range').value = ''; + // @ts-ignore + this.shadowRoot?.querySelector('#cycleQuery')!.style.display = 'none'; + // @ts-ignore + this.statisticsScatter!.config = undefined; + this.parentElement!.style.overflow = 'hidden'; + } + /** + * 查询cpu频点信息 + */ + async queryCpuFreqData(threadStatesParam: SelectionParam): Promise> { + // 查询cpu及id信息 + let result: Array<{ id: number; cpu: number }> = await queryCpuFreqFilterId(); + // 以键值对形式将cpu及id进行对应,后续会将频点数据与其对应cpu进行整合 + let idMap: Map = new Map(); + let queryId: Array = []; + for (let i = 0; i < result.length; i++) { + queryId.push(result[i].id); + idMap.set(result[i].id, result[i].cpu); + } + let dealArr: Array = []; + // 通过id去查询频点数据 + let res: Array<{ + startNS: number; + filter_id: number; + value: number; + dur: number} + > = await queryCpuFreqUsageData(queryId); + for (let i of res) { + dealArr.push( + new TabPaneCpuFreqConfig( + i.startNS + threadStatesParam.recordStartNs, + idMap.get(i.filter_id)!, + i.value, + i.dur + )); + } + return dealArr; + } + /** + * 查询框选区域内的所有running状态数据 + */ + async queryRunningData(threadStatesParam: SelectionParam): + Promise<{runningMap: Map>; sum: number}> { + let result: Array + = await getTabRunningPercent(threadStatesParam.threadIds, threadStatesParam.leftNs, threadStatesParam.rightNs); + let needDeal: Map> = new Map(); + let sum: number = 0; + if (result !== null && result.length > 0) { + let processArr: Array = threadStatesParam.processIds.length > 1 + ? [...new Set(threadStatesParam.processIds)] : threadStatesParam.processIds; + for (let e of result) { + if (processArr.includes(e.pid)) { + if (needDeal.get(e.pid + '_' + e.tid) === undefined) { + this.threadArr.push( + new TabPaneFreqUsageConfig(Utils.THREAD_MAP.get(e.tid) + ' ' + e.tid, + '', e.pid, e.tid, 0, '', '', 0, '', 0, 'thread', -1, []) + ); + needDeal.set(e.pid + '_' + e.tid, new Array()); + } + if (e.ts < threadStatesParam.leftNs + threadStatesParam.recordStartNs && + e.ts + e.dur > threadStatesParam.leftNs + threadStatesParam.recordStartNs) { + const ts = e.ts; + e.ts = threadStatesParam.leftNs + threadStatesParam.recordStartNs; + e.dur = ts + e.dur - (threadStatesParam.leftNs + threadStatesParam.recordStartNs); + } + if (e.ts + e.dur > threadStatesParam.rightNs + threadStatesParam.recordStartNs) { + e.dur = threadStatesParam.rightNs + threadStatesParam.recordStartNs - e.ts; + } + e.process = Utils.PROCESS_MAP.get(e.pid) === null ? '[NULL]' : Utils.PROCESS_MAP.get(e.pid)!; + e.thread = Utils.THREAD_MAP.get(e.tid) === null ? '[NULL]' : Utils.THREAD_MAP.get(e.tid)!; + let arr: Array | undefined = needDeal.get(e.pid + '_' + e.tid); + sum += e.dur; + arr?.push(e); + } + } + } + return {'runningMap': needDeal, 'sum': sum}; + } + /** + * 将cpu频点数据与running状态数据整合,保证其上该段时长内有对应的cpu频点数据 + */ + mergeFreqData( + needDeal: Map>, + dealArr: Array, + sum: number + ): void { + needDeal.forEach((value: Array, key: string) => { + let resultList: Array = []; + for (let i = 0; i < value.length; i++) { + for (let j = 0; j < dealArr.length; j++) { + // 只需要判断running状态数据与频点数据cpu相同的情况 + if (value[i].cpu === dealArr[j].cpu) { + // running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running状态数据的持续时间小于频点结束时间减去running状态数据开始时间的情况 + if (value[i].ts > dealArr[j].startNS && + value[i].ts < dealArr[j].startNS + dealArr[j].dur && + value[i].dur < dealArr[j].startNS + dealArr[j].dur - value[i].ts) { + resultList.push(new TabPaneFreqUsageConfig(value[i].thread, value[i].ts, value[i].pid, + value[i].tid, 0, value[i].cpu,dealArr[j].value, value[i].dur, '', (value[i].dur / sum) * 100, + 'freqdata', -1, undefined)); + break; + } + // running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running状态数据的持续时间大于频点结束时间减去running状态数据开始时间的情况 + if (value[i].ts > dealArr[j].startNS && + value[i].ts < dealArr[j].startNS + dealArr[j].dur && + value[i].dur > dealArr[j].startNS + dealArr[j].dur - value[i].ts) { + resultList.push(new TabPaneFreqUsageConfig(value[i].thread, value[i].ts, value[i].pid, + value[i].tid, 0, value[i].cpu, dealArr[j].value, dealArr[j].startNS + dealArr[j].dur - value[i].ts, '', + ((dealArr[j].startNS + dealArr[j].dur - value[i].ts) / sum) * 100, 'freqdata', -1, undefined)); + } + // running状态数据的开始时间小于频点数据开始时间,running状态数据的结束时间大于频点数据开始时间。且running状态数据在频点数据开始时间后的持续时间小于频点数据持续时间的情况 + if (value[i].ts < dealArr[j].startNS && + value[i].ts + value[i].dur > dealArr[j].startNS && + value[i].dur + value[i].ts - dealArr[j].startNS < dealArr[j].dur) { + resultList.push(new TabPaneFreqUsageConfig(value[i].thread, dealArr[j].startNS, value[i].pid, + value[i].tid, 0, value[i].cpu, dealArr[j].value, value[i].dur + value[i].ts - dealArr[j].startNS, '', + ((value[i].dur + value[i].ts - dealArr[j].startNS) / sum) * 100, 'freqdata', -1, undefined )); + break; + } + // running状态数据的开始时间小于频点数据开始时间,running状态数据的结束时间大于频点数据开始时间。且running状态数据在频点数据开始时间后的持续时间大于频点数据持续时间的情况 + if (value[i].ts < dealArr[j].startNS && + value[i].ts + value[i].dur > dealArr[j].startNS && + value[i].dur + value[i].ts - dealArr[j].startNS > dealArr[j].dur) { + resultList.push(new TabPaneFreqUsageConfig( value[i].thread, dealArr[j].startNS, value[i].pid, value[i].tid, + 0, value[i].cpu, dealArr[j].value, dealArr[j].dur, '', (dealArr[j].dur / sum) * 100, 'freqdata', -1, undefined)); + } + // running状态数据的开始时间小于频点数据开始时间,running状态数据的持续时间小于频点数据开始时间的情况 + if (value[i].ts < dealArr[j].startNS && value[i].ts + value[i].dur < dealArr[j].startNS) { + resultList.push(new TabPaneFreqUsageConfig(value[i].thread, value[i].ts, value[i].pid, value[i].tid, + 0, value[i].cpu, 'unknown', value[i].dur, '', (value[i].dur / sum) * 100, 'freqdata', -1, undefined)); + break; + } + } + } + } + this.initData.set(key, resultList); + }); + } + /** + * single方式切割数据功能 + */ + dataSingleCut( + threadId: HTMLInputElement, + threadFunc: HTMLInputElement, + resultList: Map> + ): void { + let threadIdValue: string = threadId.value.trim(); + let threadFuncName: string = threadFunc.value.trim(); + let rightNS: number = this.currentSelectionParam.rightNs; + let recordStartNs: number = this.currentSelectionParam.recordStartNs; + // @ts-ignore + this.threadStatesTbl.value = []; + if (threadIdValue !== '' && threadFuncName !== '') { + // 根据用户输入的线程ID,方法名去查询数据库,得到对应的方法起始时间,持续时间等数据,以便作为依据进行后续数据切割 + querySearchFuncData(threadFuncName, Number(threadIdValue), this.currentSelectionParam.leftNs, rightNS).then((result) => { + if (result !== null && result.length > 0) { + // targetMap为全局initData的拷贝对象,dealArr数组用来存放周期切割依据数据 + let targetMap: Map> = new Map(); + let dealArr: Array<{ts: number, dur: number}> = []; + // 新创建map对象接收传过来的实参map + resultList.forEach((item: Array, key: string) => { + targetMap.set(key, JSON.parse(JSON.stringify(item))); + }); + // 整理周期切割依据的数据 + for (let i of result) { + if (i.startTime! + recordStartNs + i.dur! < rightNS + recordStartNs) { + dealArr.push({ts: i.startTime! + recordStartNs, dur: i.dur!}); + } + } + let cycleMap: Map> = new Map(); + let totalList: Map> = new Map(); + this.mergeSingleData(dealArr, targetMap, cycleMap, totalList); + // 拷贝线程数组,防止数据污染 + let threadArr: Array = JSON.parse(JSON.stringify(this.threadArr)); + // 拷贝进程数组,防止数据污染 + let processArr: Array = JSON.parse(JSON.stringify(this.processArr)); + // 将周期层级防止到线程层级下 + this.mergeThreadData(threadArr, cycleMap); + // 将原始数据放置到对应的线程层级下,周期数据前 + this.mergeTotalData(threadArr, this.merge(totalList)); + // 合并数据到进程层级下 + this.mergePidData(processArr, threadArr); + this.fixedDeal(processArr); + this.threadStatesTblSource = processArr; + this.threadStatesTbl!.recycleDataSource = processArr; + this.threadClick(processArr); + } else { + this.threadStatesTblSource = []; + this.threadStatesTbl!.recycleDataSource = []; + } + this.threadStatesTbl!.loading = false; + }); + } else { + this.threadStatesTbl!.loading = false; + if (threadIdValue === '') { + threadId.style.border = '2px solid rgb(255,0,0)'; + } + if (threadFuncName === '') { + threadFunc.style.border = '2px solid rgb(255,0,0)'; + } + } + } + /** + * 整合Single切割方式中的频点数据与方法周期数据 + */ + mergeSingleData( + dealArr: Array<{ts: number, dur: number}>, + targetMap: Map>, + cycleMap: Map>, + totalList: Map> + ): void { + let timeDur = this.currentSelectionParam.recordStartNs; + targetMap.forEach((value: any, key) => { + cycleMap.set(key, new Array()); + totalList.set(key, new Array()); + for (let i = 0; i < dealArr.length; i++) { + let cpuArr: Array = []; + let resList: Array = []; + let cpuMap: Map> = new Map(); + // 时间倍数值 + const countMutiple: number = 1000000; + const MIN_NUM: number = 3; + cpuMap.set(key, new Array()); + cycleMap.get(key)?.push( + new TabPaneFreqUsageConfig('cycle' + (i + 1) + '—' + value[0].thread, + ((dealArr[i].ts - timeDur) / countMutiple).toFixed(MIN_NUM), key.split('_')[0], key.split('_')[1], + 0, '', '', 0, (dealArr[i].dur / countMutiple).toFixed(MIN_NUM), 0, 'cycle', i + 1, [] )); + this.dismantlingSingle( + value, + dealArr[i], + { + i: i, + key: key, + countMutiple: countMutiple, + cpuArr, + cpuMap + }, + resList, + totalList + ); + this.mergeData(resList); + // 整理排序相同周期下的数据 + this.mergeCpuData(cpuMap.get(key)!, resList); + // 将cpu数据放置到对应周期层级下 + this.mergeCycleData(cycleMap.get(key)![i], cpuMap.get(key)!); + } + }); + } + /** + * 拆解Single大函数 + * @param value 频点数据数组 + * @param funData 方法对象 + * @param constant 常量 + * @param resList 周期数组 + * @param totalList total数组 + */ + dismantlingSingle( + value: Array, funData: {ts: number, dur: number}, + constant: {i: number, key: string, countMutiple: number, cpuArr: Array, cpuMap: Map>}, + resList: Array, + totalList: Map> + ): void{ + // 判断若用户导入json文件,则替换为对应cpu下的对应频点的算力值进行算力消耗计算 + for (let j = 0; j < value.length; j++) { + let startTime = Number(value[j].ts); + let percent = Number(value[j].percent); + // @ts-ignore + let consumptionMap: Map = + SpSegmentationChart.freqInfoMapData.size > 0 && SpSegmentationChart.freqInfoMapData.get(Number(value[j].cpu)); + // 若存在算力值,则直接取值做计算。若不存在算力值,且频点值不为unknown的情况,则取频点值做计算,若为unknown,则取0做兼容 + const consumption: number = Number(consumptionMap && consumptionMap.get(Number(value[j].freq)) + ? consumptionMap.get(Number(value[j].freq)) : (value[j].freq === 'unknown' ? 0 : value[j].freq)); + if (!constant.cpuArr.includes(Number(value[j].cpu))) { + constant.cpuArr.push(Number(value[j].cpu)); + constant.cpuMap.get(constant.key)?.push( + new TabPaneFreqUsageConfig('cycle' + (constant.i + 1) + '—' + value[j].thread, '', + value[j].pid, value[j].tid, 0, value[j].cpu, '', 0, '', 0, 'cpu', -1, [])); + } + // 以下为频点数据按Single周期切割数据如何取舍的判断条件,dealArr为周期切割依据,value为某一线程下的频点汇总数据 + // 如果频点数据开始时间大于某一周期起始时间,小于该周期的结束时间。且频点数据结束时间小于周期结束时间的情况 + if (funData.ts < startTime && funData.ts + funData.dur > startTime && + funData.ts + funData.dur > startTime + value[j].dur) { + resList.push(this.returnSingleObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 1)!); + totalList.get(constant.key)?.push(this.returnSingleObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 1)!); + } + // 如果频点数据开始时间大于某一周期起始时间,小于该周期的结束时间。且频点数据结束时间大于等于周期结束时间的情况 + if (funData.ts < startTime && funData.ts + funData.dur > startTime && + funData.ts + funData.dur <= startTime + value[j].dur) { + resList.push(this.returnSingleObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 2)!); + totalList.get(constant.key)?.push(this.returnSingleObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 2)!); + break; + } + // 如果频点数据开始时间小于某一周期起始时间,结束时间大于该周期的开始时间。且频点数据结束时间大于周期结束时间的情况 + if (funData.ts > startTime && startTime + value[j].dur > funData.ts && + startTime + value[j].dur > funData.ts + funData.dur) { + resList.push(this.returnSingleObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 3)!); + totalList.get(constant.key)?.push(this.returnSingleObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 3)!); + break; + } + // 如果频点数据开始时间小于某一周期起始时间,结束时间大于该周期的开始时间。且频点数据结束时间小于等于周期结束时间的情况 + if (funData.ts > startTime && startTime + value[j].dur > funData.ts && + startTime + value[j].dur <= funData.ts + funData.dur) { + resList.push(this.returnSingleObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 4)!); + totalList.get(constant.key)?.push(this.returnSingleObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], funData, 4)!); + } + } + } + /** + * + * @param str 周期列头 + * @param arg 常量参数 + * @param value 频点数据对象 + * @param funData 方法对象 + * @param flag 标志位 + * @returns 频点数据对象 + */ + returnSingleObj( + str: string, + arg: {i: number, percent: number, startTime: number, consumption: number, countMutiple: number}, + value: TabPaneFreqUsageConfig, + funData: {ts: number, dur: number}, + flag: number + ): TabPaneFreqUsageConfig | undefined{ + switch (flag) { + case 1: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, (arg.consumption * value.dur) / arg.countMutiple, + value.cpu, value.freq, value.dur, '', arg.percent, 'freqdata', arg.i, undefined); + case 2: + return new TabPaneFreqUsageConfig(str,'', value.pid, value.tid, ((funData.ts + funData.dur - arg.startTime) + * arg.consumption) / arg.countMutiple, value.cpu, value.freq, funData.ts + funData.dur - arg.startTime, '', + ((funData.ts + funData.dur - arg.startTime) / value.dur) * arg.percent, 'freqdata', arg.i, undefined); + case 3: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, (funData.dur * arg.consumption) / arg.countMutiple, value.cpu, + value.freq, funData.dur, '', (funData.dur / value.dur) * arg.percent, 'freqdata', arg.i, undefined); + case 4: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, + ((arg.startTime + value.dur - funData.ts) * arg.consumption) / arg.countMutiple, + value.cpu, value.freq, arg.startTime + value.dur - funData.ts, '', + ((arg.startTime + value.dur - funData.ts) / value.dur) * arg.percent, + 'freqdata', arg.i, undefined); + default: + break; + } + } + /** + * Loop方式切割数据功能 + */ + dataLoopCut( + threadId: HTMLInputElement, + threadFunc: HTMLInputElement, + resultList: Map> + ): void { + let threadIdValue: string = threadId.value.trim(); + let threadFuncName: string = threadFunc.value.trim(); + let rightNS: number = this.currentSelectionParam.rightNs; + let recordStartNs: number = this.currentSelectionParam.recordStartNs; + // @ts-ignore + this.threadStatesTbl.value = []; + if (threadIdValue !== '' && threadFuncName !== '') { + querySearchFuncData(threadFuncName, Number(threadIdValue), this.currentSelectionParam.leftNs, rightNS).then((res) => { + if (res !== null && res.length > 0) { + // targetMap为全局initData的拷贝对象,cutArr数组用来存放周期切割依据数据 + let targetMap: Map> = new Map(); + let cutArr: Array<{ts: number, dur?: number}> = []; + // 新创建map对象接收传过来的实参map + resultList.forEach((item: Array, key: string) => { + targetMap.set(key, JSON.parse(JSON.stringify(item))); + }); + // 根据线程id及方法名获取的数据,处理后用作切割时间依据,时间跨度为整个方法开始时间到末个方法开始时间 + for (let i of res) { + cutArr[cutArr.length - 1] && (cutArr[cutArr.length - 1].dur = i.startTime ? i.startTime + + recordStartNs - cutArr[cutArr.length - 1].ts : 0); + cutArr.push({ts: i.startTime! + recordStartNs}); + } + let cycleMap: Map> = new Map(); + let totalList: Map> = new Map(); + this.mergeLoopData(cutArr, targetMap, cycleMap, totalList); + let threadArr: Array = JSON.parse(JSON.stringify(this.threadArr)); + let processArr: Array = JSON.parse(JSON.stringify(this.processArr)); + this.mergeThreadData(threadArr, cycleMap); + this.mergeTotalData(threadArr, this.merge(totalList)); + this.mergePidData(processArr, threadArr); + this.fixedDeal(processArr); + this.threadStatesTblSource = processArr; + this.threadStatesTbl!.recycleDataSource = processArr; + this.threadClick(processArr); + } else { + this.threadStatesTblSource = []; + this.threadStatesTbl!.recycleDataSource = []; + } + }); + this.threadStatesTbl!.loading = false; + } else { + this.threadStatesTbl!.loading = false; + if (threadIdValue === '') { + threadId.style.border = '2px solid rgb(255,0,0)'; + } + if (threadFuncName === '') { + threadFunc.style.border = '2px solid rgb(255,0,0)'; + } + } + } + /** + * 整合Loop切割方式中的频点数据与方法周期数据 + */ + mergeLoopData( + cutArr: Array<{ts: number, dur?: number}>, + targetMap: Map>, + cycleMap: Map>, + totalList: Map> + ): void { + let timeDur: number = this.currentSelectionParam.recordStartNs; + targetMap.forEach((value: any, key) => { + cycleMap.set(key, new Array()); + totalList.set(key, new Array()); + for (let i = 0; i < cutArr.length - 1; i++) { + let cpuArr: Array = []; + let resList: Array = []; + let cpuMap: Map> = new Map(); + // 时间倍数值 + const countMutiple: number = 1000000; + const MIN_NUM: number = 3; + cpuMap.set(key, new Array()); + // 创建周期层级数据 + cycleMap.get(key)?.push(new TabPaneFreqUsageConfig('cycle' + (i + 1) + '—' + value[0].thread, + ((cutArr[i].ts - timeDur) / countMutiple).toFixed(MIN_NUM), key.split('_')[0], key.split('_')[1], 0, '', + '', 0, (cutArr[i].dur! / countMutiple).toFixed(MIN_NUM), 0, 'cycle', i + 1, [])); + this.dismantlingLoop( + value, + cutArr, + { + i: i, + key: key, + countMutiple: countMutiple, + cpuArr, + cpuMap + }, + resList, + totalList + ); + // 合并相同周期内的数据 + this.mergeData(resList); + // 整理排序相同周期下的数据 + this.mergeCpuData(cpuMap.get(key)!, resList); + // 将cpu数据放置到对应周期层级下 + this.mergeCycleData(cycleMap.get(key)![i], cpuMap.get(key)!); + } + }); + } + /** + * 拆解Loop大函数 + * @param value 频点数据数组 + * @param funData 方法对象 + * @param constant 常量 + * @param resList 周期数组 + * @param totalList total数组 + */ + dismantlingLoop( + value: Array, cutArr:Array<{ts: number, dur?: number}>, + constant: {i: number, key: string, countMutiple: number, cpuArr: Array, cpuMap: Map>}, + resList: Array, + totalList: Map>): void { + for (let j = 0; j < value.length; j++) { + // 判断若用户导入json文件,则替换为对应cpu下的对应频点的算力值进行算力消耗计算 + let startTime = Number(value[j].ts); + let percent = Number(value[j].percent); + // @ts-ignore + let consumptionMap: Map = + SpSegmentationChart.freqInfoMapData.size > 0 && SpSegmentationChart.freqInfoMapData.get(Number(value[j].cpu)); + // 若存在算力值,则直接取值做计算。若不存在算力值,且频点值不为unknown的情况,则取频点值做计算,若为unknown,则取0做兼容 + const consumption: number = Number(consumptionMap && consumptionMap.get(Number(value[j].freq)) + ? consumptionMap.get(Number(value[j].freq)) : (value[j].freq === 'unknown' ? 0 : value[j].freq)); + if (!constant.cpuArr.includes(Number(value[j].cpu))) { + constant.cpuArr.push(Number(value[j].cpu)); + // 创建cpu层级数据,以便后续生成树结构 + constant.cpuMap.get(constant.key)?.push(new TabPaneFreqUsageConfig('cycle' + (constant.i + 1) + '—' + value[j].thread, + '', value[j].pid, value[j].tid, 0, value[j].cpu, '', 0, '', 0, 'cpu', -1, [])); + } + // 以下为频点数据按Loop周期切割数据如何取舍的判断条件,cutArr为周期切割依据,value为某一线程下的频点汇总数据 + // 如果频点数据开始时间大于某一周期起始时间,且结束时间小于等于下一同名方法开始时间的情况 + if (startTime >= cutArr[constant.i].ts && startTime + value[j].dur <= cutArr[constant.i + 1].ts) { + resList.push(this.returnLoopObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 1)!); + totalList.get(constant.key)?.push(this.returnLoopObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 1)!); + } + // 如果频点数据开始时间大于某一周期起始时间,且结束时间大于下一同名方法开始时间的情况 + if (startTime >= cutArr[constant.i].ts && startTime + value[j].dur > cutArr[constant.i + 1].ts) { + if (cutArr[constant.i + 1].ts - startTime > 0) { + resList.push(this.returnLoopObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 2)!); + totalList.get(constant.key)?.push(this.returnLoopObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 2)!); + break; + } + } + // 如果频点数据开始时间小于某一周期起始时间,且结束时间大于下一同名方法开始时间的情况 + if (startTime < cutArr[constant.i].ts && startTime + value[j].dur > cutArr[constant.i + 1].ts) { + resList.push(this.returnLoopObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 3)!); + totalList.get(constant.key)?.push(this.returnLoopObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 3)!); + } + // 如果频点数据开始时间小于某一周期起始时间,结束时间大于该方法开始时间。且频点数据结束时间小于下一同名方法开始时间 + if (startTime < cutArr[constant.i].ts && + startTime + value[j].dur > cutArr[constant.i].ts && startTime + value[j].dur < cutArr[constant.i + 1].ts) { + resList.push(this.returnLoopObj('cycle' + (constant.i + 1) + '—' + value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 4)!); + totalList.get(constant.key)?.push(this.returnLoopObj(value[j].thread, + {i: constant.i, percent, startTime, consumption, countMutiple: constant.countMutiple} ,value[j], cutArr, 4)!); + } + } + } + /** + * + * @param str 周期列头 + * @param arg 常量参数 + * @param value 频点数据对象 + * @param funData 方法对象 + * @param flag 标志位 + * @returns 频点数据对象 + */ + returnLoopObj( + str: string, + arg: {i: number, percent: number, startTime: number, consumption: number, countMutiple: number}, + value: TabPaneFreqUsageConfig, + cutArr: Array<{ts: number, dur?: number}>, + flag: number + ): TabPaneFreqUsageConfig | undefined{ + switch (flag) { + case 1: + return new TabPaneFreqUsageConfig(str, '', value.pid, + value.tid, (arg.consumption * value.dur) / arg.countMutiple, value.cpu, value.freq, + value.dur, '', value.percent, 'freqdata', arg.i, undefined); + case 2: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, + (arg.consumption * (cutArr[arg.i + 1].ts - arg.startTime)) / arg.countMutiple, value.cpu, value.freq, + cutArr[arg.i + 1].ts - arg.startTime, '', arg.percent * ((cutArr[arg.i + 1].ts - arg.startTime) / value.dur), + 'freqdata', arg.i, undefined); + case 3: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, + (arg.consumption * (cutArr[arg.i + 1].ts - cutArr[arg.i].ts)) / arg.countMutiple, value.cpu, value.freq, + cutArr[arg.i + 1].ts - cutArr[arg.i].ts, '', arg.percent * ((cutArr[arg.i + 1].ts - cutArr[arg.i].ts) / value.dur), + 'freqdata', arg.i, undefined); + case 4: + return new TabPaneFreqUsageConfig(str, '', value.pid, value.tid, (arg.consumption * (value.dur + arg.startTime - cutArr[arg.i].ts)) + / arg.countMutiple, value.cpu, value.freq, value.dur + arg.startTime - cutArr[arg.i].ts, '', arg.percent + * ((value.dur + arg.startTime - cutArr[arg.i].ts) / value.dur), 'freqdata', arg.i, undefined); + default: + break; + } + } + /** + * 切割后整合好的周期频点数据放置到对应的线程下 + */ + mergeThreadData( + threadArr: Array, + cycleMap: Map> + ): void { + for (let i = 0; i < threadArr.length; i++) { + let cycleMapData: Array = cycleMap.get( + threadArr[i].pid + '_' + threadArr[i].tid + )!; + for (let j = 0; j < cycleMapData!.length; j++) { + threadArr[i].children?.push(cycleMapData![j]); + threadArr[i].count += cycleMapData![j].count; + threadArr[i].dur += cycleMapData![j].dur; + // @ts-ignore + threadArr[i].percent += cycleMapData![j].percent; + } + } + } + /** + * 切割后整合好的线程级频点数据放置到对应的进程 + */ + mergePidData( + pidArr: Array, + threadArr: Array + ): void { + for (let i = 0; i < pidArr.length; i++) { + for (let j = 0; j < threadArr.length; j++) { + if (pidArr[i].pid === threadArr[j].pid) { + pidArr[i].children?.push(threadArr[j]); + pidArr[i].count += threadArr[j].count; + pidArr[i].dur += threadArr[j].dur; + // @ts-ignore + pidArr[i].percent += threadArr[j].percent; + } + } + } + } + /** + * 合并相同周期内运行所在cpu相同、频点相同的数据 + */ + mergeData(resList: Array): void { + // 合并相同周期内的数据 + for (let i = 0; i < resList.length; i++) { + for (let j = i + 1; j < resList.length; j++) { + if ( + resList[i].cpu === resList[j].cpu && + resList[i].freq === resList[j].freq && + resList[i].id === resList[j].id + ) { + resList[i].dur += resList[j].dur; + // @ts-ignore + resList[i].percent += resList[j].percent; + resList[i].count += resList[j].count; + resList.splice(j, 1); + j--; + } + } + } + } + /** + * 将cpu层级数据放到对应的周期层级下 + */ + mergeCycleData( + obj: TabPaneFreqUsageConfig, + arr: Array + ): void { + for (let i = 0; i < arr!.length; i++) { + if (arr![i].count === 0 && arr![i].dur === 0) { + continue; + } + obj.children?.push(arr![i]); + obj.count += arr![i].count; + obj.dur += arr![i].dur; + // @ts-ignore + obj.percent += arr![i].percent; + } + } + /** + * 将切割好的不区分周期的数据作为total数据放到对应的线程层级下,周期数据前 + */ + mergeTotalData( + threadArr: Array, + totalData: Array + ): void { + for (let i = 0; i < threadArr.length; i++) { + for (let j = 0; j < totalData.length; j++) { + if ( + Number(threadArr[i].pid) === Number(totalData[j].pid) && + Number(threadArr[i].tid) === Number(totalData[j].tid) + ) { + totalData[j].thread = 'TotalData'; + // @ts-ignore + threadArr[i].children.unshift(totalData[j]); + } + } + } + } + /** + * 整理排序相同周期下的数据 + */ + mergeCpuData( + cpuArray: Array, + resList: Array + ): void { + // 以算力消耗降序排列 + resList.sort((a, b) => b.count - a.count); + // 以cpu升序排列 + cpuArray.sort(( + a: TabPaneFreqUsageConfig, + b: TabPaneFreqUsageConfig + ) => Number(a.cpu) - Number(b.cpu)); + cpuArray.forEach((item: TabPaneFreqUsageConfig) => { + for (let s = 0; s < resList.length; s++) { + if (item.cpu === resList[s].cpu) { + item.children?.push(resList[s]); + item.count += resList[s].count; + item.dur += resList[s].dur; + // @ts-ignore + item.percent += resList[s].percent; + } + } + }); + } + /** + * 切割好的不区分周期的数据,以相同cpu相同频点的进行整合 + */ + merge( + totalList: Map> + ): Array { + let result: Array = new Array(); + totalList.forEach((value: Array, key: string) => { + let countNum = result.push( + new TabPaneFreqUsageConfig('', '', key.split('_')[0], key.split('_')[1], + 0, '', '', 0, '', 0, 'cycle', 0, [] + ) + ); + let cpuArr: Array = []; + let flagArr: Array = []; + for (let i = 0; i < value.length; i++) { + if (!flagArr.includes(value[i].cpu)) { + flagArr.push(value[i].cpu); + let flag = cpuArr.push( + new TabPaneFreqUsageConfig(value[i].thread, '', value[i].pid, value[i].tid, + 0, value[i].cpu, '', 0, '', 0, 'cpu', -1, [] + ) + ); + result[countNum - 1].children?.push(cpuArr[flag - 1]); + } + for (let j = i + 1; j < value.length; j++) { + if (value[i].cpu === value[j].cpu && value[i].freq === value[j].freq) { + value[i].dur += value[j].dur; + // @ts-ignore + value[i].percent += value[j].percent; + value[i].count += value[j].count; + value.splice(j, 1); + j--; + } + } + } + result[countNum - 1].children?.sort((a: TabPaneFreqUsageConfig, b: TabPaneFreqUsageConfig) => Number(a.cpu) - Number(b.cpu)); + for (let i = 0; i < cpuArr.length; i++) { + for (let j = 0; j < value.length; j++) { + if (cpuArr[i].cpu === value[j].cpu) { + cpuArr[i].children?.push(value[j]); + cpuArr[i].dur += value[j].dur; + cpuArr[i].count += value[j].count; + // @ts-ignore + cpuArr[i].percent += value[j].percent; + } + } + result[countNum - 1].dur += cpuArr[i].dur; + result[countNum - 1].count += cpuArr[i].count; + // @ts-ignore + result[countNum - 1].percent += cpuArr[i].percent; + } + }); + return result; + } + /** + * 递归整理数据,取小数位数,转换单位 + */ + fixedDeal(arr: Array): void { + if (arr === undefined) { + return; + } + for (let i = 0; i < arr.length; i++) { + // @ts-ignore + arr[i].percent = arr[i].percent.toFixed(2); + // @ts-ignore + arr[i].dur = (arr[i].dur / 1000000).toFixed(3); + if (arr[i].freq !== '') { + if (arr[i].freq === 'unknown') { + arr[i].freq = 'unknown'; + } else { + // @ts-ignore + arr[i].freq = arr[i].freq / 1000; + } + } + if (!(SpSegmentationChart.freqInfoMapData.size > 0)) { + // @ts-ignore + arr[i].count = (arr[i].count / 1000).toFixed(3); + } else { + // @ts-ignore + arr[i].count = arr[i].count.toFixed(3); + } + // @ts-ignore + this.fixedDeal(arr[i].children); + } + } + /** + * 绑定表格点击事件 + */ + private threadClick(data: Array): void { + let labels = this.threadStatesTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (!this.threadStatesTblSource.length && !this.threadStatesTbl!.recycleDataSource.length) { + data = []; + } + if (label.includes('Process') && i === 0) { + this.threadStatesTbl!.setStatus(data, false); + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('Thread') && i === 1) { + for (let item of data) { + // @ts-ignore + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.threadStatesTbl!.setStatus(item.children, false); + } + } + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement( data, RedrawTreeForm.Retract); + } else if (label.includes('Cycle') && i === 2) { + for (let item of data) { + // @ts-ignore + item.status = true; + for (let value of item.children ? item.children : []) { + // @ts-ignore + value.status = true; + if (value.children !== undefined && value.children.length > 0) { + this.threadStatesTbl!.setStatus(value.children, false); + } + } + } + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('CPU') && i === 3) { + this.threadStatesTbl!.setStatus(data, true); + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + } + }); + } + } + } + /** + * 散点图渲染数据整理 + */ + render(res: Array, str: string, queryCycleScatter: Array): void { + let maxFreq: HTMLInputElement = this.scatterInput!.querySelector('#maxFreq')!; + let maxHz: HTMLInputElement = this.scatterInput!.querySelector('#maxHz')!; + if (maxFreq.value && maxHz.value) { + if (/^[0-9]*$/.test(maxFreq.value) && /^[0-9]*$/.test(maxHz.value)) { + this.organizeData(res, str, queryCycleScatter, maxFreq.value, maxHz.value); + } else { + if (!/^[0-9]*$/.test(maxFreq.value)) { + maxFreq.style.border = '2px solid rgb(255,0,0)'; + } + if (!/^[0-9]*$/.test(maxHz.value)) { + maxHz.style.border = '2px solid rgb(255,0,0)'; + } + } + } else { + if (maxFreq.value === '') { + maxFreq.style.border = '2px solid rgb(255,0,0)'; + } + if (maxHz.value === '') { + maxHz.style.border = '2px solid rgb(255,0,0)'; + } + SpSegmentationChart.setChartData('CPU-FREQ', []); + } + } + /** + * 数据整理 + */ + organizeData( + res: Array, + str: string, + queryCycleScatter: Array, + maxFreqValue: string, + maxHzValue: string + ): void { + // @ts-ignore + this.shadowRoot?.querySelector('#cycleQuery')!.style.display = 'block'; + // @ts-ignore + let freq: Map = SpSegmentationChart.freqInfoMapData.size > 0 && + SpSegmentationChart.freqInfoMapData.get(SpSegmentationChart.freqInfoMapData.size - 1); + // @ts-ignore + let yAxis: number = freq && freq.get(Number(maxFreqValue) * 1000) + ? freq.get(Number(maxFreqValue) * 1000) : Number(maxFreqValue); + let xAxis: number = (yAxis * 1000) / Number(maxHzValue); + // 需要做筛选时,会利用下面的cycleA、cycleB数组 + let scatterArr: Array> = []; + let traceRowdata: Array<{ + dur: number; + startNS: number; + value: number; + cycle: number; + }> = []; + let cycleA: Array> = []; + let cycleB: Array> = []; + let cycleAStart: number = queryCycleScatter[0] || 0; + let cycleAEnd: number = queryCycleScatter[1] || 0; + let cycleBStart: number = queryCycleScatter[2] || 0; + let cycleBEnd: number = queryCycleScatter[3] || 0; + for (let i = 1; i < res.length; i++) { + const count: number = Number(res[i].count); + const dur: number = Number(res[i].cdur); + const rdur: number = Number(res[i].dur); //MHz·ms ms ms + scatterArr.push([count, count / dur, i, dur, rdur]); + traceRowdata.push({ + dur: dur * 1000000, + value: count, + startNS: Number(res[i].ts) * 1000000, + cycle: i - 1, + }); + if (dur >= cycleAStart && dur < cycleAEnd) { + cycleA.push([count, count / dur, i, dur, rdur]); + } + if (dur >= cycleBStart && dur < cycleBEnd) { + cycleB.push([count, count / dur, i, dur, rdur]); + } + } + this.setConfig(Number(maxHzValue), str, scatterArr, yAxis, xAxis, cycleA, cycleB); + SpSegmentationChart.setChartData('CPU-FREQ', traceRowdata); + } + /** + * 配置散点图 + */ + setConfig(maxHz: number, str: string, scatterArr: Array>, + yAxis: number, xAxis: number, cycleA: Array>, cycleB: Array> + ): void { + const DELTA: number = 5; + this.statisticsScatter!.config = { + // 纵轴坐标值 + yAxisLabel: [ + Math.round(yAxis / DELTA), + Math.round((yAxis * 2) / DELTA), + Math.round((yAxis * 3) / DELTA), + Math.round((yAxis * 4) / DELTA), + Math.round(yAxis), + ], + // 横轴坐标值 + xAxisLabel: [ + Math.round(xAxis / DELTA), + Math.round((xAxis * 2) / DELTA), + Math.round((xAxis * 3) / DELTA), + Math.round((xAxis * 4) / DELTA), + Math.round(xAxis), + Math.round((xAxis * 6) / DELTA), + ], + // 横轴字段、纵轴字段 + axisLabel: ['负载', '算力供给'], + // 是否加载最大负载线及均衡线 + drawload: true, + // 最大负载线及均衡线值 + load: [xAxis, maxHz], + // 绘制点数据信息存储数组 + paintingData: [], + // 当前移入点坐标信息 + hoverData: {}, + // 颜色池 + colorPool: () => ['#2f72f8', '#ffab67', '#a285d2'], + // 移入数据点时是否触发函数 + //@ts-ignore + hoverEvent: SpSegmentationChart.tabHover, + // 渐变色背景信息 + globalGradient: undefined, + // 渲染数据点 + data: [scatterArr, cycleA, cycleB], + // 散点图title + title: str, + colorPoolText: (): Array => ['Total', 'CycleA', 'CycleB'], + tip: (data: {c: Array}): string => { + return ` +
        + Cycle: ${data.c[2]};
        + Comsumption: ${data.c[0]};
        + Cycle_dur: ${data.c[3]} ms;
        + Running_dur: ${data.c[4]} ms;
        +
        + `; + }, + }; + } + initElements(): void { + this.threadStatesTbl = this.shadowRoot?.querySelector('#tb-running-datacut'); + // 绑定事件 + this.addListener(); + this.statisticsScatter = this.shadowRoot?.querySelector('#chart-scatter'); + // 增加表格thread层级点击更新散点图事件、周期层级点击高亮泳道图对应段事件 + let scatterData: Array = new Array(); + let str: string = ''; + this.threadStatesTbl!.addEventListener('row-click', (evt): void => { + // @ts-ignore + if (evt.detail.flag === 'thread') { + // @ts-ignore + scatterData = evt.detail.children; + // @ts-ignore + str = evt.detail.thread; + this.render(scatterData, str, []); + } + // @ts-ignore + if (evt.detail.flag === 'cycle' && evt.detail.pid === scatterData[evt.detail.id - 1].pid + // @ts-ignore + && evt.detail.tid === scatterData[evt.detail.id - 1].tid && evt.detail.id > 0) { + // @ts-ignore + SpSegmentationChart.tabHover('CPU-FREQ', true, evt.detail.id - 1); + } + }); + this.scatterInput = this.shadowRoot?.querySelector('.chart-box'); + this.shadowRoot?.querySelector('#query-btn')!.addEventListener('click', (e) => { + // @ts-ignore + let cycleAStartValue = this.shadowRoot?.querySelector('#cycle-a-start-range')!.value; + // @ts-ignore + let cycleAEndValue = this.shadowRoot?.querySelector('#cycle-a-end-range')!.value; + // @ts-ignore + let cycleBStartValue = this.shadowRoot?.querySelector('#cycle-b-start-range')!.value; + // @ts-ignore + let cycleBEndValue = this.shadowRoot?.querySelector('#cycle-b-end-range')!.value; + let queryCycleScatter = [Number(cycleAStartValue), Number(cycleAEndValue), Number(cycleBStartValue), Number(cycleBEndValue)]; + this.render(scatterData, str, queryCycleScatter); + }); + } + /** + * 配置监听事件 + */ + addListener(): void { + // 绑定single、loop按钮点击事件 + this.threadStatesDIV = this.shadowRoot?.querySelector('#dataCut'); + this.threadStatesDIV?.children[2].children[0].addEventListener('click', (e) => { + this.threadStatesTbl!.loading = true; + // @ts-ignore + this.dataSingleCut(this.threadStatesDIV?.children[0]!, this.threadStatesDIV?.children[1]!, this.initData); + } + ); + this.threadStatesDIV?.children[2].children[1].addEventListener('click', (e) => { + this.threadStatesTbl!.loading = true; + // @ts-ignore + this.dataLoopCut(this.threadStatesDIV?.children[0]!, this.threadStatesDIV?.children[1]!, this.initData); + } + ); + this.threadStatesDIV?.children[0].addEventListener('focus', (e) => { + // @ts-ignore + this.threadStatesDIV?.children[0]!.style.border = '1px solid rgb(151,151,151)'; + } + ); + this.threadStatesDIV?.children[1].addEventListener('focus', (e) => { + // @ts-ignore + this.threadStatesDIV?.children[1]!.style.border = '1px solid rgb(151,151,151)'; + } + ); + this.shadowRoot?.querySelector('#maxFreq')?.addEventListener('focus', (e) => { + // @ts-ignore + this.shadowRoot?.querySelector('#maxFreq')!.style.border = '1px solid rgb(151,151,151)'; + }); + this.shadowRoot?.querySelector('#maxHz')?.addEventListener('focus', (e) => { + // @ts-ignore + this.shadowRoot?.querySelector('#maxHz')!.style.border = '1px solid rgb(151,151,151)'; + }); + } + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadStatesTbl!); + } + initHtml(): string { + return ` + + ` + this.htmlUp() + this.htmlDown(); + } + htmlUp(): string { + return ` +
        + + +
        + + +
        +
        + + +
        + + + + + + + + + + + + + + + + + + +
        + `; + } + htmlDown(): string { + return ` + +
        +
        + maxFreq: + + Fps: + +
        +
        +
        + + +
        +
        +
        + `; + } +} diff --git a/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.ts b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.ts index 350c5055cd71f19c45cd16b8240bf86f01b006aa..a4847f092cf3b36931ce99486626a326774bbfd8 100644 --- a/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.ts +++ b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.ts @@ -21,14 +21,18 @@ import { getTabRunningPercent } from '../../../../database/sql/ProcessThread.sql import { queryCpuFreqUsageData, queryCpuFreqFilterId } from '../../../../database/sql/Cpu.sql'; import { Utils } from '../../base/Utils'; import { resizeObserver } from '../SheetUtils'; -import { TabPaneFreqUsageConfig, type TabPaneRunningConfig, TabPaneCpuFreqConfig } from './TabPaneFreqUsageConfig'; +import { SpSegmentationChart } from '../../../chart/SpSegmentationChart'; +import { + type CpuFreqData, + type RunningFreqData, + type RunningData, + type CpuFreqTd, +} from './TabPaneFreqUsageConfig'; @element('tabpane-frequsage') export class TabPaneFreqUsage extends BaseElement { private threadStatesTbl: LitTable | null | undefined; - private threadStatesTblSource: Array = []; private currentSelectionParam: SelectionParam | undefined; - private threadArr: Array = []; set data(threadStatesParam: SelectionParam) { if (this.currentSelectionParam === threadStatesParam) { @@ -36,394 +40,100 @@ export class TabPaneFreqUsage extends BaseElement { } this.threadStatesTbl!.loading = true; this.currentSelectionParam = threadStatesParam; - this.threadStatesTblSource = []; this.threadStatesTbl!.recycleDataSource = []; // @ts-ignore this.threadStatesTbl.value = []; - this.threadArr = []; this.init(threadStatesParam); } - /** - * 初始化数据 - */ - async init(threadStatesParam: SelectionParam): Promise { - let { runningMap, sum }: { - runningMap: Map>; - sum: number; - } = await this.queryRunningData(threadStatesParam); - let cpuFreqData: Array = await this.queryCpuFreqData(threadStatesParam); - let cpuMap: Map> = new Map(); - if (runningMap.size > 0) { - // 创建进程级的数组 - let pidArr: Array = []; - let processArr: Array = threadStatesParam.processIds.length > 1 - ? [...new Set(threadStatesParam.processIds)] : threadStatesParam.processIds; - for (let i of processArr) { - pidArr.push(new TabPaneFreqUsageConfig(Utils.PROCESS_MAP.get(i) === null ? 'Process ' + i - : Utils.PROCESS_MAP.get(i) + ' ' + i, '', i, '', 0, '', '', 0, '', 0, 'process', -1, [])); - } - // 将cpu频点数据与running状态数据整合,保证其上该段时长内有对应的cpu频点数据 - this.mergeFreqData( - runningMap, - cpuMap, - cpuFreqData, - sum, - threadStatesParam - ); - // 将频点数据放置到对应cpu层级下 - // @ts-ignore - this.mergeCpuData(cpuMap, runningMap); - // 将cpu层级数据放置到线程分组下 - this.mergeThreadData(this.threadArr, cpuMap); - // 将线程层级数据放置到进程级分组下 - this.mergePidData(pidArr, this.threadArr); - // 百分比保留两位小数 - this.fixedDeal(pidArr); - this.threadStatesTblSource = pidArr; - this.threadStatesTbl!.recycleDataSource = pidArr; - this.threadStatesTbl!.loading = false; - this.threadClick(pidArr); - this.threadStatesTbl!.loading = false; - } else { - this.threadStatesTblSource = []; - this.threadStatesTbl!.recycleDataSource = []; - this.threadStatesTbl!.loading = false; - } + init(threadStatesParam: SelectionParam): void { + this.queryAllData(threadStatesParam); } - /** - * 查询cpu频点信息 - */ - async queryCpuFreqData( - threadStatesParam: SelectionParam - ): Promise> { + async queryAllData(threadStatesParam: SelectionParam): Promise { + let runningResult: Array = await getTabRunningPercent( + threadStatesParam.threadIds, + threadStatesParam.leftNs, + threadStatesParam.rightNs + ); // 查询cpu及id信息 - let result: Array<{id: number, cpu: number}> = await queryCpuFreqFilterId(); + let cpuIdResult: Array<{ id: number; cpu: number }> = await queryCpuFreqFilterId(); // 以键值对形式将cpu及id进行对应,后续会将频点数据与其对应cpu进行整合 let IdMap: Map = new Map(); let queryId: Array = []; - for (let i = 0; i < result.length; i++) { - queryId.push(result[i].id); - IdMap.set(result[i].id, result[i].cpu); + for (let i = 0; i < cpuIdResult.length; i++) { + queryId.push(cpuIdResult[i].id); + IdMap.set(cpuIdResult[i].id, cpuIdResult[i].cpu); } - let dealArr: Array = []; // 通过id去查询频点数据 - let res: Array<{ - startNS: number, - filter_id: number, - value: number, - dur: number - }> = await queryCpuFreqUsageData(queryId); - for (let i of res) { - let obj = new TabPaneCpuFreqConfig( - i.startNS + threadStatesParam.recordStartNs, - IdMap.get(i.filter_id)!, - i.value, - i.dur - ); - dealArr.push(obj); + let cpuFreqResult: Array = await queryCpuFreqUsageData(queryId); + let cpuFreqData: Array = []; + for (let i of cpuFreqResult) { + cpuFreqData.push({ + ts: i.startNS + threadStatesParam.recordStartNs, + cpu: IdMap.get(i.filter_id)!, + value: i.value, + dur: i.dur, + }); } - return dealArr; + const LEFT_TIME: number = threadStatesParam.leftNs + threadStatesParam.recordStartNs; + const RIGHT_TIME: number = threadStatesParam.rightNs + threadStatesParam.recordStartNs; + let resultArr: Array = orgnazitionMap(runningResult, cpuFreqData, LEFT_TIME, RIGHT_TIME); + this.fixedDeal(resultArr); + this.threadClick(resultArr); + this.threadStatesTbl!.recycleDataSource = resultArr; + this.threadStatesTbl!.loading = false; } - + /** - * 查询框选区域内的所有running状态数据 + * 递归整理数据小数位 */ - async queryRunningData(threadStatesParam: SelectionParam): Promise<{ - runningMap: Map>; - sum: number; - }> { - // 查询running状态线程数据 - let result: Array = - await getTabRunningPercent(threadStatesParam.threadIds, threadStatesParam.leftNs, threadStatesParam.rightNs); - let needDeal: Map> = new Map(); - let sum: number = 0; - if (result !== null && result.length > 0) { - // 将running线程数据存到map中 - for (let e of result) { - if (threadStatesParam.processIds.includes(e.pid)) { - if (needDeal.get(e.pid + '_' + e.tid) === undefined) { - this.threadArr.push(new TabPaneFreqUsageConfig(Utils.THREAD_MAP.get(e.tid) + ' ' + e.tid, - '', e.pid, e.tid, 0, '', '', 0, '', 0, 'thread', -1, [])); - needDeal.set(e.pid + '_' + e.tid, new Array()); - } - if (e.ts < threadStatesParam.leftNs + threadStatesParam.recordStartNs && - e.ts + e.dur > threadStatesParam.leftNs + threadStatesParam.recordStartNs) { - const ts = e.ts; - e.ts = threadStatesParam.leftNs + threadStatesParam.recordStartNs; - e.dur = ts + e.dur - - (threadStatesParam.leftNs + threadStatesParam.recordStartNs); - } - if (e.ts + e.dur > threadStatesParam.rightNs + threadStatesParam.recordStartNs) { - e.dur = threadStatesParam.rightNs + threadStatesParam.recordStartNs - e.ts; - } - e.process = Utils.PROCESS_MAP.get(e.pid) === null ? '[NULL]' : Utils.PROCESS_MAP.get(e.pid)!; - e.thread = Utils.THREAD_MAP.get(e.tid) === null ? '[NULL]' : Utils.THREAD_MAP.get(e.tid)!; - let arr: Array = needDeal.get(e.pid + '_' + e.tid)!; - sum += e.dur; - arr?.push(e); - } + fixedDeal(arr: Array): void { + if (arr == undefined) { + return; } - } - return { runningMap: needDeal, sum: sum }; - } - - /** - * 整合running数据与频点数据 - */ - mergeFreqData( - needDeal: Map>, - cpuMap: Map>, - dealArr: Array, - sum: number, - threadStatesParam: SelectionParam - ): void { - needDeal.forEach((value: Array, key: string) => { - let resultList: Array = []; - let cpuArr: Array = []; - cpuMap.set(key, new Array()); - const multiple: number = 1000; - for (let i = 0; i < value.length; i++) { - this.pushCpuMap(cpuArr, cpuMap, value[i], key); - for (let j = 0; j < dealArr.length; j++) { - const consumption: number = dealArr[j].value!; - // 只需要合并相同cpu的数据 - if (value[i].cpu === dealArr[j].cpu) { - // 当running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running数据的持续时间小于频点结束时间减去running数据开始时间的差值的情况 - if (value[i].ts > dealArr[j].startNS && value[i].ts < dealArr[j].startNS + dealArr[j].dur && - value[i].dur < dealArr[j].startNS + dealArr[j].dur - value[i].ts ) { - resultList.push(this.pushNewData(value[i], dealArr[j], {id: 1, sum: sum, consumption: consumption, multiple: multiple})!); - break; - } - // 当running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running数据的持续时间大于等于频点结束时间减去running数据开始时间的差值的情况 - if (value[i].ts > dealArr[j].startNS && value[i].ts < dealArr[j].startNS + dealArr[j].dur && - value[i].dur >= dealArr[j].startNS + dealArr[j].dur - value[i].ts) { - resultList.push(this.pushNewData(value[i], dealArr[j], {id: 2, sum: sum, consumption: consumption, multiple: multiple})!); - } - // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间大于频点开始时间。且running数据的持续时间减去频点数据开始时间的差值小于频点数据持续时间的情况 - if (value[i].ts <= dealArr[j].startNS && value[i].ts + value[i].dur > dealArr[j].startNS && - value[i].dur + value[i].ts - dealArr[j].startNS < dealArr[j].dur) { - resultList.push(this.pushNewData(value[i], dealArr[j], {id: 3, sum: sum, consumption: consumption, multiple: multiple})!); - break; - } - // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间大于频点开始时间。且running数据的持续时间减去频点数据开始时间的差值大于等于频点数据持续时间的情况 - if (value[i].ts <= dealArr[j].startNS && value[i].ts + value[i].dur > dealArr[j].startNS && - value[i].dur + value[i].ts - dealArr[j].startNS >= dealArr[j].dur) { - resultList.push(this.pushNewData(value[i], dealArr[j], {id: 4, sum: sum, consumption: consumption, multiple: multiple})!); - } - // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间小于等于频点开始时间的情况 - if (value[i].ts <= dealArr[j].startNS && value[i].ts + value[i].dur <= dealArr[j].startNS) { - resultList.push(this.pushNewData(value[i], dealArr[j], {id: 5, sum: sum, consumption: consumption, multiple: multiple})!); - break; - } - } + const TIME_MUTIPLE: number = 1000000; + // KHz->MHz * ns->ms + const CONS_MUTIPLE: number = 1000000000; + const FREQ_MUTIPLE: number = 1000; + const MIN_PERCENT: number = 2; + const MIN_FREQ: number = 3; + for (let i = 0; i < arr.length; i++) { + let str: number; + if (arr[i].thread?.indexOf('P') !== -1) { + str = Number(arr[i].thread?.slice(1)!); + arr[i].thread = Utils.PROCESS_MAP.get(str) === null ? 'Process ' + str : Utils.PROCESS_MAP.get(str)! + ' ' + str; + } else { + str = Number(arr[i].thread!.split('_')[1]); + arr[i].thread = Utils.THREAD_MAP.get(str) === null ? 'Thread ' + str : Utils.THREAD_MAP.get(str)! + ' ' + str; } - } - cpuMap.get(key)?.sort((a: any, b: any) => a.cpu - b.cpu); - // @ts-ignore - needDeal.set(key, this.mergeData(resultList, threadStatesParam)); - }); - } - - pushCpuMap( - cpuArr: Array, - cpuMap: Map>, - value: TabPaneRunningConfig, - key: string - ): void { - if (!cpuArr.includes(value.cpu)) { - cpuArr.push(value.cpu); - cpuMap.get(key)?.push( - new TabPaneFreqUsageConfig( - value.tid + '_' + Utils.THREAD_MAP.get(value.tid), - '', - value.pid, - value.tid, - 0, - value.cpu, - '', - 0, - '', - 0, - 'cpu', - -1, - [] - ) - ); - } - } - - /** - * - * @param arg1 running 状态数据 - * @param arg2 cpu频点数据 - * @param arg3 算力值、倍数等常量 - * @returns - */ - pushNewData( - arg1: TabPaneRunningConfig, - arg2: TabPaneCpuFreqConfig, - arg3: { - id: number, - sum: number, - consumption: number, - multiple: number, - } - ): TabPaneFreqUsageConfig | undefined{ - const num: number = 100; - if (arg3.id === 1) { - return new TabPaneFreqUsageConfig( - arg1.tid + '_' + arg1.thread, arg1.ts, '', '', (arg3.consumption! * arg1.dur) / arg3.multiple, - arg1.cpu, arg2.value, arg1.dur, '', (arg1.dur / arg3.sum) * num, 'freqdata', -1, undefined); - } - if (arg3.id === 2) { - return new TabPaneFreqUsageConfig( - arg1.tid + '_' + arg1.thread, arg1.ts, '', '', (arg3.consumption! * - (arg2.startNS + arg2.dur - arg1.ts)) / arg3.multiple, arg1.cpu, arg2.value, arg2.startNS + arg2.dur - arg1.ts, - '', ((arg2.startNS + arg2.dur - arg1.ts) / arg3.sum) * num, 'freqdata', -1, undefined); - } - if (arg3.id === 3) { - return new TabPaneFreqUsageConfig( - arg1.tid + '_' + arg1.thread, arg2.startNS, '', '', - (arg3.consumption! * (arg1.dur + arg1.ts - arg2.startNS)) / arg3.multiple, arg1.cpu, arg2.value, - arg1.dur + arg1.ts - arg2.startNS, '', ((arg1.dur + arg1.ts - arg2.startNS) / arg3.sum) * num, 'freqdata', -1, undefined); - } - if (arg3.id === 4) { - return new TabPaneFreqUsageConfig( - arg1.tid + '_' + arg1.thread, arg2.startNS, '', '', - (arg3.consumption! * arg2.dur) / arg3.multiple, arg1.cpu, arg2.value, arg2.dur, - '', (arg2.dur / arg3.sum) * num, 'freqdata', -1, undefined); - } - if (arg3.id === 5) { - return new TabPaneFreqUsageConfig( - arg1.tid + '_' + arg1.thread, - arg1.ts, '', '', 0, arg1.cpu, 'unknown', arg1.dur, - '', (arg1.dur / arg3.sum) * num, 'freqdata', -1, undefined); - } - } - - /** - * 合并同一线程内,当运行所在cpu和频点相同时,dur及percent进行累加求和 - */ - mergeData( - resultList: Array, - threadStatesParam: SelectionParam - ): Array { - for (let i = 0; i < resultList.length; i++) { - for (let j = i + 1; j < resultList.length; j++) { - if ( - resultList[i].cpu === resultList[j].cpu && - resultList[i].freq === resultList[j].freq - ) { - resultList[i].dur += resultList[j].dur; + if (arr[i].cpu < 0 ) { // @ts-ignore - resultList[i].percent += resultList[j].percent; - resultList[i].count += resultList[j].count; - resultList.splice(j, 1); - j--; + arr[i].cpu = ''; } - } - // @ts-ignore - resultList[i].ts = resultList[i].ts - threadStatesParam.recordStartNs; - } - resultList.sort((a, b) => b.count - a.count); - return resultList; - } - - /** - * 将整理好的running频点数据通过map的键放到对应的cpu分组层级下 - */ - mergeCpuData( - cpuMap: Map>, - needDeal: Map> - ): void { - cpuMap.forEach((value: Array, key: string) => { - let arr = needDeal.get(key); - for (let i = 0; i < value.length; i++) { - for (let j = 0; j < arr!.length; j++) { - if (arr![j].cpu === value[i].cpu) { - value[i].children?.push(arr![j]); - value[i].count += arr![j].count; - value[i].dur += arr![j].dur; - // @ts-ignore - value[i].percent += arr![j].percent; - } + // @ts-ignore + if (arr[i].frequency < 0 ) { + arr[i].frequency = ''; } - } - }); - } - - /** - * 将整理好的cpu层级数据放到对应的线程下 - */ - mergeThreadData( - threadArr: Array, - cpuMap: Map> - ): void { - for (let i = 0; i < threadArr.length; i++) { - let cpuMapData = cpuMap.get(threadArr[i].pid + '_' + threadArr[i].tid); - for (let j = 0; j < cpuMapData!.length; j++) { - threadArr[i].children?.push(cpuMapData![j]); - threadArr[i].count += cpuMapData![j].count; - threadArr[i].dur += cpuMapData![j].dur; // @ts-ignore - threadArr[i].percent += cpuMapData![j].percent; - } - } - } - - /** - * 将整理好的线程层级数据放到对应的进程下 - */ - mergePidData( - pidArr: Array, - threadArr: Array - ): void { - for (let i = 0; i < pidArr.length; i++) { - for (let j = 0; j < threadArr.length; j++) { - if (pidArr[i].pid === threadArr[j].pid) { - pidArr[i].children?.push(threadArr[j]); - pidArr[i].count += threadArr[j].count; - pidArr[i].dur += threadArr[j].dur; - // @ts-ignore - pidArr[i].percent += threadArr[j].percent; + arr[i].percent = arr[i].percent.toFixed(MIN_PERCENT); + // @ts-ignore + arr[i].dur = (arr[i].dur / TIME_MUTIPLE).toFixed(MIN_FREQ); + // @ts-ignore + arr[i].consumption = (arr[i].consumption / CONS_MUTIPLE).toFixed(MIN_FREQ); + if (arr[i].frequency !== '') { + if (arr[i].frequency === 'unknown') { + arr[i].frequency = 'unknown'; + } else { + arr[i].frequency = Number(arr[i].frequency) / FREQ_MUTIPLE; + } } + this.fixedDeal(arr[i].children!); } - } } - /** - * 递归整理数据小数位 - */ - fixedDeal(arr: Array): void { - const multiple: number = 1000000; - const freqMultiple: number = 1000; - const fixedNum: number = 3; - const percentNum: number = 2; - if (arr === undefined) { - return; - } - for (let i = 0; i < arr.length; i++) { - // @ts-ignore - arr[i].percent = arr[i].percent.toFixed(percentNum); - // @ts-ignore - arr[i].dur = (arr[i].dur / multiple).toFixed(fixedNum); - // @ts-ignore - arr[i].count = (arr[i].count / multiple).toFixed(fixedNum); - if (arr[i].freq !== '') { - if (arr[i].freq === 'unknown') { - arr[i].freq = 'unknown'; - } else { - // @ts-ignore - arr[i].freq = arr[i].freq / freqMultiple; - } - } - this.fixedDeal(arr[i].children!); - } - } /** * 表头点击事件 */ - private threadClick(data: Array): void { + private threadClick(data: Array): void { let labels = this.threadStatesTbl?.shadowRoot ?.querySelector('.th > .td')! .querySelectorAll('label'); @@ -463,9 +173,10 @@ export class TabPaneFreqUsage extends BaseElement { } } } + initElements(): void { this.threadStatesTbl = this.shadowRoot?.querySelector( - '#tb-running-percent' + "#tb-running-percent" ); } connectedCallback(): void { @@ -486,9 +197,9 @@ export class TabPaneFreqUsage extends BaseElement { - + - + @@ -498,3 +209,258 @@ export class TabPaneFreqUsage extends BaseElement { `; } } + +/** + * + * @param runData 数据库查询上来的running数据,此函数会将数据整理成map结构,分组规则:'pid_tid'为键,running数据数字为值 + * @returns 返回map对象及所有running数据的dur和,后续会依此计算百分比 + */ +function orgnazitionMap( + runData: Array, + cpuFreqData: Array, + leftNs: number, + rightNs: number +): Array { + let result: Map> = new Map(); + let sum: number = 0; + // 循环分组 + for (let i = 0; i < runData.length; i++) { + let mapKey: string = runData[i].pid + '_' + runData[i].tid; + // 该running数据若在map对象中不包含其'pid_tid'构成的键,则新加key-value值 + if (!result.has(mapKey)) { + result.set(mapKey, new Array()); + } + // 整理左右边界数据问题, 因为涉及多线程,所以必须放在循环里 + if (runData[i].ts < leftNs && runData[i].ts + runData[i].dur > leftNs) { + runData[i].dur = runData[i].ts + runData[i].dur - leftNs; + runData[i].ts = leftNs; + } + if (runData[i].ts + runData[i].dur > rightNs) { + runData[i].dur = rightNs - runData[i].ts; + } + // 分组整理数据 + result.get(mapKey)?.push({ + pid: runData[i].pid, + tid: runData[i].tid, + cpu: runData[i].cpu, + dur: runData[i].dur, + ts: runData[i].ts + }); + sum += runData[i].dur; + } + return dealCpuFreqData(cpuFreqData, result, sum); +} + +/** + * + * @param cpuFreqData cpu频点数据的数组 + * @param result running数据的map对象 + * @param sum running数据的时间和 + * @returns 返回cpu频点数据map,'pid_tid'为键,频点算力值数据的数组为值 + */ +function dealCpuFreqData( + cpuFreqData: Array, + result: Map>, + sum: number +): Array { + let runningFreqData: Map> = new Map(); + result.forEach((item, key) => { + let resultList: Array = new Array(); + for (let i = 0; i < item.length; i++) { + for (let j = 0; j < cpuFreqData.length; j++) { + if (item[i].cpu == cpuFreqData[j].cpu) { + let flag: number; + // 当running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running数据的持续时间小于频点结束时间减去running数据开始时间的差值的情况 + if (item[i].ts > cpuFreqData[j].ts && item[i].ts < cpuFreqData[j].ts + cpuFreqData[j].dur && + item[i].dur < cpuFreqData[j].ts + cpuFreqData[j].dur - item[i].ts) { + resultList.push(returnObj(item[i], cpuFreqData[j], sum, flag = 1)!); + item.splice(i, 1); + i--; + break; + } + if (item[i].ts > cpuFreqData[j].ts && item[i].ts < cpuFreqData[j].ts + cpuFreqData[j].dur && + item[i].dur >= cpuFreqData[j].ts + cpuFreqData[j].dur - item[i].ts) { + // 当running状态数据的开始时间大于频点数据开始时间,小于频点结束时间。且running数据的持续时间大于等于频点结束时间减去running数据开始时间的差值的情况 + resultList.push(returnObj(item[i], cpuFreqData[j], sum, flag = 2)!); + } + // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间大于频点开始时间。且running数据的持续时间减去频点数据开始时间的差值小于频点数据持续时间的情况 + if (item[i].ts <= cpuFreqData[j].ts && (item[i].ts + item[i].dur) > cpuFreqData[j].ts && + item[i].dur + item[i].ts - cpuFreqData[j].ts < cpuFreqData[j].dur) { + resultList.push(returnObj(item[i], cpuFreqData[j], sum, flag = 3)!); + item.splice(i, 1); + i--; + break; + } + if (item[i].ts <= cpuFreqData[j].ts && (item[i].ts + item[i].dur) > cpuFreqData[j].ts && + item[i].dur + item[i].ts - cpuFreqData[j].ts >= cpuFreqData[j].dur) { + // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间大于频点开始时间。且running数据的持续时间减去频点数据开始时间的差值大于等于频点数据持续时间的情况 + resultList.push(returnObj(item[i], cpuFreqData[j], sum, flag = 4)!); + } + if (item[i].ts <= cpuFreqData[j].ts && (item[i].ts + item[i].dur) <= cpuFreqData[j].ts) { + // 当running状态数据的开始时间小于等于频点数据开始时间,结束时间小于等于频点开始时间的情况 + resultList.push(returnObj(item[i], cpuFreqData[j], sum, flag = 5)!); + item.splice(i, 1); + i--; + break; + } + } + } + } + runningFreqData.set(key, mergeSameData(resultList)); + }); + return dealTree(runningFreqData);; +} + +/** + * + * @param item running数据 + * @param cpuFreqData 频点数据 + * @param sum running总和 + * @param flag 标志位,根据不同值返回不同结果 + * @returns 返回新的对象 + */ +function returnObj(item: RunningData, cpuFreqData: CpuFreqData, sum: number, flag: number): RunningFreqData | undefined { + const PERCENT: number = 100; + const consumption: number = (SpSegmentationChart.freqInfoMapData.size > 0 + ? SpSegmentationChart.freqInfoMapData.get(item.cpu)?.get(cpuFreqData.value) : cpuFreqData.value)!; + switch (flag) { + case 1: + return { + 'thread': item.pid + '_' + item.tid, + 'consumption': (consumption * item.dur), + 'cpu': item.cpu, + 'frequency': cpuFreqData.value, + 'dur': item.dur, + 'percent': item.dur / sum * PERCENT + }; + case 2: + return { + 'thread': item.pid + '_' + item.tid, + 'consumption': consumption * (cpuFreqData.ts + cpuFreqData.dur - item.ts), + 'cpu': item.cpu, + 'frequency': cpuFreqData.value, + 'dur': (cpuFreqData.ts + cpuFreqData.dur - item.ts), + 'percent': (cpuFreqData.ts + cpuFreqData.dur - item.ts) / sum *PERCENT + }; + case 3: + return { + 'thread': item.pid + '_' + item.tid, + 'consumption': consumption * (item.dur + item.ts - cpuFreqData.ts), + 'cpu': item.cpu, + 'frequency': cpuFreqData.value, + 'dur': (item.dur + item.ts - cpuFreqData.ts), + 'percent': (item.dur + item.ts - cpuFreqData.ts) / sum * PERCENT + }; + case 4: + return { + 'thread': item.pid + '_' + item.tid, + 'consumption': consumption * cpuFreqData.dur, + 'cpu': item.cpu, + 'frequency': cpuFreqData.value, + 'dur': cpuFreqData.dur, + 'percent': cpuFreqData.dur / sum * PERCENT + }; + case 5: + return { + 'thread': item.pid + '_' + item.tid, + 'consumption': 0, + 'cpu': item.cpu, + 'frequency': 'unknown', + 'dur': item.dur, + 'percent': item.dur / sum * PERCENT + }; + } +} + +/** + * + * @param resultList 单线程内running数据与cpu频点数据整合成的数组 + */ +function mergeSameData(resultList: Array): Array { + let cpuFreqArr: Array = []; + let cpuArr: Array = []; + //合并同一线程内,当运行所在cpu和频点相同时,dur及percent进行累加求和 + for (let i = 0; i < resultList.length; i++) { + if (!cpuArr.includes(resultList[i].cpu)) { + cpuArr.push(resultList[i].cpu); + cpuFreqArr.push(creatNewObj(resultList[i].cpu)); + } + for (let j = i + 1; j < resultList.length; j++) { + if (resultList[i].cpu === resultList[j].cpu && resultList[i].frequency === resultList[j].frequency) { + resultList[i].dur += resultList[j].dur; + resultList[i].percent += resultList[j].percent; + resultList[i].consumption += resultList[j].consumption; + resultList.splice(j, 1); + j--; + } + } + cpuFreqArr.find(function (item) { + if (item.cpu === resultList[i].cpu) { + item.children?.push(resultList[i]); + item.children?.sort((a, b) => b.consumption - a.consumption); + item.dur += resultList[i].dur; + item.percent += resultList[i].percent; + item.consumption += resultList[i].consumption; + item.thread = resultList[i].thread; + } + }); + } + cpuFreqArr.sort((a, b) => a.cpu - b.cpu); + return cpuFreqArr; +} + +/** + * + * @param params cpu层级的数据 + * @returns 整理好的进程级数据 + */ +function dealTree(params: Map>): Array { + let result: Array = []; + params.forEach((item, key) => { + let process: RunningFreqData = creatNewObj(-1, false); + let thread: RunningFreqData = creatNewObj(-2); + for (let i = 0; i < item.length; i++) { + thread.children?.push(item[i]); + thread.dur += item[i].dur; + thread.percent += item[i].percent; + thread.consumption += item[i].consumption; + thread.thread = item[i].thread; + } + process.children?.push(thread); + process.dur += thread.dur; + process.percent += thread.percent; + process.consumption += thread.consumption; + process.thread = process.thread! + key.split('_')[0]; + result.push(process); + }); + for (let i = 0; i < result.length; i++) { + for (let j = i + 1; j < result.length; j++) { + if (result[i].thread === result[j].thread) { + result[i].children?.push(result[j].children![0]); + result[i].dur += result[j].dur; + result[i].percent += result[j].percent; + result[i].consumption += result[j].consumption; + result.splice(j, 1); + j-- + } + } + } + return result; +} + +/** + * + * @param cpu 根据cpu值创建层级结构,cpu < 0为线程、进程层级,其余为cpu层级 + * @returns + */ +function creatNewObj(cpu: number, flag: boolean = true): RunningFreqData { + return { + 'thread': flag ? '' : 'P', + 'consumption': 0, + 'cpu': cpu, + 'frequency': -1, + 'dur': 0, + 'percent': 0, + children: [] + }; +} diff --git a/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.ts b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.ts index 89be8f210cf10c62fe147618e96a3b383a7bc223..047a5286e22673093a568a6822d594033ee1ddd2 100644 --- a/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.ts +++ b/ide/src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.ts @@ -95,4 +95,36 @@ export class TabPaneCpuFreqConfig { this.value = value; this.dur = dur; } +} + +export interface RunningData { + pid: number; + tid: number; + cpu: number; + dur: number; + ts: number; +} + +export interface CpuFreqData { + ts: number; + cpu: number; + value: number; + dur: number; +} + +export interface RunningFreqData { + thread?: string; + cpu: number; + dur: number; + consumption: number; + frequency: number | string; + percent: number; + children?: Array; +} + +export interface CpuFreqTd { + startNS: number; + filter_id: number; + value: number; + dur: number; } \ No newline at end of file diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts index 2c84305af566590c4446917f49b8a808c99ab75a..c53cf47049514baafbee6a5e5c9078dd46eed428 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.ts @@ -19,7 +19,7 @@ import { VmTrackerChart } from '../../../chart/SpVmTrackerChart'; import { log } from '../../../../../log/Log'; import { SpSystemTrace } from '../../../SpSystemTrace'; import { Utils } from '../../base/Utils'; -import {queryGpuDataByTs} from "../../../../database/sql/Gpu.sql"; +import { queryGpuDataByTs } from '../../../../database/sql/Gpu.sql'; interface GpuTreeItem { name: string; id: number; @@ -69,15 +69,12 @@ export class TabPaneGpuClickSelect extends BaseElement { }); } protected createTreeData(result: any): Array { - let gpuDataObj = result.reduce((group: any, + 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), - }; + let categoryItem: GpuTreeItem = this.setGpuTreeItem(item); if (group[`${item.windowNameId}(${item.windowId})`]) { let windowGroup = group[`${item.windowNameId}(${item.windowId})`] as GpuTreeItem; windowGroup.size += item.size; @@ -102,20 +99,32 @@ export class TabPaneGpuClickSelect extends BaseElement { id: item.windowNameId, size: item.size, sizeStr: Utils.getBinaryByteWithUnit(item.size), - children: [{ + children: [ + { name: SpSystemTrace.DATA_DICT.get(item.moduleId), id: item.moduleId, size: item.size, sizeStr: Utils.getBinaryByteWithUnit(item.size), children: [categoryItem], - }], + }, + ], }; } return group; - },{} + }, + {} ); return Object.values(gpuDataObj) as GpuTreeItem[]; } + + private setGpuTreeItem(item: any): GpuTreeItem { + return { + name: SpSystemTrace.DATA_DICT.get(item.categoryId) || 'null', + id: item.categoryId, + size: item.size, + sizeStr: Utils.getBinaryByteWithUnit(item.size), + }; + } initElements(): void { this.gpuTbl = this.shadowRoot?.querySelector('#tb-gpu'); this.gpuTbl!.addEventListener('column-click', (evt: any) => { @@ -137,12 +146,7 @@ export class TabPaneGpuClickSelect extends BaseElement { table!.setStatus(data, false); table!.recycleDs = table!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if (label.includes('Module') && i === 1) { - for (let item of data) { - item.status = true; - if (item.children != undefined && item.children.length > 0) { - table!.setStatus(item.children, false); - } - } + table!.setStatus(data, false, 0, 1); table!.recycleDs = table!.meauseTreeRowElement(data, RedrawTreeForm.Retract); } else if ((label.includes('Category') && i === 2) || (label.includes('Category') && i === 1)) { table!.setStatus(data, true); diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.ts index 7ddf247d00253b85d1e39f3e1cdabcb104aaebcf..9d757041bc917a136ad8851f45ef203a5b5ff07c 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.ts @@ -22,7 +22,7 @@ import { compare, CompareStruct, resizeObserverFromMemory } from '../SheetUtils' import '../TabPaneJsMemoryFilter'; import { type TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter'; import { TabPaneGpuClickSelect } from './TabPaneGpuClickSelect'; -import {queryGpuDataByTs} from "../../../../database/sql/Gpu.sql"; +import { queryGpuDataByTs } from '../../../../database/sql/Gpu.sql'; interface GpuTreeItem { name: string; id: number; diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuGL.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuGL.ts index 5a30440f90dc250a4c0e623a316dcf0b19342000..d6aabdf58d5941609a19ffe56ffe1412c3edb2c3 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuGL.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuGL.ts @@ -21,7 +21,7 @@ import { getProbablyTime } from '../../../../database/logic-worker/ProcedureLogi import { resizeObserver } from '../SheetUtils'; import { Utils } from '../../base/Utils'; import { MemoryConfig } from '../../../../bean/MemoryConfig'; -import {queryGpuDataTab} from "../../../../database/sql/Gpu.sql"; +import { queryGpuDataTab } from '../../../../database/sql/Gpu.sql'; interface GL { startTs: number; @@ -72,6 +72,9 @@ export class TabPaneGpuGL extends BaseElement { initElements(): void { this.glTbl = this.shadowRoot?.querySelector('#tb-gl'); this.range = this.shadowRoot?.querySelector('#gl-time-range'); + this.glTbl!.addEventListener('column-click', (evt: any) => { + this.sortByColumn(evt.detail); + }); } connectedCallback(): void { @@ -97,13 +100,26 @@ export class TabPaneGpuGL extends BaseElement {
        - - + + - +
        `; } + sortByColumn(detail: { key: string; sort: number }): void { + this.glSource.sort((gpuA, gpuB) => { + if (detail.sort === 0) { + return gpuA.startTs - gpuB.startTs; + } else { + let key = detail.key.replace('Str', ''); + let valueA = (gpuA as any)[key]; + let valueB = (gpuB as any)[key]; + return detail.sort === 1 ? valueA - valueB : valueB - valueA; + } + }); + this.glTbl!.recycleDataSource = this.glSource; + } } diff --git a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts index 46b5ce5fe2c11bcfdfff215aa43ea8afd6ed543f..cbcd3c0199eee772dc2b63610aaef0b0eeb284ec 100644 --- a/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts +++ b/ide/src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.ts @@ -22,7 +22,7 @@ import { resizeObserver } from '../SheetUtils'; import { SpSystemTrace } from '../../../SpSystemTrace'; import { MemoryConfig } from '../../../../bean/MemoryConfig'; import { Utils } from '../../base/Utils'; -import {queryGpuDataByRange} from "../../../../database/sql/Gpu.sql"; +import { queryGpuDataByRange } from '../../../../database/sql/Gpu.sql'; interface Gpu { startTs: number; @@ -113,7 +113,7 @@ export class TabPaneGpuWindowBoxSelect extends BaseElement {
        - + diff --git a/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqDataCut.ts b/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqDataCut.ts new file mode 100644 index 0000000000000000000000000000000000000000..49ba49272926c6956767dd5133d514827a60913e --- /dev/null +++ b/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqDataCut.ts @@ -0,0 +1,470 @@ +/* + * Copyright (C) 2023 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'; +import { type LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import { getGpufreqData, getGpufreqDataCut } from '../../../../database/sql/Perf.sql'; +import { resizeObserver } from '../SheetUtils'; +import { SpSegmentationChart } from '../../../chart/SpSegmentationChart'; +import { GpuCountBean, TreeDataBean, type SearchGpuFuncBean, CycleDataBean, TreeDataStringBean } from '../../../../bean/GpufreqBean'; + +@element('tabpane-gpufreqdatacut') +export class TabPaneGpufreqDataCut extends BaseElement { + private threadStatesTbl: LitTable | null | undefined; + private currentSelectionParam: SelectionParam | undefined; + private _single: Element | null | undefined; + private _loop: Element | null | undefined; + private _threadId: HTMLInputElement | null | undefined; + private _threadFunc: HTMLInputElement | null | undefined; + private threadIdValue: string = ''; + private threadFuncName: string = ''; + private initData: Array = []; + private SUB_LENGTH: number = 3; + private PERCENT_SUB_LENGTH: number = 2; + private UNIT: number = 1000000; + private KUNIT: number = 1000000000000; + + set data(threadStatesParam: SelectionParam) { + if (this.currentSelectionParam === threadStatesParam) { + return; + } else { + SpSegmentationChart.setChartData('GPU-FREQ', []); + }; + this.currentSelectionParam = threadStatesParam; + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = true; + this.getGpufreqData(threadStatesParam.leftNs, threadStatesParam.rightNs, false).then((result) => { + if (result !== null && result.length > 0) { + let resultList: Array = JSON.parse(JSON.stringify(result)); + resultList[0].dur = resultList[1] ? resultList[1].startNS - threadStatesParam.leftNs : threadStatesParam.rightNs - threadStatesParam.leftNs; + resultList[0].value = resultList[0].dur * resultList[0].val; + resultList[resultList.length - 1].dur = resultList.length - 1 !== 0 ? threadStatesParam.rightNs - resultList[resultList.length - 1].startNS : resultList[0].dur; + resultList[resultList.length - 1].value = resultList.length - 1 !== 0 ? resultList[resultList.length - 1].dur * resultList[resultList.length - 1].val : resultList[0].value; + this.initData = resultList; + this.threadStatesTbl!.loading = false; + } else { + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = false; + }; + }); + this._threadId!.style.border = '1px solid rgb(151, 151, 151)'; + this._threadFunc!.style.border = '1px solid rgb(151, 151, 151)'; + }; + + initElements(): void { + this.threadStatesTbl = this.shadowRoot?.querySelector('#tb-gpufreq-percent'); + this._single = this.shadowRoot?.querySelector('#single'); + this._loop = this.shadowRoot?.querySelector('#loop'); + this._threadId = this.shadowRoot?.querySelector('#dataCutThreadId'); + this._threadFunc = this.shadowRoot?.querySelector('#dataCutThreadFunc'); + this.threadIdValue = this._threadId!.value.trim(); + this.threadFuncName = this._threadFunc!.value.trim(); + //点击single + this._single?.addEventListener('click', (e) => { + this.clickFun(this._single!.innerHTML); + }); + //点击loop + this._loop?.addEventListener('click', (e) => { + this.clickFun(this._loop!.innerHTML); + }); + //点击周期,算力泳道对应周期实现高亮效果 + this.threadStatesTbl?.addEventListener('row-click', (event: Event) => { + const EVENT_LEVEL: string = '2'; + // @ts-ignore + if (event.detail.level === EVENT_LEVEL && event.detail.thread.includes('cycle')) { + // @ts-ignore + SpSegmentationChart.tabHover('GPU-FREQ', true, event.detail.data.cycle); + }; + }); + this.addInputBorderEvent(this._threadId!); + this.addInputBorderEvent(this._threadFunc!); + }; + async getGpufreqData(leftNs: number, rightNs: number, isTrue: boolean): Promise> { + let result: Array = await getGpufreqData(leftNs, rightNs, isTrue); + return result; + }; + async getGpufreqDataCut(tIds: string, funcName: string, leftNS: number, rightNS: number, single: boolean, loop: boolean): Promise> { + let result: Array = await getGpufreqDataCut(tIds, funcName, leftNS, rightNS, single, loop); + return result; + }; + private clickFun(fun: string): void { + this.threadIdValue = this._threadId!.value.trim(); + this.threadFuncName = this._threadFunc!.value.trim(); + this.threadStatesTbl!.loading = true; + SpSegmentationChart.tabHover('GPU-FREQ', false, -1); + this.validationFun(this.threadIdValue, this.threadFuncName, fun); + }; + private addInputBorderEvent(inputElement: HTMLInputElement): void { + if (inputElement) { + inputElement.addEventListener('change', function () { + if (this.value.trim() !== '') { + this.style.border = '1px solid rgb(151, 151, 151)'; + } + }); + } + }; + private validationFun(threadIdValue: string, threadFuncName: string, fun: string): void { + if (threadIdValue === '') { + this.handleEmptyInput(this._threadId!); + } else if (threadFuncName === '') { + this.handleEmptyInput(this._threadFunc!); + } else { + this._threadId!.style.border = '1px solid rgb(151, 151, 151)'; + this._threadFunc!.style.border = '1px solid rgb(151, 151, 151)'; + if (fun === 'Single') { + this.isTrue(threadIdValue, threadFuncName, true, false); + }; + if (fun === 'Loop') { + this.isTrue(threadIdValue, threadFuncName, false, true); + }; + }; + }; + private handleEmptyInput(input: HTMLInputElement): void { + this.threadStatesTbl!.loading = false; + input!.style.border = '1px solid rgb(255,0,0)'; + this.threadStatesTbl!.recycleDataSource = []; + }; + private isTrue(threadIdValue: string, threadFuncName: string, single: boolean, loop: boolean): void { + this.getGpufreqDataCut(threadIdValue, threadFuncName, + this.currentSelectionParam!.leftNs, + this.currentSelectionParam!.rightNs, + single, loop + ).then((result: Array) => { + let _initData = JSON.parse(JSON.stringify(this.initData)); + this.handleDataCut(_initData, result); + }); + }; + private handleDataCut(initData: Array, dataCut: Array): void { + if (initData.length > 0 && dataCut.length > 0) { + let finalGpufreqData: Array = new Array(); + let startPoint: number = initData[0].startNS; + let _dataCut: Array = dataCut.filter((i) => i.startTime >= startPoint); + let _lastList: Array = []; + let i: number = 0; + let j: number = 0; + let currentIndex: number = 0; + while (i < _dataCut.length) { + let dataItem: SearchGpuFuncBean = _dataCut[i]; + let initItem: GpuCountBean = initData[j]; + _lastList.push(...this.segmentationData(initItem, dataItem, i)); + j++; + currentIndex++; + if (currentIndex === initData.length) { + i++; + j = 0; + currentIndex = 0; + }; + }; + let tree: TreeDataStringBean = this.createTree(_lastList); + finalGpufreqData.push(tree); + this.threadStatesTbl!.recycleDataSource = finalGpufreqData; + this.threadStatesTbl!.loading = false; + this.clickTableHeader(finalGpufreqData); + + } else { + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = false; + SpSegmentationChart.setChartData('GPU-FREQ', []); + }; + }; + private segmentationData(j: GpuCountBean, e: SearchGpuFuncBean, i: number): Array { + let lastList: Array = []; + if (j.startNS <= e.startTime && j.endTime >= e.startTime) { + if (j.endTime >= e.endTime) { + lastList.push( + new GpuCountBean( + j.freq, + (e.endTime - e.startTime) * j.val, + j.val, + e.endTime - e.startTime, + e.startTime, + e.endTime, + j.thread, + i + ) + ); + } else { + lastList.push( + new GpuCountBean( + j.freq, + (j.endTime - e.startTime) * j.val, + j.val, + j.endTime - e.startTime, + e.startTime, + j.endTime, + j.thread, + i + ) + ); + }; + } else if (j.startNS >= e.startTime && j.endTime <= e.endTime) { + lastList.push( + new GpuCountBean( + j.freq, + (j.endTime - j.startNS) * j.val, + j.val, + j.endTime - j.startNS, + j.startNS, + j.endTime, + j.thread, + i + ) + ); + } else if (j.startNS <= e.endTime && j.endTime >= e.endTime) { + lastList.push( + new GpuCountBean( + j.freq, + (e.endTime - j.startNS) * j.val, + j.val, + e.endTime - j.startNS, + j.startNS, + e.endTime, + j.thread, + i + ) + ); + }; + return lastList; + }; + // 创建树形结构 + private createTree(data: Array): TreeDataStringBean { + if (data.length > 0) { + const root: { + thread: string; + value: number; + dur: number; + percent: number; + level: number; + children: TreeDataBean[]; + } = { + thread: 'gpufreq Frequency', + value: 0, + dur: 0, + percent: 100, + level: 1, + children: [], + }; + const valueMap: { [parentIndex: number]: TreeDataBean } = {}; + data.forEach((item: GpuCountBean) => { + let parentIndex: number = item.parentIndex !== undefined ? item.parentIndex : 0; + let freq: number = item.freq; + item.thread = `${item.thread} Frequency`; + item.level = 4; + this.updateValueMap(item, parentIndex, freq, valueMap); + }); + Object.values(valueMap).forEach((node: TreeDataBean) => { + const parentNode: TreeDataBean = valueMap[node.freq! - 1]; + if (parentNode) { + parentNode.children.push(node); + parentNode.dur += node.dur; + parentNode.value += node.value; + } else { + root.children.push(node); + root.dur += node.dur; + root.value += node.value; + } + }); + this.flattenAndCalculate(root, root); + const firstLevelChildren = this.getFirstLevelChildren(root); + SpSegmentationChart.setChartData('GPU-FREQ', firstLevelChildren); + let _root = this.RetainDecimals(root) + return _root; + } else { + return new TreeDataStringBean('', '', '', '', '', ''); + }; + }; + private updateValueMap(item: GpuCountBean, parentIndex: number, freq: number, valueMap: { [parentIndex: string]: TreeDataBean }): void { + if (!valueMap[parentIndex]) { + valueMap[parentIndex] = { + thread: `cycle ${parentIndex + 1} ${item.thread}`, + value: item.value, + dur: item.dur, + startNS: item.startNS, + percent: 100, + level: 2, + cycle: parentIndex + 1, + children: [], + }; + } else { + valueMap[parentIndex].dur += item.dur; + valueMap[parentIndex].value += item.value; + }; + if (!valueMap[parentIndex].children[freq]) { + valueMap[parentIndex].children[freq] = { + thread: item.thread, + value: item.value, + dur: item.dur, + percent: 100, + level: 3, + children: [], + }; + } else { + valueMap[parentIndex].children[freq].dur += item.dur; + valueMap[parentIndex].children[freq].value += item.value; + }; + valueMap[parentIndex].children[freq].children.push(item as unknown as TreeDataBean); + }; + private getFirstLevelChildren(obj: TreeDataBean): Array { + const result: Array = []; + if (Array.isArray(obj.children)) { + obj.children.forEach((child) => { + if (child.cycle !== undefined && child.dur !== undefined && child.value !== undefined && child.startNS !== undefined) { + result.push(new CycleDataBean(7,child.dur, child.value, child.startNS, child.cycle,'',1)); + }; + }); + }; + return result; + }; + private flattenAndCalculate(node: TreeDataBean, root: TreeDataBean): void { + node.percent = node.value / root.value * 100; + if (node.children) { + node.children = node.children.flat(); + node.children.forEach((childNode) => this.flattenAndCalculate(childNode, root)); + }; + }; + private RetainDecimals(root: TreeDataBean): TreeDataStringBean { + const treeDataString: TreeDataStringBean = new TreeDataStringBean(root.thread!, (root.value / this.KUNIT).toFixed(this.SUB_LENGTH), (root.dur / this.UNIT).toFixed(this.SUB_LENGTH), root.percent!.toFixed(this.PERCENT_SUB_LENGTH), String(root.level), '', 0, [], '', false); + if (root.children) { + for (const child of root.children) { + treeDataString.children!.push(this.convertChildToString(child) as TreeDataStringBean); + }; + }; + return treeDataString; + }; + private convertChildToString(child: TreeDataBean | TreeDataBean[]): TreeDataStringBean | TreeDataStringBean[] { + if (Array.isArray(child)) { + if (child.length > 0) { + return child.map(c => this.convertChildToString(c) as TreeDataStringBean); + } else { + return []; + } + } else if (child && child.children) { + return { + thread: child.thread as string, + value: (child.value / this.KUNIT).toFixed(this.SUB_LENGTH), + freq: '', + cycle: child.cycle ? child.cycle : 0, + dur: (child.dur / this.UNIT).toFixed(this.SUB_LENGTH), + percent: child.percent ? child.percent.toFixed(this.PERCENT_SUB_LENGTH) : '', + level: String(child.level), + startNS: child.startNS ? child.startNS.toFixed(this.SUB_LENGTH) : '', + children: this.convertChildToString(child.children) as unknown as TreeDataStringBean[], + }; + } else { + return { + thread: child.thread as string, + value: (child.value / this.KUNIT).toFixed(this.SUB_LENGTH), + freq: child.freq ? child.freq!.toFixed(this.SUB_LENGTH) : '', + dur: (child.dur / this.UNIT).toFixed(this.SUB_LENGTH), + percent: child.percent ? child.percent.toFixed(this.PERCENT_SUB_LENGTH) : '', + level: String(child.level) + }; + } + + }; + // 表头点击事件 + private clickTableHeader(data: Array): void { + let labels = this.threadStatesTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + const THREAD_INDEX: number = 0; + const CYCLE_INDEX: number = 1; + const FREQ_INDEX: number = 2; + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Thread') && i === THREAD_INDEX) { + this.threadStatesTbl!.setStatus(data, false); + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('Cycle') && i === CYCLE_INDEX) { + for (let item of data) { + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.threadStatesTbl!.setStatus(item.children, false); + }; + }; + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('Freq') && i === FREQ_INDEX) { + for (let item of data) { + item.status = true; + for (let e of item.children ? item.children : []) { + e.status = true; + if (e.children !== undefined && e.children.length > 0) { + this.threadStatesTbl!.setStatus(e.children, true); + }; + }; + }; + + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + }; + }); + }; + }; + }; + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadStatesTbl!); + }; + + initHtml(): string { + return ` +
        + + +
        + + +
        +
        + + + + + + + + + + + + + + `; + }; +} diff --git a/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqUsage.ts b/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqUsage.ts new file mode 100644 index 0000000000000000000000000000000000000000..793b1c20139288704be86e2900ce99458d6a76bb --- /dev/null +++ b/ide/src/trace/component/trace/sheet/gpufreq/TabPaneGpufreqUsage.ts @@ -0,0 +1,229 @@ +/* + * Copyright (C) 2023 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'; +import { type LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { type SelectionParam } from '../../../../bean/BoxSelection'; +import { getGpufreqData } from '../../../../database/sql/Perf.sql'; +import { resizeObserver } from '../SheetUtils'; +import { type GpuCountBean, TreeDataBean, TreeDataStringBean } from '../../../../bean/GpufreqBean' + +@element('tabpane-gpufreq') +export class TabPaneGpufreq extends BaseElement { + private threadStatesTbl: LitTable | null | undefined; + private currentSelectionParam: SelectionParam | undefined; + private SUB_LENGTH: number = 3; + private PERCENT_SUB_LENGTH: number = 2; + private UNIT: number = 1000000; + private KUNIT: number = 1000000000000; + + set data(clockCounterValue: SelectionParam) { + let finalGpufreqData: Array = new Array(); + if (this.currentSelectionParam === clockCounterValue) { + return; + }; + this.currentSelectionParam = clockCounterValue; + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = true; + getGpufreqData(clockCounterValue.leftNs, clockCounterValue.rightNs, false).then((result: Array): void => { + if (result !== null && result.length > 0) { + let resultList: Array = JSON.parse(JSON.stringify(result)); + resultList[0].dur = resultList[1] ? resultList[1].startNS - clockCounterValue.leftNs : clockCounterValue.rightNs - clockCounterValue.leftNs; + resultList[0].value = resultList[0].dur * resultList[0].val; + resultList[resultList.length - 1].dur = resultList.length - 1 !== 0 ? clockCounterValue.rightNs - resultList[resultList.length - 1].startNS : resultList[0].dur; + resultList[resultList.length - 1].value = resultList.length - 1 !== 0 ? resultList[resultList.length - 1].dur * resultList[resultList.length - 1].val : resultList[0].value; + // 将切割完成后的数据整理成树形 + let tree: TreeDataStringBean = this.createTree(resultList); + finalGpufreqData.push(tree); + this.threadStatesTbl!.recycleDataSource = finalGpufreqData; + this.threadStatesTbl!.loading = false; + this.clickTableHeader(finalGpufreqData); + } else { + this.threadStatesTbl!.recycleDataSource = []; + this.threadStatesTbl!.loading = false; + }; + + }); + }; + + initElements(): void { + this.threadStatesTbl = this.shadowRoot?.querySelector('#tb-gpufreq-percent'); + }; + + // 创建树形结构 + private createTree(data: Array): TreeDataStringBean { + if (data.length > 0) { + const root: { + thread: string; + value: number; + dur: number; + percent: number; + children: TreeDataBean[]; + } = { + thread: 'gpufreq Frequency', + value: 0, + dur: 0, + percent: 100, + children: [], + }; + const valueMap: { [freq: string]: TreeDataBean } = {}; + data.forEach((item: GpuCountBean) => { + let freq: number = item.freq; + item.thread = `${item.thread} Frequency`; + this.updateValueMap(item, freq, valueMap); + }); + Object.values(valueMap).forEach((node: TreeDataBean) => { + const parentNode: TreeDataBean = valueMap[node.freq! - 1]; + if (parentNode) { + parentNode.children.push(node); + parentNode.dur += node.dur; + parentNode.value += node.value; + } else { + root.children.push(node); + root.dur += node.dur; + root.value += node.value; + }; + }); + this.flattenAndCalculate(root, root); + let _root = this.RetainDecimals(root) + return _root; + + }; + return new TreeDataStringBean('', '', '', '', '', ''); + }; + // 更新valueMap,用于整理相同频点的数据 + private updateValueMap(item: GpuCountBean, freq: number, valueMap: { [freq: string]: TreeDataBean }): void { + if (!valueMap[freq]) { + valueMap[freq] = { + thread: 'gpufreq Frequency', + value: item.value, + freq: item.freq, + dur: item.dur, + percent: 100, + children: [], + }; + } else { + valueMap[freq].dur += item.dur; + valueMap[freq].value += item.value; + }; + valueMap[freq].children.push(item as unknown as TreeDataBean); + }; + // 对树进行扁平化处理和计算 + private flattenAndCalculate(node: TreeDataBean, root: TreeDataBean): void { + //处理百分比计算问题并保留两位小数 + node.percent = node.value / root.value * 100; + if (node.children) { + node.children = node.children.flat(); + node.children.forEach((childNode) => this.flattenAndCalculate(childNode, root)); + }; + }; + // 将树形数据进行保留小数操作 + private RetainDecimals(root: TreeDataBean): TreeDataStringBean { + const treeDataString: TreeDataStringBean = new TreeDataStringBean(root.thread!, (root.value / this.KUNIT).toFixed(this.SUB_LENGTH), (root.dur / this.UNIT).toFixed(this.SUB_LENGTH), root.percent!.toFixed(this.PERCENT_SUB_LENGTH),String(root.level), '',0, [], '', false); + if (root.children) { + for (const child of root.children) { + treeDataString.children!.push(this.convertChildToString(child) as TreeDataStringBean); + }; + }; + return treeDataString; + }; + // 将树形数据进行保留小数的具体操作 + private convertChildToString(child: TreeDataBean | TreeDataBean[]): TreeDataStringBean | TreeDataStringBean[] { + if (Array.isArray(child)) { + if (child.length > 0) { + return child.map(c => this.convertChildToString(c) as TreeDataStringBean); + } else { + return []; + } + } else if (child && child.children) { + return { + thread: child.thread as string, + value: (child.value / this.KUNIT).toFixed(this.SUB_LENGTH), + freq: '', + dur: (child.dur / this.UNIT).toFixed(this.SUB_LENGTH), + percent: child.percent ? child.percent.toFixed(this.PERCENT_SUB_LENGTH) : '', + children: this.convertChildToString(child.children) as unknown as TreeDataStringBean[], + }; + } else { + return { + thread: child.thread as string, + value: (child.value / this.KUNIT).toFixed(this.SUB_LENGTH), + freq: child.freq ? child.freq!.toFixed(this.SUB_LENGTH) : '', + dur: (child.dur / this.UNIT).toFixed(this.SUB_LENGTH), + percent: child.percent ? child.percent.toFixed(this.PERCENT_SUB_LENGTH) : '', + level: String(child.level) + }; + } + + }; + // 表头点击事件 + private clickTableHeader(data: Array): void { + let labels = this.threadStatesTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + const THREAD_INDEX: number = 0; + const FREQ_INDEX: number = 1; + + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + + if (label.includes('Thread') && i === THREAD_INDEX) { + this.threadStatesTbl!.setStatus(data, false); + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + + } else if (label.includes('Freq') && i === FREQ_INDEX) { + + for (let item of data) { + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.threadStatesTbl!.setStatus(item.children, true); + }; + }; + this.threadStatesTbl!.recycleDs = this.threadStatesTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + + }; + }); + }; + }; + }; + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadStatesTbl!); + }; + + initHtml(): string { + return ` + + + + + + + + + + + + + + `; + }; +} \ No newline at end of file diff --git a/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts b/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts index 331c287b3ebf90f0c40b004c3d39d6000b411738..9e10a7afeca15ba9c44be3f19b27a34d664ef0ec 100644 --- a/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts +++ b/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts @@ -46,19 +46,24 @@ export class TabPaneHiLogs extends BaseElement { private allowTag: Set = new Set(); private ONE_DAY_NS = 86400000000000; private progressEL: LitProgressBar | null | undefined; + private timeOutId: number | undefined; set data(systemLogParam: SelectionParam) { if (this.hiLogsTbl) { this.hiLogsTbl.recycleDataSource = []; this.filterData = []; } + window.clearTimeout(this.timeOutId); let oneDayTime = (window as any).recordEndNS - this.ONE_DAY_NS; if (systemLogParam && systemLogParam.hiLogs.length > 0) { this.progressEL!.loading = true; queryLogAllData(oneDayTime, systemLogParam.leftNs, systemLogParam.rightNs).then((res) => { + if (res.length === 0) { + this.progressEL!.loading = false; + } systemLogParam.sysAlllogsData = res; this.systemLogSource = res; - this.tableTimeHandle?.(); + this.refreshTable(); }); } } @@ -146,8 +151,10 @@ export class TabPaneHiLogs extends BaseElement { this.hiLogsTbl.shadowRoot.querySelector('.table').style.height = this.parentElement!.clientHeight - 20 - 45 + 'px'; } - this.tableTimeHandle?.(); - this.tableTitleTimeHandle?.(); + if (this.filterData.length > 0) { + this.refreshTable(); + this.tableTitleTimeHandle?.(); + } }).observe(this.parentElement!); } @@ -193,7 +200,9 @@ export class TabPaneHiLogs extends BaseElement { if (this.hiLogsTbl && this.hiLogsTbl.currentRecycleList.length > 0) { let startDataIndex = this.hiLogsTbl.startSkip + 1; let endDataIndex = startDataIndex; - if (height < firstRowHeight * 0.3) { + let crossTopHeight = tbl!.scrollTop % firstRowHeight; + let topShowHeight = crossTopHeight === 0 ? 0 : firstRowHeight - crossTopHeight; + if (topShowHeight < firstRowHeight * 0.3) { startDataIndex++; } let tableHeight = Number(tbl!.style.height.replace('px', '')) - tableHeadHeight; @@ -204,7 +213,7 @@ export class TabPaneHiLogs extends BaseElement { height += firstRowHeight; endDataIndex++; } - if (tableHeight - height > firstRowHeight * 0.3) { + if (tableHeight - height - topShowHeight > firstRowHeight * 0.3) { endDataIndex++; } if (endDataIndex >= this.filterData.length) { @@ -217,7 +226,9 @@ export class TabPaneHiLogs extends BaseElement { } else { this.logTableTitle!.textContent = 'Hilogs [0, 0] / 0'; } - this.progressEL!.loading = false; + if (this.hiLogsTbl!.recycleDataSource.length > 0) { + this.progressEL!.loading = false; + } } initTabSheetEl(traceSheet: TraceSheet): void { @@ -232,8 +243,8 @@ export class TabPaneHiLogs extends BaseElement { tagFilterKeyEvent = (e: KeyboardEvent): void => { let inputValue = this.tagFilterInput!.value.trim(); - if (e.code === 'Enter') { - if (inputValue !== '' && !this.allowTag.has(inputValue.toLowerCase())) { + if (e.key === 'Enter') { + if (inputValue !== '' && !this.allowTag.has(inputValue.toLowerCase()) && this.allowTag.size < 10) { let tagElement = document.createElement('div'); tagElement.className = 'tagElement'; tagElement.id = inputValue; @@ -250,7 +261,7 @@ export class TabPaneHiLogs extends BaseElement { this.tagFilterInput!.value = ''; this.tagFilterInput!.placeholder = 'Filter by tag...'; } - } else if (e.code === 'Backspace') { + } else if (e.key === 'Backspace') { let index = this.tagFilterDiv!.childNodes.length - defaultIndex; if (index >= 0 && inputValue === '') { let childNode = this.tagFilterDiv!.childNodes[index]; @@ -303,10 +314,9 @@ export class TabPaneHiLogs extends BaseElement { } private delayedRefresh(optionFn: Function, dur: number = tableTimeOut): () => void { - let timeOutId: number; return (...args: []): void => { - window.clearTimeout(timeOutId); - timeOutId = window.setTimeout((): void => { + window.clearTimeout(this.timeOutId); + this.timeOutId = window.setTimeout((): void => { optionFn.apply(this, ...args); }, dur); }; diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.ts index e5542c22392084e52391b3808dce568312008cc0..0002a180f0a59c9b5c41cab4c1c7a34d85eb6e98 100644 --- a/ide/src/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.ts +++ b/ide/src/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.ts @@ -219,10 +219,10 @@ export class TabPanePerfAnalysis extends BaseElement { if (table === showTable) { initSort(table!, this.sortColumn, this.sortType); table.style.display = 'grid'; - table.setAttribute('hideDownload', ''); + table!.removeAttribute('hideDownload'); } else { table!.style.display = 'none'; - table!.removeAttribute('hideDownload'); + table.setAttribute('hideDownload', ''); } } } @@ -285,6 +285,7 @@ export class TabPanePerfAnalysis extends BaseElement { private hideProcess(): void { this.reset(this.perfTableThread!, false); + this.showAssignLevel(this.perfTableThread!, this.perfTableProcess!, 1, this.perfTableThread!.recycleDataSource); this.processName = ''; this.titleEl!.textContent = ''; this.getHiperfThread(null, this.currentSelection); @@ -292,6 +293,7 @@ export class TabPanePerfAnalysis extends BaseElement { private hideThread(it?: any): void { this.reset(this.perfTableSo!, true); + this.showAssignLevel(this.perfTableSo!, this.perfTableProcess!, 1, this.soData); this.threadName = ''; if (it) { this.getHiperfSo(it, this.currentSelection); @@ -356,8 +358,10 @@ export class TabPanePerfAnalysis extends BaseElement { private perfProcessLevelClickEvent(it: any, val: SelectionParam): void { if (this.hideThreadCheckBox!.checked) { this.hideThread(it); + this.showAssignLevel(this.perfTableSo!, this.perfTableProcess!, 1, this.soData); } else { this.reset(this.perfTableThread!, true); + this.showAssignLevel(this.perfTableThread!, this.perfTableProcess!, 1, this.threadData); this.getHiperfThread(it, val); } // @ts-ignore @@ -418,6 +422,7 @@ export class TabPanePerfAnalysis extends BaseElement { private perfThreadLevelClickEvent(it: any, val: SelectionParam): void { this.reset(this.perfTableSo!, true); + this.showAssignLevel(this.perfTableSo!, this.perfTableThread!, 2, this.soData); this.getHiperfSo(it, val); let pName = this.processName; if (this.processName.length > 0 && it.tableName.length > 0) { @@ -490,6 +495,7 @@ export class TabPanePerfAnalysis extends BaseElement { private perfSoLevelClickEvent(it: any): void { this.reset(this.tableFunction!, true); + this.showAssignLevel(this.tableFunction!, this.perfTableSo!, 3, this.functionData); this.getHiperfFunction(it); let title = ''; if (this.processName.length > 0) { @@ -749,9 +755,7 @@ export class TabPanePerfAnalysis extends BaseElement { libMap.set(`${itemData.libId}-${itemData.libName}`, dataArray); } } - if (!item) { - parentEventCount = allEventCount; - } + item ? (parentEventCount = item.eventCount) : (parentEventCount = allEventCount); this.soData = []; libMap.forEach((arr: Array) => { let libCount = 0; diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts index 6c509a6fcbddd7d9b9597b27e632c1c3d55b1ba6..b497e22e790e0400a562c57e0f5aebc4ce0c7151 100644 --- a/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts +++ b/ide/src/trace/component/trace/sheet/hiperf/TabPerfBottomUp.ts @@ -146,7 +146,7 @@ export class TabpanePerfBottomUp extends BaseElement { const bottomUpData = evt.detail.data as PerfBottomUpStruct; document.dispatchEvent( new CustomEvent('number_calibration', { - detail: {time: bottomUpData.tsArray}, + detail: { time: bottomUpData.tsArray }, }) ); callStack!.push(bottomUpData); diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts index cdbbaf91c9c2f61f1918f275a1a8ab4a3eba15fc..8866102706ccc0f78d87322e90db806172bbf6b1 100644 --- a/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts +++ b/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts @@ -468,7 +468,9 @@ export class TabpanePerfProfile extends BaseElement { } private perfProfilerFilterGetFilter(data: FilterData): void { - if (this.searchValue !== this.perfProfilerFilter!.filterValue) { + if ((this.isChartShow && data.icon === 'tree') || (!this.isChartShow && data.icon === 'block')) { + this.switchFlameChart(data); + } else if (this.searchValue !== this.perfProfilerFilter!.filterValue) { this.searchValue = this.perfProfilerFilter!.filterValue; let perfArgs = [ { @@ -585,15 +587,19 @@ export class TabpanePerfProfile extends BaseElement { this.perfProfileFrameChart?.updateCanvas(false, entries[0].contentRect.width); this.perfProfileFrameChart?.calculateChartData(); } + let headLineHeight = 0; + if (this.headLine?.isShow) { + headLineHeight = this.headLine!.clientHeight; + } // @ts-ignore this.perfProfilerTbl?.shadowRoot.querySelector('.table').style.height = // @ts-ignore - `${this.parentElement.clientHeight - 10 - 35}px`; + `${this.parentElement.clientHeight - 10 - 35 - headLineHeight}px`; this.perfProfilerTbl?.reMeauseHeight(); // @ts-ignore this.perfProfilerList?.shadowRoot.querySelector('.table').style.height = // @ts-ignore - `${this.parentElement.clientHeight - 45 - 21}px`; + `${this.parentElement.clientHeight - 45 - 21 - headLineHeight}px`; this.perfProfilerList?.reMeauseHeight(); this.perfProfileLoadingPage.style.height = `${this.parentElement!.clientHeight - 24}px`; } diff --git a/ide/src/trace/component/trace/sheet/hisysevent/TabPaneHisysEvents.ts b/ide/src/trace/component/trace/sheet/hisysevent/TabPaneHisysEvents.ts index 4f32e5e903094eafa5ca8edcd005da69ae858f4e..38484fb23e65da339fc07ade63860c0906606b8c 100644 --- a/ide/src/trace/component/trace/sheet/hisysevent/TabPaneHisysEvents.ts +++ b/ide/src/trace/component/trace/sheet/hisysevent/TabPaneHisysEvents.ts @@ -55,6 +55,7 @@ export class TabPaneHisysEvents extends BaseElement { tableTitleTimeHandle: (() => void) | undefined; private currentDetailList: Array<{ key: string; value: string }> = []; private realTime: number = -1; + private bootTime: number = -1; private baseTime: string = ''; set data(systemEventParam: SelectionParam) { @@ -71,7 +72,13 @@ export class TabPaneHisysEvents extends BaseElement { this.initTabSheetEl(); queryRealTime().then((result) => { if (result && result.length > 0) { - this.realTime = Math.floor(result[0].ts / millisecond); + result.forEach(item => { + if (item.name === 'realtime') { + this.realTime = item.ts; + } else { + this.bootTime = item.ts; + } + }); } queryHiSysEventTabData(systemEventParam.leftNs, systemEventParam.rightNs).then((res) => { this.currentSelection = systemEventParam; @@ -108,6 +115,16 @@ export class TabPaneHisysEvents extends BaseElement { this.initHiSysEventListener(); } + /** + * 按ns去补0 + * + * @param timestamp + * @private + */ + private timestampToNS(timestamp: string): number { + return Number(timestamp.toString().padEnd(19, '0')); + } + private initHiSysEventListener(): void { this.hiSysEventTable!.addEventListener('row-click', (event) => { this.changeInput!.value = ''; @@ -180,7 +197,9 @@ export class TabPaneHisysEvents extends BaseElement { if (this.hiSysEventTable && this.hiSysEventTable.currentRecycleList.length > 0) { let startDataIndex = this.hiSysEventTable.startSkip + 1; let endDataIndex = startDataIndex; - if (height < firstRowHeight * 0.3) { + let crossTopHeight = tbl!.scrollTop % firstRowHeight; + let topShowHeight = crossTopHeight === 0 ? 0 : firstRowHeight - crossTopHeight; + if (topShowHeight < firstRowHeight * 0.3) { startDataIndex++; } let tableHeight = Number(tbl!.style.height.replace('px', '')) - tableHeadHeight; @@ -191,7 +210,7 @@ export class TabPaneHisysEvents extends BaseElement { height += firstRowHeight; endDataIndex++; } - if (tableHeight - height > firstRowHeight * 0.3) { + if (tableHeight - height - topShowHeight > firstRowHeight * 0.3) { endDataIndex++; } if (endDataIndex >= this.filterDataList.length) { @@ -403,7 +422,7 @@ export class TabPaneHisysEvents extends BaseElement { let contentValue = value; if (key.endsWith('_TIME')) { if (!isNaN(Number(value))) { - contentValue = ((Number(value) - this.realTime) * millisecond).toString(); + contentValue = ((this.timestampToNS(value) - this.realTime) + this.bootTime).toString(); if (this.realTime < 0) { contentValue = value; } diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts index 882ea103ec12dca38e206b491b51036438f72e93..3aa67c12f97f8d6aa0b4121dafa8af5b6eb52106 100644 --- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts +++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts @@ -699,17 +699,21 @@ export class TabpaneNMCalltree extends BaseElement { this.nmCallTreeFrameChart?.updateCanvas(false, entries[0].contentRect.width); this.nmCallTreeFrameChart?.calculateChartData(); } + let headLineHeight = 0; + if (this.headLine?.isShow) { + headLineHeight = this.headLine!.clientHeight; + } if (this.nmCallTreeTbl) { // @ts-ignore this.nmCallTreeTbl.shadowRoot.querySelector('.table').style.height = `${ - this.parentElement!.clientHeight - 10 - 35 + this.parentElement!.clientHeight - 10 - 35 - headLineHeight }px`; } this.nmCallTreeTbl?.reMeauseHeight(); if (this.filesystemTbr) { // @ts-ignore this.filesystemTbr.shadowRoot.querySelector('.table').style.height = `${ - this.parentElement!.clientHeight - 45 - 21 + this.parentElement!.clientHeight - 45 - 21 - headLineHeight }px`; } this.filesystemTbr?.reMeauseHeight(); @@ -729,24 +733,18 @@ export class TabpaneNMCalltree extends BaseElement { } filesystemTbrRowClickHandler = (event: any): void => { - // @ts-ignore - let data = evt.detail.data as FileMerageBean; + let data = event.detail.data as FileMerageBean; this.nmCallTreeTbl?.clearAllSelection(data); (data as any).isSelected = true; this.nmCallTreeTbl!.scrollToData(data); - // @ts-ignore - if ((evt.detail as any).callBack) { - // @ts-ignore - (evt.detail as any).callBack(true); + if ((event.detail as any).callBack) { + (event.detail as any).callBack(true); } }; nmCallTreeTblColumnClickHandler = (event: any): void => { - // @ts-ignore - this.sortKey = evt.detail.key; - // @ts-ignore - this.sortType = evt.detail.sort; - // @ts-ignore + this.sortKey = event.detail.key; + this.sortType = event.detail.sort; this.setLTableData(this.nmCallTreeSource, true); this.nmCallTreeFrameChart!.data = this.nmCallTreeSource; }; diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts index 576ede79148dc16b7b8573b97b79f40235397d8c..c192166ec9ce6e4a0a51961f043b5f92adecb3ab 100644 --- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts +++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts @@ -162,12 +162,12 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { } if (this.functionUsageTbl) { // @ts-ignore - this.functionUsageTbl.shadowRoot.querySelector('.table').style.height = `${this.parentElement!.clientHeight - 30 + this.functionUsageTbl.shadowRoot.querySelector('.table').style.height = `${ + this.parentElement!.clientHeight - 30 }px`; } - this.clearData(); - this.currentSelection = statisticAnalysisParam; this.reset(this.tableType!, false); + this.currentSelection = statisticAnalysisParam; this.titleEl!.textContent = ''; this.tabName!.textContent = ''; this.range!.textContent = `Selected range: ${parseFloat( @@ -178,6 +178,7 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { this.threadName = ''; } this.getNMEventTypeSize(statisticAnalysisParam); + this.showAssignLevel(this.tableType!, this.functionUsageTbl!, 0, this.eventTypeData); } initNmTableArray(): void { @@ -273,6 +274,7 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { this.hideThreadCheckBox = popover!!.querySelector('div > #hideThread'); this.hideThreadCheckBox?.addEventListener('change', () => { this.reset(this.tableType!, false); + this.showAssignLevel(this.tableType!, this.functionUsageTbl!, 0, this.eventTypeData); this.getNMTypeSize(this.currentSelection, this.processData); }); this.initNmTableArray(); @@ -366,10 +368,10 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { if (table === showTable) { initSort(table, this.nmSortColumn, this.nmSortType); table.style.display = 'grid'; - table.setAttribute('hideDownload', ''); + table!.removeAttribute('hideDownload'); } else { table!.style.display = 'none'; - table!.removeAttribute('hideDownload'); + table.setAttribute('hideDownload', ''); } } } @@ -641,9 +643,11 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { private nativeProcessLevelClickEvent(it: any): void { if (this.hideThreadCheckBox?.checked || this.isStatistic) { this.reset(this.soUsageTbl!, true); + this.showAssignLevel(this.soUsageTbl!, this.tableType!, 1, this.eventTypeData); this.getNMLibSize(it); } else { this.reset(this.threadUsageTbl!, true); + this.showAssignLevel(this.threadUsageTbl!, this.tableType!, 1, this.eventTypeData); this.getNMThreadSize(it); } const typeName = it.typeName === TYPE_MAP_STRING ? TYPE_OTHER_MMAP : it.typeName; @@ -655,6 +659,7 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { private nativeThreadLevelClickEvent(it: AnalysisObj): void { this.reset(this.soUsageTbl!, true); + this.showAssignLevel(this.soUsageTbl!, this.threadUsageTbl!, 2, this.eventTypeData); this.getNMLibSize(it); const typeName = this.type === TYPE_MAP_STRING ? TYPE_OTHER_MMAP : this.type; @@ -670,6 +675,7 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { private nativeSoLevelClickEvent(it: any): void { this.reset(this.functionUsageTbl!, true); + this.showAssignLevel(this.functionUsageTbl!, this.soUsageTbl!, 3, this.eventTypeData); this.getNMFunctionSize(it); const typeName = this.type === TYPE_MAP_STRING ? TYPE_OTHER_MMAP : this.type; // @ts-ignore @@ -703,12 +709,12 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { for (let type of val.nativeMemory) { if (type === 'All Heap & Anonymous VM') { typeFilter = []; - typeFilter.push(...['\'AllocEvent\'', '\'FreeEvent\'', '\'MmapEvent\'', '\'MunmapEvent\'']); + typeFilter.push(...["'AllocEvent'", "'FreeEvent'", "'MmapEvent'", "'MunmapEvent'"]); break; } else if (type === 'All Heap') { - typeFilter.push(...['\'AllocEvent\'', '\'FreeEvent\'']); + typeFilter.push(...["'AllocEvent'", "'FreeEvent'"]); } else { - typeFilter.push(...['\'MmapEvent\'', '\'MunmapEvent\'']); + typeFilter.push(...["'MmapEvent'", "'MunmapEvent'"]); } } this.getDataFromWorker(val, typeFilter); @@ -837,7 +843,6 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { } } - private getNMLibSize(item: any): void { this.progressEL!.loading = true; let typeId = item.typeId; @@ -901,7 +906,7 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { return; } for (let data of this.processData) { - if (this.shouldSkipItem(typeName, types, data)) { + if (this.skipItemByType(typeName, types, data, libId)) { continue; } if (tid !== undefined && tid !== data.tid) { @@ -937,6 +942,43 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { this.functionPieChart(); } + private skipItemByType(typeName: string, types: Array, data: any, libId: number) { + if (typeName === TYPE_ALLOC_STRING) { + // @ts-ignore + if (!types.includes(data.type) || data.libId !== libId) { + return true; + } + } else if (typeName === TYPE_MAP_STRING) { + if (this.isStatistic) { + if (data.subType) { + // @ts-ignore + if (!types.includes(data.subType) || !types.includes(data.type) || data.libId !== libId) { + return true; + } + } else { + return true; + } + } else { + if (!data.subType) { + // @ts-ignore + if (!types.includes(data.type) || data.libId !== libId) { + return true; + } + } else { + return true; + } + } + } else { + if (data.subType) { + // @ts-ignore + if (!types.includes(data.subType) || !types.includes(data.type) || data.libId !== libId) { + return true; + } + } else { + return true; + } + } + } private baseSort(data: Array): void { if (data === this.functionData) { this.functionData.sort((a, b) => b.existSize - a.existSize); @@ -945,7 +987,6 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { this.currentLevel = 3; this.progressEL!.loading = false; } - ; if (data === this.soData) { this.soData.sort((a, b) => b.existSize - a.existSize); this.libStatisticsData = this.totalData(this.libStatisticsData); @@ -1234,8 +1275,10 @@ export class TabPaneNMStatisticAnalysis extends BaseElement { return sortColumnArr; } - - private caseTableName(statisticAnalysisLeftData: { tableName: number; }, statisticAnalysisRightData: { tableName: number; }): number { + private caseTableName( + statisticAnalysisLeftData: { tableName: number }, + statisticAnalysisRightData: { tableName: number } + ): number { if (this.nmSortType === 1) { if (statisticAnalysisLeftData.tableName > statisticAnalysisRightData.tableName) { return 1; diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts index 0b6d62ed6ce25419e1c5880bab06ff161c501ea2..a09f4bed9a000cf1a0b33e7f5936d69ca490e3b9 100644 --- a/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts +++ b/ide/src/trace/component/trace/sheet/process/TabPaneSlices.ts @@ -30,6 +30,7 @@ export class TabPaneSlices extends BaseElement { private slicesRange: HTMLLabelElement | null | undefined; private slicesSource: Array = []; private currentSelectionParam: SelectionParam | undefined; + private flag: boolean = false; set data(slicesParam: SelectionParam | any) { if (this.currentSelectionParam === slicesParam) { @@ -83,9 +84,9 @@ export class TabPaneSlices extends BaseElement { // @ts-ignore this.sortByColumn(evt.detail); }); - this.slicesTbl!.addEventListener('row-click', async (evt) => { - // @ts-ignore - let data = evt.detail.data; + // @ts-ignore + let testData; + this.slicesTbl!.addEventListener('contextmenu', async (evt) => { let spApplication = document.querySelector('body > sp-application') as SpAllocations; let spSystemTrace = spApplication?.shadowRoot?.querySelector( 'div > div.content > sp-system-trace' @@ -96,11 +97,13 @@ export class TabPaneSlices extends BaseElement { it.draw(); }); spSystemTrace?.timerShaftEL?.removeTriangle('inverted'); - await spSystemTrace!.searchFunction([], data.name).then((mixedResults) => { + // @ts-ignore + await spSystemTrace!.searchFunction([], testData.name).then((mixedResults) => { if (mixedResults && mixedResults.length === 0) { return; } - search.list = mixedResults.filter((item) => item.funName === data.name); + // @ts-ignore + search.list = mixedResults.filter((item) => item.funName === testData.name); const sliceRowList: Array> = []; // 框选的slice泳道 for (let row of spSystemTrace.rangeSelect.rangeTraceRow!) { @@ -118,9 +121,18 @@ export class TabPaneSlices extends BaseElement { if (sliceRowList.length === 0) { return; } - this.slicesTblFreshSearchSelect(search, sliceRowList, data, spSystemTrace); + // @ts-ignore + this.slicesTblFreshSearchSelect(search, sliceRowList, testData, spSystemTrace); }); }); + this.slicesTbl!.addEventListener('row-click', async (evt) => { + // @ts-ignore + testData = evt.detail.data; + }); + this.shadowRoot?.querySelector('#filterName')?.addEventListener('input', (e) => { + // @ts-ignore + this.findName(e.target.value); + }); } private slicesTblFreshSearchSelect( @@ -180,9 +192,14 @@ export class TabPaneSlices extends BaseElement { padding: 10px 10px; flex-direction: column; } + #filterName:focus{ + outline: none; + } - +
        + + +
        @@ -237,4 +254,29 @@ export class TabPaneSlices extends BaseElement { } this.slicesTbl!.recycleDataSource = this.slicesSource; } + + findName(str: string): void { + // 有一个问题就是,是否要在筛选之后的表格上方显示总数据 + let searchData: Array = []; + let sumWallDuration: number = 0; + let sumOccurrences: number = 0; + if(str === ''){ + this.slicesTbl!.recycleDataSource = this.slicesSource; + } else { + this.slicesSource.forEach(item => { + if (item.name.toLowerCase().indexOf(str.toLowerCase()) !== -1) { + searchData.push(item); + sumWallDuration += item.wallDuration; + sumOccurrences += item.occurrences; + } + }); + let count: SelectionData = new SelectionData(); + count.process = ''; + count.name = ''; + count.wallDuration = Number(sumWallDuration.toFixed(3)); + count.occurrences = sumOccurrences; + searchData.unshift(count); + this.slicesTbl!.recycleDataSource = searchData; + } + } } diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneStartup.ts b/ide/src/trace/component/trace/sheet/process/TabPaneStartup.ts index aef77ad5717c948adbda581814f9ceee1238d1da..2f7237125766c8adc52bb73d60ee3133a547c3b3 100644 --- a/ide/src/trace/component/trace/sheet/process/TabPaneStartup.ts +++ b/ide/src/trace/component/trace/sheet/process/TabPaneStartup.ts @@ -44,10 +44,10 @@ export class TabPaneStartup extends BaseElement { } this.currentSelectionParam = startupParam; //@ts-ignore - this.startupTbl?.shadowRoot?.querySelector('.table')?.style?.height = - `${this.parentElement!.clientHeight - 45 }px`; - this.range!.textContent = - `Selected range: ${ ((startupParam.rightNs - startupParam.leftNs) / 1000000.0).toFixed(5) } ms`; + this.startupTbl?.shadowRoot?.querySelector('.table')?.style?.height = `${this.parentElement!.clientHeight - 45}px`; + this.range!.textContent = `Selected range: ${((startupParam.rightNs - startupParam.leftNs) / 1000000.0).toFixed( + 5 + )} ms`; this.startupTbl!.loading = true; getTabStartups(startupParam.processIds, startupParam.leftNs, startupParam.rightNs).then( (result: AppStartupStruct[]) => { @@ -146,9 +146,9 @@ export class TabPaneStartup extends BaseElement { Selected range:0.0 ms
        - + + key="name" align="flex-start" retract> diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneStaticInit.ts b/ide/src/trace/component/trace/sheet/process/TabPaneStaticInit.ts index 760f2ef1ca145c562e4a471b523a5c91dcdf895d..d60edb9473960df2119997f6e27514ca9f83ceb6 100644 --- a/ide/src/trace/component/trace/sheet/process/TabPaneStaticInit.ts +++ b/ide/src/trace/component/trace/sheet/process/TabPaneStaticInit.ts @@ -43,7 +43,7 @@ export class TabPaneStaticInit extends BaseElement { (result: SoStruct[]) => { this.staticinitTbl!.loading = false; if (result !== null && result.length > 0) { - log(`getTabStaticInit result size : ${ result.length}`); + log(`getTabStaticInit result size : ${result.length}`); let map: Map = new Map(); result.forEach((item) => { let so: SoTreeItem = { @@ -73,7 +73,7 @@ export class TabPaneStaticInit extends BaseElement { soArr.forEach((it) => { it.durStr = getProbablyTime(it.dur); it.children!.forEach((child) => { - child.ratio = `${((child.dur * 100) / it.dur).toFixed(2) }%`; + child.ratio = `${((child.dur * 100) / it.dur).toFixed(2)}%`; }); }); this.staticinitSource = soArr; @@ -92,10 +92,12 @@ export class TabPaneStaticInit extends BaseElement { } this.currentSelectionParam = staticParam; //@ts-ignore - this.staticinitTbl?.shadowRoot?.querySelector('.table')?.style?.height = - `${this.parentElement!.clientHeight - 45 }px`; - this.range!.textContent = - `Selected range: ${ ((staticParam.rightNs - staticParam.leftNs) / 1000000.0).toFixed(5) } ms`; + this.staticinitTbl?.shadowRoot?.querySelector('.table')?.style?.height = `${ + this.parentElement!.clientHeight - 45 + }px`; + this.range!.textContent = `Selected range: ${((staticParam.rightNs - staticParam.leftNs) / 1000000.0).toFixed( + 5 + )} ms`; this.staticinitTbl!.loading = true; } @@ -134,7 +136,7 @@ export class TabPaneStaticInit extends BaseElement {
        + key="name" align="flex-start" retract order> diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneThreadStates.ts b/ide/src/trace/component/trace/sheet/process/TabPaneThreadStates.ts index fdd2399b5fc4008ef58cb36bc80bdbedcecb697b..01c6e9004a7a47d4d078092ec5743d60d72786bb 100644 --- a/ide/src/trace/component/trace/sheet/process/TabPaneThreadStates.ts +++ b/ide/src/trace/component/trace/sheet/process/TabPaneThreadStates.ts @@ -94,7 +94,7 @@ export class TabPaneThreadStates extends BaseElement { map.get(`${pre.state}-${mapKey}`).wallDuration += pre.dur; durExceptionDataMap['delete'](mapKey); } - if (current.dur === -1) { + if (current.dur === null || current.dur === undefined || current.dur === -1) { //如果出现dur 为-1的数据,dur先以0计算,在后续循环中碰到相同线程数据,则补上dur的值 current.dur = 0; durExceptionDataMap.set(mapKey, current); diff --git a/ide/src/trace/component/trace/sheet/process/TabPaneThreadUsage.ts b/ide/src/trace/component/trace/sheet/process/TabPaneThreadUsage.ts index cfe63adbc56b3d0838b40029df8cf846175566cd..32bde189428f315fe937d4a92fdec2a37af75d8b 100644 --- a/ide/src/trace/component/trace/sheet/process/TabPaneThreadUsage.ts +++ b/ide/src/trace/component/trace/sheet/process/TabPaneThreadUsage.ts @@ -63,7 +63,7 @@ export class TabPaneThreadUsage extends BaseElement { } //@ts-ignore this.threadUsageTbl?.shadowRoot?.querySelector('.table')?.style?.height = - `${this.parentElement!.clientHeight - 45 }px`; + `${this.parentElement!.clientHeight - 45}px`; // 框选区域内running的时间 getTabRunningPersent(threadUsageParam.threadIds, threadUsageParam.leftNs, threadUsageParam.rightNs).then( (result) => { @@ -72,8 +72,8 @@ export class TabPaneThreadUsage extends BaseElement { let leftStartNs = threadUsageParam.leftNs + threadUsageParam.recordStartNs; // 结束的时间rightEndNs let rightEndNs = threadUsageParam.rightNs + threadUsageParam.recordStartNs; - let sum = judgement(result, leftStartNs, rightEndNs); - this.range!.textContent = `Selected range: ${ (sum / 1000000.0).toFixed(5) } ms`; + let sum = rightEndNs - leftStartNs; + this.range!.textContent = `Selected range: ${(sum / 1000000.0).toFixed(5)} ms`; } ); this.threadUsageTbl!.loading = true; @@ -85,20 +85,20 @@ export class TabPaneThreadUsage extends BaseElement { ); } - private threadStatesCpuDataHandler(result: any[], threadUsageParam: SelectionParam | any): void{ + private threadStatesCpuDataHandler(result: any[], threadUsageParam: SelectionParam | any): void { if (result !== null && result.length > 0) { - log(`getTabThreadStates result size : ${ result.length}`); + log(`getTabThreadStates result size : ${result.length}`); let filterArr = result.filter((it) => threadUsageParam.processIds.includes(it.pid)); + let totalDurtion = 0; + filterArr.forEach((item) => { + totalDurtion = totalDurtion + item.wallDuration; + }); let map: Map = new Map(); for (let resultEl of filterArr) { if (threadUsageParam.processIds.includes(resultEl.pid)) { if (map.has(resultEl.tid)) { map.get(resultEl.tid)[`cpu${resultEl.cpu}`] = resultEl.wallDuration || 0; map.get(resultEl.tid)[`cpu${resultEl.cpu}TimeStr`] = getProbablyTime(resultEl.wallDuration || 0); - map.get(resultEl.tid)[`cpu${resultEl.cpu}Ratio`] = ( - (100.0 * (resultEl.wallDuration || 0)) / - (threadUsageParam.rightNs - threadUsageParam.leftNs) - ).toFixed(2); map.get(resultEl.tid).wallDuration = map.get(resultEl.tid).wallDuration + (resultEl.wallDuration || 0); map.get(resultEl.tid).wallDurationTimeStr = getProbablyTime(map.get(resultEl.tid).wallDuration); @@ -120,14 +120,15 @@ export class TabPaneThreadUsage extends BaseElement { } threadStatesStruct[`cpu${resultEl.cpu}`] = resultEl.wallDuration || 0; threadStatesStruct[`cpu${resultEl.cpu}TimeStr`] = getProbablyTime(resultEl.wallDuration || 0); - threadStatesStruct[`cpu${resultEl.cpu}Ratio`] = ( - (100.0 * (resultEl.wallDuration || 0)) / - (threadUsageParam.rightNs - threadUsageParam.leftNs) - ).toFixed(2); map.set(resultEl.tid, threadStatesStruct); } } } + map.forEach((val) => { + for (let i = 0; i < this.cpuCount; i++){ + val[`cpu${i}Ratio`] = (100.0 *val[`cpu${i}`]/val.wallDuration).toFixed(2); + } + }) this.threadUsageSource = Array.from(map.values()); this.threadUsageTbl!.recycleDataSource = this.threadUsageSource; } else { @@ -230,7 +231,7 @@ export class TabPaneThreadUsage extends BaseElement { export function judgement(result: Array, leftStart: any, rightEnd: any): number { let sum = 0; if (result !== null && result.length > 0) { - log(`getTabRunningTime result size : ${ result.length}`); + log(`getTabRunningTime result size : ${result.length}`); let rightEndNs = rightEnd; let leftStartNs = leftStart; // 尾部running的结束时间 diff --git a/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstruction.ts b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstruction.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab51b08c5cdb2654916f77a386e1a0e73582a417 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstruction.ts @@ -0,0 +1,434 @@ +/* + * 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'; +import { Rect, drawString } from '../../../../database/ui-worker/ProcedureWorkerCommon'; +import { ColorUtils } from '../../base/ColorUtils'; +import { SampleStruct } from '../../../../database/ui-worker/ProcedureWorkerSample'; +import { SpApplication } from '../../../../SpApplication'; + +const SAMPLE_STRUCT_HEIGHT = 30; +const Y_PADDING = 4; + +@element('tab-sample-instruction') +export class TabPaneSampleInstruction extends BaseElement { + private instructionEle: HTMLCanvasElement | undefined | null; + private ctx: CanvasRenderingContext2D| undefined | null; + private textEle: HTMLSpanElement | undefined | null; + private instructionArray: Array = []; + private instructionData: Array = []; + private flattenTreeData: Array = []; + private isUpdateCanvas = false; + private canvasX = -1; // 鼠标当前所在画布x坐标 + private canvasY = -1; // 鼠标当前所在画布y坐标 + private startX = 0; // 画布相对于整个界面的x坐标 + private startY = 0; // 画布相对于整个界面的y坐标 + private hintContent = ""; //悬浮框内容 + private floatHint!: HTMLDivElement | undefined | null; //悬浮框 + private canvasScrollTop = 0; // tab页上下滚动位置 + private hoverSampleStruct: any | undefined; + private isChecked: boolean = false; + private maxDepth = 0; + + initHtml(): string { + return ` + +
        + +
        +
        + 指令数数据流 +
        +
        + ` + } + + initElements(): void { + this.instructionEle = this.shadowRoot?.querySelector('#instruct-canvas'); + this.textEle = this.shadowRoot?.querySelector('.headline'); + this.ctx = this.instructionEle?.getContext('2d'); + this.floatHint = this.shadowRoot?.querySelector('#float_hint'); + } + + connectedCallback(): void { + super.connectedCallback(); + this.parentElement!.onscroll = () => { + this.canvasScrollTop = this.parentElement!.scrollTop; + this.hideTip(); + } + this.instructionEle!.onmousemove = (e): void => { + if (!this.isUpdateCanvas) { + this.updateCanvasCoord(); + } + this.canvasX = e.clientX - this.startX; + this.canvasY = e.clientY - this.startY + this.canvasScrollTop; + this.onMouseMove(); + } + this.instructionEle!.onmouseleave = () => { + this.hideTip(); + } + document.addEventListener('sample-popver-change', (e: any) => { + const select = Number(e.detail.select); + this.isChecked = Boolean(select); + this.hoverSampleStruct = undefined; + this.drawInstructionData(this.isChecked); + }) + this.listenerResize(); + } + /** + * 初始化窗口大小 + * @param newWidth + */ + updateCanvas(newWidth?: number): void { + if (this.instructionEle instanceof HTMLCanvasElement) { + this.instructionEle.style.width = `${100}%`; + this.instructionEle.style.height = `${(this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT}px`; + if (this.instructionEle.clientWidth === 0 && newWidth) { + this.instructionEle.width = newWidth; + } else { + this.instructionEle.width = this.instructionEle.clientWidth; + } + this.instructionEle.height = (this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT; + this.updateCanvasCoord(); + } + } + + setSampleInstructionData(clickData: SampleStruct, reqProperty: any): void { + this.hoverSampleStruct = undefined; + this.instructionData = reqProperty.uniqueProperty; + this.flattenTreeData = reqProperty.flattenTreeArray; + this.setRelationDataProperty(this.flattenTreeData, clickData); + this.updateCanvas(this.clientWidth); + this.drawInstructionData(this.isChecked); + } + + /** + * 鼠标移动 + */ + onMouseMove(): void { + const lastNode = this.hoverSampleStruct; + //查找鼠标所在的node + const searchResult = this.searchDataByCoord(this.instructionArray!, this.canvasX, this.canvasY); + if (searchResult) { + this.hoverSampleStruct = searchResult; + //鼠标悬浮的node未改变则不需重新渲染文字 + if (searchResult !== lastNode) { + this.updateTipContent(); + this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height); + this.ctx!.beginPath(); + for (const key in this.instructionArray) { + for (let i = 0; i < this.instructionArray[key].length; i++) { + const cur = this.instructionArray[key][i]; + this.draw(this.ctx!, cur); + } + } + this.ctx!.closePath(); + } + this.showTip(); + } else { + this.hideTip(); + this.hoverSampleStruct = undefined; + } + } + + /** + * 隐藏悬浮框 + */ + hideTip(): void { + if (this.floatHint) { + this.floatHint.style.display = 'none'; + } + } + + /** + * 显示悬浮框 + */ + showTip(): void { + this.floatHint!.innerHTML = this.hintContent; + this.floatHint!.style.display = 'block'; + let x = this.canvasX; + let y = this.canvasY - this.canvasScrollTop; + //右边的函数悬浮框显示在左侧 + if (this.canvasX + this.floatHint!.clientWidth > (this.instructionEle!.clientWidth) || 0) { + x -= this.floatHint!.clientWidth - 1; + } else { + x += 30; + } + //最下边的函数悬浮框显示在上方 + y -= this.floatHint!.clientHeight - 1; + this.floatHint!.style.transform = `translate(${x}px, ${y}px)`; + } + + /** + * 更新悬浮框内容 + * @returns + */ + updateTipContent(): void { + const hoverNode = this.hoverSampleStruct; + if (!hoverNode) { + return; + } + this.hintContent = `${hoverNode.detail}(${hoverNode.name})
        + ${ this.isChecked ? hoverNode.hoverCycles : hoverNode.hoverInstructions} + + `; + } + + /** + * 设置绘制所需的坐标及宽高 + * @param sampleNode + * @param instructions + * @param x + */ + setSampleFrame(sampleNode: SampleStruct, instructions: number, x: number): void { + if (!sampleNode.frame) { + sampleNode.frame! = new Rect(0, 0, 0, 0); + } + sampleNode.frame!.x = x; + sampleNode.frame!.y = sampleNode.depth! * SAMPLE_STRUCT_HEIGHT; + sampleNode.frame!.width = instructions; + sampleNode.frame!.height = SAMPLE_STRUCT_HEIGHT; + } + + /** + * 判断鼠标当前在那个函数上 + * @param frame + * @param x + * @param y + * @returns + */ + isContains(frame: any, x: number, y: number): boolean { + return x >= frame.x && x <= frame.x + frame.width && frame.y <= y && y <= frame.y + frame.height; + } + + /** + * 绘制 + * @param isCycles + */ + drawInstructionData(isCycles: boolean): void { + this.isChecked ? this.textEle!.innerText = "cycles数据流" : this.textEle!.innerText = "instructions数据流"; + const clientWidth = this.instructionEle!.width; + //将数据转换为层级结构 + const instructionArray = this.flattenTreeData + .filter((item: SampleStruct) => isCycles ? item.cycles : item.instructions) + .reduce((pre: any, cur: any) => { + (pre[`${cur.depth}`] = pre[`${cur.depth}`] || []).push(cur); + return pre; + }, {}); + for (const key in instructionArray) { + for (let i = 0; i < instructionArray[key].length; i++) { + const cur = instructionArray[key][i]; + //第一级节点直接将宽度设置为容器宽度 + if (key === '0') { + this.setSampleFrame(cur, clientWidth, 0) + } else { + //获取上一层级节点数据 + const preList = instructionArray[Number(key) - 1]; + //获取当前节点的父节点 + const parentNode = preList.find((node: SampleStruct) => node.name === cur.parentName); + //计算当前节点下指令数之和 用于计算每个节点所占的宽度比 + const total = isCycles ? instructionArray[key].filter((i: any) => i.parentName === parentNode.name).reduce((pre: number, cur: SampleStruct) => pre + cur.cycles!, 0) : + instructionArray[key].filter((i: any) => i.parentName === parentNode.name).reduce((pre: number, cur: SampleStruct) => pre + cur.instructions!, 0); + const curWidth = isCycles ? cur.cycles : cur.instructions; + const width = Math.floor(parentNode.frame.width * (curWidth / total)); + if (i === 0) { + this.setSampleFrame(cur, width, parentNode.frame.x); + } else { + const preNode = instructionArray[key][i - 1]; + preNode.parentName === parentNode.name ? + this.setSampleFrame(cur, width, preNode.frame.x + preNode.frame.width) : + this.setSampleFrame(cur, width, parentNode.frame.x); + } + } + } + } + this.instructionArray = instructionArray; + this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height); + this.ctx!.beginPath(); + for (const key in this.instructionArray) { + for (let i = 0; i < this.instructionArray[key].length; i++) { + const cur = this.instructionArray[key][i]; + this.draw(this.ctx!, cur) + } + } + this.ctx!.closePath() + } + + /** + * 更新canvas坐标 + */ + updateCanvasCoord(): void { + if (this.instructionEle instanceof HTMLCanvasElement) { + this.isUpdateCanvas = this.instructionEle.clientWidth !== 0; + if (this.instructionEle.getBoundingClientRect()) { + const box = this.instructionEle.getBoundingClientRect(); + const D = document.documentElement; + this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft; + this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop; + } + } + } + + /** + * 获取鼠标悬停的函数 + * @param nodes + * @param canvasX + * @param canvasY + * @returns + */ + searchDataByCoord(nodes: any, canvasX: number, canvasY: number) { + for (const key in nodes) { + for (let i = 0; i < nodes[key].length; i++) { + const cur = nodes[key][i]; + if (this.isContains(cur.frame, canvasX, canvasY)) { + return cur; + } + } + } + return null; + } + + /** + * 绘制方法 + * @param ctx + * @param data + */ + draw(ctx: CanvasRenderingContext2D, data: SampleStruct) { + let spApplication = document.getElementsByTagName('sp-application')[0]; + if (data.frame) { + ctx.globalAlpha = 1; + ctx.fillStyle = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)]; + const textColor = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)]; + ctx.lineWidth = 0.4; + if (this.hoverSampleStruct && data.name == this.hoverSampleStruct.name) { + if (spApplication.dark) { + ctx.strokeStyle = '#fff'; + } else { + ctx.strokeStyle = '#000'; + } + } else { + if (spApplication.dark) { + ctx.strokeStyle = '#000'; + } else { + ctx.strokeStyle = '#fff'; + } + } + ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING); + ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING); + ctx.fillStyle = ColorUtils.funcTextColor(textColor); + drawString(ctx, `${data.detail}(${data.name})`, 5, data.frame, data); + } + } + + /** + * 关系树节点赋值 + * @param relationData + * @param clickData + */ + setRelationDataProperty(relationData: Array, clickData: SampleStruct): void { + const propertyData = this.instructionData.find((subArr: any) => subArr.some((obj: SampleStruct) => obj.begin === clickData.begin)); + //获取非unknown数据 + const knownRelation = relationData.filter(relation => relation['name'].indexOf('unknown') < 0); + propertyData.forEach((property: any) => { + const relation = knownRelation.find(relation => relation['name'] === property['func_name']); + relation['instructions'] = Math.ceil(property['instructions']) || 1; + relation['hoverInstructions'] = Math.ceil(property['instructions']); + relation['cycles'] = Math.ceil(property['cycles']) || 1; + relation['hoverCycles'] = Math.ceil(property['cycles']); + this.maxDepth = Math.max(this.maxDepth, relation['depth']); + }) + //获取所有unknown数据 + let instructionSum = 0; + let cyclesSum = 0; + let hoverInstructionsSum= 0; + let hoverCyclesSum = 0; + const unknownRelation = relationData.filter(relation => relation['name'].indexOf('unknown') > -1); + if (unknownRelation.length > 0) { + unknownRelation.forEach(unknownItem => { + instructionSum = 0; + cyclesSum = 0; + hoverInstructionsSum = 0; + hoverCyclesSum = 0; + const children = unknownItem['children']; + for (const key in children) { + const it = relationData.find(relation => relation['name'] === key); + instructionSum += it['instructions'] ?? 0; + cyclesSum += it['cycles'] ?? 0; + hoverInstructionsSum += it['hoverInstructions'] ?? 0; + hoverCyclesSum += it['hoverCycles'] ?? 0; + } + unknownItem['instructions'] = instructionSum; + unknownItem['hoverInstructions'] = hoverInstructionsSum; + unknownItem['cycles'] = cyclesSum; + unknownItem['hoverCycles'] = hoverCyclesSum; + }) + } + } + + /** + * 监听页面size变化 + */ + listenerResize(): void { + new ResizeObserver(() => { + if (this.instructionEle!.getBoundingClientRect()) { + const box = this.instructionEle!.getBoundingClientRect(); + const element = this.parentElement!; + this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft; + this.startY = + box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop; + } + }).observe(this.parentElement!) + } + + +} diff --git a/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionDistributions.ts b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionDistributions.ts new file mode 100644 index 0000000000000000000000000000000000000000..949eb601fc4df883330e89dc38987a59517e3b49 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionDistributions.ts @@ -0,0 +1,400 @@ +/* + * 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'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import { debounce } from '../../../Utils'; +const paddingLeft = 100; +const paddingBottom = 15; +const xStep = 50; // x轴间距 +const barWidth = 2 // 柱子宽度 + +@element('tab-sample-instructions-distrubtions-chart') +export class TabPaneSampleInstructionDistributions extends BaseElement { + private instructionChartEle: HTMLCanvasElement | undefined | null; + private ctx: CanvasRenderingContext2D | undefined | null; + private onReadableData: Array = []; + private hintContent = ""; //悬浮框内容 + private floatHint!: HTMLDivElement | undefined | null; //悬浮框 + private canvasScrollTop = 0; // tab页上下滚动位置 + private isUpdateCanvas = false; + private cacheData: Array = []; + private canvasX = -1; // 鼠标当前所在画布x坐标 + private canvasY = -1; // 鼠标当前所在画布y坐标 + private startX = 0; // 画布相对于整个界面的x坐标 + private startY = 0; // 画布相对于整个界面的y坐标 + private hoverBar: any; + private isChecked: boolean = false; + private xCount = 0; //x轴刻度个数 + private xMaxValue = 0; //x轴上数据最大值 + private xSpacing = 50; //x轴间距 + private xAvg = 0; //根据xMaxValue进行划分 用于x轴上刻度显示 + private yAvg = 0; //根据yMaxValue进行划分 用于y轴上刻度显示 + + initHtml(): string { + return ` + + +
        + ` + } + + initElements(): void { + this.instructionChartEle = this.shadowRoot?.querySelector('#instruct-chart-canvas'); + this.ctx = this.instructionChartEle?.getContext('2d'); + this.floatHint = this.shadowRoot?.querySelector('#float_hint'); + } + + set data(SampleParam: SelectionParam) { + this.onReadableData = SampleParam.sampleData[0].property; + this.calInstructionRangeCount(this.isChecked); + } + + connectedCallback(): void { + super.connectedCallback(); + this.parentElement!.onscroll = () => { + this.canvasScrollTop = this.parentElement!.scrollTop; + this.hideTip(); + } + this.instructionChartEle!.onmousemove = (e): void => { + if (!this.isUpdateCanvas) { + this.updateCanvasCoord(); + } + this.canvasX = e.clientX - this.startX; + this.canvasY = e.clientY - this.startY + this.canvasScrollTop; + this.onMouseMove(); + } + this.instructionChartEle!.onmouseleave = () => { + this.hideTip(); + } + document.addEventListener('sample-popver-change', (e: any) => { + const select = Number(e.detail.select); + this.isChecked = Boolean(select); + this.calInstructionRangeCount(this.isChecked); + }) + this.listenerResize(); + } + + /** + * 更新canvas坐标 + */ + updateCanvasCoord(): void { + if (this.instructionChartEle instanceof HTMLCanvasElement) { + this.isUpdateCanvas = this.instructionChartEle.clientWidth !== 0; + if (this.instructionChartEle.getBoundingClientRect()) { + const box = this.instructionChartEle.getBoundingClientRect(); + const D = this.parentElement!; + this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft; + this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop; + } + } + } + + /** + * 获取鼠标悬停的函数 + * @param nodes + * @param canvasX + * @param canvasY + * @returns + */ + searchDataByCoord(nodes: any, canvasX: number, canvasY: number) { + for (let i = 0; i < nodes.length; i++) { + const element = nodes[i]; + if (this.isContains(element, canvasX, canvasY)) { + return element; + } + } + return null; + } + + /** + * 鼠标移动 + */ + onMouseMove(): void { + const lastNode = this.hoverBar; + //查找鼠标所在的node + const searchResult = this.searchDataByCoord(this.cacheData, this.canvasX, this.canvasY); + if (searchResult) { + this.hoverBar = searchResult; + //鼠标悬浮的node未改变则不需重新渲染文字 + if (searchResult !== lastNode) { + this.updateTipContent(); + } + this.showTip(); + } else { + this.hideTip(); + this.hoverBar = undefined; + } + } + + /** + * 隐藏悬浮框 + */ + hideTip(): void { + if (this.floatHint) { + this.floatHint.style.display = 'none'; + this.instructionChartEle!.style.cursor = 'default'; + } + } + + /** + * 显示悬浮框 + */ + showTip(): void { + this.floatHint!.innerHTML = this.hintContent; + this.floatHint!.style.display = 'block'; + this.instructionChartEle!.style.cursor = 'pointer'; + let x = this.canvasX; + let y = this.canvasY - this.canvasScrollTop; + //右边的函数悬浮框显示在左侧 + if (this.canvasX + this.floatHint!.clientWidth > (this.instructionChartEle!.clientWidth || 0)) { + x -= this.floatHint!.clientWidth - 1; + } else { + x += 20; + } + //最下边的函数悬浮框显示在上方 + y -= this.floatHint!.clientHeight - 1; + this.floatHint!.style.transform = `translate(${x}px, ${y}px)`; + } + + /** + * 更新悬浮框内容 + * @returns + */ + updateTipContent(): void { + const hoverNode = this.hoverBar; + if (!hoverNode) { + return; + } + const detail = hoverNode!; + this.hintContent = ` + ${detail.instruct}
        + ${parseFloat(detail.heightPer)} + `; + } + + /** + * 判断鼠标当前在那个函数上 + * @param frame + * @param x + * @param y + * @returns + */ + isContains(point: any, x: number, y: number): boolean { + return x >= point.x && x <= point.x + 2 && point.y <= y && y <= point.y + point.height; + } + + /** + * 统计onReadable数据各指令的个数 + * @param isCycles + */ + calInstructionRangeCount(isCycles: boolean) { + if (this.onReadableData.length === 0) return; + this.cacheData.length = 0; + const count = this.onReadableData.length; + let instructions = {}; + if (isCycles) { + instructions = this.onReadableData.reduce((pre: any, current: any) => { + (pre[`${Math.ceil(current.cycles)}`] = pre[`${Math.ceil(current.cycles)}`] || []).push(current); + return pre; + }, {}) + } else { + instructions = this.onReadableData.reduce((pre: any, current: any) => { + (pre[`${Math.ceil(current.instructions)}`] = pre[`${Math.ceil(current.instructions)}`] || []).push(current); + return pre; + }, {}) + } + this.ctx!.clearRect(0, 0, this.instructionChartEle!.width, this.instructionChartEle!.height); + this.instructionChartEle!.width = this.clientWidth; + + this.xMaxValue = Object.keys(instructions).map(i => Number(i)).reduce((pre, cur) => Math.max(pre, cur), 0) + 10; + const yMaxValue = Object.values(instructions).reduce((pre: number, cur: any) => Math.max(pre, Number((cur.length / count).toFixed(2))), 0); + this.yAvg = Number((yMaxValue / 5 * 1.5).toFixed(2)) || yMaxValue; + const height = this.instructionChartEle!.height; + const width = this.instructionChartEle!.width; + this.drawLineLabelMarkers(width, height, isCycles); + this.drawBar(instructions, height, count); + } + + /** + * 绘制柱状图 + * @param instructionData + * @param height + * @param count + */ + drawBar(instructionData: any, height: number, count: number) { + const yTotal = Number((this.yAvg * 5).toFixed(2)); + const interval = Math.floor((height - paddingBottom) / 6); + for (const x in instructionData) { + const xNum = Number(x); + const xPosition = xStep + (xNum / (this.xCount * this.xAvg)) * (this.xCount * this.xSpacing) - (barWidth / 2); + const yNum = Number((instructionData[x].length / count).toFixed(3)); + const percent = Number((yNum / yTotal).toFixed(2)); + const barHeight = (height - paddingBottom - interval) * percent; + this.drawRect(xPosition, height - paddingBottom - barHeight, barWidth, barHeight); + const existX = this.cacheData.find(i => i.instruct === x); + if (!existX) { + this.cacheData.push({ + instruct: x, + x: xPosition, + y: height - paddingBottom - barHeight, + height: barHeight, + heightPer: yNum + }) + } else { + existX.x = xPosition; + } + } + } + + /** + * 绘制x y轴 + * @param width + * @param height + * @param isCycles + */ + drawLineLabelMarkers(width: number, height: number, isCycles: boolean) { + this.ctx!.font = "12px Arial"; + this.ctx!.lineWidth = 1; + this.ctx!.fillStyle = "#333"; + this.ctx!.strokeStyle = "#ccc"; + if (isCycles) { + this.ctx!.fillText('cycles数(1e5)', width - paddingLeft + 10, height - paddingBottom); + } else { + this.ctx!.fillText('指令数(1e5)', width - paddingLeft + 10, height - paddingBottom); + } + + //绘制x轴 + this.drawLine(xStep, height - paddingBottom, width - paddingLeft, height - paddingBottom); + //绘制y轴 + this.drawLine(xStep, 5, xStep, height - paddingBottom); + //绘制标记 + this.drawMarkers(width, height) + } + + /** + * 绘制横线 + * @param x + * @param y + * @param X + * @param Y + */ + drawLine(x: number, y: number, X: number, Y: number) { + this.ctx!.beginPath; + this.ctx!.moveTo(x, y); + this.ctx!.lineTo(X, Y); + this.ctx!.stroke(); + this.ctx!.closePath(); + } + + /** + * 绘制x y轴刻度 + * @param width + * @param height + */ + drawMarkers(width: number, height: number) { + this.xCount = 0; + //绘制x轴锯齿 + let serrateX = 50; + let y = height - paddingBottom; + const clientWidth = width - paddingLeft - 50; + if (clientWidth > this.xMaxValue) { + this.xSpacing = Math.floor(clientWidth / 20) + this.xAvg = Math.ceil(this.xMaxValue / 20) + } else { + this.xSpacing = Math.floor(clientWidth / 10) + this.xAvg = Math.ceil(this.xMaxValue / 10) + } + while (serrateX <= clientWidth) { + this.xCount++; + serrateX += this.xSpacing; + this.drawLine(serrateX, y, serrateX, y + 5); + } + //绘制x轴刻度 + this.ctx!.textAlign = "center"; + for (let i = 0; i <= this.xCount; i++) { + const x = xStep + (i * this.xSpacing); + this.ctx!.fillText(`${i * this.xAvg}`, x, height); + } + //绘制y轴刻度 + this.ctx!.textAlign = "center"; + const yPadding = Math.floor((height - paddingBottom) / 6); + for (let i = 0; i < 6; i++) { + if (i === 0) { + this.ctx!.fillText(`${i}%`, 30, y); + } else { + const y = (height - paddingBottom) - (i * yPadding); + this.drawLine(xStep, y, width - paddingLeft, y); + this.ctx!.fillText(`${parseFloat((i * this.yAvg).toFixed(2))}%`, 30, y); + } + } + } + + + + /** + * 监听页面size变化 + */ + listenerResize(): void { + new ResizeObserver(debounce(() => { + if (this.instructionChartEle!.getBoundingClientRect()) { + const box = this.instructionChartEle!.getBoundingClientRect(); + const element = this.parentElement!; + this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft; + this.startY = + box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop; + this.calInstructionRangeCount(this.isChecked); + } + }, 100)).observe(this.parentElement!) + } + /** + * 绘制方块 + * @param x + * @param y + * @param X + * @param Y + */ + drawRect(x: number, y: number, X: number, Y: number) { + this.ctx!.beginPath(); + this.ctx!.rect(x, y, X, Y); + this.ctx!.fill(); + this.ctx!.closePath() + } +} diff --git a/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelection.ts b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelection.ts new file mode 100644 index 0000000000000000000000000000000000000000..ceff34046965f6fd455c3c366c50c312a009c680 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelection.ts @@ -0,0 +1,436 @@ +/* + * 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'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import { Rect, drawString } from '../../../../database/ui-worker/ProcedureWorkerCommon'; +import { ColorUtils } from '../../base/ColorUtils'; +import { SampleStruct } from '../../../../database/ui-worker/ProcedureWorkerSample'; +import { SpApplication } from '../../../../SpApplication'; + +const SAMPLE_STRUCT_HEIGHT = 30; +const Y_PADDING = 4; + +@element('tab-sample-instruction-selection') +export class TabPaneSampleInstructionSelection extends BaseElement { + private instructionEle: HTMLCanvasElement | undefined | null; + private ctx: CanvasRenderingContext2D| undefined | null; + private textEle: HTMLSpanElement | undefined | null; + private instructionArray: Array = []; + private instructionData: Array = []; + private isUpdateCanvas = false; + private canvasX = -1; // 鼠标当前所在画布x坐标 + private canvasY = -1; // 鼠标当前所在画布y坐标 + private startX = 0; // 画布相对于整个界面的x坐标 + private startY = 0; // 画布相对于整个界面的y坐标 + private hintContent = ""; //悬浮框内容 + private floatHint: HTMLDivElement | undefined | null; //悬浮框 + private canvasScrollTop = 0; // tab页上下滚动位置 + private hoverSampleStruct: any | undefined; + private isChecked: boolean = false; + private maxDepth = 0; + + initHtml(): string { + return ` + +
        + +
        +
        + 指令数数据流 +
        +
        + ` + } + + initElements(): void { + this.instructionEle = this.shadowRoot?.querySelector('#instruct-select-canvas'); + this.textEle = this.shadowRoot?.querySelector('.headline'); + this.ctx = this.instructionEle?.getContext('2d'); + this.floatHint = this.shadowRoot?.querySelector('#select_float_hint'); + } + + set data(SampleParam: SelectionParam) { + this.hoverSampleStruct = undefined; + this.instructionData = SampleParam.sampleData; + this.getAvgInstructionData(this.instructionData); + queueMicrotask(() => { + this.updateCanvas(this.clientWidth); + this.drawInstructionData(this.isChecked); + }) + } + + connectedCallback(): void { + super.connectedCallback(); + this.parentElement!.onscroll = () => { + this.canvasScrollTop = this.parentElement!.scrollTop; + this.hideTip(); + } + this.instructionEle!.onmousemove = (e): void => { + if (!this.isUpdateCanvas) { + this.updateCanvasCoord(); + } + this.canvasX = e.clientX - this.startX; + this.canvasY = e.clientY - this.startY + this.canvasScrollTop; + this.onMouseMove(); + } + this.instructionEle!.onmouseleave = () => { + this.hideTip(); + } + document.addEventListener('sample-popver-change', (e: any) => { + const select = Number(e.detail.select); + this.hoverSampleStruct = undefined; + this.isChecked = Boolean(select); + this.drawInstructionData(this.isChecked); + }) + this.listenerResize(); + } + + /** + * 初始化窗口大小 + * @param newWidth + */ + updateCanvas(newWidth?: number): void { + if (this.instructionEle instanceof HTMLCanvasElement) { + this.instructionEle.style.width = `${100}%`; + this.instructionEle.style.height = `${(this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT}px`; + if (this.instructionEle.clientWidth === 0 && newWidth) { + this.instructionEle.width = newWidth; + } else { + this.instructionEle.width = this.instructionEle.clientWidth; + } + this.instructionEle.height = (this.maxDepth + 1) * SAMPLE_STRUCT_HEIGHT; + } + } + + /** + * 鼠标移动 + */ + onMouseMove(): void { + const lastNode = this.hoverSampleStruct; + //查找鼠标所在的node + const searchResult = this.searchDataByCoord(this.instructionArray!, this.canvasX, this.canvasY); + if (searchResult) { + this.hoverSampleStruct = searchResult; + //鼠标悬浮的node未改变则不需重新渲染文字 + if (searchResult !== lastNode) { + this.updateTipContent(); + this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height); + this.ctx!.beginPath(); + for (const key in this.instructionArray) { + for (let i = 0; i < this.instructionArray[key].length; i++) { + const cur = this.instructionArray[key][i]; + this.draw(this.ctx!, cur); + } + } + this.ctx!.closePath(); + } + this.showTip(); + } else { + this.hideTip(); + this.hoverSampleStruct = undefined; + } + } + + /** + * 隐藏悬浮框 + */ + hideTip(): void { + if (this.floatHint) { + this.floatHint.style.display = 'none'; + } + } + + /** + * 显示悬浮框 + */ + showTip(): void { + this.floatHint!.innerHTML = this.hintContent; + this.floatHint!.style.display = 'block'; + let x = this.canvasX; + let y = this.canvasY - this.canvasScrollTop; + //右边的函数悬浮框显示在左侧 + if (this.canvasX + this.floatHint!.clientWidth > (this.instructionEle!.clientWidth) || 0) { + x -= this.floatHint!.clientWidth - 1; + } else { + x += 30; + } + //最下边的函数悬浮框显示在上方 + y -= this.floatHint!.clientHeight - 1; + this.floatHint!.style.transform = `translate(${x}px, ${y}px)`; + } + + + /** + * 更新悬浮框内容 + * @returns + */ + updateTipContent(): void { + const hoverNode = this.hoverSampleStruct; + if (!hoverNode) { + return; + } + this.hintContent = `${hoverNode.detail}(${hoverNode.name})
        + ${ this.isChecked ? hoverNode.hoverCycles : hoverNode.hoverInstructions} + + `; + } + + /** + * 设置绘制所需的坐标及宽高 + * @param sampleNode + * @param instructions + * @param x + */ + setSampleFrame(sampleNode: SampleStruct, instructions: number, x: number): void { + if (!sampleNode.frame) { + sampleNode.frame! = new Rect(0, 0, 0, 0); + } + sampleNode.frame!.x = x; + sampleNode.frame!.y = sampleNode.depth! * SAMPLE_STRUCT_HEIGHT; + sampleNode.frame!.width = instructions; + sampleNode.frame!.height = SAMPLE_STRUCT_HEIGHT; + } + + /** + * 判断鼠标当前在那个函数上 + * @param frame + * @param x + * @param y + * @returns + */ + isContains(frame: any, x: number, y: number): boolean { + return x >= frame.x && x <= frame.x + frame.width && frame.y <= y && y <= frame.y + frame.height; + } + + /** + * 绘制 + * @param isCycles + */ + drawInstructionData(isCycles: boolean): void { + this.isChecked ? this.textEle!.innerText = "cycles数据流" : this.textEle!.innerText = "instructions数据流"; + const clientWidth = this.instructionEle!.width; + //将数据转换为层级结构 + const instructionArray = this.instructionData + .filter((item: any) => isCycles ? item.cycles : item.instructions) + .reduce((pre: any, cur: any) => { + (pre[`${cur.depth}`] = pre[`${cur.depth}`] || []).push(cur); + return pre; + }, {}); + for (const key in instructionArray) { + for (let i = 0; i < instructionArray[key].length; i++) { + const cur = instructionArray[key][i]; + //第一级节点直接将宽度设置为容器宽度 + if (key === '0') { + this.setSampleFrame(cur, clientWidth, 0) + } else { + //获取上一层级节点数据 + const preList = instructionArray[Number(key) - 1]; + //获取当前节点的父节点 + const parentNode = preList.find((node: SampleStruct) => node.name === cur.parentName); + //计算当前节点下指令数之和 用于计算每个节点所占的宽度比 + const total = isCycles ? instructionArray[key].filter((i: any) => i.parentName === parentNode.name).reduce((pre: number, cur: SampleStruct) => pre + cur.cycles!, 0) : + instructionArray[key].filter((i: any) => i.parentName === parentNode.name).reduce((pre: number, cur: SampleStruct) => pre + cur.instructions!, 0); + const curWidth = isCycles ? cur.cycles : cur.instructions; + const width = Math.floor(parentNode.frame.width * (curWidth / total)); + if (i === 0) { + this.setSampleFrame(cur, width, parentNode.frame.x); + } else { + const preNode = instructionArray[key][i - 1]; + preNode.parentName === parentNode.name ? + this.setSampleFrame(cur, width, preNode.frame.x + preNode.frame.width) : + this.setSampleFrame(cur, width, parentNode.frame.x); + } + } + } + } + this.instructionArray = instructionArray; + + this.ctx!.clearRect(0, 0, this.instructionEle!.width, this.instructionEle!.height); + this.ctx!.beginPath(); + for (const key in instructionArray) { + for (let i = 0; i < instructionArray[key].length; i++) { + const cur = instructionArray[key][i]; + this.draw(this.ctx!, cur) + } + } + this.ctx!.closePath() + } + + /** + * 更新canvas坐标 + */ + updateCanvasCoord(): void { + if (this.instructionEle instanceof HTMLCanvasElement) { + this.isUpdateCanvas = this.instructionEle.clientWidth !== 0; + if (this.instructionEle.getBoundingClientRect()) { + const box = this.instructionEle.getBoundingClientRect(); + const D = document.documentElement; + this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft; + this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop; + } + } + } + + /** + * 获取鼠标悬停的函数 + * @param nodes + * @param canvasX + * @param canvasY + * @returns + */ + searchDataByCoord(nodes: any, canvasX: number, canvasY: number) { + for (const key in nodes) { + for (let i = 0; i < nodes[key].length; i++) { + const cur = nodes[key][i]; + if (this.isContains(cur.frame, canvasX, canvasY)) { + return cur; + } + } + } + return null; + } + + /** + * 绘制方法 + * @param ctx + * @param data + */ + draw(ctx: CanvasRenderingContext2D, data: SampleStruct) { + let spApplication = document.getElementsByTagName('sp-application')[0]; + if (data.frame) { + ctx.globalAlpha = 1; + ctx.fillStyle = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)]; + const textColor = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth!, ColorUtils.FUNC_COLOR.length)]; + ctx.lineWidth = 0.4; + if (this.hoverSampleStruct && data.name == this.hoverSampleStruct.name) { + if (spApplication.dark) { + ctx.strokeStyle = '#fff'; + } else { + ctx.strokeStyle = '#000'; + } + } else { + if (spApplication.dark) { + ctx.strokeStyle = '#000'; + } else { + ctx.strokeStyle = '#fff'; + } + } + ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING); + ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING); + ctx.fillStyle = ColorUtils.funcTextColor(textColor); + drawString(ctx, `${data.detail}(${data.name})`, 5, data.frame, data); + } + } + + /** + * 统计框选指令数的平均值 + * @param instructionData + * @returns + */ + getAvgInstructionData(instructionData: Array) { + const length = instructionData[0].property.length; + const knowData = instructionData.filter(instruction => instruction["name"].indexOf("unknown") < 0); + knowData.forEach(instruction => { + if (instruction.property.length > 0) { + const totalInstruction = instruction["property"].reduce((pre: number, cur: SampleStruct) => pre + Math.ceil(cur["instructions"]!), 0); + const totalCycles = instruction["property"].reduce((pre: number, cur: SampleStruct) => pre + Math.ceil(cur["cycles"]!), 0); + instruction["instructions"] = Math.ceil(totalInstruction / length) || 1; + instruction["cycles"] = Math.ceil(totalCycles / length) || 1; + instruction['hoverInstructions'] = Math.ceil(totalInstruction / length); + instruction['hoverCycles'] = Math.ceil(totalCycles / length); + this.maxDepth = Math.max(this.maxDepth, instruction["depth"]); + } + }) + const unknownData = instructionData.filter(instruction => instruction["name"].indexOf("unknown") > -1); + let instructionSum = 0; + let cyclesSum = 0; + let hoverInstructionsSum= 0; + let hoverCyclesSum = 0; + unknownData.forEach(unknown => { + instructionSum = 0; + cyclesSum = 0; + hoverInstructionsSum= 0; + hoverCyclesSum = 0; + for (const key in unknown["children"]) { + const child = instructionData.find(instruction => instruction["name"] === key); + instructionSum += child['instructions'] ?? 0; + cyclesSum += child["cycles"] ?? 0; + hoverInstructionsSum += child['hoverInstructions'] ?? 0; + hoverCyclesSum += child['hoverCycles'] ?? 0; + } + unknown["instructions"] = instructionSum; + unknown["cycles"] = cyclesSum; + unknown['hoverInstructions'] = hoverInstructionsSum; + unknown['hoverCycles'] = hoverCyclesSum; + }) + return instructionData; + } + + /** + * 监听页面size变化 + */ + listenerResize(): void { + new ResizeObserver(() => { + if (this.instructionEle!.getBoundingClientRect()) { + const box = this.instructionEle!.getBoundingClientRect(); + const element = document.documentElement; + this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft; + this.startY = + box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop; + } + }).observe(this.parentElement!) + } + + +} diff --git a/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.ts b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.ts new file mode 100644 index 0000000000000000000000000000000000000000..b83bce8d44572411101ad5cfcea5228f8fe328e3 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.ts @@ -0,0 +1,381 @@ +/* + * 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'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import { debounce } from '../../../Utils'; + +const paddingLeft = 100; +const paddingBottom = 15; +const xStart = 50; // x轴起始位置 +const barWidth = 2 // 柱子宽度 +const millisecond = 1_000_000; + +@element('tab-sample-instructions-totaltime-selection') +export class TabPaneSampleInstructionTotalTime extends BaseElement { + private instructionChartEle: HTMLCanvasElement | undefined | null; + private ctx: CanvasRenderingContext2D| undefined | null; + private cacheData: Array = []; + private canvasX = -1; // 鼠标当前所在画布x坐标 + private canvasY = -1; // 鼠标当前所在画布y坐标 + private startX = 0; // 画布相对于整个界面的x坐标 + private startY = 0; // 画布相对于整个界面的y坐标 + private hoverBar: any; + private onReadableData: Array = []; + private hintContent = ""; //悬浮框内容 + private floatHint: HTMLDivElement | undefined | null; //悬浮框 + private canvasScrollTop = 0; // tab页上下滚动位置 + private isUpdateCanvas = false; + private xCount = 0; //x轴刻度个数 + private xMaxValue = 0; //x轴上数据最大值 + private xSpacing = 50; //x轴间距 + private xAvg = 0; //根据xMaxValue进行划分 用于x轴上刻度显示 + private yAvg = 0; //根据yMaxValue进行划分 用于y轴上刻度显示 + + initHtml(): string { + return ` + + +
        + ` + } + + initElements(): void { + this.instructionChartEle = this.shadowRoot?.querySelector('#instruct-chart-canvas'); + this.ctx = this.instructionChartEle?.getContext('2d'); + this.floatHint = this.shadowRoot?.querySelector('#float_hint'); + } + + set data(SampleParam: SelectionParam) { + this.onReadableData = SampleParam.sampleData[0].property; + this.calInstructionRangeCount(); + } + + connectedCallback(): void { + super.connectedCallback(); + this.parentElement!.onscroll = () => { + this.canvasScrollTop = this.parentElement!.scrollTop; + this.hideTip(); + } + this.instructionChartEle!.onmousemove = (e): void => { + if (!this.isUpdateCanvas) { + this.updateCanvasCoord(); + } + this.canvasX = e.clientX - this.startX; + this.canvasY = e.clientY - this.startY + this.canvasScrollTop; + this.onMouseMove(); + } + this.instructionChartEle!.onmouseleave = () => { + this.hideTip(); + } + this.listenerResize(); + } + + /** + * 更新canvas坐标 + */ + updateCanvasCoord(): void { + if (this.instructionChartEle instanceof HTMLCanvasElement) { + this.isUpdateCanvas = this.instructionChartEle.clientWidth !== 0; + if (this.instructionChartEle.getBoundingClientRect()) { + const box = this.instructionChartEle.getBoundingClientRect(); + const D = this.parentElement!; + this.startX = box.left + Math.max(D.scrollLeft, document.body.scrollLeft) - D.clientLeft; + this.startY = box.top + Math.max(D.scrollTop, document.body.scrollTop) - D.clientTop + this.canvasScrollTop; + } + } + } + + /** + * 获取鼠标悬停的函数 + * @param nodes + * @param canvasX + * @param canvasY + * @returns + */ + searchDataByCoord(nodes: any, canvasX: number, canvasY: number) { + for (let i = 0; i < nodes.length; i++) { + const element = nodes[i]; + if (this.isContains(element, canvasX, canvasY)) { + return element; + } + } + return null; + } + + /** + * 鼠标移动 + */ + onMouseMove(): void { + const lastNode = this.hoverBar; + //查找鼠标所在的node + const searchResult = this.searchDataByCoord(this.cacheData, this.canvasX, this.canvasY); + if (searchResult) { + this.hoverBar = searchResult; + //鼠标悬浮的node未改变则不需重新渲染文字 + if (searchResult !== lastNode) { + this.updateTipContent(); + } + this.showTip(); + } else { + this.hideTip(); + this.hoverBar = undefined; + } + } + + /** + * 隐藏悬浮框 + */ + hideTip(): void { + if (this.floatHint) { + this.floatHint.style.display = 'none'; + this.instructionChartEle!.style.cursor = 'default'; + } + } + + /** + * 显示悬浮框 + */ + showTip(): void { + this.floatHint!.innerHTML = this.hintContent; + this.floatHint!.style.display = 'block'; + this.instructionChartEle!.style.cursor = 'pointer'; + let x = this.canvasX; + let y = this.canvasY - this.canvasScrollTop; + //右边的函数悬浮框显示在左侧 + if (this.canvasX + this.floatHint!.clientWidth > (this.instructionChartEle!.clientWidth || 0)) { + x -= this.floatHint!.clientWidth - 1; + } else { + x += 30; + } + //最下边的函数悬浮框显示在上方 + y -= this.floatHint!.clientHeight - 1; + this.floatHint!.style.transform = `translate(${x}px, ${y}px)`; + } + + /** + * 更新悬浮框内容 + */ + updateTipContent(): void { + const hoverNode = this.hoverBar; + if (!hoverNode) { + return; + } + const detail = hoverNode!; + this.hintContent = ` + ${detail.instruct}
        + ${parseFloat(detail.heightPer)} + `; + } + + /** + * 判断鼠标当前在那个函数上 + * @param frame + * @param x + * @param y + * @returns + */ + isContains(point: any, x: number, y: number): boolean { + return x >= point.x && x <= point.x + 2 && point.y <= y && y <= point.y + point.height; + } + + /** + * 统计onReadable数据各指令数个数 + */ + calInstructionRangeCount() { + if (this.onReadableData.length === 0) return; + this.cacheData.length = 0; + const count = this.onReadableData.length; + const onReadableData = this.onReadableData; + const instructionArray = onReadableData.reduce((pre: any, current: any) => { + const dur = ((current.end - current.begin) / millisecond).toFixed(1); + (pre[dur] = pre[dur] || []).push(current); + return pre; + }, {}); + this.ctx!.clearRect(0, 0, this.instructionChartEle!.width, this.instructionChartEle!.height); + this.instructionChartEle!.width = this.clientWidth; + + this.xMaxValue = Object.keys(instructionArray).map(i => Number(i)).reduce((pre, cur) => Math.max(pre, cur), 0) + 5; + const yMaxValue = Object.values(instructionArray).reduce((pre: number, cur: any) => Math.max(pre, Number((cur.length / count).toFixed(2))), 0); + this.yAvg = Number(((yMaxValue / 5) * 1.5).toFixed(2)); + const height = this.instructionChartEle!.height; + const width = this.instructionChartEle!.width; + this.drawLineLabelMarkers(width, height); + this.drawBar(instructionArray, height, count); + } + + /** + * 绘制柱状图 + * @param instructionData + * @param height + * @param count + */ + drawBar(instructionData: any, height: number, count: number) { + const yTotal = Number((this.yAvg * 5).toFixed(2)); + const interval = Math.floor((height - paddingBottom) / 6); + for (const x in instructionData) { + const xNum = Number(x); + const xPosition = xStart + ( xNum / (this.xCount * this.xAvg) ) * (this.xCount * this.xSpacing) - (barWidth / 2); + const yNum = Number((instructionData[x].length / count).toFixed(3)); + const percent = Number((yNum / yTotal).toFixed(2)); + const barHeight = (height - paddingBottom - interval) * percent; + this.drawRect(xPosition, height - paddingBottom - barHeight, barWidth, barHeight); + const existX = this.cacheData.find(i => i.instruct === x); + if (!existX) { + this.cacheData.push({ + instruct: x, + x: xPosition, + y: height - paddingBottom - barHeight, + height: barHeight, + heightPer: yNum + }) + } else { + existX.x = xPosition; + } + } + } + + /** + * 绘制x y轴 + * @param width + * @param height + */ + drawLineLabelMarkers(width: number, height: number) { + this.ctx!.font = "12px Arial"; + this.ctx!.lineWidth = 1; + this.ctx!.fillStyle = "#333"; + this.ctx!.strokeStyle = "#ccc"; + + this.ctx!.fillText('时长 / ms', width - paddingLeft, height - paddingBottom); + + //绘制x轴 + this.drawLine(xStart, height - paddingBottom, width - paddingLeft, height - paddingBottom); + //绘制y轴 + this.drawLine(xStart, 5, xStart, height - paddingBottom); + //绘制标记 + this.drawMarkers(width, height) + } + + /** + * 绘制横线 + * @param x + * @param y + * @param X + * @param Y + */ + drawLine(x:number, y: number, X: number, Y: number) { + this.ctx!.beginPath; + this.ctx!.moveTo(x, y); + this.ctx!.lineTo(X, Y); + this.ctx!.stroke(); + this.ctx!.closePath(); + } + + /** + * 绘制x y轴刻度 + * @param width + * @param height + */ + drawMarkers(width: number, height: number) { + this.xCount = 0; + //绘制x轴锯齿 + let serrateX = 50; + let yHeight = height - paddingBottom; + const clientWidth = width - paddingLeft - 50; + if (clientWidth > this.xMaxValue) { + this.xSpacing = Math.floor(clientWidth / 20) + this.xAvg = Math.ceil(this.xMaxValue / 20) + } else { + this.xSpacing = Math.floor(clientWidth / 10) + this.xAvg = Math.ceil(this.xMaxValue / 10) + } + while (serrateX <= clientWidth) { + this.xCount++; + serrateX += this.xSpacing; + this.drawLine(serrateX, yHeight, serrateX, yHeight + 5); + } + //绘制x轴刻度 + this.ctx!.textAlign = "center"; + for (let i = 0; i <= this.xCount; i++) { + const x = xStart + (i * this.xSpacing); + this.ctx!.fillText(`${i * this.xAvg}`, x, height); + } + //绘制y轴刻度 + this.ctx!.textAlign = "center"; + const yPadding = Math.floor((height - paddingBottom) / 6); + for (let i = 0; i < 6; i++) { + const y = (height - paddingBottom) - (i * yPadding); + if (i === 0) { + this.ctx!.fillText(`${i}%`, 30, y); + } else { + this.drawLine(xStart, y, width - paddingLeft, y); + this.ctx!.fillText(`${parseFloat((i * this.yAvg).toFixed(2))}%`, 30, y); + } + } + } + + /** + * 监听页面size变化 + */ + listenerResize(): void { + new ResizeObserver(debounce(() => { + if (this.instructionChartEle!.getBoundingClientRect()) { + const box = this.instructionChartEle!.getBoundingClientRect(); + const element = this.parentElement!; + this.startX = box.left + Math.max(element.scrollLeft, document.body.scrollLeft) - element.clientLeft; + this.startY = + box.top + Math.max(element.scrollTop, document.body.scrollTop) - element.clientTop + this.canvasScrollTop; + this.calInstructionRangeCount(); + } + }, 100)).observe(this.parentElement!) + } + /** + * 绘制方块 + * @param x + * @param y + * @param X + * @param Y + */ + drawRect(x: number, y: number, X: number, Y: number) { + this.ctx!.beginPath(); + this.ctx!.rect(x, y, X, Y); + this.ctx!.fill(); + this.ctx!.closePath() + } +} diff --git a/ide/src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.ts b/ide/src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac3af74a4e15bd933c8b7fe711f9624f6f3943b3 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.ts @@ -0,0 +1,752 @@ +/* + * Copyright (C) 2023 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'; +import { LitButton } from '../../../../../base-ui/button/LitButton'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { SelectionData, SelectionParam } from '../../../../bean/BoxSelection'; +import { querySchedThreadStates, querySingleCutData, queryLoopCutData } from '../../../../database/sql/ProcessThread.sql'; +import { Utils } from '../../base/Utils'; +import { resizeObserver } from '../SheetUtils'; +import { LitChartColumn } from '../../../../../base-ui/chart/column/LitChartColumn'; +import { SpSegmentationChart } from '../../../../../trace/component/chart/SpSegmentationChart' +import { + type TreeSwitchConfig, + HistogramSourceConfig, + ThreadInitConfig, + CutDataObjConfig, + SchedSwitchCountBean, +} from '../../../../bean/SchedSwitchStruct'; +const UNIT: number = 1000000.0; +const NUM_DIGITS: number = 3; +const SINGLE_BUTTON_TEXT: string = 'Single'; +const LOOP_BUTTON_TEXT: string = 'Loop'; +@element('tabpane-schedswitch') +export class TabPaneSchedSwitch extends BaseElement { + private schedSwitchTbl: LitTable | null | undefined; + private threadQueryDIV: Element | null | undefined; + private rightDIV: HTMLDivElement | null | undefined; + private threadIdInput: HTMLInputElement | null | undefined; + private funcNameInput: HTMLInputElement | null | undefined; + private singleBtn: LitButton | null | undefined; + private loopBtn: LitButton | null | undefined; + private cycleALeftInput: HTMLInputElement | null | undefined; + private cycleARightInput: HTMLInputElement | null | undefined; + private cycleBLeftInput: HTMLInputElement | null | undefined; + private cycleBRightInput: HTMLInputElement | null | undefined; + private queryButton: LitButton | null | undefined; + private selectionParam: SelectionParam | undefined; + private canvansName: HTMLDivElement | null | undefined; + private threadMap: Map> = new Map>(); + private chartTotal: LitChartColumn | null | undefined; + private histogramSource: Array = []; + private rangeA: HistogramSourceConfig = new HistogramSourceConfig(); + private rangeB: HistogramSourceConfig = new HistogramSourceConfig(); + private rangeTotal: HistogramSourceConfig = new HistogramSourceConfig(); + private getThreadChildren: Array = []; + private hasThreadStatesData: boolean = false; + private clickThreadName: string = ''; + + set data(threadStatesParam: SelectionParam) { + if (this.selectionParam === threadStatesParam) {return;}; + let tabpaneSwitch = this.parentElement as HTMLElement; + tabpaneSwitch.style.overflow = 'hidden'; + this.schedSwitchTbl!.recycleDataSource = []; + this.queryButton!.style.pointerEvents = 'none'; + this.schedSwitchTbl!.loading = false; + this.hasThreadStatesData = false; + // @ts-ignore + this.schedSwitchTbl!.value = []; + this.funcNameInput!.style.border = '1px solid rgb(151,151,151)'; + this.threadIdInput!.style.border = '1px solid rgb(151,151,151)'; + SpSegmentationChart.setChartData('SCHED-SWITCH', []); + SpSegmentationChart.tabHover('SCHED-SWITCH', false, -1); + this.canvansName!.textContent = 'sched switch平均分布图'; + this.selectionParam = threadStatesParam; + this.canQueryButtonClick(false); + this.isSingleBtnColor(false); + this.isLoopBtnColor(false); + this.isCanvansHidden(true); + //当Tab页发生变化时,ResizeObserver会被通知并且检测到Tab页布局和大小的变化,可以按需求调整页面UI + new ResizeObserver((entries) => { + // @ts-ignore + let lastHeight = this.schedSwitchTbl!.tableElement!.offsetHeight; + //控制右侧区域高度实时变化与左侧区域Div保持一致,避免滚动滚动条时出现空白的情况 + this.rightDIV!.style.height = String(lastHeight) + 'px'; + }).observe(tabpaneSwitch); + } + initElements(): void { + this.schedSwitchTbl = this.shadowRoot!.querySelector('#tb-running'); + this.threadQueryDIV = this.shadowRoot?.querySelector('#data-cut'); + this.rightDIV = this.shadowRoot?.querySelector('#right'); + this.canvansName = this.shadowRoot!.querySelector('.sched-subheading'); + this.chartTotal = this.shadowRoot!.querySelector('#chart_total'); + this.threadIdInput = this.shadowRoot?.getElementById('cut-threadid') as HTMLInputElement; + this.funcNameInput = this.shadowRoot?.querySelector('#cut-thread-func') as HTMLInputElement; + this.singleBtn = this.shadowRoot?.querySelector('.single-btn'); + this.loopBtn = this.shadowRoot?.querySelector('.loop-btn'); + this.cycleALeftInput = this.shadowRoot?.getElementById('leftA') as HTMLInputElement; + this.cycleARightInput = this.shadowRoot?.getElementById('rightA') as HTMLInputElement; + this.cycleBLeftInput = this.shadowRoot?.getElementById('leftB') as HTMLInputElement; + this.cycleBRightInput = this.shadowRoot?.getElementById('rightB') as HTMLInputElement; + this.queryButton = this.shadowRoot?.querySelector('.query-btn'); + this.singleBtn?.addEventListener('click', (e) => { this.queryCutInfoFn(this.singleBtn!.innerHTML); }); + this.loopBtn?.addEventListener('click', (e) => { this.queryCutInfoFn(this.loopBtn!.innerHTML); }); + this.queryButton!.addEventListener('click', (e) => { this.queryCycleRangeData(); }); + this.schedSwitchTbl!.addEventListener('row-click', (evt) => { this.clickTreeRowEvent(evt); }); + this.listenInputEvent(); + } + //监听周期A、B对应输入框的值 + listenInputEvent(): void { + this.cycleALeftInput!.addEventListener('input', (evt) => { + this.checkInputRangeFn( + this.cycleALeftInput, + this.cycleARightInput, + this.cycleBLeftInput, + this.cycleBRightInput, + this.cycleALeftInput!.value, + this.cycleARightInput!.value + ); + }); + this.cycleARightInput!.addEventListener('input', (evt) => { + this.checkInputRangeFn( + this.cycleARightInput, + this.cycleALeftInput, + this.cycleBLeftInput, + this.cycleBRightInput, + this.cycleALeftInput!.value, + this.cycleARightInput!.value + ); + }); + this.cycleBLeftInput!.addEventListener('input', (evt) => { + this.checkInputRangeFn( + this.cycleBLeftInput, + this.cycleBRightInput, + this.cycleALeftInput, + this.cycleARightInput, + this.cycleBLeftInput!.value, + this.cycleBRightInput!.value + ); + }); + this.cycleBRightInput!.addEventListener('input', (evt) => { + this.checkInputRangeFn( + this.cycleBRightInput, + this.cycleBLeftInput, + this.cycleALeftInput, + this.cycleARightInput, + this.cycleBLeftInput!.value, + this.cycleBRightInput!.value + ); + }); + } + //校验周期A、B对应输入框的值是否符合要求,不符合时给出相应提示 + checkInputRangeFn( + firstInput: HTMLInputElement | null | undefined, + secondInput: HTMLInputElement | null | undefined, + thirdInput: HTMLInputElement | null | undefined, + fourInput: HTMLInputElement | null | undefined, + lVal: string, + rVal: string + ): void { + let leftVal: number = Number(lVal); + let rightVal: number = Number(rVal); + if (firstInput!.value !== '' && secondInput!.value !== '') { + if (firstInput!.value !== '' && secondInput!.value !== '') { + if (leftVal >= rightVal) { + firstInput!.style.color = 'red'; + this.queryButton!.style.pointerEvents = 'none'; + this.canQueryButtonClick(false); + } else if (leftVal < rightVal) { + firstInput!.style.color = 'black'; + secondInput!.style.color = 'black'; + this.queryButton!.style.pointerEvents = 'auto'; + this.canQueryButtonClick(true); + }; + }; + } else if ( + (firstInput!.value === '' && secondInput!.value !== '') || + (firstInput!.value !== '' && secondInput!.value === '') + ) { + this.queryButton!.style.pointerEvents = 'none'; + this.canQueryButtonClick(false); + } else if ( + firstInput!.value === '' && + secondInput!.value === '' && + thirdInput!.value !== '' && + fourInput!.value !== '' + ) { + this.queryButton!.style.pointerEvents = 'auto'; + this.canQueryButtonClick(true); + }; + if ( + (thirdInput!.value === '' && fourInput!.value !== '') || + (thirdInput!.value !== '' && fourInput!.value === '') + ) { + this.queryButton!.style.pointerEvents = 'none'; + this.canQueryButtonClick(false); + }; + } + //点击树节点不同层级触发相应的功能 + clickTreeRowEvent(evt: Event): void { + //@ts-ignore + let data = evt.detail.data; + if (data.level === 'process') { + //点击进程canvans相关内容隐藏 + this.isCanvansHidden(true); + SpSegmentationChart.setChartData('SCHED-SWITCH', []); + SpSegmentationChart.tabHover('SCHED-SWITCH', false, -1); + this.clickThreadName = data.nodeFlag; + } else if (data.level === 'thread') { + //点击线程绘制canvans,相同线程canvans不会重新绘制,切换线程时清空周期输入框等相关内容 + if (this.clickThreadName !== data.nodeFlag) { + this.cycleALeftInput!.value = ''; + this.cycleARightInput!.value = ''; + this.cycleBLeftInput!.value = ''; + this.cycleBRightInput!.value = ''; + this.histogramSource = []; + SpSegmentationChart.tabHover('SCHED-SWITCH', false, -1);//清空上一次的泳道高亮 + this.getThreadChildren = data.children; + this.queryButton!.style.pointerEvents = 'none'; + this.isCanvansHidden(false); + this.canQueryButtonClick(false); + this.clickThreadName = data.nodeFlag; + //绘制canvans柱状图需要的数据 + this.rangeTotal = { + value: data.value, + cycleNum: data.children.length, + average: data.children.length ? Math.ceil(data.value / data.children.length) : 0, + size: 'Total', + isHover: false, + color: '#2f72f8', + }; + this.histogramSource.push(this.rangeTotal); + //点击树节点时高亮 + data.isSelected = true; + this.schedSwitchTbl!.clearAllSelection(data); + this.schedSwitchTbl!.setCurrentSelection(data); + this.drawHistogramChart(); + }; + //点击线程绘制对应泳道图 + SpSegmentationChart.setChartData('SCHED-SWITCH', data.children); + } else if (data.level === 'cycle') { + if (this.clickThreadName === data.nodeFlag) { + data.isSelected = true; + this.schedSwitchTbl!.clearAllSelection(data); + this.schedSwitchTbl!.setCurrentSelection(data); + SpSegmentationChart.tabHover('SCHED-SWITCH', true, data!.cycle); + }; + }; + } + //点击single或loop按钮时触发 + async queryCutInfoFn(btnHtml: string): Promise { + let funcData: Array = []; + let threadId: string = this.threadIdInput!.value.trim(); + let threadFunName: string = this.funcNameInput!.value.trim(); + let leftStartNs: number = this.selectionParam!.leftNs + this.selectionParam!.recordStartNs; + let rightEndNs: number = this.selectionParam!.rightNs + this.selectionParam!.recordStartNs; + if (threadId !== '' && threadFunName !== '') { + this.threadIdInput!.style.border = '1px solid rgb(151,151,151)'; + this.funcNameInput!.style.border = '1px solid rgb(151,151,151)'; + //@ts-ignore + this.schedSwitchTbl!.value = []; + this.isCanvansHidden(true); + this.schedSwitchTbl!.loading = true; + this.clickThreadName = ''; + SpSegmentationChart.setChartData('SCHED-SWITCH', []); + SpSegmentationChart.tabHover('SCHED-SWITCH', false, -1); + //首次点击single或loop时去查询数据 + if (!this.hasThreadStatesData) { this.initThreadStateData(this.selectionParam); }; + if (btnHtml === SINGLE_BUTTON_TEXT) { + this.isSingleBtnColor(true); + this.isLoopBtnColor(false); + funcData = await querySingleCutData(threadFunName, threadId, leftStartNs, rightEndNs); + }; + if (btnHtml === LOOP_BUTTON_TEXT) { + this.isSingleBtnColor(false); + this.isLoopBtnColor(true); + funcData = await queryLoopCutData(threadFunName, threadId, leftStartNs, rightEndNs); + }; + //获取到线程数据和方法数据,处理周期 + this.handleCycleLogic(funcData, btnHtml); + } else { + if (threadId === '') { + this.threadIdInput!.style.border = '2px solid rgb(255,0,0)'; + this.threadIdInput!.setAttribute('placeholder', 'Please input thread id'); + } else { + this.threadIdInput!.style.border = '1px solid rgb(151,151,151)'; + }; + if (threadFunName === '') { + this.funcNameInput!.style.border = '2px solid rgb(255,0,0)'; + this.funcNameInput!.setAttribute('placeholder', 'Please input function name'); + } else { + this.funcNameInput!.style.border = '1px solid rgb(151,151,151)'; + }; + }; + } + + //获取每次被框选线程对应的state数据 + async initThreadStateData(threadParam: SelectionParam | null | undefined): Promise { + let threadSourceData: Array = []; + let leftStartNs: number = threadParam!.leftNs + threadParam!.recordStartNs; + let rightEndNs: number = threadParam!.rightNs + threadParam!.recordStartNs; + let processIds: Array = [...new Set(threadParam!.processIds)]; + let res: Array = await querySchedThreadStates(processIds, threadParam!.threadIds, leftStartNs, rightEndNs); + threadSourceData = JSON.parse(JSON.stringify(res)); + //每次新款选线程时清空Map对象 + this.threadMap.clear(); + //state数据转换成以pid+tid为key值的Map对象 + for (let i = 0; i < threadSourceData.length; i++) { + let stateItem = threadSourceData[i]; + if (this.threadMap.has(`${stateItem.pid} - ${stateItem.tid}`)) { + let obj = this.threadMap.get(`${stateItem.pid} - ${stateItem.tid}`); + obj!.push(stateItem) + } else { + this.threadMap.set(`${stateItem.pid} - ${stateItem.tid}`, [stateItem]); + }; + }; + this.hasThreadStatesData = true; + } + + //线程下周期的处理逻辑 + handleCycleLogic(res: Array, btnHtml: string): void { + //处理sql查询数据为0条,或者当loop切割获取的数据时1条 + if (res.length === 0 || this.threadMap.size === 0 || (btnHtml === LOOP_BUTTON_TEXT && res.length === 1)) { + this.schedSwitchTbl!.recycleDataSource = []; + this.schedSwitchTbl!.loading = false; + this.clickTableLabel(this.schedSwitchTbl!.recycleDataSource); + return; + } + let group: { [key: number]: SchedSwitchCountBean } = {}; + for (let value of this.threadMap.values()) { + let cyclesArr: Array = []; + let processInfo: string | undefined = Utils.PROCESS_MAP.get(value[0].pid); + let process: string | undefined = processInfo === null || processInfo!.length === 0 ? '[NULL]' : processInfo; + let threadInfo: string | undefined = Utils.THREAD_MAP.get(value[0].tid); + let thread: string | undefined = threadInfo === null || threadInfo!.length === 0 ? '[NULL]' : threadInfo; + //整理出一个对象并将周期空数组放进对象里 + let cutDataObj: CutDataObjConfig = { + cyclesArr: cyclesArr, + pid: value[0].pid, + tid: value[0].tid, + process: process, + thread: thread, + processTitle: `${process}[${value[0].pid}]`, + threadTitle: `${thread}[${[value[0].tid]}]`, + threadCountTotal: 0, + threadDurTotal: 0 + }; + //此处根据切割方法不同处理一下方法循环长度 + for (let idx = 0; idx < (btnHtml === LOOP_BUTTON_TEXT ? res.length - 1 : res.length); idx++) { + if (btnHtml === LOOP_BUTTON_TEXT) { res[idx].cycleEndTime = res[idx + 1].cycleStartTime; };//当切割方法为loop时,处理出周期结束时间 + let duration = ((res[idx].cycleEndTime - res[idx].cycleStartTime) / UNIT).toFixed(NUM_DIGITS); + let dur = Number(duration) * UNIT; + value.map((item: ThreadInitConfig) => { + //当idx变化时添加周期 + if (cyclesArr.length !== idx + 1) { + let nodeFlag = `${process} - ${item.pid} - ${thread} - ${item.tid}`; + let startNS = res[idx].cycleStartTime - this.selectionParam!.recordStartNs; + let cycleStartTime = (startNS / UNIT).toFixed(NUM_DIGITS); + let title = `cycle ${idx + 1}-` + thread;//周期名称 + cyclesArr.push(new SchedSwitchCountBean(nodeFlag, startNS, cycleStartTime, dur, duration, idx + 1, title, 0, 'cycle', 9,[])); + cutDataObj!.threadDurTotal = (Number(duration) + Number(cutDataObj.threadDurTotal)).toFixed(NUM_DIGITS);//本次线程下所有周期的dur和 + }; + //判断数据是否符合这个周期,符合的进入判断累加count + if (res[idx].cycleEndTime > item.endTs && item.endTs > res[idx].cycleStartTime) { + let index = cyclesArr.length - 1; + if (index === idx) { cyclesArr[index].value += 1; }; + cutDataObj.threadCountTotal += 1; + }; + }); + } + //本轮线程处理过的数据传入并处理成树结构,放入group对象中 + this.translateIntoTree(cutDataObj, group); + }; + this.schedSwitchTbl!.recycleDataSource = Object.values(group); + this.schedSwitchTbl!.loading = false; + this.clickTableLabel(this.schedSwitchTbl!.recycleDataSource); + } + //根据处理好的单个线程对应的周期数据、count总数、dur总数以及所属进程、线程相关信息,转换成树结构数据 + translateIntoTree(data: CutDataObjConfig, group: { [key: number]: SchedSwitchCountBean }): void { + //给进程节点、线程节点添加节点标志 + let nodeFlag = `${data.process} - ${data.pid} - ${data.thread} - ${data.tid}`; + //将线程放到对应的进程节点下 + let dur = Number(data.threadDurTotal) * UNIT; + if (group[data.pid]) { + let process = group[data.pid]; + process.value += data.threadCountTotal; + process.duration = (Number(data.threadDurTotal) + Number(process.duration)).toFixed(NUM_DIGITS); + process.children.push( + new SchedSwitchCountBean(nodeFlag, -1, '', dur, data.threadDurTotal, -1, data.threadTitle, data.threadCountTotal, 'thread', 9, data.cyclesArr) + ); + } else { + group[data.pid] = new SchedSwitchCountBean( + '', -1, '', dur, data.threadDurTotal, -1, data.processTitle, data.threadCountTotal, 'process', 9, [new SchedSwitchCountBean( + nodeFlag, + -1, + '', + dur, + data.threadDurTotal, + -1, + data.threadTitle, + data.threadCountTotal, + 'thread', + 9, + data.cyclesArr + )] + ); + } + } + //点击表格标签,判断点击的是那个标签,进而展开或收缩对应的节点 + clickTableLabel(data: Array): void { + let labelList = this.schedSwitchTbl!.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labelList) { + for (let i = 0; i < labelList.length; i++) { + let lable = labelList[i].innerHTML; + labelList[i].addEventListener('click', (e) => { + if (lable.includes('Process')) { + this.schedSwitchTbl!.setStatus(data, false); + this.schedSwitchTbl!.recycleDs = this.schedSwitchTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (lable.includes('Thread')) { + for (let item of data) { + item.status = true; + if (item.children !== undefined && item.children.length > 0) { + this.schedSwitchTbl!.setStatus(item.children, false); + }; + } + this.schedSwitchTbl!.recycleDs = this.schedSwitchTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (lable.includes('Cycle')) { + this.schedSwitchTbl!.setStatus(data, true); + this.schedSwitchTbl!.recycleDs = this.schedSwitchTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + }; + }); + }; + }; + } + //根据A、B周期输入的dur的范围值,计算对应周期的数据 + queryCycleRangeData(): void { + let cycleALeft: string = this.cycleALeftInput!.value.trim(); + let cycleARight: string = this.cycleARightInput!.value.trim(); + let cycleBLeft: string = this.cycleBLeftInput!.value.trim(); + let cycleBRight: string = this.cycleBRightInput!.value.trim(); + this.histogramSource = []; + this.histogramSource.push(this.rangeTotal); + //周期A处理 + if (cycleALeft !== '' && cycleARight !== '' && cycleALeft !== cycleARight) { + let countA: number = 0; + let rangeFilterA: Array = this.getThreadChildren.filter( + (it: TreeSwitchConfig) => Number(it.duration) >= Number(cycleALeft) && Number(it.duration) < Number(cycleARight) + ); + rangeFilterA.forEach((item: TreeSwitchConfig) => { + countA += item.value; + }); + this.rangeA = { + value: countA, + cycleNum: rangeFilterA.length, + average: rangeFilterA.length ? Math.ceil(countA / rangeFilterA.length) : 0, + size: 'Cycle A', + isHover: false, + color: '#ffab67', + }; + this.histogramSource.push(this.rangeA); + } + //周期B处理 + if (cycleBLeft !== '' && cycleBRight !== '' && cycleBLeft !== cycleBRight) { + let countB: number = 0; + let rangeFilterB: Array = this.getThreadChildren.filter( + (it: TreeSwitchConfig) => Number(it.duration) >= Number(cycleBLeft) && Number(it.duration) < Number(cycleBRight) + ); + rangeFilterB.forEach((item: TreeSwitchConfig) => { + countB += item.value; + }); + this.rangeB = { + value: countB, + cycleNum: rangeFilterB.length, + average: rangeFilterB.length ? Math.ceil(countB / rangeFilterB.length) : 0, + size: 'Cycle B', + isHover: false, + color: '#a285d2', + }; + this.histogramSource.push(this.rangeB); + }; + this.drawHistogramChart(); + } + //绘制柱状图 + drawHistogramChart(): void { + let source = []; + source = this.histogramSource.map((it: HistogramSourceConfig, index: number) => { + let data = { + cycle: it.size, + average: it.average, + visible: 1, + color: it.color, + }; + return data; + }); + this.chartTotal!.config = { + data: source,//画柱状图的数据源 + appendPadding: 10, + xField: 'cycle',//x轴代表属于那个周期 + yField: 'average',//y轴代表count/周期个数的值 + notSort: true,//绘制的柱状图不排序 + removeUnit: true,//移除单位换算 + seriesField: '', + //设置柱状图的颜色 + color(a): string { + if (a.cycle === 'Total') { + return '#2f72f8'; + } else if (a.cycle === 'Cycle A') { + return '#ffab67'; + } else if (a.cycle === 'Cycle B') { + return '#a285d2'; + } else { + return '#0a59f7'; + }; + }, + //鼠标悬浮柱状图上方时显示对应的提示信息 + tip(a): string { + if (a && a[0]) { + let tip = ''; + for (let obj of a) { + tip = `${tip} +
        +
        +
        ${obj.xLabel}:${obj.obj.average}
        +
        + `; + } + return tip; + } else { + return ''; + } + }, + label: null, + }; + } + //canvans涉及的区域是否被隐藏 + isCanvansHidden(flag: boolean): void { + if (flag) { + this.setAttribute('canvans-hidden', ''); + } else { + this.removeAttribute('canvans-hidden'); + }; + } + //切换single按钮时颜色是否变化 + isSingleBtnColor(flag: boolean): void { + if (flag) { + this.setAttribute('single', ''); + } else { + this.removeAttribute('single'); + }; + } + //切换single按钮时颜色是否变化 + isLoopBtnColor(flag: boolean): void { + if (flag) { + this.setAttribute('loop', ''); + } else { + this.removeAttribute('loop'); + }; + } + //Query按钮能不能被点击,即在此处设置符合条件时鼠标箭头为手的样式表示可点击,反之表示禁止触发点击事件 + canQueryButtonClick(flag: boolean): void { + if (flag) { + this.setAttribute('query-button', ''); + } else { + this.removeAttribute('query-button'); + }; + } + //回调函数,this.schedSwitchTbl首次插入DOM时执行的初始化回调 + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.schedSwitchTbl!); + } + initHtml(): string { + return ` + +
        + + +
        + + +
        +
        + ` + } + initMainContent(): string { + return ` +
        +
        + + + + + + + + + + +
        + + +
        + ` + } +} diff --git a/ide/src/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut.ts b/ide/src/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut.ts new file mode 100644 index 0000000000000000000000000000000000000000..65363367b7e5ba9419ecce114d8da92c6b6a5dc2 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut.ts @@ -0,0 +1,740 @@ +/* + * 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'; +import { LitTable, RedrawTreeForm } from '../../../../../base-ui/table/lit-table'; +import { Utils } from '../../base/Utils'; +import { SelectionParam } from '../../../../bean/BoxSelection'; +import { BinderGroup, DataSource } from '../../../../bean/BinderProcessThread'; +import { querySingleFuncNameCycleStates, queryStatesCut, queryLoopFuncNameCycle } from '../../../../database/sql/Func.sql'; +import { FuncNameCycle } from '../../../../bean/BinderProcessThread'; +import { resizeObserver } from '../SheetUtils'; +import { LitChartColumn } from '../../../../../base-ui/chart/column/LitChartColumn'; +import '../../../../../base-ui/chart/column/LitChartColumn'; +import { SpSegmentationChart } from '../../../chart/SpSegmentationChart'; +import { StateGroup } from '../../../../bean/StateModle'; +import { TraceSheet } from '../../base/TraceSheet'; +import { Flag } from '../../timer-shaft/Flag'; +import { TraceRow } from '../../base/TraceRow'; +import { Rect, ns2x } from '../../../../database/ui-worker/ProcedureWorkerCommon'; +import { SpSystemTrace } from '../../../SpSystemTrace'; + +@element('tabpane-states-datacut') +export class TabPaneFreqStatesDataCut extends BaseElement { + private threadBindersTbl: LitTable | null | undefined; + private currentSelectionParam: SelectionParam | any; + private threadStatesDIV: Element | null | undefined; + private cycleARangeArr: StateGroup[] | undefined; + private cycleBRangeArr: StateGroup[] | undefined; + private cycleAStartRangeDIV: HTMLInputElement | null | undefined; + private cycleAEndRangeDIV: HTMLInputElement | null | undefined; + private cycleBStartRangeDIV: HTMLInputElement | null | undefined; + private cycleBEndRangeDIV: HTMLInputElement | null | undefined; + private chartTotal: LitChartColumn | null | undefined; + private dataSource: DataSource[] | undefined; + private rowCycleData: StateGroup[] | undefined; + private funcNameCycleArr: FuncNameCycle[] | undefined; + private currentThreadId: string | undefined; + private cycleStartTime: number | undefined; + private cycleEndTime: number | undefined; + private filterState: Array = []; + private traceSheetEl: TraceSheet | undefined | null; + private spSystemTrace: SpSystemTrace | undefined | null; + private lineCycleNum: number = -1; + private cycleIsClick: Boolean = false; + + + // tab页入口函数 + set data(threadStatesParam: SelectionParam | any) { + // 获取输入框 + let threadIdDIV = this.shadowRoot!.querySelector('.thread-id-input') as HTMLElement; + threadIdDIV.style.border = '1px solid rgb(151,151,151)'; + let cycleNameDIV = this.shadowRoot!.querySelector('.cycle-name-input') as HTMLElement; + cycleNameDIV.style.border = '1px solid rgb(151,151,151)'; + if (this.currentSelectionParam === threadStatesParam) { + return; + } + // 隐藏右半边区域 + this.dispalyQueryArea(true); + // 清空切割按钮状态 + this.clickLoop(false); + this.clickSingle(false); + this.currentSelectionParam = threadStatesParam; + // 清空表格数据 + this.threadBindersTbl!.recycleDataSource = []; + this.theadClick(this.threadBindersTbl!.recycleDataSource); + } + + initTabSheetEl(traceSheet: TraceSheet): void { + this.traceSheetEl = traceSheet; + } + + dispalyQueryArea(b: boolean) { + if (b) { + this.setAttribute('dispalyQueryArea', ''); + } else { + this.removeAttribute('dispalyQueryArea'); + } + } + + clickSingle(b: boolean) { + if (b) { + this.setAttribute('clickSingle', ''); + } else { + this.removeAttribute('clickSingle'); + } + } + + clickLoop(b: boolean) { + if (b) { + this.setAttribute('clickLoop', ''); + } else { + this.removeAttribute('clickLoop'); + } + } + + // LOOP切割方法 + async dataLoopCut(threadId: HTMLInputElement, threadFunc: HTMLInputElement): Promise { + // 清除表格数据 + SpSegmentationChart.setStateChartData([]); + // 获取框选范围内包含的进程和线程ID + let threadIds: number[] = this.currentSelectionParam.threadIds; + let processIds: number[] = this.currentSelectionParam.processIds; + // 获取输入的进程号和方法名 + let threadIdValue: string = threadId.value.trim(); + let threadFuncName: string = threadFunc.value.trim(); + // 获取框选的左右边界 + let leftNS: number = this.currentSelectionParam.leftNs; + let rightNS: number = this.currentSelectionParam.rightNs; + // 判断进程号和方法名是否都输入了内容 + if (threadIdValue !== '' && threadFuncName !== '') { + // 修改按钮样式 + this.clickLoop(true); + this.clickSingle(false); + threadId.style.border = '1px solid rgb(151,151,151)'; + threadFunc.style.border = '1px solid rgb(151,151,151)'; + this.threadBindersTbl!.loading = true; + this.funcNameCycleArr = await queryLoopFuncNameCycle(threadFuncName, threadIdValue, leftNS, rightNS); + // 遍历设置周期的起始时间 + for (let i = 0; i < this.funcNameCycleArr!.length - 1; i++) { + this.funcNameCycleArr![i].endTime = this.funcNameCycleArr![i + 1].cycleStartTime; + } + // 框选范围内的状态数据 + let stateItemArr = await queryStatesCut(threadIds, leftNS, rightNS); + // 周期数组里的最后一项不满足loop要求,直接删除 + this.funcNameCycleArr!.pop(); + if (this.funcNameCycleArr!.length !== 0) { + let stateCutArr: StateGroup[] = []; + // pid数组去重 + processIds = Array.from(new Set(processIds)); + // 去除切割范围以外的数据 + this.filterState = new Array; + stateItemArr.map(stateItem => { + for (let i = 0; i < this.funcNameCycleArr!.length; i++) { + // @ts-ignore + if (stateItem.ts + stateItem.dur > this.funcNameCycleArr[i].cycleStartTime && stateItem.ts + stateItem.dur < this.funcNameCycleArr[i].endTime + && (stateItem.state === 'S' || stateItem.state === 'R' || stateItem.state === 'D' || stateItem.state === 'Running')) { + this.filterState!.push(stateItem); + }; + }; + }); + // 周期内有数据 + if (this.filterState.length !== 0) { + for (let i = 0; i < processIds.length; i++) { + this.setProcessData(this.filterState, processIds[i], stateCutArr); + } + } + this.threadBindersTbl!.recycleDataSource = stateCutArr; + this.threadBindersTbl!.loading = false; + // 表格添加点击事件 + this.theadClick(this.threadBindersTbl!.recycleDataSource); + } else { + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTbl!.loading = false; + this.theadClick(this.threadBindersTbl!.recycleDataSource); + } + } else { + this.verifyInputIsEmpty(threadIdValue, threadFuncName, threadId, threadFunc); + } + } + + async dataSingleCut(threadId: HTMLInputElement, threadFunc: HTMLInputElement): Promise { + SpSegmentationChart.setStateChartData([]); + this.currentThreadId = ''; + let threadIds: number[] = this.currentSelectionParam.threadIds; + let processIds: number[] = this.currentSelectionParam.processIds; + let threadIdValue: string = threadId.value.trim(); + let threadFuncName: string = threadFunc.value.trim(); + let leftNS: number = this.currentSelectionParam.leftNs; + let rightNS: number = this.currentSelectionParam.rightNs; + if (threadIdValue !== '' && threadFuncName !== '') { + this.clickLoop(false); + this.clickSingle(true); + threadId.style.border = '1px solid rgb(151,151,151)'; + threadFunc.style.border = '1px solid rgb(151,151,151)'; + this.threadBindersTbl!.loading = true; + this.funcNameCycleArr = await querySingleFuncNameCycleStates(threadFuncName, threadIdValue, leftNS, rightNS); + this.cycleStartTime = this.funcNameCycleArr!.length > 0 ? this.funcNameCycleArr![0].cycleStartTime : undefined; + this.cycleEndTime = this.funcNameCycleArr!.length > 0 ? this.funcNameCycleArr![this.funcNameCycleArr!.length - 1].endTime : undefined; + let stateItemArr = await queryStatesCut(threadIds, leftNS, rightNS); + if (this.funcNameCycleArr!.length !== 0) { + let stateCutArr: StateGroup[] = []; + // pid数组去重 + processIds = Array.from(new Set(processIds)); + // 去除切割范围以外的数据 + this.filterState = new Array; + stateItemArr.map(stateItem => { + for (let i = 0; i < this.funcNameCycleArr!.length; i++) { + // @ts-ignore + if (stateItem.ts + stateItem.dur > this.funcNameCycleArr[i].cycleStartTime && stateItem.ts + stateItem.dur < this.funcNameCycleArr[i].endTime + && (stateItem.state === 'S' || stateItem.state === 'R' || stateItem.state === 'D' || stateItem.state === 'Running')) { + this.filterState!.push(stateItem); + }; + }; + }); + if (this.filterState.length > 0) { + for (let i = 0; i < processIds.length; i++) { + this.setProcessData(this.filterState, processIds[i], stateCutArr); + } + } + this.threadBindersTbl!.recycleDataSource = stateCutArr; + this.threadBindersTbl!.loading = false; + this.theadClick(this.threadBindersTbl!.recycleDataSource); + } else { + this.threadBindersTbl!.recycleDataSource = []; + this.threadBindersTbl!.loading = false; + this.theadClick(this.threadBindersTbl!.recycleDataSource); + } + } else { + this.verifyInputIsEmpty(threadIdValue, threadFuncName, threadId, threadFunc); + } + } + + // 处理进程数据 + setProcessData(filterState: StateGroup[], processId: number, stateCutArr: StateGroup[]): void { + // 当前进程级别的数据 + let filterObj = new StateGroup(); + // 筛选出当前进程下的所有数据 + let processArr = new Array; + filterState.map(filterItem => { + if (filterItem.pid === processId) { + processArr.push(filterItem); + filterObj.totalCount! += 1; + filterItem.state === 'R' ? filterObj.RunnableCount += 1 : filterItem.state === 'Running' + ? filterObj.RunningCount += 1 : filterItem.state === 'D' + ? filterObj.DCount += 1 : filterObj.SleepingCount += 1; + filterObj.title = (Utils.PROCESS_MAP.get(processId) || 'Process') + processId; + filterObj.pid = processId; + filterObj.type = 'process'; + } + }) + if (processArr.length > 0) { + filterObj.children = this.setThreadData(processArr); + } + stateCutArr.push(filterObj); + }; + + // 处理线程数据 + setThreadData(threadData: Array) { + // 进程下面的线程,相当于process的children + let threadArr = new Array; + let threads = this.currentSelectionParam.threadIds; + for (let i = 0; i < threads.length; i++) { + // 单个线程 + let threadObj = new StateGroup(); + threadObj.tid = threads[i]; + threadObj.pid = threadData[0].pid; + threadObj.children = new Array; + threadObj.type = 'thread'; + threadObj.title = (Utils.THREAD_MAP.get(threads[i]) || 'Process') + threads[i], + threadArr.push(threadObj); + } + for (let i = 0; i < threadArr.length; i++) { + let threadList = new Array; + threadData.map(threadItem => { + if (threadItem.tid === threadArr[i].tid) { + threadList.push(threadItem); + threadArr[i].totalCount! += 1; + threadItem.state === 'R' + ? (threadArr[i].RunnableCount += 1, threadArr[i].RunnableDur += threadItem.dur!) + : threadItem.state === 'Running' + ? (threadArr[i].RunningCount += 1, threadArr[i].RunningDur += threadItem.dur!) + : threadItem.state === 'S' + ? (threadArr[i].SleepingCount += 1, threadArr[i].SleepingDur += threadItem.dur!) + : (threadArr[i].DCount += 1, threadArr[i].DDur += threadItem.dur!); + } + }) + threadArr[i].SleepingDur = Number((threadArr[i].SleepingDur / 1000000).toFixed(3)); + threadArr[i].RunnableDur = Number((threadArr[i].RunnableDur / 1000000).toFixed(3)); + threadArr[i].RunningDur = Number((threadArr[i].RunningDur / 1000000).toFixed(3)); + threadArr[i].DDur = Number((threadArr[i].DDur / 1000000).toFixed(3)); + if (threadList.length > 0) { + threadArr[i].children = this.setCycleData(threadList) + } + } + threadArr = threadArr.filter(V => { + return V.totalCount! > 0; + }) + return threadArr; + } + + // 处理周期数据 + setCycleData(threadData: Array): Array { + let cycleArr = new Array; + if (this.funcNameCycleArr !== undefined && this.funcNameCycleArr.length > 0) { + for (let i = 0; i < this.funcNameCycleArr!.length; i++) { + let cycleItem = new StateGroup(); + cycleItem.title = `cycle-${i + 1}`; + cycleItem.cycle = i; + threadData.map(v => { + // @ts-ignore + if (v.ts + v.dur > this.funcNameCycleArr[i].cycleStartTime && v.dur + v.ts < this.funcNameCycleArr[i].endTime) { + cycleItem.totalCount! += 1; + v.state === 'R' + ? (cycleItem.RunnableCount += 1, cycleItem.RunnableDur += v.dur!) + : v.state === 'Running' + ? (cycleItem.RunningCount += 1, cycleItem.RunningDur += v.dur!) + : v.state === 'S' + ? (cycleItem.SleepingCount += 1, cycleItem.SleepingDur += v.dur!) + : (cycleItem.DCount += 1, cycleItem.DDur += v.dur!); + } + }) + cycleItem.SleepingDur = Number((cycleItem.SleepingDur / 1000000).toFixed(3)); + cycleItem.RunningDur = Number((cycleItem.RunningDur / 1000000).toFixed(3)); + cycleItem.RunnableDur = Number((cycleItem.RunnableDur / 1000000).toFixed(3)); + cycleItem.DDur = Number((cycleItem.DDur / 1000000).toFixed(3)); + cycleItem.cycleDur! = Number(((this.funcNameCycleArr[i].endTime - this.funcNameCycleArr[i].cycleStartTime) / 1000000).toFixed(3)); + cycleItem.type = 'cycle'; + cycleArr.push(cycleItem); + } + } + return cycleArr + }; + + // 输入框为空点击按钮之后的样式 + verifyInputIsEmpty(threadIdValue: string, threadFuncName: string, threadId: HTMLInputElement, threadFunc: HTMLInputElement): void { + if (threadIdValue === '') { + threadId.style.border = '1px solid rgb(255,0,0)'; + threadId.setAttribute('placeholder', 'Please input thread id'); + } else { + threadId.style.border = '1px solid rgb(151,151,151)'; + } + + if (threadFuncName === '') { + threadFunc.style.border = '1px solid rgb(255,0,0)'; + threadFunc.setAttribute('placeholder', 'Please input function name'); + } else { + threadFunc.style.border = '1px solid rgb(151,151,151)'; + } + } + + + // 线程点击 + private theadClick(data: Array): void { + let labels = this.threadBindersTbl?.shadowRoot?.querySelector('.th > .td')!.querySelectorAll('label'); + if (labels) { + for (let i = 0; i < labels.length; i++) { + let label = labels[i].innerHTML; + labels[i].addEventListener('click', (e) => { + if (label.includes('Process') && i === 0) { + // 数据递归设置status + this.threadBindersTbl!.setStatus(data, false); + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('Thread') && i === 1) { + for (let item of data) { + item.status = true; + if (item.children != undefined && item.children.length > 0) { + this.threadBindersTbl!.setStatus(item.children, false); + } + } + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement(data, RedrawTreeForm.Retract); + } else if (label.includes('Cycle') && i === 2) { + this.threadBindersTbl!.setStatus(data, true); + this.threadBindersTbl!.recycleDs = this.threadBindersTbl!.meauseTreeRowElement(data, RedrawTreeForm.Expand); + } + }); + } + } + } + + initElements(): void { + this.threadBindersTbl = this.shadowRoot?.querySelector('#tb-binder-count'); + this.chartTotal = this.shadowRoot!.querySelector('#chart_cycle'); + this.cycleAStartRangeDIV = this.shadowRoot?.querySelector('#cycle-a-start-range'); + this.cycleAEndRangeDIV = this.shadowRoot?.querySelector('#cycle-a-end-range'); + this.cycleBStartRangeDIV = this.shadowRoot?.querySelector('#cycle-b-start-range'); + this.cycleBEndRangeDIV = this.shadowRoot?.querySelector('#cycle-b-end-range'); + + this.threadStatesDIV = this.shadowRoot!.querySelector('#dataCut'); + this.threadStatesDIV?.children[2].children[0].addEventListener('click', (e) => { + this.dispalyQueryArea(true); + this.dataSource = []; + // @ts-ignore + this.dataSingleCut(this.threadStatesDIV!.children[0], this.threadStatesDIV?.children[1]); + }) + this.threadStatesDIV?.children[2].children[1].addEventListener('click', (e) => { + this.dispalyQueryArea(true); + this.dataSource = []; + // @ts-ignore + this.dataLoopCut(this.threadStatesDIV?.children[0], this.threadStatesDIV?.children[1]); + }) + + this.threadBindersTbl!.addEventListener('mouseout', (): void => { + this.cycleIsClick = false; + this.lineCycleNum = -1; + this.traceSheetEl!.systemLogFlag = undefined; + this.spSystemTrace?.refreshCanvas(false); + }) + + this.threadBindersTbl!.addEventListener('row-click', (evt: any) => { + let currentData: StateGroup = evt.detail.data; + if (currentData.type === 'thread') { + this.currentThreadId = currentData.tid + '' + currentData.pid; + this.clearCycleRange(); + currentData.isSelected = true; + this.threadBindersTbl!.clearAllSelection(currentData); + this.threadBindersTbl!.setCurrentSelection(currentData); + this.rowCycleData = currentData.children; + this.dispalyQueryArea(false); + let totalCount = currentData.SleepingCount + currentData.RunnableCount + currentData.DCount + currentData.RunningCount; + this.dataSource = []; + this.dataSource.push({ + xName: 'Total', + yAverage: totalCount !== 0 ? Math.ceil(totalCount! / this.rowCycleData!.length) : 0 + }) + if (this.dataSource!.length !== 0) { + this.drawColumn(); + } + let statesChartData = this.filCycleData(currentData.pid, currentData.tid); + SpSegmentationChart.setStateChartData(statesChartData); + } + if (currentData.type === 'cycle') { + currentData.isSelected = true; + this.threadBindersTbl!.clearAllSelection(currentData); + this.threadBindersTbl!.setCurrentSelection(currentData); + if (currentData.cycle === this.lineCycleNum && this.cycleIsClick === true) { + this.traceSheetEl!.systemLogFlag = undefined; + this.cycleIsClick = false; + } else { + let pointX: number = ns2x( + this.funcNameCycleArr![currentData.cycle].cycleStartTime || 0, + TraceRow.range!.startNS, + TraceRow.range!.endNS, + TraceRow.range!.totalNS, + new Rect(0, 0, TraceRow.FRAME_WIDTH, 0) + ); + this.traceSheetEl!.systemLogFlag = new Flag( + Math.floor(pointX), + 0, + 0, + 0, + this.funcNameCycleArr![currentData.cycle].cycleStartTime!, + '#000000', + '', + true, + '' + ); + this.lineCycleNum = currentData.cycle; + this.cycleIsClick = true; + } + this.spSystemTrace?.refreshCanvas(false); + } + }); + + + // 筛选柱状图数据 + this.shadowRoot?.querySelector('#query-btn')?.addEventListener('click', () => { + this.cycleARangeArr = this.rowCycleData?.filter((it: StateGroup) => { + return it.cycleDur! >= Number(this.cycleAStartRangeDIV!.value) + && it.cycleDur! < Number(this.cycleAEndRangeDIV!.value); + }) + this.cycleBRangeArr = this.rowCycleData?.filter((it: StateGroup) => { + return it.cycleDur! >= Number(this.cycleBStartRangeDIV!.value) + && it.cycleDur! < Number(this.cycleBEndRangeDIV!.value); + }) + let cycleACount: number = 0; + this.cycleARangeArr?.forEach((it: StateGroup) => { + cycleACount += it.totalCount!; + }) + let cycleBCount: number = 0; + this.cycleBRangeArr?.forEach((it: StateGroup) => { + cycleBCount += it.totalCount!; + }) + this.dataSource!.length > 1 && this.dataSource?.splice(1); + this.dataSource!.push({ + xName: 'cycleA', + yAverage: cycleACount !== 0 ? Math.ceil(cycleACount / this.cycleARangeArr!.length) : 0 + }) + this.dataSource!.push({ + xName: 'cycleB', + yAverage: cycleBCount !== 0 ? Math.ceil(cycleBCount / this.cycleBRangeArr!.length) : 0 + }) + if (this.dataSource!.length !== 0) { + this.drawColumn(); + } + }) + } + + // 筛选出点击的线程数据 + filCycleData(pid: number, tid: number): Array { + return this.filterState?.filter((v: StateGroup) => { + return v.pid === pid && v.tid === tid && v.ts + v.dur! > this.cycleStartTime! && v.ts + v.dur! < this.cycleEndTime!; + }) + }; + + // 清空dur筛选输入框内容 + clearCycleRange(): void { + this.cycleAStartRangeDIV!.value = ''; + this.cycleAEndRangeDIV!.value = ''; + this.cycleBStartRangeDIV!.value = ''; + this.cycleBEndRangeDIV!.value = ''; + } + + // 画柱状图 + drawColumn(): void { + this.chartTotal!.dataSource = this.dataSource!; + this.chartTotal!.config = { + data: this.dataSource!, + appendPadding: 10, + xField: 'xName', + yField: 'yAverage', + seriesField: '', + removeUnit: true, + notSort: true, + color: (a) => { + if (a.xName === 'Total') { + return '#2f72f8'; + } else if (a.xName === 'cycleA') { + return '#ffab67'; + } else if (a.xName === 'cycleB') { + return '#a285d2'; + } else { + return '#0a59f7'; + } + }, + tip: (a) => { + if (a && a[0]) { + let tip: string = ''; + tip = `
        +
        Average count: ${a[0].obj.yAverage}
        +
        `; + return tip; + } else { + return ''; + } + }, + label: null, + }; + } + + connectedCallback(): void { + super.connectedCallback(); + resizeObserver(this.parentElement!, this.threadBindersTbl!); + } + + // 页面结构 + + initHtml(): string { + return ` + +
        + + +
        + + +
        +
        +
        + +
        + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
        +
        +
        + Cycle A: + + ~ + +
        +
        +
        + Cycle B: + + ~ + +
        +
        + +
        +
        +
        +
        +
        Average State Count
        + +
        +
        Total
        +
        CycleA
        +
        CycleB
        +
        +
        +
        +
        +
        + ` + } +} \ No newline at end of file diff --git a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts index c68d6cd17be2eb6990197c078d085f8f6531ae2b..5adeeb47a7f26a18fd06da84e7a29a7cb1703303 100644 --- a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts +++ b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts @@ -73,13 +73,13 @@ export class TabPaneTaskFrames extends BaseElement { let executeStartTime = 0; let returnEndTime = 0; let priorityId = 1; - let executeId = ''; + let relationId = ''; let executeStruct: FuncStruct | undefined = undefined; taskArray.forEach((item) => { if (item.funName!.indexOf(ALLOCATION_TASK) >= 0) { allocationStartTime = item.startTs!; priorityId = TabPaneTaskFrames.getPriorityId(item.funName!); - executeId = TabPaneTaskFrames.getExecuteId(item.funName!); + relationId = TabPaneTaskFrames.getRelationId(item.funName!); } else if (item.funName!.indexOf(PERFORM_TASK) >= 0) { executeStruct = item; executeStartTime = item.startTs!; @@ -94,7 +94,7 @@ export class TabPaneTaskFrames extends BaseElement { let tableList: TaskTabStruct[] = []; this.buildConcurrencyTable(executeStruct!, tableList, framesParam, isClick); } else { - this.buildNoConcurrencyTable(executeId, priorityId, allocationTime, executeTime, returnTime); + this.buildNoConcurrencyTable(relationId, priorityId, allocationTime, executeTime, returnTime); } } } @@ -125,14 +125,14 @@ export class TabPaneTaskFrames extends BaseElement { }); } private buildNoConcurrencyTable( - executeId: string, + relationId: string, priorityId: number, sTime: number, eTime: number, rTime: number ): void { let task: TaskTabStruct = new TaskTabStruct(); - task.executeId = executeId; + task.executeId = relationId; task.taskPriority = Priority[priorityId]; task.taskST = this.getMsTime(sTime); task.taskET = this.getMsTime(eTime); @@ -160,7 +160,7 @@ export class TabPaneTaskFrames extends BaseElement { let tempExecuteTaskIds: number[] = []; for (let index = 0; index < groupsValue.length; index++) { let data = groupsValue[index]; - let executeId = TabPaneTaskFrames.getExecuteId(data.funName!); + let executeId = TabPaneTaskFrames.getRelationId(data.funName!); if (data.funName!.indexOf(PERFORM_TASK) >= 0) { tempExecuteTaskList.push(data); } @@ -217,7 +217,7 @@ export class TabPaneTaskFrames extends BaseElement { Selected range:0.0 ms - 1) { return executeIdMatch[1]; + } else { + executeIdMatch = funName.match(/taskId\s*:\s*(\d+)/i); + if (executeIdMatch && executeIdMatch.length > 1) { + return executeIdMatch[1]; + } } return ''; } diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts index c0523626837d747c3f18d3b70bd61d09ebc7f5ed..cc384281a193aadbbaf48dfdec0e4202bfcc7b98 100644 --- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts @@ -162,7 +162,7 @@ export class RangeRuler extends Graph { let miniWidth = Math.ceil(this.frame.width / 100); //每格宽度 for (let index = 0; index < this._cpuUsage.length; index++) { let cpuUsageItem = this._cpuUsage[index]; - const color = interpolateColorBrightness(ColorUtils.MD_PALETTE[cpuUsageItem.cpu], cpuUsageItem.rate); + const color = interpolateColorBrightness(ColorUtils.FUNC_COLOR_B[cpuUsageItem.cpu % ColorUtils.FUNC_COLOR_B.length], cpuUsageItem.rate); this.context2D.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; this.context2D.globalAlpha = cpuUsageItem.rate; this.context2D.fillRect( @@ -515,6 +515,10 @@ export class RangeRuler extends Graph { if (currentSlicesTime) { this.currentSlicesTime = currentSlicesTime; } + this.isMouseDown = false; + this.isMovingRange = false; + this.isNewRange = false; + this.movingMark = null; this.cancelPressFrame(); this.cancelUpFrame(); this.pressedKeys.push(keyboardEvent.key.toLocaleLowerCase()); @@ -567,6 +571,7 @@ export class RangeRuler extends Graph { this.range.refresh = false; return; } + this.animaStartTime = this.animaStartTime || Date.now(); this.currentDuration = (Date.now() - this.animaStartTime!) / this.f; //reg if (this.currentDuration >= this.fixReg) { this.currentDuration = this.fixReg; @@ -591,6 +596,7 @@ export class RangeRuler extends Graph { this.range.refresh = false; return; } + this.animaStartTime = this.animaStartTime || Date.now(); this.currentDuration = (Date.now() - this.animaStartTime!) / this.f; if (this.currentDuration >= this.fixReg) { this.currentDuration = this.fixReg; @@ -615,6 +621,7 @@ export class RangeRuler extends Graph { this.range.refresh = false; return; } + this.animaStartTime = this.animaStartTime || Date.now(); this.currentDuration = (Date.now() - this.animaStartTime!) / this.f; if (this.currentDuration >= this.fixReg) { this.currentDuration = this.fixReg; @@ -640,6 +647,7 @@ export class RangeRuler extends Graph { this.range.refresh = false; return; } + this.animaStartTime = this.animaStartTime || Date.now(); this.currentDuration = (Date.now() - this.animaStartTime!) / this.f; if (this.currentDuration >= this.fixReg) this.currentDuration = this.fixReg; let bb = Math.tan((Math.PI / 180) * this.currentDuration); diff --git a/ide/src/trace/component/trace/timer-shaft/SportRuler.ts b/ide/src/trace/component/trace/timer-shaft/SportRuler.ts index 601e81679d9b60d8c2cc4a9a729917377b08c9d8..a420b6f5e5640271f3ad69fc3733bd55b68cfd5a 100644 --- a/ide/src/trace/component/trace/timer-shaft/SportRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/SportRuler.ts @@ -193,7 +193,7 @@ export class SportRuler extends Graph { }); } - draBasicsRuler(): void{ + draBasicsRuler(): void { this.rulerW = this.canvas!.offsetWidth; this.context2D.clearRect(this.frame.x, this.frame.y, this.frame.width, this.frame.height + 1); this.context2D.beginPath(); @@ -257,7 +257,7 @@ export class SportRuler extends Graph { } } - drawRangeSelect(): void{ + drawRangeSelect(): void { this.initRangeSelect(); if (this.timeArray.length > 0 && TraceRow.rangeSelectObject) { // 页面可视框选区域的宽度 @@ -286,12 +286,12 @@ export class SportRuler extends Graph { let sectionTime = (endNS - startNS) / section; let countArr = new Uint32Array(section); let count: number = 0; //某段时间的调用栈数量 - const useIndex: number[] = []; const isEbpf = this.durArray && this.durArray.length > 0; + const processTimeArray = new Array(this.timeArray.length).fill(false); for (let i = 1; i <= section; i++) { count = 0; for (let j = 0; j < this.timeArray.length; j++) { - if (isEbpf && useIndex.includes(j)) { + if (processTimeArray[j]){ continue; } let inRange = this.freshInRange(j, startNS, sectionTime, i); @@ -303,8 +303,8 @@ export class SportRuler extends Graph { } else { count++; } - useIndex.push(j); countArr[i - 1] = count; + processTimeArray[j] = true; } else { // 如果遇到大于分割点的时间,就跳过该分割点,计算下一个分割点的时间点数量 continue; @@ -317,7 +317,7 @@ export class SportRuler extends Graph { this.context2D.closePath(); } - private drawRangeSelectFillText(rangeSelectWidth: number, section: number, i: number, countArr: Uint32Array){ + private drawRangeSelectFillText(rangeSelectWidth: number, section: number, i: number, countArr: Uint32Array) { let x = TraceRow.rangeSelectObject!.startX! + (rangeSelectWidth / section) * i; if (i !== section) { this.context2D.moveTo(x, this.frame.y + 22); @@ -446,7 +446,9 @@ export class SportRuler extends Graph { } } - setSlicesMark( startTime: number | null = null, endTime: number | null = null, + setSlicesMark( + startTime: number | null = null, + endTime: number | null = null, shiftKey: boolean | null = null ): SlicesTime | null { let findSlicesTime = this.slicesTimeList.find((it) => it.startTime === startTime && it.endTime === endTime); diff --git a/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts b/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts index 87e8c5fe8e0342334dde4e721ae6ce7479acd758..3b99e41381408ef83db3aa23dccf8ae3c1fd75b1 100644 --- a/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts +++ b/ide/src/trace/component/trace/timer-shaft/TabPaneFlag.ts @@ -131,7 +131,6 @@ export class TabPaneFlag extends BaseElement { */ private eventHandler(): void { let tr = this.panelTable!.shadowRoot!.querySelectorAll('.tr') as NodeListOf; - tr[0].querySelector('#text-input')!.disabled = true; tr[0].querySelector('.removeAll')!.addEventListener('click', () => { this.systemTrace!.flagList = []; let flagList = [...this.flagList]; @@ -143,23 +142,6 @@ export class TabPaneFlag extends BaseElement { return; }); - // 更新备注信息 - this.panelTable!.addEventListener('click', (event: any) => { - if (this.flagList.length === 0) { - return; - } - for (let i = 1; i < tr.length; i++) { - let inputValue = tr[i].querySelector('#text-input')!.value; - if (this.tableDataSource[i].startTime === this.flagList[i - 1].time) { - this.flagList[i - 1].text = inputValue; - document.dispatchEvent(new CustomEvent('flag-change', { detail: this.flagList[i - 1] })); - // 旗子颜色改变时,重绘泳道图 - this.systemTrace?.refreshCanvas(true); - } - } - event.stopPropagation(); - }); - // 第一个tr是移除全部,所以跳过,从第二个tr开始,和this.flagList数组的第一个对应……,所以i从1开始,在this.flagList数组中取值时用i-1 for (let i = 1; i < tr.length; i++) { tr[i].querySelector('#color-input')!.value = this.flagList[i - 1].color; diff --git a/ide/src/trace/database/ConvertTraceWorker.ts b/ide/src/trace/database/ConvertTraceWorker.ts index 06d6644e176cc9f00b289b385da7c63a64b69c75..1307f097029186a2e5a18dbc0f589de34f7bc6a5 100644 --- a/ide/src/trace/database/ConvertTraceWorker.ts +++ b/ide/src/trace/database/ConvertTraceWorker.ts @@ -38,6 +38,11 @@ function initConvertWASM() { }); } +function isRawTrace(uint8Array: Uint8Array): boolean { + let rowTraceStr = Array.from(new Uint16Array(uint8Array.buffer.slice(0, 2))); + return rowTraceStr[0] === 57161; +} + const ARRAY_BUF_SIZE = 2 * 1024 * 1024; self.onmessage = async (e: MessageEvent) => { if (e.data.action === 'getConvertData') { @@ -47,16 +52,14 @@ self.onmessage = async (e: MessageEvent) => { let totalSize = fileData.byteLength; let traceInsPtr = convertModule._GetTraceConverterIns(); // 获取TraceConverter 实例 convertModule._SetDebugFlag(false, traceInsPtr); // 设置是否为debug模式 - let uint8Array = new Uint8Array(fileData.slice(0, 8)); // 获取前8个字节,用来判断文件是htrace还是raw trace - let enc = new TextDecoder(); - let headerStr = enc.decode(uint8Array); let currentPosition = 1024; let dataHeader = convertModule._malloc(1100); let traceAllData = new Uint8Array(e.data.buffer); - if (headerStr.indexOf('OHOSPROF') === 0) { - handleHTrace(fileData, dataHeader, traceInsPtr); + let isRawTraceConvert = isRawTrace(e.data); + if (isRawTraceConvert) { + [totalSize, currentPosition] = handleRowTrace(e, fileData, dataHeader, traceInsPtr, currentPosition, traceAllData, totalSize); } else { - handleRowTrace(e, fileData, dataHeader, traceInsPtr, currentPosition, traceAllData, totalSize); + handleHTrace(fileData, dataHeader, traceInsPtr); } let dataPtr = convertModule._malloc(stepSize); let arrayBufferPtr = convertModule._malloc(ARRAY_BUF_SIZE); @@ -70,7 +73,7 @@ self.onmessage = async (e: MessageEvent) => { }; let bodyFn = convertModule.addFunction(callback, 'vii'); convertModule._SetCallback(bodyFn, traceInsPtr); - convertData(currentPosition, traceAllData, arrayBufferPtr, dataPtr, traceInsPtr, headerStr, stepSize, totalSize); + convertData(currentPosition, traceAllData, arrayBufferPtr, dataPtr, traceInsPtr, isRawTraceConvert, stepSize, totalSize); convertModule._GetRemainingData(traceInsPtr); let headerData: string[] = []; let headerCallback = (heapPtr: number, size: number) => { @@ -89,11 +92,13 @@ self.onmessage = async (e: MessageEvent) => { postMessage(e, allDataStr); } }; + function handleHTrace(fileData: Array, dataHeader: any, traceInsPtr: any) { let uint8Array = new Uint8Array(fileData.slice(0, 1024)); convertModule.HEAPU8.set(uint8Array, dataHeader); convertModule._SendFileHeader(dataHeader, 1024, traceInsPtr); } + function handleRowTrace( e: MessageEvent, fileData: Array, @@ -102,18 +107,17 @@ function handleRowTrace( currentPosition: number, traceAllData: Uint8Array, totalSize: number -): void { +): [number, number] { let uint8Array = new Uint8Array(fileData.slice(0, 12)); convertModule.HEAPU8.set(uint8Array, dataHeader); convertModule._SendRawFileHeader(dataHeader, 12, traceInsPtr); currentPosition = 12; let allRowTraceData = new Uint8Array(e.data.buffer); let commonDataOffsetList: Array<{ - startOffset: number; - endOffset: number; + startOffset: number + endOffset: number }> = []; - let commonTotalLength = 0; - setCommonDataOffsetList(e, allRowTraceData, commonTotalLength, commonDataOffsetList); + let commonTotalLength = setCommonDataOffsetList(e, allRowTraceData, commonDataOffsetList); let commonTotalOffset = 0; let commonTotalData = new Uint8Array(commonTotalLength); commonDataOffsetList.forEach((item) => { @@ -125,13 +129,15 @@ function handleRowTrace( traceAllData.set(commonTotalData, currentPosition); traceAllData.set(allRowTraceData.slice(currentPosition), commonTotalData.length + currentPosition); totalSize += commonTotalData.length; + return [totalSize, currentPosition]; } + function setCommonDataOffsetList( e: MessageEvent, allRowTraceData: Uint8Array, - commonTotalLength: number, commonDataOffsetList: Array -): void { +): number { + let commonTotalLength: number = 0; let commonOffset = 12; let tlvTypeLength = 4; while (commonOffset < allRowTraceData.length) { @@ -152,14 +158,16 @@ function setCommonDataOffsetList( commonDataOffsetList.push(commonDataOffset); } } + return commonTotalLength; } + function convertData( currentPosition: number, traceAllData: Uint8Array, arrayBufferPtr: any, dataPtr: any, traceInsPtr: any, - headerStr: string, + isRawTraceConvert: boolean = false, stepSize: number, totalSize: number ): void { @@ -180,12 +188,10 @@ function convertData( let subArrayBuffer = convertModule.HEAPU8.subarray(blockPtr, blockPtr + blockSize); convertModule.HEAPU8.set(subArrayBuffer, arrayBufferPtr); // 调用分片转换接口 - if (headerStr.indexOf('OHOSPROF') === 0) { - // htrace - convertModule._ConvertBlockData(arrayBufferPtr, subArrayBuffer.length, traceInsPtr); + if (isRawTraceConvert) { + convertModule._ConvertRawBlockData(arrayBufferPtr, subArrayBuffer.length, traceInsPtr); // raw trace } else { - // raw trace - convertModule._ConvertRawBlockData(arrayBufferPtr, subArrayBuffer.length, traceInsPtr); + convertModule._ConvertBlockData(arrayBufferPtr, subArrayBuffer.length, traceInsPtr); // htrace } processedLen = processedLen + blockSize; blockPtr = dataPtr + processedLen; @@ -194,13 +200,14 @@ function convertData( currentPosition = endPosition; } } + function postMessage(e: MessageEvent, allDataStr: Array): void { self.postMessage( { id: e.data.id, action: 'convert', status: true, - results: new Blob(allDataStr, { type: 'text/plain' }), + results: new Blob(allDataStr, {type: 'text/plain'}), buffer: e.data.buffer, }, // @ts-ignore diff --git a/ide/src/trace/database/StateBusyTimeWorker.ts b/ide/src/trace/database/StateBusyTimeWorker.ts index 97ba010b48d1a84f660e1a02b9fa9f804d5a3b64..e79e42f2fe32b630a119e91752abeb32ad4ff414 100644 --- a/ide/src/trace/database/StateBusyTimeWorker.ts +++ b/ide/src/trace/database/StateBusyTimeWorker.ts @@ -108,8 +108,8 @@ function handleBusyTimeLogic(initFreqResult: Array, initStateResult: Array< } self.onmessage = (e: MessageEvent) => { - let leftStartNs = e.data.frqSampleParam.leftNs + e.data.frqSampleParam.recordStartNs; - let rightEndNs = e.data.frqSampleParam.rightNs + e.data.frqSampleParam.recordStartNs; + let leftStartNs = e.data.timeParam.leftNs + e.data.timeParam.recordStartNs; + let rightEndNs = e.data.timeParam.rightNs + e.data.timeParam.recordStartNs; e.data.cpuFiliterOrder.forEach((a: number) => { getBusyTime( e.data.result.filter((f: any) => f.cpu == a), diff --git a/ide/src/trace/database/TraceWorker.ts b/ide/src/trace/database/TraceWorker.ts index 4d715a4b18db6a8903e0a9bef0ef550a7ee2c70b..119d8dd7061923c9228cb622fc0d6f45a7d9556e 100644 --- a/ide/src/trace/database/TraceWorker.ts +++ b/ide/src/trace/database/TraceWorker.ts @@ -369,8 +369,7 @@ self.onmessage = async (e: MessageEvent) => { } let wrSize = 0; let r2 = -1; - let rowTraceStr = Array.from(new Uint16Array(e.data.buffer.slice(0, 2))); - if (rowTraceStr[0] === 57161) { + if (isRawTrace(e.data)) { let commonDataOffsetList: Array<{ startOffset: number; endOffset: number; @@ -1052,18 +1051,60 @@ enum FileTypeEnum { json, } +function isRawTrace(uint8Array: Uint8Array): boolean { + let rowTraceStr = Array.from(new Uint16Array(uint8Array.buffer.slice(0, 2))); + return rowTraceStr[0] === 57161; +} + function cutFileBufferByOffSet(out: Uint8Array, uint8Array: Uint8Array) { let jsonStr: string = dec.decode(out); let jsonObj = JSON.parse(jsonStr); - let valueArray: Array<{ offset: number; size: number }> = jsonObj.value; - const sum = valueArray.reduce((total, obj) => total + obj.size, 0); - let cutBuffer = new Uint8Array(sum); - let offset = 0; - valueArray.forEach((item, index) => { - const dataSlice = uint8Array.subarray(item.offset, item.offset + item.size); - cutBuffer.set(dataSlice, offset); - offset += item.size; - }); + let valueArray: Array<{ type: number; offset: number; size: number }> = jsonObj.value; + let cutBuffer: Uint8Array; + if (isRawTrace(uint8Array)) { + let commDataSize = 0; + let otherDataSize = 0; + valueArray.forEach(item => { + const type = item.type; + if (type === 0) { + commDataSize += item.size; + } else { + otherDataSize += item.size; + otherDataSize += 8; + } + }); + cutBuffer = new Uint8Array(commDataSize + otherDataSize); + let commOffset = 0; + let tlvOffset = commDataSize; + valueArray.forEach((item) => { + if (item.type !== 0) { + let typeArray = new Uint32Array(1); + typeArray[0] = item.type; + cutBuffer.set(new Uint8Array(typeArray.buffer), tlvOffset); + tlvOffset += typeArray.byteLength; + let lengthArray = new Uint32Array(1); + lengthArray[0] = item.size; + cutBuffer.set(new Uint8Array(lengthArray.buffer), tlvOffset); + tlvOffset += typeArray.byteLength; + const dataSlice = uint8Array.subarray(item.offset, item.offset + item.size); + cutBuffer.set(dataSlice, tlvOffset); + tlvOffset += item.size; + } else { + const dataSlice = uint8Array.subarray(item.offset, item.offset + item.size); + cutBuffer.set(dataSlice, commOffset); + commOffset += item.size; + } + }); + } else { + const sum = valueArray.reduce((total, obj) => total + obj.size, 0); + cutBuffer = new Uint8Array(sum); + let offset = 0; + valueArray.forEach((item, index) => { + const dataSlice = uint8Array.subarray(item.offset, item.offset + item.size); + cutBuffer.set(dataSlice, offset); + offset += item.size; + }); + } return cutBuffer; } diff --git a/ide/src/trace/database/data-trafic/AbilityMonitorReceiver.ts b/ide/src/trace/database/data-trafic/AbilityMonitorReceiver.ts index e1c39e693bf17d017f210ad3f0e915cbe56c9ad0..17c630b23cb86ca50b845496ce0769e64e1315c4 100644 --- a/ide/src/trace/database/data-trafic/AbilityMonitorReceiver.ts +++ b/ide/src/trace/database/data-trafic/AbilityMonitorReceiver.ts @@ -87,75 +87,135 @@ export const abilityPacketsOutDataSql = (args: any): string => { export const cpuAbilityMonitorDataProtoSql = (args: any): string => { return `select (t.total_load) as value, - (t.ts - ${args.recordStartNS} ) as startNs - from cpu_usage t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from cpu_usage t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const cpuAbilityUserDataProtoSql = (args: any): string => { return `select t.user_load as value, - (t.ts - ${args.recordStartNS} ) as startNs - from cpu_usage t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from cpu_usage t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const cpuAbilitySystemDataProtoSql = (args: any): string => { return `select t.system_load as value, - (t.ts - ${args.recordStartNS} ) as startNs - from cpu_usage t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from cpu_usage t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityMemoryDataProtoSql = (args: any): string => { return `select t.value as value, - (t.ts - ${args.recordStartNS} ) as startNs + (t.ts - ${args.recordStartNS} ) as startNs, + t.dur as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px from sys_mem_measure t - where t.filter_id = ${args.id}`; + where t.filter_id = ${args.id} + and startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityBytesReadDataProtoSql = (args: any): string => { return `select t.rd_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from diskio t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from diskio t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityBytesWrittenDataProtoSql = (args: any): string => { return `select t.wr_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from diskio t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from diskio t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityReadOpsDataProtoSql = (args: any): string => { return `select t.rd_count_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from diskio t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from diskio t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityWrittenOpsDataProtoSql = (args: any): string => { return `select t.wr_count_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from diskio t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from diskio t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityBytesInTraceDataProtoSql = (args: any): string => { return `select t.tx_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from network t`; + (t.ts - ${args.recordStartNS} ) as startNs, + t.dur as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from network t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityBytesOutTraceDataProtoSql = (args: any): string => { return `select t.rx_speed as value, - (t.ts - ${args.recordStartNS} ) as startNs - from network t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from network t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityPacketInDataProtoSql = (args: any): string => { return `select t.packet_in_sec as value, - (t.ts - ${args.recordStartNS} ) as startNs - from network t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from network t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; export const abilityPacketsOutDataProtoSql = (args: any): string => { return `select t.packet_out_sec as value, - (t.ts - ${args.recordStartNS} ) as startNs - from network t`; + (t.ts - ${args.recordStartNS} ) as startNs, + max(ifnull(t.dur, ${args.recordEndNS} - t.ts)) as dur, + ((t.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px + from network t + where startNs + (ifnull(dur,0)) >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px`; }; let totalList: Array = []; @@ -225,7 +285,7 @@ export function cpuAbilitySystemDataReceiver(data: any, proc: Function): void { } else { let sql = cpuAbilitySystemDataProtoSql(data.params); let res = proc(sql); - arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + cpuArrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); } } export function abilityMemoryUsedDataReceiver(data: any, proc: Function): void { diff --git a/ide/src/trace/database/data-trafic/ClockDataReceiver.ts b/ide/src/trace/database/data-trafic/ClockDataReceiver.ts index a25e2300607640b6013aac9d4a656c4c83e292a9..286a62d93d9e2189dc507d1eb6079bca0f369aa2 100644 --- a/ide/src/trace/database/data-trafic/ClockDataReceiver.ts +++ b/ide/src/trace/database/data-trafic/ClockDataReceiver.ts @@ -101,7 +101,7 @@ export function clockDataReceiver(data: any, proc: Function): void { } if (data.params.queryAll) { //框选时候取数据,只需要根据时间过滤数据 - res = (list || []).filter(it => it.startNs + it.dur >= data.params.startNS && it.startNs <= data.params.endNS); + res = (list || []).filter(it => it.startNs + it.dur >= data.params.selectStartNS && it.startNs <= data.params.selectEndNS); } else { res = filterDataByGroup(list || [], 'startNs', 'dur', data.params.startNS, data.params.endNS, data.params.width, "value"); } diff --git a/ide/src/trace/database/data-trafic/ClockDataSender.ts b/ide/src/trace/database/data-trafic/ClockDataSender.ts index ae2cd745172b4a08ba29544e68876bd81dcc014c..81eb0763ef25cb66f42a2c7e0be2d25be87fa171 100644 --- a/ide/src/trace/database/data-trafic/ClockDataSender.ts +++ b/ide/src/trace/database/data-trafic/ClockDataSender.ts @@ -38,12 +38,15 @@ export function clockDataSender( { clockName: clockName, sqlType: sqlType, - startNS: args ? args.startNS : (TraceRow.range?.startNS || 0), - endNS: args ? args.endNS : (TraceRow.range?.endNS || 0), - totalNS: args ? (args.endNS - args.startNS) : (TraceRow.range?.totalNS || 0), + startNS: (TraceRow.range?.startNS || 0), + endNS: (TraceRow.range?.endNS || 0), + totalNS: (TraceRow.range?.totalNS || 0), recordStartNS: window.recordStartNS, recordEndNS: window.recordEndNS, queryAll: args && args.queryAll, + selectStartNS: args ? args.startNS : 0, + selectEndNS: args ? args.endNS : 0, + selectTotalNS: args ? (args.endNS - args.startNS) : 0, t: Date.now(), width: width, trafic: trafic, diff --git a/ide/src/trace/database/data-trafic/CpuDataReceiver.ts b/ide/src/trace/database/data-trafic/CpuDataReceiver.ts index 84159d6ad01ed0c636d0736c49da7209ce8939c0..8e77a6f530852e2216933675b09e596d432ef75c 100644 --- a/ide/src/trace/database/data-trafic/CpuDataReceiver.ts +++ b/ide/src/trace/database/data-trafic/CpuDataReceiver.ts @@ -55,7 +55,7 @@ export function cpuDataReceiver(data: any, proc: Function): void { if (!cpuList.has(data.params.cpu)) { list = proc(chartCpuDataProtoSqlMem(data.params)); for (let i = 0; i < list.length; i++) { - if (list[i].dur == -1) { + if (list[i].dur === -1 || list[i].dur === null || list[i].dur === undefined) { list[i].nofinish = 1; if (i === list.length - 1) { list[i].dur = data.params.endNS - list[i].startTime; @@ -123,11 +123,12 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean): void { processId: processId.buffer, cpu: cpu.buffer, argSetID: argSetId.buffer, + nofinish: nofinish.buffer, } : {}, len: res.length, transfer: transfer, }, - transfer ? [startTime.buffer, dur.buffer, tid.buffer, id.buffer, processId.buffer, cpu.buffer, argSetId.buffer] : [] + transfer ? [startTime.buffer, dur.buffer, tid.buffer, id.buffer, processId.buffer, cpu.buffer, argSetId.buffer, nofinish.buffer] : [] ); } diff --git a/ide/src/trace/database/data-trafic/CpuDataSender.ts b/ide/src/trace/database/data-trafic/CpuDataSender.ts index 4b46c69d0683f20a95fcfd7289755c8e00c5005f..ff21c22aeed29641ee10682738232f9b33ed5844 100644 --- a/ide/src/trace/database/data-trafic/CpuDataSender.ts +++ b/ide/src/trace/database/data-trafic/CpuDataSender.ts @@ -79,7 +79,7 @@ function arrayBufferHandler(res: any, len: number): CpuStruct[] { dur: dur[i], startTime: startTime[i], argSetID: argSetID[i], - nofinish: nofinish[i] == 1 ? true : false + nofinish: nofinish[i] === 1 ? true : false } as CpuStruct); } return outArr; @@ -94,6 +94,7 @@ function searchArrayBufferHandler(res: any, len: number): CpuStruct[] { let tid = new Uint16Array(res.tid); let cpu = new Uint8Array(res.cpu); let argSetID = new Int8Array(res.argSetID); + let nofinish = new Uint8Array(res.nofinish); for (let i = 0; i < len; i++) { outArr.push({ processId: processId[i], @@ -104,6 +105,7 @@ function searchArrayBufferHandler(res: any, len: number): CpuStruct[] { startTime: startTime[i], type: 'cpu', argSetID: -1, + nofinish: nofinish[i] === 1 ? true : false } as CpuStruct); } return outArr; diff --git a/ide/src/trace/database/data-trafic/EnergySysEventReceiver.ts b/ide/src/trace/database/data-trafic/EnergySysEventReceiver.ts index 6ae494fecda93696b55e036af4bd086efbae4ecb..bfcee83ba93a984c7cd83d2246c28336810f865a 100644 --- a/ide/src/trace/database/data-trafic/EnergySysEventReceiver.ts +++ b/ide/src/trace/database/data-trafic/EnergySysEventReceiver.ts @@ -14,128 +14,176 @@ */ import { TraficEnum } from './utils/QueryEnum'; +import { energyList } from './utils/AllMemoryCache'; export const systemDataSql = (args: any): string => { return `SELECT S.id, - S.ts - ${args.recordStartNS} AS startNs, - D.data AS eventName, + S.ts - ${args.recordStartNS} AS startNs, + D.data AS eventName, (case when D.data == 'POWER_RUNNINGLOCK' then 1 when D.data == 'GNSS_STATE' then 2 else 0 end) AS appKey, - contents AS eventValue + contents AS eventValue, + ((S.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) as px FROM hisys_all_event AS S LEFT JOIN data_dict AS D ON S.event_name_id = D.id LEFT JOIN data_dict AS D2 ON S.domain_id = D2.id - WHERE eventName IN ('POWER_RUNNINGLOCK', 'GNSS_STATE', 'WORK_START', 'WORK_REMOVE', 'WORK_STOP', 'WORK_ADD');`; + WHERE eventName IN ('POWER_RUNNINGLOCK', 'GNSS_STATE', 'WORK_START', 'WORK_REMOVE', 'WORK_STOP', 'WORK_ADD') + and startNs >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} + group by px;`; +}; + +export const systemDataMemSql = (args: any): string => { + return `SELECT S.id, + S.ts - ${args.recordStartNS} AS startNs, + D.data AS eventName, + (case when D.data == 'POWER_RUNNINGLOCK' then '1' when D.data == 'GNSS_STATE' then '2' else '0' end) AS appKey, + contents AS eventValue + FROM hisys_all_event AS S + LEFT JOIN data_dict AS D ON S.event_name_id = D.id + LEFT JOIN data_dict AS D2 ON S.domain_id = D2.id + WHERE eventName IN + ('POWER_RUNNINGLOCK', 'GNSS_STATE', 'WORK_START', 'WORK_REMOVE', 'WORK_STOP', 'WORK_ADD');`; }; export const chartEnergyAnomalyDataSql = (args: any): string => { return ` select S.id, - S.ts - ${args.recordStartNS} as startNs, - D.data as eventName, - D2.data as appKey, + S.ts - ${args.recordStartNS} as startNs, + D.data as eventName, + D2.data as appKey, (case when S.type==1 then group_concat(S.string_value, ',') else group_concat(S.int_value, ',') end) as eventValue from hisys_event_measure as S - left join data_dict as D - on D.id=S.name_id - left join app_name as APP on APP.id=S.key_id - left join data_dict as D2 on D2.id=APP.app_key - where D.data in ('ANOMALY_SCREEN_OFF_ENERGY' - , 'ANOMALY_KERNEL_WAKELOCK' - , 'ANOMALY_CPU_HIGH_FREQUENCY' - , 'ANOMALY_WAKEUP') - or (D.data in ('ANOMALY_RUNNINGLOCK' - , 'ANORMALY_APP_ENERGY' - , 'ANOMALY_GNSS_ENERGY' - , 'ANOMALY_CPU_ENERGY' - , 'ANOMALY_ALARM_WAKEUP') - and D2.data in ('APPNAME')) + left join data_dict as D + on D.id = S.name_id + left join app_name as APP on APP.id = S.key_id + left join data_dict as D2 on D2.id = APP.app_key + where D.data in + ('ANOMALY_SCREEN_OFF_ENERGY', 'ANOMALY_KERNEL_WAKELOCK', 'ANOMALY_CPU_HIGH_FREQUENCY', 'ANOMALY_WAKEUP') + or (D.data in ('ANOMALY_RUNNINGLOCK', 'ANORMALY_APP_ENERGY', 'ANOMALY_GNSS_ENERGY', 'ANOMALY_CPU_ENERGY', + 'ANOMALY_ALARM_WAKEUP') + and D2.data in ('APPNAME')) group by S.serial, D.data`; }; export const queryPowerValueSql = (args: any): string => { return ` - SELECT - S.id, - S.ts - ${args.recordStartNS} as startNs, - D.data AS eventName, - D2.data AS appKey, - group_concat( ( CASE WHEN S.type == 1 THEN S.string_value ELSE S.int_value END ), ',' ) AS eventValue - FROM - hisys_event_measure AS S - LEFT JOIN data_dict AS D - ON D.id = S.name_id - LEFT JOIN app_name AS APP - ON APP.id = S.key_id - LEFT JOIN data_dict AS D2 - ON D2.id = APP.app_key - where - D.data in ('POWER_IDE_CPU','POWER_IDE_LOCATION','POWER_IDE_GPU','POWER_IDE_DISPLAY','POWER_IDE_CAMERA','POWER_IDE_BLUETOOTH','POWER_IDE_FLASHLIGHT','POWER_IDE_AUDIO','POWER_IDE_WIFISCAN') - and - D2.data in ('BACKGROUND_ENERGY','FOREGROUND_ENERGY','SCREEN_ON_ENERGY','SCREEN_OFF_ENERGY','ENERGY','APPNAME') - GROUP BY - S.serial, - APP.app_key, - D.data, - D2.data - ORDER BY - eventName;`; + SELECT S.id, + S.ts - ${args.recordStartNS} as startNs, + D.data AS eventName, + D2.data AS appKey, + group_concat((CASE WHEN S.type == 1 THEN S.string_value ELSE S.int_value END), ',') AS eventValue + FROM hisys_event_measure AS S + LEFT JOIN data_dict AS D + ON D.id = S.name_id + LEFT JOIN app_name AS APP + ON APP.id = S.key_id + LEFT JOIN data_dict AS D2 + ON D2.id = APP.app_key + where D.data in ('POWER_IDE_CPU', 'POWER_IDE_LOCATION', 'POWER_IDE_GPU', 'POWER_IDE_DISPLAY', 'POWER_IDE_CAMERA', + 'POWER_IDE_BLUETOOTH', 'POWER_IDE_FLASHLIGHT', 'POWER_IDE_AUDIO', 'POWER_IDE_WIFISCAN') + and D2.data in + ('BACKGROUND_ENERGY', 'FOREGROUND_ENERGY', 'SCREEN_ON_ENERGY', 'SCREEN_OFF_ENERGY', 'ENERGY', 'APPNAME') + GROUP BY S.serial, + APP.app_key, + D.data, + D2.data + ORDER BY eventName;`; }; + export const queryStateDataSql = (args: any): string => { return ` - select - S.id, - S.ts - ${args.recordStartNS} as startNs, - D.data as eventName, - D2.data as appKey, - S.int_value as eventValue + select S.id, + S.ts - ${args.recordStartNS} as startNs, + D.data as eventName, + D2.data as appKey, + S.int_value as eventValue from hisys_event_measure as S - left join data_dict as D on D.id=S.name_id - left join app_name as APP on APP.id=S.key_id - left join data_dict as D2 on D2.id=APP.app_key + left join data_dict as D on D.id = S.name_id + left join app_name as APP on APP.id = S.key_id + left join data_dict as D2 on D2.id = APP.app_key where (case when 'SENSOR_STATE'== '${args.eventName}' then D.data like '%SENSOR%' else D.data = '${args.eventName}' end) - and D2.data in ('BRIGHTNESS','STATE','VALUE','LEVEL','VOLUME','OPER_TYPE','VOLUME') - group by S.serial,APP.app_key,D.data,D2.data;`; + and D2.data in ('BRIGHTNESS', 'STATE', 'VALUE', 'LEVEL', 'VOLUME', 'OPER_TYPE', 'VOLUME') + group by S.serial, APP.app_key, D.data, D2.data;`; }; export const queryStateProtoDataSql = (args: any): string => { return ` - SELECT - S.id, - S.ts - ${args.recordStartNS} AS startNs, - D.data AS eventName, - '' AS appKey, - contents AS eventValue - FROM - hisys_all_event AS S - LEFT JOIN data_dict AS D ON S.event_name_id = D.id - LEFT JOIN data_dict AS D2 ON S.domain_id = D2.id - WHERE - eventName = ${args.eventName}`; + SELECT S.id, + S.ts - ${args.recordStartNS} AS startNs, + D.data AS eventName, + '' AS appKey, + contents AS eventValue + FROM hisys_all_event AS S + LEFT JOIN data_dict AS D ON S.event_name_id = D.id + LEFT JOIN data_dict AS D2 ON S.domain_id = D2.id + WHERE eventName = ${args.eventName}`; }; +let systemList: Array = []; +let anomalyList: Array = []; +let powerList: Array = []; + +export function resetEnergyEvent(): void { + systemList = []; + anomalyList = []; + powerList = []; +} export function energySysEventReceiver(data: any, proc: Function) { - let sql = systemDataSql(data.params); - let res = proc(sql); - systemBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + if (systemList.length === 0) { + systemList = proc(systemDataMemSql(data.params)); + } + systemBufferHandler(data, systemList, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else if (data.params.trafic === TraficEnum.ProtoBuffer) { + let sql = systemDataSql(data.params); + let res = proc(sql); + systemBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } export function hiSysEnergyAnomalyDataReceiver(data: any, proc: Function) { - let sql = chartEnergyAnomalyDataSql(data.params); - let res = proc(sql); - anomalyBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + if (anomalyList.length === 0) { + anomalyList = proc(chartEnergyAnomalyDataSql(data.params)); + } + anomalyBufferHandler(data, anomalyList, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else if (data.params.trafic === TraficEnum.ProtoBuffer) { + let sql = chartEnergyAnomalyDataSql(data.params); + let res = proc(sql); + anomalyBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } export function hiSysEnergyPowerReceiver(data: any, proc: Function): void { - let sql = queryPowerValueSql(data.params); - let res = proc(sql); - powerBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + if (powerList.length === 0) { + powerList = proc(queryPowerValueSql(data.params)); + } + powerBufferHandler(data, powerList, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else if (data.params.trafic === TraficEnum.ProtoBuffer) { + let sql = queryPowerValueSql(data.params); + let res = proc(sql); + powerBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } export function hiSysEnergyStateReceiver(data: any, proc: Function): void { - let stateDataSql = queryStateDataSql(data.params); - let stateDataRes = proc(stateDataSql); - stateBufferHandler(data, stateDataRes, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + let res: any[], list: any[]; + if (!energyList.has(data.params.eventName)) { + list = proc(queryStateDataSql(data.params)); + energyList.set(data.params.eventName, list); + } else { + list = energyList.get(data.params.eventName) || []; + } + res = list; + stateBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else if (data.params.trafic === TraficEnum.ProtoBuffer) { + let stateDataSql = queryStateDataSql(data.params); + let stateDataRes = proc(stateDataSql); + stateBufferHandler(data, stateDataRes, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } function systemBufferHandler(data: any, res: any[], transfer: boolean) { @@ -145,8 +193,14 @@ function systemBufferHandler(data: any, res: any[], transfer: boolean) { let nameIdMap: Map> = new Map(); res.forEach((it, index) => { data.params.trafic === TraficEnum.ProtoBuffer && (it = it.energyData); - let parseData = JSON.parse(it.eventValue); - it.eventValue = parseData; + let parsedData = it.eventValue; + if (typeof it.eventValue === 'string') { + try { + parsedData = JSON.parse(it.eventValue); + } catch (error) { + } + } + it.eventValue = parsedData; let beanData: any = {}; if (it.appKey === '1') { eventNameWithPowerRunninglock(beanData, it, systemDataList); @@ -175,6 +229,7 @@ function systemBufferHandler(data: any, res: any[], transfer: boolean) { }); postMessage(data, transfer, hiSysEnergy, res.length); } + function eventNameWithPowerRunninglock(beanData: any, it: any, systemDataList: Array): void { let lockCount = 0; let tokedIds: Array = []; @@ -203,6 +258,7 @@ function eventNameWithPowerRunninglock(beanData: any, it: any, systemDataList: A } } } + function eventNameWithGnssState(beanData: any, it: any, systemDataList: Array): void { let locationIndex = -1; let locationCount = 0; @@ -227,6 +283,7 @@ function eventNameWithGnssState(beanData: any, it: any, systemDataList: Array>, beanData: any, @@ -254,6 +311,7 @@ function eventNameWithWorkStart( beanData.type = 0; systemDataList.push(beanData); } + function eventNameWithWorkStop( nameIdMap: Map>, beanData: any, @@ -276,6 +334,7 @@ function eventNameWithWorkStop( } } } + function postMessage(data: any, transfer: boolean, hiSysEnergy: HiSysEnergy, len: number): void { (self as unknown as Worker).postMessage( { @@ -283,26 +342,26 @@ function postMessage(data: any, transfer: boolean, hiSysEnergy: HiSysEnergy, len action: data.action, results: transfer ? { - id: hiSysEnergy.id.buffer, - startNs: hiSysEnergy.startNs.buffer, - count: hiSysEnergy.count.buffer, - type: hiSysEnergy.type.buffer, - token: hiSysEnergy.token.buffer, - dataType: hiSysEnergy.dataType.buffer, - } + id: hiSysEnergy.id.buffer, + startNs: hiSysEnergy.startNs.buffer, + count: hiSysEnergy.count.buffer, + type: hiSysEnergy.type.buffer, + token: hiSysEnergy.token.buffer, + dataType: hiSysEnergy.dataType.buffer, + } : {}, len: len, transfer: transfer, }, transfer ? [ - hiSysEnergy.id.buffer, - hiSysEnergy.startNs.buffer, - hiSysEnergy.count.buffer, - hiSysEnergy.type.buffer, - hiSysEnergy.token.buffer, - hiSysEnergy.dataType.buffer, - ] + hiSysEnergy.id.buffer, + hiSysEnergy.startNs.buffer, + hiSysEnergy.count.buffer, + hiSysEnergy.type.buffer, + hiSysEnergy.token.buffer, + hiSysEnergy.dataType.buffer, + ] : [] ); } @@ -339,9 +398,9 @@ function anomalyBufferHandler(data: any, res: any[], transfer: boolean) { action: data.action, results: transfer ? { - id: id.buffer, - startNs: startNs.buffer, - } + id: id.buffer, + startNs: startNs.buffer, + } : {}, len: res.length, transfer: transfer, @@ -364,9 +423,9 @@ function powerBufferHandler(data: any, res: any[], transfer: boolean) { action: data.action, results: transfer ? { - id: id.buffer, - startNs: startNs.buffer, - } + id: id.buffer, + startNs: startNs.buffer, + } : {}, len: res.length, transfer: transfer, @@ -400,10 +459,10 @@ function stateBufferHandler(data: any, res: any[], transfer: boolean) { action: data.action, results: transfer ? { - id: id.buffer, - startNs: startNs.buffer, - eventValue: eventValue.buffer, - } + id: id.buffer, + startNs: startNs.buffer, + eventValue: eventValue.buffer, + } : {}, len: res.length, transfer: transfer, diff --git a/ide/src/trace/database/data-trafic/FrameDynamicEffectReceiver.ts b/ide/src/trace/database/data-trafic/FrameDynamicEffectReceiver.ts index cd52c8f1530d4e08a79291a44c5173cddf87a0a7..71fe88cafa94f0e8d865aedcb58fbe7d8657e70a 100644 --- a/ide/src/trace/database/data-trafic/FrameDynamicEffectReceiver.ts +++ b/ide/src/trace/database/data-trafic/FrameDynamicEffectReceiver.ts @@ -46,7 +46,7 @@ export const chartFrameAnimationDataProtoSql = (args: any): string => { animation AS a;`; }; -export const chartFrameDynamicDataProtoSql = (args: any): string => { +export const chartFrameDynamicDataMemSql = (args: any): string => { return ` SELECT dy.id, @@ -56,15 +56,14 @@ export const chartFrameDynamicDataProtoSql = (args: any): string => { dy.height, dy.alpha, (dy.end_time - ${args.recordStartNS}) AS ts, - dy.name as appName, - ((dy.end_time - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) AS px + dy.name as appName FROM dynamic_frame AS dy WHERE ts >= ${Math.floor(args.startNS)} and ts <= ${Math.floor(args.endNS)}`; }; -export const chartFrameSpacingDataProtoSql = (args: any): string => { +export const chartFrameSpacingDataMemSql = (args: any): string => { return ` SELECT d.id, @@ -73,13 +72,11 @@ export const chartFrameSpacingDataProtoSql = (args: any): string => { d.width AS currentFrameWidth, d.height AS currentFrameHeight, (d.end_time - ${args.recordStartNS}) AS currentTs, - d.name AS nameId, - ((d.end_time - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) AS px + d.name AS nameId FROM dynamic_frame AS d WHERE currentTs >= ${Math.floor(args.startNS)} - and currentTs <= ${Math.floor(args.endNS)} - group by px;`; + and currentTs <= ${Math.floor(args.endNS)};`; }; export function frameAnimationReceiver(data: any, proc: Function): void { @@ -175,18 +172,26 @@ class FrameAnimation { } } +let frameSpacingList: Array = []; +let frameDynamic: Array = []; +export function resetDynamicEffect(): void { + frameSpacingList = []; + frameDynamic = []; +} export function frameDynamicReceiver(data: any, proc: Function): void { - let res = proc(chartFrameDynamicDataProtoSql(data.params)); + if (frameDynamic.length === 0) { + frameDynamic = proc(chartFrameDynamicDataMemSql(data.params)); + } let transfer = data.params.trafic !== TraficEnum.SharedArrayBuffer; - let id = new Uint16Array(transfer ? res.length : data.params.sharedArrayBuffers.id); - let x = new Float32Array(transfer ? res.length : data.params.sharedArrayBuffers.x); - let y = new Float32Array(transfer ? res.length : data.params.sharedArrayBuffers.y); - let width = new Float32Array(transfer ? res.length : data.params.sharedArrayBuffers.width); - let height = new Float32Array(transfer ? res.length : data.params.sharedArrayBuffers.height); - let alpha = new Float32Array(transfer ? res.length : data.params.sharedArrayBuffers.alpha); - let ts = new Float64Array(transfer ? res.length : data.params.sharedArrayBuffers.ts); - for (let index: number = 0; index < res.length; index++) { - let itemData = res[index]; + let id = new Uint16Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.id); + let x = new Float32Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.x); + let y = new Float32Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.y); + let width = new Float32Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.width); + let height = new Float32Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.height); + let alpha = new Float32Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.alpha); + let ts = new Float64Array(transfer ? frameDynamic.length : data.params.sharedArrayBuffers.ts); + for (let index: number = 0; index < frameDynamic.length; index++) { + let itemData = frameDynamic[index]; data.params.trafic === TraficEnum.ProtoBuffer && (itemData = itemData.frameDynamicData); id[index] = itemData.id; x[index] = Number(itemData.x); @@ -211,20 +216,21 @@ export function frameDynamicReceiver(data: any, proc: Function): void { ts: ts.buffer, } : {}, - len: res.length, + len: frameDynamic.length, transfer: transfer, }, transfer ? [id.buffer, x.buffer, y.buffer, width.buffer, height.buffer, alpha.buffer, ts.buffer] : [] ); } - export function frameSpacingReceiver(data: any, proc: Function): void { - let res = proc(chartFrameSpacingDataProtoSql(data.params)); + if (frameSpacingList.length === 0) { + frameSpacingList = proc(chartFrameSpacingDataMemSql(data.params)); + } let transfer = data.params.trafic !== TraficEnum.SharedArrayBuffer; - let frameSpacing = new FrameSpacing(data, res.length, transfer); + let frameSpacing = new FrameSpacing(data, frameSpacingList, transfer); let nameDataMap: Map> = new Map(); - for (let index: number = 0; index < res.length; index++) { - let itemData = res[index]; + for (let index: number = 0; index < frameSpacingList.length; index++) { + let itemData = frameSpacingList[index]; data.params.trafic === TraficEnum.ProtoBuffer && (itemData = itemData.frameSpacingData); if (nameDataMap.has(itemData.nameId)) { setSpacingStructs(nameDataMap, itemData, data); @@ -244,7 +250,7 @@ export function frameSpacingReceiver(data: any, proc: Function): void { frameSpacing.preX[index] = Number(itemData.preX); frameSpacing.preY[index] = Number(itemData.preY); } - postFrameSpacingMessage(data, transfer, frameSpacing, res.length); + postFrameSpacingMessage(data, transfer, frameSpacing, frameSpacingList.length); } function postFrameSpacingMessage(data: any, transfer: boolean, frameSpacing: FrameSpacing, len: number) { (self as unknown as Worker).postMessage( diff --git a/ide/src/trace/database/data-trafic/FrameDynamicEffectSender.ts b/ide/src/trace/database/data-trafic/FrameDynamicEffectSender.ts index 5fb769fbd77af11b85ad2beb7137a3c44969d9ff..3b62caf4c3761188b253803cfba150ef478efe3e 100644 --- a/ide/src/trace/database/data-trafic/FrameDynamicEffectSender.ts +++ b/ide/src/trace/database/data-trafic/FrameDynamicEffectSender.ts @@ -73,7 +73,7 @@ function animationBufferHandler(res: any, len: number): any[] { } export function frameDynamicSender(row: TraceRow): Promise { - let transferDynamicDataType: number = TraficEnum.ProtoBuffer; + let transferDynamicDataType: number = TraficEnum.Memory; let width = row.clientWidth - CHART_OFFSET_LEFT; if (transferDynamicDataType === TraficEnum.SharedArrayBuffer && !row.sharedArrayBuffers) { row.sharedArrayBuffers = { @@ -134,7 +134,7 @@ export function frameSpacingSender( physicalHeight: number, row: TraceRow ): Promise { - let transferSpacingDataType: number = TraficEnum.ProtoBuffer; + let transferSpacingDataType: number = TraficEnum.Memory; let width = row.clientWidth - CHART_OFFSET_LEFT; if (transferSpacingDataType === TraficEnum.SharedArrayBuffer && !row.sharedArrayBuffers) { row.sharedArrayBuffers = { @@ -196,7 +196,7 @@ function spacingBufferHandler(res: any, len: number): any[] { currentFrameWidth: currentFrameWidth[index], currentFrameHeight: currentFrameHeight[index], currentTs: currentTs[index], - frameSpacingResult: frameSpacingResult[index], + frameSpacingResult: frameSpacingResult[index].toFixed(1), preTs: preTs[index], preFrameWidth: preFrameWidth[index], preFrameHeight: preFrameHeight[index], diff --git a/ide/src/trace/database/data-trafic/FrameJanksReceiver.ts b/ide/src/trace/database/data-trafic/FrameJanksReceiver.ts index 116ccc2814ff3abb9fd22d9908ccb06873a96fd1..b3941f9ad1d6ab40bd522e3403fd050f90ca2143 100644 --- a/ide/src/trace/database/data-trafic/FrameJanksReceiver.ts +++ b/ide/src/trace/database/data-trafic/FrameJanksReceiver.ts @@ -13,6 +13,7 @@ import { TraficEnum } from './utils/QueryEnum'; import { JanksStruct } from '../../bean/JanksStruct'; +import { processFrameList } from './utils/AllMemoryCache'; export const frameJankDataSql = (args: any, configure: any): string => { let timeLimit: string = ''; @@ -94,14 +95,14 @@ function setFrameJanksSql(args: any, timeLimit: string, flag: string, fsType: nu ${fsFlag} ${timeLimit} ORDER by ts`; } -let frameDepthList: Map = new Map(); export function frameExpectedReceiver(data: any, proc: Function): void { if (data.params.trafic === TraficEnum.Memory) { - frameDepthList = new Map(); - let sql = frameJankDataSql(data.params, 'ExepectMemory'); - let res = proc(sql); - frameJanksReceiver(data, res, 'expect', true); + if (!processFrameList.has(`FrameTimeLine_expected`)) { + let sql = frameJankDataSql(data.params, 'ExepectMemory'); + processFrameList.set(`FrameTimeLine_expected`, proc(sql)); + } + frameJanksReceiver(data, processFrameList.get(`FrameTimeLine_expected`)!, 'expected', true); } else { let sql = frameJankDataSql(data.params, 'ExpectedData'); let res = proc(sql); @@ -111,9 +112,11 @@ export function frameExpectedReceiver(data: any, proc: Function): void { export function frameActualReceiver(data: any, proc: Function): void { if (data.params.trafic === TraficEnum.Memory) { - let sql = frameJankDataSql(data.params, 'ActualMemoryData'); - let res = proc(sql); - frameJanksReceiver(data, res, 'actual', true); + if (!processFrameList.has(`FrameTimeLine_actual`)) { + let sql = frameJankDataSql(data.params, 'ActualMemoryData'); + processFrameList.set(`FrameTimeLine_actual`, proc(sql)); + } + frameJanksReceiver(data, processFrameList.get(`FrameTimeLine_actual`)!, 'actual', true); } else { let sql = frameJankDataSql(data.params, 'ActualData'); let res = proc(sql); @@ -125,48 +128,36 @@ let isIntersect = (leftData: JanksStruct, rightData: JanksStruct): boolean => leftData.dur! + rightData.dur!; function frameJanksReceiver(data: any, res: any[], type: string, transfer: boolean): void { let frameJanks = new FrameJanks(data, transfer, res.length); - if (data.params.trafic === TraficEnum.Memory) { - let unitIndex: number = 1; - let depths: any[] = []; - for (let index = 0; index < res.length; index++) { - let item = res[index]; - data.params.trafic === TraficEnum.ProtoBuffer && (item = item.frameData); - if (!item.dur || item.dur < 0) { - continue; - } - if (depths.length === 0) { - item.depth = 0; - depths[0] = item; - } else { - let depthIndex: number = 0; - let isContinue: boolean = true; - while (isContinue) { - if (isIntersect(depths[depthIndex], item)) { - if (depths[depthIndex + unitIndex] === undefined || !depths[depthIndex + unitIndex]) { - item.depth = depthIndex + unitIndex; - depths[depthIndex + unitIndex] = item; - isContinue = false; - } - } else { - item.depth = depthIndex; - depths[depthIndex] = item; + let unitIndex: number = 1; + let depths: any[] = []; + for (let index = 0; index < res.length; index++) { + let item = res[index]; + data.params.trafic === TraficEnum.ProtoBuffer && (item = item.frameData); + if (!item.dur || item.dur < 0) { + continue; + } + if (depths.length === 0) { + item.depth = 0; + depths[0] = item; + } else { + let depthIndex: number = 0; + let isContinue: boolean = true; + while (isContinue) { + if (isIntersect(depths[depthIndex], item)) { + if (depths[depthIndex + unitIndex] === undefined || !depths[depthIndex + unitIndex]) { + item.depth = depthIndex + unitIndex; + depths[depthIndex + unitIndex] = item; isContinue = false; } - depthIndex++; + } else { + item.depth = depthIndex; + depths[depthIndex] = item; + isContinue = false; } - } - setFrameJanks(frameJanks, item, index); - frameDepthList.set(`${type}_${item.id}_${item.ipid}_${item.name}`, item.depth); - } - } else { - for (let index = 0; index < res.length; index++) { - let itemData = res[index]; - data.params.trafic === TraficEnum.ProtoBuffer && (itemData = itemData.frameData); - setFrameJanks(frameJanks, itemData, index); - if (frameDepthList.has(`${type}_${itemData.id}_${itemData.ipid}_${itemData.name}`)) { - frameJanks.depth[index] = frameDepthList.get(`${type}_${itemData.id}_${itemData.ipid}_${itemData.name}`)!; + depthIndex++; } } + setFrameJanks(frameJanks, item, index); } postFrameJanksMessage(data, transfer, frameJanks, res.length); } diff --git a/ide/src/trace/database/data-trafic/FrameJanksSender.ts b/ide/src/trace/database/data-trafic/FrameJanksSender.ts index 5c5fa005317f9cbd84f9c87f48ac01d41d42c28d..93fbf84e1acc3ff86a378faf3d81bed88a9eefd0 100644 --- a/ide/src/trace/database/data-trafic/FrameJanksSender.ts +++ b/ide/src/trace/database/data-trafic/FrameJanksSender.ts @@ -18,9 +18,6 @@ import { JanksStruct } from '../../bean/JanksStruct'; export function frameJanksSender(queryEnum: number, row: TraceRow): Promise { let transferJankDataType: number = TraficEnum.Memory; - if (row.isComplete) { - transferJankDataType = TraficEnum.ProtoBuffer; - } let width = row.clientWidth - CHART_OFFSET_LEFT; if ((transferJankDataType === TraficEnum.SharedArrayBuffer) && !row.sharedArrayBuffers) { row.sharedArrayBuffers = { diff --git a/ide/src/trace/database/data-trafic/HiSysEventDataReceiver.ts b/ide/src/trace/database/data-trafic/HiSysEventDataReceiver.ts index 8346700b0c82da39f35d9e03181770dc182ea615..de8175b972e9fe0fa7476d48917b17490d37cf41 100644 --- a/ide/src/trace/database/data-trafic/HiSysEventDataReceiver.ts +++ b/ide/src/trace/database/data-trafic/HiSysEventDataReceiver.ts @@ -13,36 +13,70 @@ * limitations under the License. */ import { TraficEnum } from './utils/QueryEnum'; +import { hiSysEventList } from './utils/AllMemoryCache'; +import { filterDataByGroupLayer } from './utils/DataFilter'; export const chartHiSysEventDataSql = (args: any): string => { return ` SELECT S.id, - (S.ts - ${args.recordStartNS}) AS startNs, - pid, - tid, - uid, - seq, - CASE - WHEN S.level = 'MINOR' THEN 0 - WHEN S.level = 'CRITICAL' THEN 1 - END - AS depth, - 1 AS dur, - ((S.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) + (CASE - WHEN S.level = 'MINOR' THEN 0 - WHEN S.level = 'CRITICAL' THEN 1 - END * ${args.width}) AS px + (S.ts - ${args.recordStartNS}) AS startNs, + pid, + tid, + uid, + seq, + CASE + WHEN S.level = 'MINOR' THEN 0 + WHEN S.level = 'CRITICAL' THEN 1 + END + AS depth, + 1 AS dur, + ((S.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) + (CASE + WHEN S.level = 'MINOR' + THEN 0 + WHEN S.level = 'CRITICAL' + THEN 1 + END * + ${args.width}) AS px FROM hisys_all_event AS S where S.id is not null - and startNs + dur >= ${Math.floor(args.startNS)} - and startNs <= ${Math.floor(args.endNS)} + and startNs + dur >= ${Math.floor(args.startNS)} + and startNs <= ${Math.floor(args.endNS)} group by px`; }; +export const chartHiSysEventSql = (args: any): string => { + return ` + SELECT S.id, + (S.ts - ${args.recordStartNS}) AS startNs, + pid, + tid, + uid, + seq, + CASE + WHEN S.level = 'MINOR' THEN 0 + WHEN S.level = 'CRITICAL' THEN 1 + END + AS depth, + 1 AS dur + FROM hisys_all_event AS S + where S.id is not null + ORDER BY S.id`; +}; + export function hiSysEventDataReceiver(data: any, proc: Function) { - let sql = chartHiSysEventDataSql(data.params); - let res = proc(sql); - arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + if (!hiSysEventList.has(data.params.id)) { + let sql = chartHiSysEventSql(data.params); + hiSysEventList.set(data.params.id, proc(sql)); + } + let list = hiSysEventList.get(data.params.id) || []; + let res = filterDataByGroupLayer(list || [], 'depth','startNs', 'dur', data.params.startNS, data.params.endNS, data.params.width); + arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else { + let sql = chartHiSysEventDataSql(data.params); + let res = proc(sql); + arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } function arrayBufferHandler(data: any, res: any[], transfer: boolean) { @@ -58,7 +92,7 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean) { data.params.trafic === TraficEnum.ProtoBuffer && (it = it.hiSysEventData); uid[index] = it.uid; id[index] = it.id; - ts[index] = it.ts; + ts[index] = it.startNs || it.ts; pid[index] = it.pid; tid[index] = it.tid; seq[index] = it.seq; @@ -71,15 +105,15 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean) { action: data.action, results: transfer ? { - uid: uid.buffer, - id: id.buffer, - ts: ts.buffer, - pid: pid.buffer, - tid: tid.buffer, - seq: seq.buffer, - dur: dur.buffer, - depth: depth.buffer, - } + uid: uid.buffer, + id: id.buffer, + ts: ts.buffer, + pid: pid.buffer, + tid: tid.buffer, + seq: seq.buffer, + dur: dur.buffer, + depth: depth.buffer, + } : {}, len: res.length, transfer: transfer, diff --git a/ide/src/trace/database/data-trafic/LogDataReceiver.ts b/ide/src/trace/database/data-trafic/LogDataReceiver.ts index 41206a17ad058c0b8f5ebc5419d704d9b268813c..1edee3527b008d3d042bf97950b62cde7d06f8b3 100644 --- a/ide/src/trace/database/data-trafic/LogDataReceiver.ts +++ b/ide/src/trace/database/data-trafic/LogDataReceiver.ts @@ -13,51 +13,83 @@ * limitations under the License. */ import { TraficEnum } from './utils/QueryEnum'; +import { hiLogList } from './utils/AllMemoryCache'; +import { filterDataByGroupLayer } from './utils/DataFilter'; export const chartLogDataSql = (args: any): string => { - return `SELECT - l.seq AS id, - l.pid, - l.tid, - CASE - WHEN l.ts < ${args.oneDayTime} THEN 0 - ELSE (l.ts - ${args.recordStartNS}) - END AS startTs, - CASE - WHEN l.level = 'D' THEN 0 - WHEN l.level = 'I' THEN 1 - WHEN l.level = 'W' THEN 2 - WHEN l.level = 'E' THEN 3 - WHEN l.level = 'F' THEN 4 - END AS depth, - 1 AS dur, - ((l.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) + - CASE - WHEN l.level = 'D' THEN 0 - WHEN l.level = 'I' THEN 1 - WHEN l.level = 'W' THEN 2 - WHEN l.level = 'E' THEN 3 - WHEN l.level = 'F' THEN 4 - END * ${args.width} AS px - FROM - (SELECT DISTINCT seq FROM log) AS inner_log - JOIN log AS l ON l.seq = inner_log.seq - WHERE - (CASE - WHEN l.ts < ${args.oneDayTime} THEN 0 - ELSE (l.ts - ${args.recordStartNS}) - END) + 1 >= ${Math.floor(args.startNS)} + return `SELECT l.seq AS id, + l.pid, + l.tid, + CASE + WHEN l.ts < ${args.oneDayTime} THEN 0 + ELSE (l.ts - ${args.recordStartNS}) + END AS startTs, + CASE + WHEN l.level = 'D' THEN 0 + WHEN l.level = 'I' THEN 1 + WHEN l.level = 'W' THEN 2 + WHEN l.level = 'E' THEN 3 + WHEN l.level = 'F' THEN 4 + END AS depth, + 1 AS dur, + ((l.ts - ${args.recordStartNS}) / (${Math.floor((args.endNS - args.startNS) / args.width)})) + + CASE + WHEN l.level = 'D' THEN 0 + WHEN l.level = 'I' THEN 1 + WHEN l.level = 'W' THEN 2 + WHEN l.level = 'E' THEN 3 + WHEN l.level = 'F' THEN 4 + END * ${args.width} AS px + FROM (SELECT DISTINCT seq FROM log) AS inner_log + JOIN log AS l ON l.seq = inner_log.seq + WHERE (CASE + WHEN l.ts < ${args.oneDayTime} THEN 0 + ELSE (l.ts - ${args.recordStartNS}) + END) + 1 >= ${Math.floor(args.startNS)} AND (CASE WHEN l.ts < ${args.oneDayTime} THEN 0 ELSE (l.ts - ${args.recordStartNS}) END) <= ${Math.floor(args.endNS)} GROUP BY px`; }; + +export const chartLogDataMemorySql = (args: any): string => { + return `SELECT l.seq AS id, + l.pid, + l.tid, + CASE + WHEN l.ts < ${args.oneDayTime} THEN 0 + ELSE (l.ts - ${args.recordStartNS}) + END AS startTs, + CASE + WHEN l.level = 'D' THEN 0 + WHEN l.level = 'I' THEN 1 + WHEN l.level = 'W' THEN 2 + WHEN l.level = 'E' THEN 3 + WHEN l.level = 'F' THEN 4 + END AS depth, + 1 AS dur + FROM (SELECT DISTINCT seq FROM log) AS inner_log + JOIN log AS l ON l.seq = inner_log.seq + ORDER BY l.seq`; +}; + export function logDataReceiver(data: any, proc: Function) { - let sql = chartLogDataSql(data.params); - let res = proc(sql); - arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + if (data.params.trafic === TraficEnum.Memory) { + if (!hiLogList.has(data.params.id)) { + let sql = chartLogDataMemorySql(data.params); + hiLogList.set(data.params.id, proc(sql)); + } + let list = hiLogList.get(data.params.id) || []; + let res = filterDataByGroupLayer(list || [], 'depth','startTs', 'dur', data.params.startNS, data.params.endNS, data.params.width); + arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } else { + let sql = chartLogDataSql(data.params); + let res = proc(sql); + arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); + } } + function arrayBufferHandler(data: any, res: any[], transfer: boolean) { let id = new Uint16Array(transfer ? res.length : data.params.sharedArrayBuffers.id); let startTs = new Float64Array(transfer ? res.length : data.params.sharedArrayBuffers.startTs); @@ -81,13 +113,13 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean) { action: data.action, results: transfer ? { - id: id.buffer, - startTs: startTs.buffer, - pid: pid.buffer, - tid: tid.buffer, - dur: dur.buffer, - depth: depth.buffer, - } + id: id.buffer, + startTs: startTs.buffer, + pid: pid.buffer, + tid: tid.buffer, + dur: dur.buffer, + depth: depth.buffer, + } : {}, len: res.length, transfer: transfer, diff --git a/ide/src/trace/database/data-trafic/LostFrameReceiver.ts b/ide/src/trace/database/data-trafic/LostFrameReceiver.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2a9d4ac956c58c3195c2610dadc80dde6ab1916 --- /dev/null +++ b/ide/src/trace/database/data-trafic/LostFrameReceiver.ts @@ -0,0 +1,59 @@ +// Copyright (c) 2021 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 {TraficEnum} from './utils/QueryEnum'; + +export const queryPresentInfo = (args: any): string => { + return `SELECT ts,dur,name FROM callstack WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('${args.threadName}')) + AND name LIKE('${args.funcName}')` +} + +export function lostFrameReceiver (data: any, proc: Function) :void { + let sql = queryPresentInfo(data.params); + let res = proc(sql); + arrayBufferHandler(data, res, data.params.trafic !== TraficEnum.SharedArrayBuffer); +} + +function arrayBufferHandler(data: any, res: any[], transfer: boolean): void { + let startTime = new Float64Array(transfer ? res.length : data.params.sharedArrayBuffers.startTime); + let dur = new Float64Array(transfer ? res.length : data.params.sharedArrayBuffers.dur); + let argSetId = new Uint8Array(transfer ? res.length : data.params.sharedArrayBuffers.argSetId); + let nofinish = new Uint8Array(transfer ? res.length : data.params.sharedArrayBuffers.nofinish); + let presentId = new Float64Array(transfer ? res.length : data.params.sharedArrayBuffers.presentId); + res.forEach((it, i) => { + let nameCutArr = it.name.split(' '); + data.params.trafic === TraficEnum.ProtoBuffer && (it = it.cpuData); + startTime[i] = it.ts; + dur[i] = it.dur; + nofinish[i] = it.nofinish; + argSetId[i] = it.argSetId; + presentId[i] = Number(nameCutArr[nameCutArr.length-1]); + }); + (self as unknown as Worker).postMessage( + { + id: data.id, + action: data.action, + results: transfer + ? { + startTime: startTime.buffer, + dur: dur.buffer, + argSetID: argSetId.buffer, + presentId: presentId.buffer, + } + : {}, + len: res.length, + transfer: transfer, + }, + transfer ? [startTime.buffer, dur.buffer, argSetId.buffer] : [] + ); +} diff --git a/ide/src/trace/database/data-trafic/LostFrameSender.ts b/ide/src/trace/database/data-trafic/LostFrameSender.ts new file mode 100644 index 0000000000000000000000000000000000000000..fabdab2d675a9f9baa80609d888534c05b921a47 --- /dev/null +++ b/ide/src/trace/database/data-trafic/LostFrameSender.ts @@ -0,0 +1,61 @@ +// Copyright (c) 2021 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 { type LtpoStruct } from '../../database/ui-worker/ProcedureWorkerLTPO' +import { CHART_OFFSET_LEFT, MAX_COUNT, QueryEnum, TraficEnum } from './utils/QueryEnum'; +import { threadPool } from '../SqlLite'; +import { TraceRow } from '../../component/trace/base/TraceRow'; + +export function lostFrameSender(tName: String, fName: String, row: TraceRow): Promise { + let trafic: number = TraficEnum.Memory; + let width = row.clientWidth - CHART_OFFSET_LEFT; + if ((trafic === TraficEnum.SharedArrayBuffer || trafic === TraficEnum.Memory) && !row.sharedArrayBuffers) { + row.sharedArrayBuffers = { + dur: new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * MAX_COUNT), + startTime: new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * MAX_COUNT), + presentId: new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * MAX_COUNT), + }; + } + return new Promise((resolve): void => { + threadPool.submitProto(QueryEnum.LostFrameData, { + threadName: tName, + funcName: fName, + startNS: TraceRow.range?.startNS || 0, + endNS: TraceRow.range?.endNS || 0, + recordStartNS: window.recordStartNS, + recordEndNS: window.recordEndNS, + width: width, + trafic: trafic, + sharedArrayBuffers: row.sharedArrayBuffers, + }, (res: any, len: number, transfer: boolean): void => { + resolve(arrayBufferHandler(transfer ? res : row.sharedArrayBuffers, len)); + }); + }); +} + +function arrayBufferHandler(res: any, len: number): LtpoStruct[] { + let outArr: LtpoStruct[] = []; + let startTime = new Float64Array(res.startTime); + let dur = new Float64Array(res.dur); + let id = new Uint16Array(res.id); + let presentId = new Float64Array(res.presentId); + for (let i = 0; i < len; i++) { + outArr.push({ + id: id[i], + dur: dur[i], + startTime: startTime[i], + presentId: presentId[i], + } as unknown as LtpoStruct); + } + return outArr; +} diff --git a/ide/src/trace/database/data-trafic/cpu/CpuStateReceiver.ts b/ide/src/trace/database/data-trafic/cpu/CpuStateReceiver.ts index 91dd37b18841f240b47ddc88a033d570cca4c787..56bde12dcecf0572971b5e8917e2b05b6d62a1e2 100644 --- a/ide/src/trace/database/data-trafic/cpu/CpuStateReceiver.ts +++ b/ide/src/trace/database/data-trafic/cpu/CpuStateReceiver.ts @@ -56,7 +56,7 @@ export function cpuStateReceiver(data: any, proc: Function): void { if (!cpuStateList.has(data.params.filterId)) { list = proc(chartCpuStateDataSqlMem(data.params)); for (let i = 0; i < list.length; i++) { - if (list[i].dur===-1 || list[i].dur===null || list[i].dur === undefined){ + if (list[i].dur === -1 || list[i].dur === null || list[i].dur === undefined){ list[i].dur = data.params.recordEndNS - data.params.recordStartNS - list[i].startTs; } } diff --git a/ide/src/trace/database/data-trafic/hiperf/HiperfProcessDataSender.ts b/ide/src/trace/database/data-trafic/hiperf/HiperfProcessDataSender.ts index efbfdb7af7f3b34f8257ae120f8ba3fc8d7cdb26..249377c3bef1db53891a39e896ea9a0996b3cc40 100644 --- a/ide/src/trace/database/data-trafic/hiperf/HiperfProcessDataSender.ts +++ b/ide/src/trace/database/data-trafic/hiperf/HiperfProcessDataSender.ts @@ -14,12 +14,12 @@ import { TraceRow } from '../../../component/trace/base/TraceRow'; import { CHART_OFFSET_LEFT, MAX_COUNT, QueryEnum, TraficEnum } from '../utils/QueryEnum'; import { threadPool } from '../../SqlLite'; -import { HiPerfCpuStruct } from '../../ui-worker/hiperf/ProcedureWorkerHiPerfCPU2'; import { HiPerfProcessStruct } from '../../ui-worker/hiperf/ProcedureWorkerHiPerfProcess2'; export function hiperfProcessDataSender( pid: number, drawType: number, + maxCpu: number, intervalPerf: number, scale: number, row: TraceRow @@ -49,7 +49,7 @@ export function hiperfProcessDataSender( trafic: trafic, sharedArrayBuffers: row.sharedArrayBuffers, pid: pid, - maxCpuCount: -1, + maxCpuCount: maxCpu, scale: scale, drawType: drawType, }, diff --git a/ide/src/trace/database/data-trafic/hiperf/HiperfThreadDataSender.ts b/ide/src/trace/database/data-trafic/hiperf/HiperfThreadDataSender.ts index b329bf177134ad21a2432541022eace2140f3fa5..5fbd3b12829c5c51f95388ad50a85a20ee132284 100644 --- a/ide/src/trace/database/data-trafic/hiperf/HiperfThreadDataSender.ts +++ b/ide/src/trace/database/data-trafic/hiperf/HiperfThreadDataSender.ts @@ -19,6 +19,7 @@ import { HiPerfThreadStruct } from '../../ui-worker/hiperf/ProcedureWorkerHiPerf export function hiperfThreadDataSender( tid: number, drawType: number, + maxCpu: number, intervalPerf: number, scale: number, row: TraceRow @@ -50,7 +51,7 @@ export function hiperfThreadDataSender( trafic: trafic, sharedArrayBuffers: row.sharedArrayBuffers, tid: tid, - maxCpuCount: -1, + maxCpuCount: maxCpu, }, (res: any, len: number, transfer: boolean): void => { resolve(arrayBufferHandler(transfer ? res : row.sharedArrayBuffers, len)); diff --git a/ide/src/trace/database/data-trafic/process/FuncDataReceiver.ts b/ide/src/trace/database/data-trafic/process/FuncDataReceiver.ts index 5cd2ce12f6a2bcc9c9d8ec8d37f2b6db8de1557e..f91f3dc57d532951e6fee092fe587ebe20b09e7d 100644 --- a/ide/src/trace/database/data-trafic/process/FuncDataReceiver.ts +++ b/ide/src/trace/database/data-trafic/process/FuncDataReceiver.ts @@ -29,7 +29,7 @@ export const chartFuncDataSql = (args: any):string => { from ( select c.ts - ${args.recordStartNS} as startTs, c.dur as dur, - case when (c.dur=-1 ) then ${args.recordEndNS} else c.dur end as dur2, + case when (c.dur=-1 or c.dur is null ) then ${args.recordEndNS} else c.dur end as dur2, c.argsetid, c.depth, c.id as id @@ -65,7 +65,7 @@ export function funcDataReceiver(data: any, proc: Function):void { if (!threadCallStackList.has(key)) { let list = proc(chartFuncDataSqlMem(data.params)); for (let i = 0; i < list.length; i++) { - if (list[i].dur == -1) { + if (list[i].dur === -1 || list[i].dur === null || list[i].dur === undefined) { list[i].nofinish = 1; list[i].dur = data.params.endNS - list[i].startTs; } else { @@ -80,7 +80,7 @@ export function funcDataReceiver(data: any, proc: Function):void { 'depth', 'startTs', 'dur', data.params.startNS, data.params.endNS, data.params.width); - arrayBufferHandler(data, res, true,array.length===0); + arrayBufferHandler(data, res, true,array.length === 0); } else { let sql = chartFuncDataSql(data.params); let res = proc(sql); @@ -94,6 +94,7 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean,isEmpty:boo let argsetid = new Int32Array(transfer ? res.length : data.params.sharedArrayBuffers.argsetid); let depth = new Int32Array(transfer ? res.length : data.params.sharedArrayBuffers.depth); let id = new Int32Array(transfer ? res.length : data.params.sharedArrayBuffers.id); + let nofinish = new Uint8Array(transfer ? res.length : data.params.sharedArrayBuffers.nofinish); res.forEach((it, i) => { data.params.trafic === TraficEnum.ProtoBuffer && (it = it.processFuncData); startTs[i] = it.startTs; @@ -101,6 +102,7 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean,isEmpty:boo argsetid[i] = it.argsetid; depth[i] = it.depth; id[i] = it.id; + nofinish[i] = it.nofinish; }); (self as unknown as Worker).postMessage( { @@ -113,12 +115,13 @@ function arrayBufferHandler(data: any, res: any[], transfer: boolean,isEmpty:boo argsetid: argsetid.buffer, depth: depth.buffer, id: id.buffer, + nofinish: nofinish.buffer } : {}, len: res.length, transfer: transfer, isEmpty:isEmpty, }, - transfer ? [startTs.buffer, dur.buffer, argsetid.buffer, depth.buffer, id.buffer] : [] + transfer ? [startTs.buffer, dur.buffer, argsetid.buffer, depth.buffer, id.buffer, nofinish.buffer] : [] ); } diff --git a/ide/src/trace/database/data-trafic/process/FuncDataSender.ts b/ide/src/trace/database/data-trafic/process/FuncDataSender.ts index 63a474cd5a16d6c19bff3dd4f400232059e9cb9b..606dbd5039ed9fdb4570e13f5732cc7925d5e216 100644 --- a/ide/src/trace/database/data-trafic/process/FuncDataSender.ts +++ b/ide/src/trace/database/data-trafic/process/FuncDataSender.ts @@ -26,6 +26,7 @@ export function funcDataSender(tid: number, ipid: number, row: TraceRow { @@ -54,12 +55,13 @@ export function funcDataSender(tid: number, ipid: number, row: TraceRow> = new Map(); //clock 泳道 memory 模式缓存 @@ -30,6 +32,10 @@ export const cpuStateList: Map> = new Map(); export const threadCallStackList: Map> = new Map(); //irq 泳道图 memory 模式缓存 export const lrqList: Map> = new Map(); +//Lost Frame 泳道图 memory 模式缓存 +export const lostFrameList: Map> = new Map(); +//Hitch Time 泳道图 memory 模式缓存 +export const hitchTimeList: Map> = new Map(); //进程 泳道图 memory 模式缓存 export const processList: Map> = new Map(); //进程内存 泳道图 memory 模式缓存数据 @@ -38,6 +44,13 @@ export const memList: Map> = new Map(); export const threadStateList: Map> = new Map(); //进程下卡顿丢帧 泳道图 memory 模式缓存 export const processFrameList: Map> = new Map(); +//hiSysEvent 泳道图 memory 模式缓存 +export const hiSysEventList: Map> = new Map(); +//hiLog 泳道图 memory 模式缓存 +export const hiLogList: Map> = new Map(); + +//energy 泳道图 memory 模式缓存 +export const energyList: Map> = new Map(); export function clearMemoryCache(data: any, proc: Function) { cpuList.clear(); clockList.clear(); @@ -50,12 +63,19 @@ export function clearMemoryCache(data: any, proc: Function) { memList.clear(); threadStateList.clear(); processFrameList.clear(); + lostFrameList.clear(); + hitchTimeList.clear(); + hiSysEventList.clear(); + hiLogList.clear(); + energyList.clear(); hiPerfCallChartClearCache(true); nativeMemoryCacheClear(); resetVmTracker(); resetAbilityMonitor(); resetAbility(); resetVM(); + resetDynamicEffect(); + resetEnergyEvent(); (self as unknown as Worker).postMessage( { id: data.id, diff --git a/ide/src/trace/database/data-trafic/utils/DataFilter.ts b/ide/src/trace/database/data-trafic/utils/DataFilter.ts index 6d81bc4630f4bfbb645b1ca4e449713af64dfe9c..8eceab24811ff2ff951e98223b5c0b3fcb46ca8d 100644 --- a/ide/src/trace/database/data-trafic/utils/DataFilter.ts +++ b/ide/src/trace/database/data-trafic/utils/DataFilter.ts @@ -146,7 +146,7 @@ export function filterDataByGroupLayer( arr = arr.map((it) => { it.px = Math.floor(it[startKey] / ((endNS - startNS) / width) + it[layerKey] * width); //设置临时变量durTmp 用于参与计算,分组后有dur为-1的数据按最长宽度显示 - it.durTmp = it[durKey] === -1 ? (endNS - it[startKey]) : it[durKey]; + it.durTmp = (it[durKey] === -1 || it[durKey] === null || it[durKey] === undefined) ? (endNS - it[startKey]) : it[durKey]; return it; }); let group = groupBy(arr, 'px'); diff --git a/ide/src/trace/database/data-trafic/utils/ExecProtoForWorker.ts b/ide/src/trace/database/data-trafic/utils/ExecProtoForWorker.ts index 2ba5537b4b4e37c89ffcb011653689e5773f423e..649f53f013b98b1516fa12e5a691b6062e844ac5 100644 --- a/ide/src/trace/database/data-trafic/utils/ExecProtoForWorker.ts +++ b/ide/src/trace/database/data-trafic/utils/ExecProtoForWorker.ts @@ -76,6 +76,8 @@ import { } from '../EnergySysEventReceiver'; import {clearMemoryCache} from "./AllMemoryCache"; import { cpuFreqDataReceiver } from '../cpu/CpuFreqDataReceiver'; +import { lostFrameReceiver } from './../LostFrameReceiver' + const traficHandlers: Map = new Map([]); export const execProtoForWorker = (data: any, proc: Function): void => traficHandlers.get(data.name)?.(data, proc); @@ -144,3 +146,4 @@ traficHandlers.set(QueryEnum.FrameAnimationData, frameAnimationReceiver); traficHandlers.set(QueryEnum.FrameDynamicData, frameDynamicReceiver); traficHandlers.set(QueryEnum.FrameSpacingData, frameSpacingReceiver); traficHandlers.set(QueryEnum.EnergySystemData, energySysEventReceiver); +traficHandlers.set(QueryEnum.LostFrameData, lostFrameReceiver); diff --git a/ide/src/trace/database/data-trafic/utils/QueryEnum.ts b/ide/src/trace/database/data-trafic/utils/QueryEnum.ts index 88484a72f7c6ada362658833f6d2cdba45cd62e9..d793ad90ef353ccd27f42897b59f4a4dd7077201 100644 --- a/ide/src/trace/database/data-trafic/utils/QueryEnum.ts +++ b/ide/src/trace/database/data-trafic/utils/QueryEnum.ts @@ -82,6 +82,8 @@ export enum QueryEnum { HeapSnapshotData = 161, CpuProfilerData = 162, SearchCpuData = 163, + LostFrameData = 164, + HitchTime = 165, } export const MAX_COUNT = 2000; export enum TraficEnum { diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts index 8d1d82e49854ee442bc8f0cd6d50e72e1c86c7fb..86c6aeda592e06b075e860123c69c9ced9351ee6 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts @@ -425,11 +425,11 @@ export let getByteWithUnit = (bytes: number): string => { let gb = ((1 << 10) << 10) << 10; // 1 gb let res = ''; if (currentBytes > gb) { - res += (currentBytes / gb).toFixed(2) + ' Gb'; + res += (currentBytes / gb).toFixed(2) + ' GB'; } else if (currentBytes > mb) { - res += (currentBytes / mb).toFixed(2) + ' Mb'; + res += (currentBytes / mb).toFixed(2) + ' MB'; } else if (currentBytes > kb1) { - res += (currentBytes / kb1).toFixed(2) + ' Kb'; + res += (currentBytes / kb1).toFixed(2) + ' KB'; } else { res += Math.round(currentBytes) + ' byte'; } diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.ts index dff91aaf728b813f96f79c4dff2a4131cf11f2f6..249f268b813ca9b6cd5e8ec8044471d5be8b4f3a 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.ts @@ -356,7 +356,9 @@ export class ProcedureLogicWorkerFileSystem extends LogicHandler { from file_system_sample A, trace_range B left join process C on A.ipid = C.id left join thread D on A.itid = D.id - where A.type in (${types}) and( (A.end_ts - B.start_ts) between $leftNS and $rightNS ) + where A.type in (${types}) + and (A.end_ts - B.start_ts) >= $leftNS + and (A.start_ts - B.start_ts) <= $rightNS order by A.end_ts;`; } private queryFileSysEventsSQL2(types: string): string { @@ -369,7 +371,9 @@ export class ProcedureLogicWorkerFileSystem extends LogicHandler { ifnull(C.name,'Process') || '[' || C.pid || ']' as process from file_system_sample A, trace_range B left join process C on A.ipid = C.id - where A.type in (${types}) and fd not null and( (A.start_ts - B.start_ts) between $leftNS and $rightNS ) + where A.type in (${types}) and fd not null + and (A.start_ts - B.start_ts) <= $rightNS + and (A.end_ts - B.start_ts) >= $leftNS order by A.end_ts;`; } private queryFileSysEventsSQL3(rightNs: number): string { @@ -385,7 +389,10 @@ export class ProcedureLogicWorkerFileSystem extends LogicHandler { max(case when type = 0 then A.end_ts else 0 end) as openTs, max(case when type = 1 then A.end_ts else 0 end) as closeTs from file_system_sample A - where type in (0, 1) and A.end_ts between $leftNS and $rightNS group by fd, ipid + where type in (0, 1) + and A.end_ts >= $leftNS + and A.start_ts <= $rightNS + group by fd, ipid ) TA left join file_system_sample TB on TA.fd = TB.fd and TA.ipid = TB.ipid and TA.openTs = TB.end_ts left join process TC on TB.ipid = TC.ipid @@ -409,7 +416,7 @@ export class ProcedureLogicWorkerFileSystem extends LogicHandler { left join process C on A.ipid = C.id left join thread T on T.id = A.itid where ( - (A.end_ts - B.start_ts) between $leftNS and $rightNS + (A.end_ts - B.start_ts) >= $leftNS and (A.start_ts - B.start_ts) <= $rightNS );`; this.queryData(this.currentEventId, 'fileSystem-queryVMEvents', sql, { $leftNS: leftNs, @@ -440,7 +447,7 @@ export class ProcedureLogicWorkerFileSystem extends LogicHandler { left join process C on A.ipid = C.id left join thread T on T.id = A.itid where ( - (A.end_ts - B.start_ts) between $leftNS and $rightNS + (A.end_ts - B.start_ts) >= $leftNS and (A.start_ts - B.start_ts) <= $rightNS ) ${ipidsSql};`; this.queryData(this.currentEventId, 'fileSystem-queryIOEvents', sql, { $leftNS: leftNs, @@ -685,7 +692,9 @@ class FileSystemCallTreeHandler { `select s.start_ts - t.start_ts as ts, s.callchain_id as callChainId,h.tid,h.name as threadName,s.dur,s.type,p.pid,p.name as processName from file_system_sample s,trace_range t left join process p on p.id = s.ipid left join thread h on h.id = s.itid -where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionParam.rightNs} + t.start_ts ${sqlFilter} and callchain_id != -1;`, +where s.end_ts >= ${selectionParam.leftNs} + t.start_ts +and s.start_ts <= ${selectionParam.rightNs} + t.start_ts +${sqlFilter} and callchain_id != -1;`, { $startTime: selectionParam.leftNs, $endTime: selectionParam.rightNs, @@ -719,7 +728,10 @@ where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionPara `select s.start_ts - t.start_ts as ts, s.callchain_id as callChainId,h.tid,h.name as threadName,s.latency_dur as dur,s.type,p.pid,p.name as processName from bio_latency_sample s,trace_range t left join process p on p.id = s.ipid left join thread h on h.id = s.itid -where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionParam.rightNs} + t.start_ts ${sqlFilter} and callchain_id != -1;`, +where s.end_ts >= ${selectionParam.leftNs} + t.start_ts +and s.start_ts <= ${selectionParam.rightNs} + t.start_ts +${sqlFilter} +and callchain_id != -1;`, { $startTime: selectionParam.leftNs, $endTime: selectionParam.rightNs, @@ -746,7 +758,8 @@ where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionPara `select s.start_ts - t.start_ts as ts, s.callchain_id as callChainId,h.tid,h.name as threadName,s.dur,s.type,p.pid,p.name as processName from paged_memory_sample s,trace_range t left join process p on p.id = s.ipid left join thread h on h.id = s.itid -where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionParam.rightNs} + t.start_ts ${sqlFilter} and callchain_id != -1;`, +where s.end_ts >= ${selectionParam.leftNs} + t.start_ts +and s.start_ts <= ${selectionParam.rightNs} + t.start_ts ${sqlFilter} and callchain_id != -1;`, { $startTime: selectionParam.leftNs, $endTime: selectionParam.rightNs, @@ -763,11 +776,18 @@ where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionPara samples.forEach((sample: FileSample): void => { totalCount += sample.dur; let callChains = this.createThreadAndType(sample); - if (callChains.length === 2) { + let minDepth = 2; + if (this.isHideEvent){ + minDepth--; + } + if (this.isHideThread){ + minDepth--; + } + if (callChains.length === minDepth) { return; } let topIndex = isTopDown ? 0 : callChains.length - 1; - if (callChains.length > 1) { + if (callChains.length > 0) { let root = this.currentTreeMapData[callChains[topIndex].symbolsId + '' + callChains[topIndex].pathId + sample.pid]; if (root === undefined) { @@ -777,7 +797,9 @@ where s.end_ts between ${selectionParam.leftNs} + t.start_ts and ${selectionPara this.currentTreeList.push(root); } FileMerageBean.merageCallChainSample(root, callChains[topIndex], sample, false); - this.merageChildrenByIndex(root, callChains, topIndex, sample, isTopDown); + if (callChains.length > 1){ + this.merageChildrenByIndex(root, callChains, topIndex, sample, isTopDown); + } } }); let rootMerageMap = this.mergeNodeData(totalCount); @@ -1061,7 +1083,7 @@ export class FileMerageBean extends MerageBean { currentNode.canCharge = true; currentNode.pathId = callChain.pathId; currentNode.symbolsId = callChain.symbolsId; - currentNode.processName = `${sample.processName || 'Process'} ${sample.pid})`; + currentNode.processName = `${sample.processName || 'Process'} (${sample.pid})`; } if (isEnd) { currentNode.selfDur += sample.dur; diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts index f8186bb938192f7a9969a0f969196bb4ef4fe95a..d5a2a492a77218209edaf11df0494639a02efd75 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts @@ -696,8 +696,8 @@ export class ProcedureLogicWorkerPerf extends LogicHandler { sampleArray.forEach((sample: PerfCallChainMerageData): void => { if ((sample.symbol && sample.symbol.toLocaleLowerCase().includes(search)) || parentSearch) { sample.searchShow = true; - let parentNode = sample.parent; sample.isSearch = sample.symbol !== undefined && sample.symbol.toLocaleLowerCase().includes(search); + let parentNode = sample.parent; while (parentNode !== undefined && !parentNode.searchShow) { parentNode.searchShow = true; parentNode = parentNode.parent; @@ -1132,7 +1132,7 @@ export class PerfCallChainMerageData extends ChartStruct { } else { symbolName = callChain.name; } - currentNode.symbol = `${symbolName} ${callChain.fileName ? `(${callChain.fileName})` : ''}`; + currentNode.symbol = `${symbolName} ${callChain.fileName ? `(${callChain.fileName})` : ''}`; currentNode.symbolName = symbolName; currentNode.pid = sample.pid; currentNode.tid = sample.tid; diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts index ab1e346a09654a4bc3f6c0d9210a9770071ec598..6c1b586c187728aa5bd6efa3306b145958063f66 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerSchedulingAnalysis.ts @@ -707,7 +707,7 @@ where cpu not null let threads = arr.filter((f) => Math.min(f.ts + f.dur, freqEndTs) - Math.max(f.ts, it.ts) > 0); for (let tf of threads) { let tfEndTs = tf.ts + tf.dur; - let dur = Math.min(tfEndTs, tfEndTs) - Math.max(it.ts, tf.ts); + let dur = Math.min(freqEndTs, tfEndTs) - Math.max(it.ts, tf.ts); if (map.has(tf.tid)) { map.get(tf.tid)!.dur = map.get(tf.tid)!.dur + dur; map.get(tf.tid)!.durStr = getProbablyTime(map.get(tf.tid)!.dur); diff --git a/ide/src/trace/database/sql/Clock.sql.ts b/ide/src/trace/database/sql/Clock.sql.ts index ff2cd1731e82d43caf113a157048fb296f59a32b..e9f4b77c2178a62170ba223d6d6895b692457028 100644 --- a/ide/src/trace/database/sql/Clock.sql.ts +++ b/ide/src/trace/database/sql/Clock.sql.ts @@ -78,5 +78,14 @@ export const queryScreenState = (): Promise> => export const queryRealTime = (): Promise< Array<{ ts: number; + name: string }> -> => query('queryRealTime', `select CS.ts as ts from clock_snapshot as CS where clock_name = 'realtime';`); +> => query('queryRealTime', `SELECT + ( CASE WHEN CS.clock_name = 'realtime' THEN CS.ts ELSE CS.ts - TR.start_ts END ) AS ts, + CS.clock_name AS name + FROM + clock_snapshot AS CS, + trace_range AS TR + WHERE + CS.clock_name = 'realtime' + OR CS.clock_name = 'boottime';`); diff --git a/ide/src/trace/database/sql/Cpu.sql.ts b/ide/src/trace/database/sql/Cpu.sql.ts index 10b8e8fe1f68991e3183867a52bcd50b77bbb19b..eb3e5c73ec6b16d63050ce3fb48524db7e83d9fd 100644 --- a/ide/src/trace/database/sql/Cpu.sql.ts +++ b/ide/src/trace/database/sql/Cpu.sql.ts @@ -205,8 +205,8 @@ export const getTabCpuByProcess = (cpus: Array, leftNS: number, rightNS: ` select B.pid as pid, - sum(B.dur) as wallDuration, - avg(B.dur) as avgDuration, + sum(iif(B.dur = -1 or B.dur is null, 0, B.dur)) as wallDuration, + avg(iif(B.dur = -1 or B.dur is null, 0, B.dur)) as avgDuration, count(B.tid) as occurrences from thread_state AS B @@ -215,7 +215,7 @@ export const getTabCpuByProcess = (cpus: Array, leftNS: number, rightNS: where B.cpu in (${cpus.join(',')}) and - not ((B.ts - TR.start_ts + B.dur < $leftNS) or (B.ts - TR.start_ts > $rightNS )) + not ((B.ts - TR.start_ts + iif(B.dur = -1 or B.dur is null, 0, B.dur) < $leftNS) or (B.ts - TR.start_ts > $rightNS )) group by B.pid order by @@ -230,7 +230,7 @@ export const getTabCpuByThread = (cpus: Array, leftNS: number, rightNS: TS.pid as pid, TS.tid as tid, TS.cpu, - sum( min(${rightNS},(TS.ts - TR.start_ts + TS.dur)) - max(${leftNS},TS.ts - TR.start_ts)) wallDuration, + sum( min(${rightNS},(TS.ts - TR.start_ts + iif(TS.dur = -1 or TS.dur is null, 0, TS.dur))) - max(${leftNS},TS.ts - TR.start_ts)) wallDuration, count(TS.tid) as occurrences from thread_state AS TS @@ -239,7 +239,7 @@ export const getTabCpuByThread = (cpus: Array, leftNS: number, rightNS: where TS.cpu in (${cpus.join(',')}) and - not ((TS.ts - TR.start_ts + TS.dur < $leftNS) or (TS.ts - TR.start_ts > $rightNS)) + not ((TS.ts - TR.start_ts + iif(TS.dur = -1 or TS.dur is null, 0, TS.dur) < $leftNS) or (TS.ts - TR.start_ts > $rightNS)) group by TS.cpu, TS.pid, @@ -662,7 +662,6 @@ export const getCpuLimitFreqBoxSelect = ( and ts - T.start_ts < ${rightNS} group by ts `; - console.log(sql); return query('getCpuLimitFreqBoxSelect', sql, {}); }; export const getCpuLimitFreq = (maxId: number, minId: number, cpu: number): Promise> => diff --git a/ide/src/trace/database/sql/Func.sql.ts b/ide/src/trace/database/sql/Func.sql.ts index 0f569762839fd9c2bc7fd0e0934854d4fd2eff85..148cf0bae8d71892411f23cfd20517d9a9a21c5a 100644 --- a/ide/src/trace/database/sql/Func.sql.ts +++ b/ide/src/trace/database/sql/Func.sql.ts @@ -17,6 +17,95 @@ import { FuncStruct } from '../ui-worker/ProcedureWorkerFunc'; import { SearchFuncBean } from '../../bean/SearchFuncBean'; import { SelectionData } from '../../bean/BoxSelection'; import { HeapTraceFunctionInfo } from '../../../js-heap/model/DatabaseStruct'; +import { FunctionItem } from '../../bean/BinderProcessThread'; +import { StateGroup } from '../../bean/StateModle'; +import { FuncNameCycle } from '../../bean/BinderProcessThread'; + +export const queryFuncNameCycle = ( + funcName: string, + tIds: string, + leftNS: number, + rightNS: number +): Promise> => + query( + 'queryFuncNameCycle', + ` + SELECT + c.ts - r.start_ts AS cycleStartTime, + c.dur, + c.id, + t.tid, + p.pid + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name like '${funcName}%' + AND + t.tid = ${tIds} + AND NOT + ((cycleStartTime < ${leftNS}) + OR + ((c.ts - r.start_ts + c.dur) > ${rightNS})) + `, + { + $funcName: funcName, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } + ); + +export const querySingleFuncNameCycle = ( + funcName: string, + tIds: string, + leftNS: number, + rightNS: number +): Promise> => + query( + 'querySingleFuncNameCycle', + ` + SELECT + c.name AS funcName, + c.ts - r.start_ts AS cycleStartTime, + c.dur AS cycleDur, + c.id, + t.tid, + p.pid, + c.ts - r.start_ts + c.dur AS endTime + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name = '${funcName}' + AND + t.tid = ${tIds} + AND NOT + ((cycleStartTime < ${leftNS}) + OR + (endTime > ${rightNS})) + `, + { + $funcName: funcName, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } + ); export const queryAllFuncNames = (): Promise> => { return query( @@ -67,7 +156,7 @@ export const getFunDataByTid = (tid: number, ipid: number): Promise> => query( @@ -114,21 +203,18 @@ export const querySearchFuncData = ( not ((startTime < ${leftNS}) or (startTime > ${rightNS})); ` ); -export const querySearchRowFuncData = ( +export const queryFuncRowData = ( funcName: string, tIds: number, leftNS: number, rightNS: number ): Promise> => query( - 'querySearchRowFuncData', + 'queryFuncRowData', ` select c.name as funName, - c.ts - r.start_ts as startTime, - t.tid, - t.name as threadName, - 'func' as type + c.ts - r.start_ts as startTime from callstack c left join @@ -148,8 +234,44 @@ export const querySearchRowFuncData = ( and not ((startTime < ${leftNS}) or (startTime > ${rightNS})); `, + {$search: funcName} + ); + +export const fuzzyQueryFuncRowData = ( + funcName: string, + tIds: number, + leftNS: number, + rightNS: number +): Promise> => + query( + 'fuzzyQueryFuncRowData', + ` + select + c.name as funName, + c.ts - r.start_ts as startTime, + c.ts - r.start_ts + c.dur as endTime + from + callstack c + left join + thread t + on + c.callid = t.id + left join + process p + on + t.ipid = p.id + left join + trace_range r + where + c.name like '%${funcName}%' + and + t.tid = ${tIds} + and + not ((endTime < ${leftNS}) or (endTime > ${rightNS})); + `, { $search: funcName } ); + export const getTabSlicesAsyncFunc = ( asyncNames: Array, asyncPid: Array, @@ -180,14 +302,14 @@ export const getTabSlicesAsyncFunc = ( and P.pid in (${asyncPid.join(',')}) and - c.name in (${asyncNames.map((it) => "'" + it + "'").join(',')}) + c.name in (${asyncNames.map((it) => '\'' + it + '\'').join(',')}) and not ((C.ts - D.start_ts + C.dur < $leftNS) or (C.ts - D.start_ts > $rightNS)) group by c.name order by wallDuration desc;`, - { $leftNS: leftNS, $rightNS: rightNS } + {$leftNS: leftNS, $rightNS: rightNS} ); export const querySearchFunc = (search: string): Promise> => query( @@ -208,7 +330,7 @@ export const querySearchFunc = (search: string): Promise> left join trace_range r where c.name like '%${search}%' and startTime > 0; `, - { $search: search } + {$search: search} ); export const querySceneSearchFunc = (search: string, processList: Array): Promise> => @@ -230,7 +352,7 @@ export const querySceneSearchFunc = (search: string, processList: Array) left join trace_range r where c.name like '%${search}%' ESCAPE '\\' and startTime > 0 and p.pid in (${processList.join(',')}); `, - { $search: search } + {$search: search} ); export const queryHeapFunction = (fileId: number): Promise> => query( @@ -275,7 +397,12 @@ export const queryHeapTraceNode = (fileId: number): Promise> => ORDER BY N.id` ); -export const queryTaskPoolOtherRelationData = (ids: Array, tid: number): Promise> => { +export const queryTaskPoolOtherRelationData = ( + ids: Array, + tid: number +): Promise< + Array +> => { let sqlStr = `select c.ts-D.start_ts as startTs, c.dur, @@ -288,10 +415,15 @@ export const queryTaskPoolOtherRelationData = (ids: Array, tid: number): from thread A,trace_range D left join callstack C on A.id = C.callid where startTs not null and c.cookie is null and tid = $tid and c.id in (${ids.join(',')})`; - return query('queryTaskPoolOtherRelationData', sqlStr, { $ids: ids, $tid: tid }); + return query('queryTaskPoolOtherRelationData', sqlStr, {$ids: ids, $tid: tid}); }; -export const queryTaskPoolRelationData = (ids: Array, tids: Array): Promise> => { +export const queryTaskPoolRelationData = ( + ids: Array, + tids: Array +): Promise< + Array +> => { const sqlArray: Array = []; if (ids.length > 0) { for (let index = 0; index < ids.length; index++) { @@ -316,3 +448,125 @@ export const queryTaskPoolRelationData = (ids: Array, tids: Array, leftNS: number, rightNS: number +): Promise< + Array +> => + query( + 'queryBinderByThreadId', + ` + select + B.id, + B.pid, + B.tid, + B.type, + B.dur, + B.cpu, + B.state, + B.ts - C.start_ts AS ts, + B.dur + B.ts as endTs + from + thread_state AS B,trace_range AS C + where + B.tid in (${tIds.join(',')}) + and + not ((B.ts + + ifnull(B.dur,0) < ($leftStartNs + C.start_ts)) or (B.ts + B.dur > ($rightEndNs + C.start_ts))) + order by + B.pid; + `, + { + $tIds: tIds, + $leftStartNs: leftNS, + $rightEndNs: rightNS + } + ); + + export const queryLoopFuncNameCycle = ( + funcName: string, + tIds: string, + leftNS: number, + rightNS: number + ): Promise> => + query( + 'queryLoopFuncNameCycle', + ` + SELECT + c.name AS funcName, + c.ts - r.start_ts AS cycleStartTime, + 0 AS cycleDur, + c.id, + t.tid, + p.pid + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name = '${funcName}' + AND + t.tid = ${tIds} + AND NOT + ((cycleStartTime < ${leftNS}) + OR + (cycleStartTime > ${rightNS})) + `, + { + $funcName: funcName, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } + ); + + export const querySingleFuncNameCycleStates = ( + funcName: string, + tIds: string, + leftNS: number, + rightNS: number + ): Promise> => + query( + 'querySingleFuncNameCycle', + ` + SELECT + c.name AS funcName, + c.ts - r.start_ts AS cycleStartTime, + c.dur AS cycleDur, + c.id, + t.tid, + p.pid, + c.ts - r.start_ts + c.dur AS endTime + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name = '${funcName}' + AND + t.tid = ${tIds} + AND NOT + ((cycleStartTime < ${leftNS}) + OR + (endTime > ${rightNS})) + `, + { + $funcName: funcName, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } + ); + \ No newline at end of file diff --git a/ide/src/trace/database/sql/Ltpo.sql.ts b/ide/src/trace/database/sql/Ltpo.sql.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0f0b046a36e232f04e4e68d38795e0f0c5179b7 --- /dev/null +++ b/ide/src/trace/database/sql/Ltpo.sql.ts @@ -0,0 +1,43 @@ +/* + * 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 { LtpoStruct } from './../ui-worker/ProcedureWorkerLTPO' +import {query} from "../SqlLite"; + +export const queryPresentInfo =(): Promise > => + query( + 'queryPresentInfo', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('Present%')) + AND name LIKE('H:Waiting for Present Fence%')` + ) + +export const queryFanceNameList = ():Promise> => + query( + 'queryFanceNameList', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%')) + AND name LIKE('H:Present Fence%')` + ) + +export const queryFpsNameList = ():Promise> => + query( + 'queryFpsNameList', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%')) + AND name LIKE('%Layers rate%')` + ) +export const queryRealFpsList = ():Promise> => + query( + 'queryRealFpsList', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%')) + AND name LIKE('H:RSHardwareThread::PerformSetActiveMode%')` + ) diff --git a/ide/src/trace/database/sql/Memory.sql.ts b/ide/src/trace/database/sql/Memory.sql.ts index 40d52376954d60cc7221c280d979c442c3312c61..57af6d4c1b2d1ca399ae1f9fffa6d8cf0cce8afd 100644 --- a/ide/src/trace/database/sql/Memory.sql.ts +++ b/ide/src/trace/database/sql/Memory.sql.ts @@ -129,7 +129,9 @@ export const getTabVirtualMemoryType = (startTime: number, endTime: number): Pro 'getTabVirtualMemoryType', ` SELECT type from paged_memory_sample s,trace_range t - WHERE s.end_ts between $startTime + t.start_ts and $endTime + t.start_ts group by type`, + WHERE s.end_ts >= $startTime + t.start_ts + and s.start_ts <= $endTime + t.start_ts + group by type`, { $startTime: startTime, $endTime: endTime }, 'exec' ); @@ -352,7 +354,7 @@ export const getTabPaneVirtualMemoryStatisticsData = (leftNs: number, rightNs: n avg(dur) as avgDuration from paged_memory_sample as f left join process as p on f.ipid=p.ipid left join thread as t on f.itid=t.itid where f.end_ts >= $leftNs - and f.end_ts <= $rightNs + and f.start_ts <= $rightNs group by f.type,f.ipid,f.itid order by f.type; `, diff --git a/ide/src/trace/database/sql/Perf.sql.ts b/ide/src/trace/database/sql/Perf.sql.ts index e754c0b88d889aef607d20d7ea761c45363f11fa..6de015a83265eab795fec1cdfb5119e9447d23d4 100644 --- a/ide/src/trace/database/sql/Perf.sql.ts +++ b/ide/src/trace/database/sql/Perf.sql.ts @@ -16,6 +16,7 @@ import { PerfCmdLine, PerfFile, PerfSample, PerfStack, PerfThread } from '../../ import { query } from '../SqlLite'; import { HiSysEventStruct } from '../ui-worker/ProcedureWorkerHiSysEvent'; import { TaskTabStruct } from '../../component/trace/sheet/task/TabPaneTaskFrames'; +import { GpuCountBean, SearchGpuFuncBean } from '../../bean/GpufreqBean.js'; export const queryPerfFiles = (): Promise> => query('queryPerfFiles', `select file_id as fileId,symbol,path from perf_files`, {}); @@ -233,6 +234,114 @@ from perf_sample sp, where tid = ${tid} and sp.thread_id != 0 ;`, { $tid: tid } ); + +export const getGpufreqDataCut = ( + tIds: string, + funcName: string, + leftNS: number, + rightNS: number, + single: boolean, + loop: boolean +): Promise> => { + let queryCondition: string = ''; + if (single) { + queryCondition += `select s.funName,s.startTime,s.dur,s.startTime+s.dur as endTime,s.tid,s.threadName,s.pid from state s + where endTime between ${leftNS} and ${rightNS}`; + } + if (loop) { + queryCondition += `select s.funName,s.startTime,s.loopEndTime-s.startTime as dur,s.loopEndTime as endTime,s.tid,s.threadName,s.pid from state s + where endTime between ${leftNS} and ${rightNS} `; + } + return query( + 'getGpufreqDataCut', + ` + with state as + (select + * + from + (select + c.name as funName, + c.ts - r.start_ts as startTime, + c.dur, + lead(c.ts - r.start_ts, 1, null) over( order by c.ts - r.start_ts) loopEndTime, + t.tid, + t.name as threadName, + p.pid + from + callstack c + left join + thread t on c.callid = t.id + left join + process p on t.ipid = p.id + left join + trace_range r + where + c.name like '${funcName}%' + and + tid = '${tIds}' + and + startTime between ${leftNS} and ${rightNS})) + ${queryCondition} + `, + { $search: funcName } + ); +}; +export const getGpufreqData = (leftNS: number, rightNS: number, earliest: boolean): Promise> => { + let queryCondition: string = ''; + if (!earliest) { + queryCondition += ` where not ((s.ts - r.start_ts + ifnull(s.dur,0) < ${leftNS}) or (s.ts - r.start_ts > ${rightNS}))`; + } + return query( + 'getGpufreqData', + ` + with state as + (select + name, + filter_id, + ts, + endts, + endts-ts as dur, + value as val + from + (select + measure.filter_id, + clock_event_filter.name, + measure.ts, + lead(ts, 1, null) over( order by measure.ts) endts, + measure.value + from + clock_event_filter, + trace_range + left join + measure + where + clock_event_filter.name = 'gpufreq' + and + clock_event_filter.type = 'clock_set_rate' + and + clock_event_filter.id = measure.filter_id + order by measure.ts) + where + endts is not null + ) + select + s.name as thread, + s.val/1000000 as freq, + s.val*s.dur as value, + s.val, + s.ts-r.start_ts as startNS, + s.dur, + s.endts- r.start_ts as endTime + from + state s, + trace_range r + ${queryCondition} + order by ts + `, + { $leftNS: leftNS, $rightNS: rightNS } + ); +}; + export const queryHiSysEventTabData = (leftNs: number, rightNs: number): Promise> => query( 'queryHiSysEventTabData', @@ -328,14 +437,14 @@ export const queryConcurrencyTask = ( task_pool.allocation_task_row AS allocationTaskRow, task_pool.execute_task_row AS executeTaskRow, task_pool.return_task_row AS returnTaskRow, - task_pool.execute_id AS executeId + task_pool.task_id AS executeId FROM thread LEFT JOIN callstack ON thread.id = callstack.callid LEFT JOIN task_pool ON callstack.id = task_pool.execute_task_row WHERE ipid in (SELECT thread.ipid FROM thread WHERE thread.itid = $itid) - AND thread.name = 'TaskWorkThread' + AND thread.name LIKE '%TaskWork%' AND callstack.name LIKE 'H:Task Perform:%' AND -- 左包含 (($selectStartTime <= callstack.ts AND $selectEndTime > callstack.ts) diff --git a/ide/src/trace/database/sql/ProcessThread.sql.ts b/ide/src/trace/database/sql/ProcessThread.sql.ts index 66fb0b730c6abc9b213a7890eaedaa553d85aa3f..21a93e502e643d572735ba1be3edcdbf213ed789 100644 --- a/ide/src/trace/database/sql/ProcessThread.sql.ts +++ b/ide/src/trace/database/sql/ProcessThread.sql.ts @@ -23,35 +23,194 @@ import { AppStartupStruct } from '../ui-worker/ProcedureWorkerAppStartup'; import { SoStruct } from '../ui-worker/ProcedureWorkerSoInit'; import { LiveProcess, ProcessHistory } from '../../bean/AbilityMonitor'; import { EnergyAnomalyStruct } from '../ui-worker/ProcedureWorkerEnergyAnomaly'; +import { BinderItem } from '../../bean/BinderProcessThread'; -export const querySchedThreadStates = ( +export const queryBinderByThreadId = ( + pIds: number[], tIds: Array, - leftStartNs: number, - rightEndNs: number -): Promise> => - query( - 'getTabThreadStates', + leftNS: number, + rightNS: number +): Promise> => + query( + 'queryBinderByThreadId', ` - select - B.id, - B.pid, - B.tid, - B.state, - B.type, - B.dur, - B.ts, - B.dur + B.ts as endTs - from - thread_state AS B - where - B.tid in (${tIds.join(',')}) - and - not ((B.ts + ifnull(B.dur,0) < $leftStartNs) or (B.ts > $rightEndNs)) - order by - B.pid; - `, - { $leftStartNs: leftStartNs, $rightEndNs: rightEndNs } + SELECT + c.name, + c.ts - r.start_ts AS ts, + c.dur, + t.tid, + p.pid + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name in ('binder transaction', 'binder async rcv', 'binder reply', 'binder transaction async') + AND + t.tid in (${tIds.join(',')}) + AND + p.pid in (${pIds.join(',')}) + AND NOT + (((c.ts - r.start_ts) < ${leftNS}) + OR + ((c.ts - r.start_ts) > ${rightNS})) + `, + { + $pIds: pIds, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } + ); +export const getTabBindersCount = ( + pIds: number[], + tIds: number[], + leftNS: number, + rightNS: number +): Promise> => + query( + 'getTabBindersCount', + ` + SELECT + c.name, + c.dur, + 1 AS count, + c.ts, + c.ts - r.start_ts AS startTime, + c.ts -r.start_ts + c.dur AS endTime, + t.tid, + p.pid + FROM + callstack c, trace_range r + LEFT JOIN + thread t + ON + c.callid = t.id + LEFT JOIN + process p + ON + t.ipid = p.id + WHERE + c.name in ('binder transaction', 'binder async rcv', 'binder reply', 'binder transaction async') + AND + t.tid in (${tIds.join(',')}) + AND + p.pid in (${pIds.join(',')}) + AND NOT + ((startTime < ${leftNS}) + OR + (endTime > ${rightNS})); + `, + { + $pIds: pIds, + $tIds: tIds, + $leftNS: leftNS, + $rightNS: rightNS, + } ); + + export const querySchedThreadStates = ( + pIds: Array, + tIds: Array, + leftStartNs: number, + rightEndNs: number + ): Promise> => + query( + 'getTabThreadStates', + ` + select + B.pid, + B.tid, + B.state, + B.dur, + B.ts, + B.dur + B.ts as endTs + from + thread_state AS B + where + B.tid in (${tIds.join(',')}) + and + B.pid in (${pIds.join(',')}) + and + B.state='Running' + and + not ((B.ts + ifnull(B.dur,0) < $leftStartNs) or (B.ts > $rightEndNs)) + order by + B.pid; + `, + { $leftStartNs: leftStartNs, $rightEndNs: rightEndNs } + ); + + export const querySingleCutData = ( + funcName: string, + tIds: string, + leftStartNs: number, + rightEndNs: number + ): Promise> => + query( + 'querySingleCutData', + ` + select + c.ts as cycleStartTime, + c.ts + c.dur as cycleEndTime, + t.tid, + p.pid, + c.dur + from + callstack c + left join + thread t on c.callid = t.id + left join + process p on t.ipid = p.id + left join + trace_range r + where + c.name like '${funcName}%' + and + t.tid = '${tIds}' + and + not ((c.ts < $leftStartNs) or (c.ts + ifnull(c.dur, 0) > $rightEndNs)) + order by + c.ts + `, + { $leftStartNs: leftStartNs, $rightEndNs: rightEndNs } + ); + + export const queryLoopCutData = ( + funcName: string, + tIds: string, + leftStartNs: number, + rightEndNs: number + ): Promise> => + query( + 'queryLoopCutData', + ` + select + c.ts as cycleStartTime, + t.tid, + p.pid + from callstack c + left join + thread t on c.callid = t.id + left join + process p on t.ipid = p.id + where + c.name like '${funcName}%' + and + t.tid = '${tIds}' + and + not ((c.ts < $leftStartNs) or (c.ts > $rightEndNs)) + order by + c.ts + `, + { $leftStartNs: leftStartNs, $rightEndNs: rightEndNs } + ); // 框选区域内sleeping的时间 export const getTabSleepingTime = (tIds: Array, leftNS: number, rightNS: number): Promise> => query( @@ -80,16 +239,16 @@ export const getTabSleepingTime = (tIds: Array, leftNS: number, rightNS: ); export const getTabThreadStatesCpu = (tIds: Array, leftNS: number, rightNS: number): Promise> => { let sql = ` -select +select B.pid, B.tid, B.cpu, - sum( min(${rightNS},(B.ts - TR.start_ts + B.dur)) - max(${leftNS},B.ts - TR.start_ts)) wallDuration + sum( min(${rightNS},(B.ts - TR.start_ts + iif(B.dur = -1 or B.dur is null, 0, B.dur))) - max(${leftNS},B.ts - TR.start_ts)) wallDuration from thread_state as B left join trace_range as TR where cpu notnull and B.tid in (${tIds.join(',')}) - and not ((B.ts - TR.start_ts + ifnull(B.dur,0) < ${leftNS}) or (B.ts - TR.start_ts > ${rightNS})) + and not ((B.ts - TR.start_ts + iif(B.dur = -1 or B.dur is null, 0, B.dur) < ${leftNS}) or (B.ts - TR.start_ts > ${rightNS})) group by B.tid, B.pid, B.cpu;`; return query('getTabThreadStatesCpu', sql, { $leftNS: leftNS, @@ -107,7 +266,7 @@ export const getTabRunningPersent = (tIds: Array, leftNS: number, rightN B.tid, B.state, B.cpu, - B.dur, + iif(B.dur = -1 or B.dur is null, 0, B.dur) as dur, B.ts from thread_state AS B @@ -118,7 +277,7 @@ export const getTabRunningPersent = (tIds: Array, leftNS: number, rightN and B.state='Running' and - not ((B.ts - TR.start_ts + ifnull(B.dur,0) < ${leftNS}) or (B.ts - TR.start_ts > ${rightNS})) + not ((B.ts - TR.start_ts + iif(B.dur = -1 or B.dur is null, 0, B.dur) < ${leftNS}) or (B.ts - TR.start_ts > ${rightNS})) order by ts;`, { $leftNS: leftNS, $rightNS: rightNS } @@ -437,7 +596,7 @@ export const queryProcessThreadsByTable = (): Promise> => query( 'queryProcessThreadsByTable', ` - select p.pid as pid,p.ipid as upid,t.tid as tid,p.name as processName,t.name as threadName,t.switch_count as switchCount from thread t left join process p on t.ipid = p.id where t.tid != 0; + select p.pid as pid,p.ipid as upid,t.tid as tid,p.name as processName,t.name as threadName,t.switch_count as switchCount, t.itid as utid from thread t left join process p on t.ipid = p.id where t.tid != 0; ` ); export const queryProcessThreads = (): Promise> => @@ -1114,7 +1273,7 @@ export const queryBySelectExecute = ( FROM task_pool LEFT JOIN callstack ON callstack.id = task_pool.allocation_task_row LEFT JOIN thread ON thread.id = callstack.callid - WHERE task_pool.execute_id = $executeId AND task_pool.execute_itid = $itid; + WHERE task_pool.task_id = $executeId AND task_pool.execute_itid = $itid; `; return query('queryBySelectExecute', sqlStr, { $executeId: executeId, $itid: itid }); }; diff --git a/ide/src/trace/database/sql/SqlLite.sql.ts b/ide/src/trace/database/sql/SqlLite.sql.ts index 5baa6cffb9bfc83ec839ec60671f9e2fe9db6fd9..199ab5c144947ea6b3bd01abe1b033a12135f3f9 100644 --- a/ide/src/trace/database/sql/SqlLite.sql.ts +++ b/ide/src/trace/database/sql/SqlLite.sql.ts @@ -440,8 +440,8 @@ export const getTabPaneFilesystemStatisticsAll = (leftNs: number, rightNs: numbe round(avg(dur),2) as avgDuration, type from file_system_sample - where start_ts >= $leftNs - and end_ts <= $rightNs; + where start_ts <= $rightNs + and end_ts >= $leftNs; `, { $leftNs: leftNs, $rightNs: rightNs } ); @@ -463,8 +463,8 @@ export const getTabPaneFilesystemStatistics = (leftNs: number, rightNs: number, max(dur) as maxDuration, avg(dur) as avgDuration from file_system_sample as f left join process as p on f.ipid=p.ipid - where end_ts >= $leftNs - and end_ts <= $rightNs + where f.end_ts >= $leftNs + and f.start_ts <= $rightNs and f.type in (${types.join(',')}) group by f.type,f.ipid order by f.type; @@ -495,7 +495,7 @@ export const getTabPaneIOTierStatisticsData = ( max(latency_dur) as maxDuration, avg(latency_dur) as avgDuration from bio_latency_sample as i left join process as p on i.ipid=p.ipid - where i.start_ts+latency_dur >= $leftNs + where i.end_ts+latency_dur >= $leftNs and i.start_ts+latency_dur <= $rightNs ${str} group by i.tier,i.ipid,i.path_id @@ -837,7 +837,8 @@ export const getTabIoCompletionTimesType = (startTime: number, endTime: number): 'getTabIoCompletionTimesType', ` SELECT tier from bio_latency_sample s,trace_range t - WHERE s.start_ts + s.latency_dur between $startTime + t.start_ts and $endTime + t.start_ts group by tier`, + WHERE s.start_ts + s.latency_dur >= $startTime + t.start_ts + and s.start_ts <= $endTime + t.start_ts group by tier`, { $startTime: startTime, $endTime: endTime }, 'exec' ); @@ -1082,7 +1083,7 @@ export const queryBySelectAllocationOrReturn = ( FROM task_pool LEFT JOIN callstack ON callstack.id = task_pool.execute_task_row LEFT JOIN thread ON thread.id = callstack.callid - WHERE task_pool.execute_task_row IS NOT NULL AND task_pool.execute_id = $executeId + WHERE task_pool.execute_task_row IS NOT NULL AND task_pool.task_id = $executeId AND task_pool.allocation_itid = $itid; `; return query('queryBySelectAllocationOrReturn', sqlStr, { $executeId: executeId, $itid: itid }); @@ -1097,12 +1098,12 @@ export const queryTaskListByExecuteTaskIds = ( task_pool.allocation_task_row AS allocationTaskRow, task_pool.execute_task_row AS executeTaskRow, task_pool.return_task_row AS returnTaskRow, - task_pool.execute_id AS executeId, + task_pool.task_id AS executeId, task_pool.priority FROM task_pool LEFT JOIN callstack ON callstack.id = task_pool.allocation_task_row LEFT JOIN thread ON thread.id = callstack.callid - WHERE task_pool.execute_id IN (${executeTaskIds.join(',')}) + WHERE task_pool.task_id IN (${executeTaskIds.join(',')}) AND thread.ipid = $ipid AND task_pool.execute_task_row IS NOT NULL; `; @@ -1123,7 +1124,7 @@ export const queryTaskPoolTotalNum = (itid: number) => WHERE ipid in (SELECT thread.ipid FROM thread WHERE thread.itid = $itid) - AND thread.name = 'TaskWorkThread' + AND thread.name LIKE '%TaskWork%' GROUP BY thread.tid;`, { $itid: itid } ); diff --git a/ide/src/trace/database/ui-worker/ProcedureWorker.ts b/ide/src/trace/database/ui-worker/ProcedureWorker.ts index c279965ca8dddffb1220bbe589d16937c0c22c01..69af09f64e3d504c4221922f8e3f064d002a3ff3 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorker.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorker.ts @@ -60,6 +60,10 @@ import { HiperfProcessRender2 } from './hiperf/ProcedureWorkerHiPerfProcess2'; import { HiperfThreadRender2 } from './hiperf/ProcedureWorkerHiPerfThread2'; import { AllAppStartupRender } from './ProcedureWorkerAllAppStartup'; import { FreqExtendRender } from './ProcedureWorkerFreqExtend'; +import { hitchTimeRender } from './ProcedureWorkerHitchTime'; +import { LtpoRender } from './ProcedureWorkerLTPO'; +import { BinderRender } from './procedureWorkerBinder'; +import { SampleRender } from './ProcedureWorkerSample'; let dataList: any = {}; let dataList2: any = {}; @@ -80,6 +84,8 @@ export let renders: any = { process: new ProcessRender(), 'app-start-up': new AppStartupRender(), 'all-app-start-up': new AllAppStartupRender(), + 'ltpo-present': new LtpoRender(), + 'hitch': new hitchTimeRender(), 'app-so-init': new SoRender(), heap: new HeapRender(), 'heap-timeline': new HeapTimelineRender(), @@ -117,11 +123,13 @@ export let renders: any = { logs: new LogRender(), hiSysEvent: new HiSysEventRender(), 'freq-extend': new FreqExtendRender(), + binder: new BinderRender(), + sample: new SampleRender(), }; function match(type: string, req: RequestMessage): void { Reflect.ownKeys(renders).filter((it) => { - if (type.startsWith(it as string)) { + if (type && type.startsWith(it as string)) { if (dataList[type]) { req.lazyRefresh = dataList[type].length > 20000; } @@ -173,6 +181,7 @@ self.onmessage = (e: any): void => { match(req.type!, req); }; + function clear(e: any) { if (e.data.type && (e.data.type as string).startsWith('clear')) { dataList = {}; @@ -189,6 +198,7 @@ function clear(e: any) { return; } } + function setReq(req: RequestMessage, e: any) { req.canvas = canvasList[e.data.type]; req.context = contextList[e.data.type]; @@ -232,4 +242,6 @@ function setReq(req: RequestMessage, e: any) { } } } -self.onmessageerror = function (e: any): void {}; + +self.onmessageerror = function (e: any): void { +}; diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts index e88380a7bc33283e41889092a364e79f1b5338e1..54cabdfaa9cc436fd397dedb623cce20468e9fdd 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts @@ -68,7 +68,7 @@ export function AppStartupStructOnClick(clickRowType: string, sp: SpSystemTrace, AppStartupStruct.selectStartupStruct = AppStartupStruct.hoverStartupStruct; sp.traceSheetEL?.displayStartupData(AppStartupStruct.selectStartupStruct, scrollToFuncHandler); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerClock.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerClock.ts index 69c055e1990183e6b32c76566cae026a6f46a738..d0ac70d3ac90d3dec7a28cc675a1185b79ee2743 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerClock.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerClock.ts @@ -72,7 +72,7 @@ export function ClockStructOnClick(clickRowType: string, sp: SpSystemTrace) { ClockStruct.selectClockStruct = ClockStruct.hoverClockStruct; sp.traceSheetEL?.displayClockData(ClockStruct.selectClockStruct); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts index 066ff349e9d1cfc0d2d9bf31464a83c9278ef8c6..044fe49308667c106cde885f70bbbe6985567e36 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerCommon.ts @@ -50,10 +50,10 @@ export class RequestMessage { totalNS: any; slicesTime: | { - startTime: number | null; - endTime: number | null; - color: string | null; - } + startTime: number | null; + endTime: number | null; + color: string | null; + } | undefined; range: any; scale: any; @@ -66,9 +66,9 @@ export class RequestMessage { id: any; postMessage: | { - (message: any, targetOrigin: string, transfer?: Transferable[]): void; - (message: any, options?: WindowPostMessageOptions): void; - } + (message: any, targetOrigin: string, transfer?: Transferable[]): void; + (message: any, options?: WindowPostMessageOptions): void; + } | undefined; } @@ -101,8 +101,8 @@ export function ns2Timestamp(ns: number): string { return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}:${second .toString() .padStart(2, '0')}:${millisecond.toString().padStart(3, '0')}:${microsecond - .toString() - .padStart(3, '0')}:${nanosecond.toString().padStart(3, '0')}`; + .toString() + .padStart(3, '0')}:${nanosecond.toString().padStart(3, '0')}`; } const offsetX = 5; @@ -300,6 +300,7 @@ export const dataFilterHandler = (fullData: Array, filterData: Array, filterData.push(...slice.filter((it) => it.v)); } }; + function setSliceFrame(slice: Array, condition: FilterConfig, pns: number, i: number) { let sum = 0; if (slice[i][condition.durKey] >= pns || slice.length < 100) { @@ -335,6 +336,7 @@ function setSliceFrame(slice: Array, condition: FilterConfig, pns: number, } } } + function setNodeFrame( node: any, pns: number, @@ -410,6 +412,7 @@ export class Rect { y: number = 0; width: number = 0; height: number = 0; + constructor(x: number, y: number, width: number, height: number) { this.x = x; this.y = y; @@ -507,6 +510,7 @@ export class PairPoint { business: string = ''; hidden?: boolean = false; backrowEL?: TraceRow; + constructor( rowEL: TraceRow, x: number, @@ -556,10 +560,10 @@ export function drawFlagLine( frame: any, slicesTime: | { - startTime: number | null | undefined; - endTime: number | null | undefined; - color: string | null | undefined; - } + startTime: number | null | undefined; + endTime: number | null | undefined; + color: string | null | undefined; + } | undefined ) { if (commonCtx) { @@ -746,12 +750,9 @@ export function drawSelectionRange(context: any, params: TraceRow) { ); context.globalAlpha = 1; } - // 绘制方法H:RSMainThread::DoComposition平均帧率的箭头指示线条 - if (params._docompositionList?.length) { - const rateList: Array = [...new Set(params.docompositionList)]; - if (rateList.length >= 2) { - changeFrameRatePoint(rateList, context, params); - } + // 绘制线程中方法平均帧率的箭头指示线条 + if (params.frameRateList && params.frameRateList.length) { + drawAvgFrameRate(params.frameRateList, context, params); } } } @@ -777,6 +778,30 @@ function setStartXEndX(params: TraceRow) { ); } +// 处理文字坐标 +function handleTextCoordinate(arrList: Array, selectParams: TraceRow, textWidth: number) { + const TEXT_WIDTH_HALF = 2; + let textX = Math.floor(ns2x( + (arrList[0]! + arrList[arrList.length - 1]!) / 2, + TraceRow.range?.startNS ?? 0, + TraceRow.range?.endNS ?? 0, + TraceRow.range?.totalNS ?? 0, + selectParams.frame + )) - textWidth / TEXT_WIDTH_HALF; //根据帧率范围的中间值转换文本的起始x坐标 + let textY = selectParams.frame.y + 10; + if (selectParams.hitchTimeData?.length) { + textY = selectParams.frame.y + 10; + } else { + // 展开时显示在第二行,折叠显示第一行 + if (selectParams.funcExpand) { + textY = selectParams.frame.y + 28; + } else { + textY = selectParams.frame.y + 10; + } + } + return [textX, textY]; +} + function setAvgRateStartXEndX(rateList: number[], params: TraceRow) { let avgRateStartX = Math.floor( ns2x( @@ -858,80 +883,96 @@ function drawSelectionRangeContext(rateList: number[], context: any, params: Tra } // 转换起始点坐标 -function changeFrameRatePoint(rateList: Array, ctx: any, selectParams: TraceRow): void { +function changeFrameRatePoint(arrList: Array, selectParams: TraceRow) { let avgRateStartX = Math.floor( ns2x( - rateList[0]!, + arrList[0]!, TraceRow.range?.startNS ?? 0, TraceRow.range?.endNS ?? 0, TraceRow.range?.totalNS ?? 0, selectParams.frame ) - ); + );// 起始坐标 + let avgRateEndX = Math.floor( ns2x( - rateList[rateList.length - 1]!, + arrList[arrList.length - 1]!, TraceRow.range?.startNS ?? 0, TraceRow.range?.endNS ?? 0, TraceRow.range?.totalNS ?? 0, selectParams.frame ) - ); - drawAvgFrameRate(rateList, ctx, selectParams, avgRateStartX, avgRateEndX); + );// 结束坐标 + return [avgRateStartX, avgRateEndX]; } // 计算平均帧率 -function calculateAvgRate(arr: Array) { +function calculateAvgRate(arr: Array, selectParams: TraceRow) { const CONVERT_SECONDS = 1000000000; - let cutres: number = arr[arr.length - 1]! - arr[0]!; - let avgRate: string = (((arr.length - 1) / cutres) * CONVERT_SECONDS).toFixed(1); + let cutres: number = (arr[arr.length - 1]! - arr[0]!); // 结束时间-开始时间 + let avgRate: string = ((arr.length - 1) / cutres * CONVERT_SECONDS).toFixed(1); // 帧数/时间差 * 1000000000 + if (selectParams.hitchTimeData?.length) { + let sum: number = selectParams.hitchTimeData.reduce((accumulator, currentValue) => accumulator + currentValue, 0); + let hitchRate: number = (sum / ((TraceRow.rangeSelectObject!.endNS! - TraceRow.rangeSelectObject!.startNS!) / 1000000)); + let avgHitchTime: string = (Number(hitchRate) * 100).toFixed(2) + '%'; + avgRate = avgRate + 'fps' + ' ' + ',' + ' ' + 'HitchTime:' + ' ' + sum.toFixed(1) + 'ms' + ' ' + ',' + ' ' + avgHitchTime; + } else { + avgRate = avgRate + 'fps'; + } return avgRate; } // 绘制平均帧率箭头指示线条 -function drawAvgFrameRate( - arrList: Array, - ctx: any, - selectParams: TraceRow, - startX: number, - endX: number -): void { - let avgFrameRate: string = calculateAvgRate(arrList) + 'fps'; - const textWidth = ctx.measureText(avgFrameRate).width; - const TEXT_WIDTH_HALF = 2; - let textX = - Math.floor( - ns2x( - (arrList[0]! + arrList[arrList.length - 1]!) / 2, - TraceRow.range?.startNS ?? 0, - TraceRow.range?.endNS ?? 0, - TraceRow.range?.totalNS ?? 0, - selectParams.frame - ) - ) - - textWidth / TEXT_WIDTH_HALF; - const textY = selectParams.frame.y + 25; - if (startX <= 0) { - startX = -100; - } - if (endX <= 0) { - endX = -100; - } - if (textX <= 0) { - textX = -100; - } +function drawAvgFrameRate(arrList: Array, ctx: any, selectParams: TraceRow): void { + let rateList: Array = [...new Set(arrList)]; + let avgFrameRate: string = calculateAvgRate(rateList, selectParams); + let startX = changeFrameRatePoint(rateList, selectParams)[0]; + let endX = changeFrameRatePoint(rateList, selectParams)[1]; + const textWidth = ctx.measureText(avgFrameRate).width; // 测量文本的宽度 + const textHeight = 25; + const padding = 5; + let textX = handleTextCoordinate(rateList, selectParams, textWidth)[0]; //文本横向起始坐标 + let textY = handleTextCoordinate(rateList, selectParams, textWidth)[1];//文本纵向坐标 + //左移到边界,不画线和文字 + startX = startX <= 0 ? -100 : startX; + endX = endX <= 0 ? -100 : endX; + textX = textX <= 0 ? -200 : textX; + //右移到边界,不画线和文字 const ADD_DISTANCE = 100; - if (textX + textWidth / 2 >= selectParams.frame.width) { - textX = selectParams.frame.width + ADD_DISTANCE; - } - if (startX >= selectParams.frame.width) { - startX = selectParams.frame.width + ADD_DISTANCE; - } - if (endX >= selectParams.frame.width) { - endX = selectParams.frame.width + ADD_DISTANCE; - } - drawAvgFrameRateArrow(ctx, textX, textY, textWidth, startX, endX, avgFrameRate); + textX = textX + textWidth / 2 >= selectParams.frame.width ? selectParams.frame.width + ADD_DISTANCE : textX; + startX = startX >= selectParams.frame.width ? selectParams.frame.width + ADD_DISTANCE : startX; + endX = endX >= selectParams.frame.width ? selectParams.frame.width + ADD_DISTANCE : endX; + + ctx.lineWidth = 2; + ctx.strokeStyle = 'yellow'; + ctx.beginPath(); + ctx.moveTo(startX, textY); + ctx.lineTo(endX, textY); + ctx.stroke(); + + const arrowSize = 5.5; + const arrowHead = (x: number, y: number, direction: 'left' | 'right') => { + ctx.beginPath(); + const headX = x + (direction === 'left' ? arrowSize : -arrowSize); + const headY = y - arrowSize / 2; + ctx.moveTo(x, y); + ctx.lineTo(headX, headY); + ctx.lineTo(headX, y + arrowSize); + ctx.closePath(); + ctx.fillStyle = 'yellow'; + ctx.fill(); + }; + arrowHead(startX, textY - 1, 'left'); + arrowHead(endX, textY - 1, 'right'); + + const TEXT_RECT_PADDING = 2; + ctx.fillStyle = 'red'; + ctx.fillRect(textX - padding, textY - textHeight / TEXT_RECT_PADDING + padding, textWidth + padding * TEXT_RECT_PADDING, textHeight - padding * TEXT_RECT_PADDING); + + ctx.fillStyle = 'white'; + ctx.fillText(avgFrameRate, textX, textY + 4); } + function drawAvgFrameRateArrow( ctx: any, textX: number, @@ -962,6 +1003,7 @@ function drawAvgFrameRateArrow( ctx.fillStyle = 'white'; ctx.fillText(avgFrameRate, textX, textY - 8); } + const arrowSize = 5.5; const arrowHead = (ctx: any, x: number, y: number, direction: 'left' | 'right') => { ctx.beginPath(); @@ -1056,6 +1098,7 @@ function drawWakeUpIfSelect( const wid = 5; const linkLineColor = '#ff0000'; + export function drawLinkLines( context: CanvasRenderingContext2D, nodes: PairPoint[][], @@ -1072,6 +1115,8 @@ export function drawLinkLines( function setLinkLinesNodes(nodes: any, isFav: any, favH: number, max: number, context: any, perc: number): void { for (let i = 0; i < nodes.length; i++) { let it = nodes[i]; + it[0].y = it[0].rowEL.translateY + it[0].offsetY; + it[1].y = it[1].rowEL.translateY + it[1].offsetY; let newFirstNode = new PairPoint( it[0].rowEL, it[0].x, @@ -1230,6 +1275,7 @@ function drawStraightLine(it: PairPoint[], maxWidth: number, context: CanvasRend drawArrow(context, startPoint, endPoint, arrowSize); } } + function drawArrow(context: CanvasRenderingContext2D, startPoint: PairPoint, endPoint: PairPoint, arrowSize: number) { context.beginPath(); context.lineWidth = 2; @@ -1263,6 +1309,7 @@ function drawArrow(context: CanvasRenderingContext2D, startPoint: PairPoint, end context.stroke(); context.closePath(); } + function drawBrokenLine(it: PairPoint[], maxWidth: number, context: CanvasRenderingContext2D): void { let brokenLineStart = it[0].x > it[1].x ? it[1] : it[0]; let brokenLineEnd = it[0].x > it[1].x ? it[0] : it[1]; @@ -1339,13 +1386,15 @@ export function drawLoading( frame: any, left: number, right: number -) {} +) { +} let loadingText = 'Loading...'; let loadingTextWidth = 0; let loadingBackground = '#f1f1f1'; let loadingFont = 'bold 11pt Arial'; let loadingFontColor = '#696969'; + export function drawLoadingFrame( ctx: CanvasRenderingContext2D, list: Array, @@ -1670,6 +1719,7 @@ export class HiPerfStruct extends BaseStruct { return arr; } } + function filterGroupArray(groupArray: Array, maxEventCount: number, usage?: boolean, event?: number) { return groupArray .map((it) => { @@ -1741,6 +1791,7 @@ export function mem( memFilter.length = 0; setMemFilter(list, memFilter, startNS, endNS, totalNS, frame); } + function setMemFilter( list: Array, memFilter: Array, diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerCpuProfiler.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerCpuProfiler.ts index 7ffd329b443d94012d62b2fc3073baff87fcda7b..f1ec46bdd3e85044ca32c0d841439980c967530e 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerCpuProfiler.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerCpuProfiler.ts @@ -107,8 +107,15 @@ export function jsCpuProfiler( } const padding = 1; -export function JsCpuProfilerStructOnClick(clickRowType: string, sp: SpSystemTrace) { +export function JsCpuProfilerStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow) { return new Promise((resolve, reject) => { + if (clickRowType === TraceRow.ROW_TYPE_JS_CPU_PROFILER) { + if (row.findHoverStruct) { + row.findHoverStruct(); + }else { + JsCpuProfilerStruct.hoverJsCpuProfilerStruct = JsCpuProfilerStruct.hoverJsCpuProfilerStruct || row.getHoverStruct(); + } + } if (clickRowType === TraceRow.ROW_TYPE_JS_CPU_PROFILER && JsCpuProfilerStruct.hoverJsCpuProfilerStruct) { JsCpuProfilerStruct.selectJsCpuProfilerStruct = JsCpuProfilerStruct.hoverJsCpuProfilerStruct; let selectStruct = JsCpuProfilerStruct.selectJsCpuProfilerStruct; @@ -117,7 +124,7 @@ export function JsCpuProfilerStructOnClick(clickRowType: string, sp: SpSystemTra let that = sp; getTopJsCpuProfilerStruct(selectStruct.parentId, selectStruct, that, dataArr, parentIdArr); that.traceSheetEL?.displayJsProfilerData(dataArr); - reject(); + reject(new Error()); } else { resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerEBPF.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerEBPF.ts index 8db49c867eaa9645b2cab375bad969bcdf53bdab..d5a8313fd3aff20db6a5bbe17051c88e7332cc79 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerEBPF.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerEBPF.ts @@ -13,17 +13,7 @@ * limitations under the License. */ -import { - BaseStruct, - drawFlagLine, - drawLines, - drawLoading, - drawLoadingFrame, - drawSelection, - PerfRender, - Rect, - RequestMessage, -} from './ProcedureWorkerCommon'; +import { BaseStruct, drawLoadingFrame, PerfRender, Rect, RequestMessage } from './ProcedureWorkerCommon'; import { TraceRow } from '../../component/trace/base/TraceRow'; export class EBPFRender extends PerfRender { @@ -124,7 +114,7 @@ function setFrameGroupBy10MS(eBPFFilters: Array, startNS: number, endNS: nu let y = frame.y; for (let i = 0; i < eBPFFilters.length; i++) { let it = eBPFFilters[i]; - if ((it.startNS || 0) + (it.size || 0) > startNS && (it.startNS || 0) < endNS) { + if ((it.startNS || 0) + (it.dur || 0) > startNS && (it.startNS || 0) < endNS) { if (!it.frame) { it.frame = {}; it.frame.y = y; @@ -168,8 +158,10 @@ function setFrameByArr( it.frame = {}; it.frame.y = y; } - EBPFChartStruct.setFrame(it, pns, startNS, endNS, frame, false); - eBPFFilters.push(it); + if (it.size > 0) { + EBPFChartStruct.setFrame(it, pns, startNS, endNS, frame, false); + eBPFFilters.push(it); + } }); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameAnimation.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameAnimation.ts index 0752a7aa650622b855df9048a3ac0396b1cf5126..c4625d49bf0fb2e16c3992541850c429bf40bdb2 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameAnimation.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameAnimation.ts @@ -106,13 +106,15 @@ export class FrameAnimationRender extends Render { } } } -export function FrameAnimationStructOnClick(clickRowType: string, sp: SpSystemTrace) { +export function FrameAnimationStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow) { return new Promise((resolve,reject) => { - if (clickRowType === TraceRow.ROW_TYPE_FRAME_ANIMATION && FrameAnimationStruct.hoverFrameAnimationStruct) { - FrameAnimationStruct.selectFrameAnimationStruct = FrameAnimationStruct.hoverFrameAnimationStruct; - sp.traceSheetEL?.displayFrameAnimationData(FrameAnimationStruct.selectFrameAnimationStruct); - sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + if (clickRowType === TraceRow.ROW_TYPE_FRAME_ANIMATION) { + FrameAnimationStruct.selectFrameAnimationStruct = FrameAnimationStruct.hoverFrameAnimationStruct || row.getHoverStruct(); + if (FrameAnimationStruct.selectFrameAnimationStruct) { + sp.traceSheetEL?.displayFrameAnimationData(FrameAnimationStruct.selectFrameAnimationStruct); + sp.timerShaftEL?.modifyFlagList(undefined); + } + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameDynamic.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameDynamic.ts index baeb077d1466893b4732d3c5400aa1a8b57f9169..27bccce0470a260978029003b3b3328baa194ea5 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameDynamic.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameDynamic.ts @@ -287,11 +287,13 @@ export class FrameDynamicRender extends Render { } export function FrameDynamicStructOnClick(clickRowType: string, sp: SpSystemTrace, row: undefined | TraceRow) { return new Promise((resolve,reject) => { - if (clickRowType === TraceRow.ROW_TYPE_FRAME_DYNAMIC && FrameDynamicStruct.hoverFrameDynamicStruct) { - FrameDynamicStruct.selectFrameDynamicStruct = FrameDynamicStruct.hoverFrameDynamicStruct; - sp.traceSheetEL?.displayFrameDynamicData(row!, FrameDynamicStruct.selectFrameDynamicStruct); - sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + if (clickRowType === TraceRow.ROW_TYPE_FRAME_DYNAMIC) { + FrameDynamicStruct.selectFrameDynamicStruct = FrameDynamicStruct.hoverFrameDynamicStruct || row?.getHoverStruct(); + if (FrameDynamicStruct.selectFrameDynamicStruct) { + sp.traceSheetEL?.displayFrameDynamicData(row!, FrameDynamicStruct.selectFrameDynamicStruct); + sp.timerShaftEL?.modifyFlagList(undefined); + } + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts index 62323feddfaf526a3b6277c78053b4f28c6759b5..70204094170110d7ce7e20817ecc0b01e47cf25a 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFrameSpacing.ts @@ -298,13 +298,15 @@ export class FrameSpacingRender extends Render { return [min, max]; } } -export function FrameSpacingStructOnClick(clickRowType: string, sp: SpSystemTrace) { +export function FrameSpacingStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow) { return new Promise((resolve,reject) => { - if (clickRowType === TraceRow.ROW_TYPE_FRAME_SPACING && FrameSpacingStruct.hoverFrameSpacingStruct) { - FrameSpacingStruct.selectFrameSpacingStruct = FrameSpacingStruct.hoverFrameSpacingStruct; - sp.traceSheetEL?.displayFrameSpacingData(FrameSpacingStruct.selectFrameSpacingStruct); - sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + if (clickRowType === TraceRow.ROW_TYPE_FRAME_SPACING) { + FrameSpacingStruct.selectFrameSpacingStruct = FrameSpacingStruct.hoverFrameSpacingStruct || row.getHoverStruct(); + if (FrameSpacingStruct.selectFrameSpacingStruct) { + sp.traceSheetEL?.displayFrameSpacingData(FrameSpacingStruct.selectFrameSpacingStruct); + sp.timerShaftEL?.modifyFlagList(undefined); + } + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFreq.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFreq.ts index 6f7526e47d6a466a865c91f4bd8fd7428be4a47e..79323c52354b025aecc16e53aa0c881c1f7ec93f 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFreq.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFreq.ts @@ -75,7 +75,7 @@ export function CpuFreqStructOnClick(clickRowType: string, sp: SpSystemTrace) { CpuFreqStruct.selectCpuFreqStruct = CpuFreqStruct.hoverCpuFreqStruct; sp.traceSheetEL?.displayFreqData(); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFreqExtend.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFreqExtend.ts index cb0d0049c66f9d682f7af9b0301e0b2fdffec334..13d9fefc368818a327fa76284a8798c2940c9ce6 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFreqExtend.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFreqExtend.ts @@ -38,9 +38,14 @@ export class FreqExtendRender extends Render { paddingTop: 5, useCache: freqReq.useCache || !(TraceRow.range?.refresh ?? false), }); - if (row.isHover) { - CpuFreqExtendStruct.cycle = -1; + if (freqReq.type === 'cpu-freq') { + CpuFreqExtendStruct.cpuCycle = -1; + } else if (freqReq.type === 'gpu-freq') { + CpuFreqExtendStruct.gpuCycle = -1; + } else { + CpuFreqExtendStruct.schedCycle = -1 + } CpuFreqExtendStruct.isTabHover = false; } freqReq.context.beginPath(); @@ -49,52 +54,52 @@ export class FreqExtendRender extends Render { CpuFreqExtendStruct.hoverCpuFreqStruct = re; } if (!row.isHover && !CpuFreqExtendStruct.isTabHover) CpuFreqExtendStruct.hoverCpuFreqStruct = undefined; - CpuFreqExtendStruct.draw(freqReq.context, re); + CpuFreqExtendStruct.draw(freqReq.context, re, freqReq.type); } freqReq.context.closePath(); } } export class CpuFreqExtendStruct extends BaseStruct { - static maxValue: number = 0; - static cycle: number = -1; + static cpuMaxValue: number = 0; + static gpuMaxValue: number = 0; + static schedMaxValue: number = 0; + static cpuCycle: number = -1; + static gpuCycle: number = -1; + static schedCycle: number = -1; static isTabHover: boolean = false; + static hoverType: string = ''; static hoverCpuFreqStruct: CpuFreqExtendStruct | undefined; - freq: number = 0; static selectCpuFreqStruct: CpuFreqExtendStruct | undefined; - cpu: number | undefined; value: number = 0; startNS: number | undefined; dur: number | undefined; //自补充,数据库没有返回 cycle: number | undefined; - type: string | undefined; - count: number = 0; + colorIndex: number = 0; - static draw(freqContext: CanvasRenderingContext2D, data: CpuFreqExtendStruct) { + static draw(freqContext: CanvasRenderingContext2D, data: CpuFreqExtendStruct, type: string) { if (data.frame) { let width = data.frame.width || 0; - let index = data.cpu || 0; + let index = data.colorIndex || 0; index += 2; let color = ColorUtils.colorForTid(index); freqContext.fillStyle = color; - freqContext.strokeStyle = color; if ( data === CpuFreqExtendStruct.hoverCpuFreqStruct || data === CpuFreqExtendStruct.selectCpuFreqStruct || - data === CpuFreqExtendStruct.selectCpuFreqStruct || - (data.cycle === CpuFreqExtendStruct.cycle && CpuFreqExtendStruct.cycle !== -1) + (type === CpuFreqExtendStruct.hoverType && + ((data.cycle === CpuFreqExtendStruct.cpuCycle && CpuFreqExtendStruct.cpuCycle !== -1) || + (data.cycle === CpuFreqExtendStruct.gpuCycle && CpuFreqExtendStruct.gpuCycle !== -1) || + (data.cycle === CpuFreqExtendStruct.schedCycle && CpuFreqExtendStruct.schedCycle !== -1))) ) { freqContext.fillStyle = '#ff0000'; freqContext.strokeStyle = '#ff0000'; freqContext.lineWidth = 3; freqContext.globalAlpha = 0.6; - if (data.type === 'SCHED-SWITCH' || data.type === 'GPU-FREQ') { - freqContext.globalAlpha = 1; - freqContext.fillStyle = color; - freqContext.strokeStyle = color; - } let drawHeight: number = Math.floor( - ((data.value || 0) * (data.frame.height || 0) * 1.0) / CpuFreqExtendStruct.maxValue + ((data.value || 0) * (data.frame.height || 0) * 1.0) / (type === 'CPU-FREQ' + ? CpuFreqExtendStruct.cpuMaxValue : type === 'GPU-FREQ' + ? CpuFreqExtendStruct.gpuMaxValue : CpuFreqExtendStruct.schedMaxValue) ); if (drawHeight < 1) { drawHeight = 1; @@ -106,7 +111,9 @@ export class CpuFreqExtendStruct extends BaseStruct { freqContext.globalAlpha = 0.6; freqContext.lineWidth = 1; let drawHeight: number = Math.floor( - ((data.value || 0) * (data.frame.height || 0)) / CpuFreqExtendStruct.maxValue + ((data.value || 0) * (data.frame.height || 0)) / (type === 'CPU-FREQ' + ? CpuFreqExtendStruct.cpuMaxValue : type === 'GPU-FREQ' + ? CpuFreqExtendStruct.gpuMaxValue : CpuFreqExtendStruct.schedMaxValue) ); if (drawHeight < 1) { drawHeight = 1; diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts index 0136fbd4f3ac2583c6fddc2228a0a933cb5374c8..7fd2b4c681f772274b030325ca9e378625eed80a 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts @@ -58,6 +58,7 @@ export class FuncRender extends Render { if (re.dur == 0 || re.dur == null || re.dur == undefined) { if ( re.frame && + re.itid && row.hoverX >= re.frame.x - 5 && row.hoverX <= re.frame.x + 5 && row.hoverY >= re.frame.y && @@ -67,7 +68,7 @@ export class FuncRender extends Render { funcFind = true; } } else { - if (re.frame && isFrameContainPoint(re.frame, row.hoverX, row.hoverY)) { + if (re.frame && re.itid && isFrameContainPoint(re.frame, row.hoverX, row.hoverY)) { FuncStruct.hoverFuncStruct = re; funcFind = true; } @@ -145,7 +146,7 @@ export function FuncStructOnClick(clickRowType: string, sp:any,row:TraceRow } sp.traceSheetEL?.displayFuncData(showTabArray, FuncStruct.selectFuncStruct, scrollToFuncHandler); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); } else { resolve(null); } @@ -223,10 +224,38 @@ export class FuncStruct extends BaseFuncStruct { if (flagConfig!.TaskPool === 'Enabled' && data.funName!.indexOf('H:Thread Timeout Exit') >= 0) { FuncStruct.drawTaskPoolTimeOutFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 20, 10, data!); } + // 如果该函数没有结束时间,则绘制锯齿。 + if (data.nofinish && data.frame!.width > 4) { + FuncStruct.drawRupture(ctx, data.frame.x, data.frame.y , data.frame.width, data.frame.height ); + } } } } + /** + * 绘制锯齿 + * @param ctx 绘图上下文环境 + * @param x 水平坐标 + * @param y 垂直坐标 + * @param width 函数矩形框的宽度 + * @param height 函数矩形框的高度 + */ + static drawRupture(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number) { + ctx.fillStyle = '#fff'; // 白色: '#fff' , 红色: '#FF0000'; + let ruptureWidth = 5; + let ruptureNode = height / ruptureWidth; + let len = height / ruptureNode; + ctx.moveTo(x + width - 1, y); + for (let i = 1; i <= ruptureNode; i++) { + ctx.lineTo( + x + width - 1 - (i % 2 == 0 ? 0 : ruptureWidth), + y + len * i - 2 + ); + } + ctx.closePath(); + ctx.fill(); + } + static drawTaskPoolUnSuccessFlag( ctx: CanvasRenderingContext2D, x: number, diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerHeap.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerHeap.ts index 1a3c0cfbb1cdb75da4e5be601654b08c0305f05b..8dfdb2eeee078d1ea4d9c214dbb50d3c55acb864 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerHeap.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerHeap.ts @@ -142,7 +142,7 @@ export function HeapStructOnClick(clickRowType: string, sp: SpSystemTrace, row: } sp.traceSheetEL?.displayNativeHookData(HeapStruct.selectHeapStruct, row.rowId!, ipid); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.ts index 1fe6e265ab3f18232f82ccc6b22891a507b4d9e2..bc6f7848eb565c4b94f689738da9582adf48972f 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.ts @@ -64,20 +64,24 @@ export function HeapSnapshot( } } const padding = 3; -export function HeapSnapshotStructOnClick(clickRowType: string, sp: SpSystemTrace, snapshotClickHandler: any) { +export function HeapSnapshotStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow,snapshotClickHandler: any) { return new Promise((resolve, reject) => { - if (clickRowType === TraceRow.ROW_TYPE_HEAP_SNAPSHOT && HeapSnapshotStruct.hoverSnapshotStruct) { - let snapshotRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='heapsnapshot']` - ); - HeapSnapshotStruct.selectSnapshotStruct = HeapSnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displaySnapshotData( - HeapSnapshotStruct.selectSnapshotStruct!, - snapshotRow!.dataListCache, - snapshotClickHandler - ); - reject(); - }else{ + if (clickRowType === TraceRow.ROW_TYPE_HEAP_SNAPSHOT) { + if (row.findHoverStruct) { + row.findHoverStruct(); + }else { + HeapSnapshotStruct.hoverSnapshotStruct = HeapSnapshotStruct.hoverSnapshotStruct || row.getHoverStruct(); + } + if (HeapSnapshotStruct.hoverSnapshotStruct) { + HeapSnapshotStruct.selectSnapshotStruct = HeapSnapshotStruct.hoverSnapshotStruct; + sp.traceSheetEL?.displaySnapshotData( + HeapSnapshotStruct.selectSnapshotStruct!, + row!.dataListCache, + snapshotClickHandler + ); + } + reject(new Error()); + } else { resolve(null); } }); diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerHitchTime.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerHitchTime.ts new file mode 100644 index 0000000000000000000000000000000000000000..42d43a60a2278b12e76d4bf6c21642df95c674dd --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerHitchTime.ts @@ -0,0 +1,119 @@ +/* + * 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 { BaseStruct, dataFilterHandler } from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; + +export class hitchTimeRender { + renderMainThread( + req: { + appStartupContext: CanvasRenderingContext2D; + useCache: boolean; + type: string; + }, + ltpoRow: TraceRow + ): void { + let list = ltpoRow.dataListCache; + HitchTimeStruct.maxVal = 0; + for (let i = 0; i < list.length; i++) { + if (Number(list[i].value) > HitchTimeStruct.maxVal) { + HitchTimeStruct.maxVal = Number(list[i].value) + }; + } + let filter = ltpoRow.dataListCache; + dataFilterHandler(list, filter, { + startKey: 'startTs', + durKey: 'dur', + startNS: TraceRow.range?.startNS ?? 0, + endNS: TraceRow.range?.endNS ?? 0, + totalNS: TraceRow.range?.totalNS ?? 0, + frame: ltpoRow.frame, + paddingTop: 5, + useCache: req.useCache || !(TraceRow.range?.refresh ?? false), + }); + req.appStartupContext.globalAlpha = 0.6; + let find = false; + let offset = 3; + for (let re of filter) { + if (ltpoRow.isHover) { + if ( + re.frame && + ltpoRow.hoverX >= re.frame.x - offset && + ltpoRow.hoverX <= re.frame.x + re.frame.width + offset + ) { + HitchTimeStruct.hoverHitchTimeStruct = re; + find = true; + } + } + if (!ltpoRow.isHover) HitchTimeStruct.hoverHitchTimeStruct = undefined + if (!find && ltpoRow.isHover) { + HitchTimeStruct.hoverHitchTimeStruct = undefined; + } + req.appStartupContext.beginPath() + HitchTimeStruct.draw(req.appStartupContext, re); + req.appStartupContext.closePath() + } + } +} + + +export class HitchTimeStruct extends BaseStruct { + static hoverHitchTimeStruct: HitchTimeStruct | undefined; + static selectHitchTimeStruct: HitchTimeStruct | undefined; + static maxVal: number = 0; + dur: number | undefined; + name: string | undefined; + presentId: number | undefined; + ts: number | undefined; + fanceId: number | undefined; + fps: number | undefined; + startTs: number | undefined; + nextStartTs: string | number | undefined; + nextDur: number | undefined; + value: number | undefined; + pid: number | undefined; + itid: number | undefined; + startTime: number | undefined; + signaled: number | undefined; + + static draw(ctx: CanvasRenderingContext2D, data: HitchTimeStruct): void { + if (data.frame) { + ctx.fillStyle = '#9933FA'; + if (data === HitchTimeStruct.hoverHitchTimeStruct || data === HitchTimeStruct.selectHitchTimeStruct) { + let drawHeight: number = HitchTimeStruct.maxVal !== 0 ? Math.round( + ((Number(data.value) || 0) * (data.frame.height || 0) * 1.0) / HitchTimeStruct.maxVal! + ):0; + drawHeight = data.name ==='0'? 0 : drawHeight; + drawHeight = drawHeight < 1 ? 1 : drawHeight; + ctx.globalAlpha = 1.0; + ctx.fillRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight); + ctx.lineWidth = 1; + ctx.strokeStyle = '#0000FF'; + ctx.strokeRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight) + } else { + ctx.globalAlpha = 0.6; + let drawHeight: number = 0; + if(HitchTimeStruct.maxVal! !== 0){ + drawHeight = Math.round(((Number(data.value) || 0) * (data.frame.height || 0)) / HitchTimeStruct.maxVal!); + } + drawHeight = data.name ==='0' ? 0 : drawHeight; + drawHeight = drawHeight < 1 ? 1 : drawHeight; + ctx.fillRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight) + } + + } + } + +} diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerIrq.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerIrq.ts index 2b3927dc304fabe60a1de14668170a5d175ce1b4..6c8a3b8a5fe6aab57eaa3d26a0a762228b3b0a88 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerIrq.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerIrq.ts @@ -76,7 +76,7 @@ export function IrqStructOnClick(clickRowType: string,sp:SpSystemTrace) { IrqStruct.selectIrqStruct = IrqStruct.hoverIrqStruct; sp.traceSheetEL?.displayIrqData(IrqStruct.selectIrqStruct); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerJank.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerJank.ts index 16c299895f2b0061d1230b7b8f1907cf6f5ce8b2..e9b9ec4a9b82748c8783ba0da0f0add6fd06c0d5 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerJank.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerJank.ts @@ -118,8 +118,9 @@ export function jank( } } -export function JankStructOnClick(clickRowType: string, sp: SpSystemTrace, jankClickHandler: any) { +export function JankStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow,jankClickHandler: any) { return new Promise((resolve, reject) => { + JankStruct.hoverJankStruct = JankStruct.hoverJankStruct || row.getHoverStruct(); if (clickRowType === TraceRow.ROW_TYPE_JANK && JankStruct.hoverJankStruct) { JankStruct.selectJankStructList.length = 0; sp.removeLinkLinesByBusinessType('janks'); @@ -142,7 +143,7 @@ export function JankStructOnClick(clickRowType: string, sp: SpSystemTrace, jankC }, jankClickHandler ); - reject(); + reject(new Error()); } else { resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerLTPO.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerLTPO.ts new file mode 100644 index 0000000000000000000000000000000000000000..59b41084ccc1860b0f1b7fc021837c2b6230b7ff --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerLTPO.ts @@ -0,0 +1,115 @@ +/* + * 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 { BaseStruct, dataFilterHandler } from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; + +export class LtpoRender { + renderMainThread( + req: { + appStartupContext: CanvasRenderingContext2D; + useCache: boolean; + type: string; + }, + ltpoRow: TraceRow + ): void { + let list = ltpoRow.dataListCache; + LtpoStruct.maxVal = 0; + for (let i = 0; i < list.length; i++) { + if (Number(list[i].value) > LtpoStruct.maxVal) LtpoStruct.maxVal = Number(list[i].value); + } + let filter = ltpoRow.dataListCache; + dataFilterHandler(list, filter, { + startKey: 'startTs', + durKey: 'dur', + startNS: TraceRow.range?.startNS ?? 0, + endNS: TraceRow.range?.endNS ?? 0, + totalNS: TraceRow.range?.totalNS ?? 0, + frame: ltpoRow.frame, + paddingTop: 5, + useCache: req.useCache || !(TraceRow.range?.refresh ?? false), + }); + req.appStartupContext.globalAlpha = 0.6; + let find = false; + let offset = 3; + for (let re of filter) { + if (ltpoRow.isHover) { + if ( + re.frame && + ltpoRow.hoverX >= re.frame.x - offset && + ltpoRow.hoverX <= re.frame.x + re.frame.width + offset + ) { + LtpoStruct.hoverLtpoStruct = re; + find = true; + } + } + if(!ltpoRow.isHover) LtpoStruct.hoverLtpoStruct = undefined + if (!find && ltpoRow.isHover) { + LtpoStruct.hoverLtpoStruct = undefined; + } + req.appStartupContext.beginPath() + LtpoStruct.draw(req.appStartupContext, re); + req.appStartupContext.closePath() + } + } +} + + +export class LtpoStruct extends BaseStruct { + static hoverLtpoStruct: LtpoStruct | undefined; + static selectLtpoStruct: LtpoStruct | undefined; + static maxVal: number | undefined; + dur: number | undefined; + name: string | undefined; + presentId: number | undefined; + ts: number | undefined; + fanceId: number | undefined; + fps: number | undefined; + startTs: number | undefined; + nextStartTs: string | number | undefined; + nextDur: number | undefined; + value: number | undefined ; + pid: number | undefined; + itid: number | undefined; + startTime: number | undefined; + signaled: number | undefined; + + static draw(ctx: CanvasRenderingContext2D, data: LtpoStruct): void { + if (data.frame) { + ctx.fillStyle = '#9933FA'; + if (data === LtpoStruct.hoverLtpoStruct || data === LtpoStruct.selectLtpoStruct) { + let drawHeight: number = LtpoStruct.maxVal !== 0 ? Math.floor( + ((Number(data.value) || 0) * (data.frame.height || 0) * 1.0) / LtpoStruct.maxVal! + ): 0; + drawHeight = drawHeight < 1 ? 1 : drawHeight + ctx.globalAlpha = 1.0; + ctx.fillRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight); + ctx.lineWidth = 1; + ctx.strokeStyle = ' #0000FF'; + ctx.strokeRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight) + } else { + ctx.globalAlpha = 0.6; + let drawHeight: number = 0; + if(LtpoStruct.maxVal !== 0){ + drawHeight = Math.floor(((Number(data.value) || 0) * (data.frame.height || 0)) / LtpoStruct.maxVal!); + } + drawHeight = drawHeight < 1 ? 1 : drawHeight + ctx.fillRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, data.frame.width, drawHeight) + } + + } + } + +} diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerSample.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerSample.ts new file mode 100644 index 0000000000000000000000000000000000000000..06c5395d9c0a9cc445334d84018e4bc2e634657b --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerSample.ts @@ -0,0 +1,214 @@ +/* + * 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 { ColorUtils } from '../../component/trace/base/ColorUtils'; +import { + BaseStruct, + Render, + ns2x, + Rect, + drawString, + isFrameContainPoint, + drawLoadingFrame +} from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; +import { SpSystemTrace } from "../../component/SpSystemTrace"; + +const SAMPLE_STRUCT_HEIGHT = 20; +const Y_PADDING = 2; + +export class SampleRender extends Render { + renderMainThread( + req: { + context: CanvasRenderingContext2D, + useCache: boolean, + type: string, + start_ts: number, + uniqueProperty: Array, + flattenTreeArray: Array + }, + row: TraceRow + ) { + let startTs = req.start_ts; + let sampleList = row.dataList; + let sampleFilter = row.dataListCache; + SampleStruct.reqProperty = req; + func( + sampleList, + sampleFilter, + TraceRow.range!.startNS, + TraceRow.range!.endNS, + TraceRow.range!.totalNS, + startTs, + row.frame, + req.useCache || TraceRow.range!.refresh + ); + drawLoadingFrame(req.context, sampleFilter, row, true); + req.context.beginPath(); + let find = false; + for (let re of sampleFilter) { + SampleStruct.draw(req.context, re); + if (row.isHover && re.frame && isFrameContainPoint(re.frame, row.hoverX, row.hoverY)) { + SampleStruct.hoverSampleStruct = re; + find = true; + } + } + if (!find && row.isHover) SampleStruct.hoverSampleStruct = undefined; + req.context.closePath(); + } +} + +export function func ( + sampleList: Array, + sampleFilter: Array, + startNS: number, + endNS: number, + totalNS: number, + startTS: number, + frame: any, + use: boolean +) { + if (use && sampleFilter.length > 0) { + for (let i = 0, len = sampleFilter.length; i < len; i++) { + if (((sampleFilter[i].end - startTS) || 0) >= startNS && ((sampleFilter[i].begin - startTS) || 0) <= endNS) { + SampleStruct.setSampleFrame(sampleFilter[i], 0, startNS, endNS, totalNS, startTS, frame); + } else { + sampleFilter[i].frame = undefined; + } + } + return; + } + sampleFilter.length = 0; + setSampleFilter(sampleList, sampleFilter, startNS, startTS, endNS, totalNS, frame); +} + +function setSampleFilter( + sampleList: Array, + sampleFilter: Array, + startNS: number, + startTS: number, + endNS: number, + totalNS: number, + frame: any +) { + if (sampleList) { + sampleList.forEach(func => { + let funcProperty: Array = func.property!; + let groups = funcProperty + .filter(it => (( it.end - startTS) ?? 0) >= startNS && (( it.begin - startTS) ?? 0 ) <= endNS) + .map(it => { + SampleStruct.setSampleFrame(it, 0, startNS, endNS, totalNS, startTS, frame); + return it; + }) + .reduce((pre, current) => { + ( pre[`${current.frame.x}-${current.depth}`] = pre[`${current.frame.x}-${current.depth}`] || []).push(current); + return pre; + }, {}); + Reflect.ownKeys(groups).map((kv) => { + let arr = groups[kv].sort(( a: any, b: any) => (b.end - b.start) - (a.end - a.start)); + sampleFilter.push(arr[0]); + }) + }) + } +} + +export function sampleStructOnClick(clickRowType: string, sp: SpSystemTrace) { + return new Promise((resolve, reject) => { + if (clickRowType === TraceRow.ROW_TYPE_SAMPLE && SampleStruct.hoverSampleStruct) { + SampleStruct.selectSampleStruct = SampleStruct.hoverSampleStruct; + sp.traceSheetEL?.displaySampleData(SampleStruct.selectSampleStruct, SampleStruct.reqProperty); + sp.timerShaftEL?.modifyFlagList(undefined); + reject(new Error()); + }else{ + resolve(null); + } + }); +} + +export class SampleStruct extends BaseStruct { + static hoverSampleStruct: SampleStruct | undefined; + static selectSampleStruct: SampleStruct | undefined; + static reqProperty: any | undefined; + name: string | undefined; + detail: string | undefined; + property: Array | undefined; + begin: number | undefined; + end: number | undefined; + depth: number | undefined; + startTs: number | undefined; + instructions: number | undefined; + cycles: number | undefined; + static setSampleFrame( + sampleNode: SampleStruct, + padding: number, + startNS: number, + endNS: number, + totalNS: number, + startTS: number, + frame: any + ): void { + let x1: number, x2: number; + if (((sampleNode.begin! - startTS) || 0) > startNS && ((sampleNode.begin! - startTS) || 0) < endNS) { + x1 = ns2x((sampleNode.begin! - startTS) || 0, startNS, endNS, totalNS, frame); + } else { + x1 = 0; + } + if (((sampleNode.end! - startTS) || 0) > startNS && ((sampleNode.end! - startTS) || 0) < endNS) { + x2 = ns2x((sampleNode.end! - startTS) || 0, startNS, endNS, totalNS, frame) + } else { + x2 = frame.width; + } + if (!sampleNode.frame) { + sampleNode.frame! = new Rect(0, 0, 0, 0); + } + let getV: number = x2 - x1 < 1 ? 1 : x2 - x1; + sampleNode.frame!.x = Math.floor(x1); + sampleNode.frame!.y = sampleNode.depth! * SAMPLE_STRUCT_HEIGHT; + sampleNode.frame!.width = Math.ceil(getV); + sampleNode.frame!.height = SAMPLE_STRUCT_HEIGHT; + sampleNode.startTs = startTS; + } + static draw(ctx: CanvasRenderingContext2D, data: SampleStruct): void { + if (data.depth === undefined || data.depth === null) { + return; + } + if (data.frame) { + ctx.globalAlpha = 1; + ctx.fillStyle = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth, ColorUtils.FUNC_COLOR.length)]; + const textColor = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', data.depth, ColorUtils.FUNC_COLOR.length)]; + if (SampleStruct.hoverSampleStruct && data.name === SampleStruct.hoverSampleStruct.name) { + ctx.globalAlpha = 0.7; + } + ctx.strokeStyle = '#fff'; + ctx.lineWidth = 1; + ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING); + ctx.fillStyle = ColorUtils.funcTextColor(textColor); + drawString(ctx, `${data.detail + '(' + data.name + ')' || ''}`, 5, data.frame, data); + if (data === SampleStruct.selectSampleStruct) { + ctx.strokeStyle = '#000'; + ctx.lineWidth = 2; + ctx.strokeRect(data.frame.x, data.frame.y + 1, data.frame.width, SAMPLE_STRUCT_HEIGHT - Y_PADDING - 2); + } + } + } + static equals(d1: SampleStruct, d2: SampleStruct): boolean { + return ( + d1 && + d2 && + d1.name == d2.name && + d1.begin == d2.begin + ); + } +} \ No newline at end of file diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerSnapshot.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerSnapshot.ts index bed6023615ee431953c57f763a384bfee8ef4f6e..7e9124688a2528f73104a3d3c6783cfb2035f3c8 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerSnapshot.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerSnapshot.ts @@ -12,7 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { BaseStruct, Rect, Render, drawLoadingFrame, isFrameContainPoint, ns2x } from './ProcedureWorkerCommon'; + +import { BaseStruct, Rect, Render, drawLoadingFrame, isFrameContainPoint } from './ProcedureWorkerCommon'; import { TraceRow } from '../../component/trace/base/TraceRow'; import { Utils } from '../../component/trace/base/Utils'; import { MemoryConfig } from '../../bean/MemoryConfig'; @@ -67,160 +68,118 @@ export function snapshot( } } const padding = 2; -export function SnapshotStructOnClick(clickRowType: string, sp: SpSystemTrace) { + +const snapshotTypeHandlerMap = new Map, reject: any) => void>([ + [TraceRow.ROW_TYPE_SYS_MEMORY_GPU_TOTAL, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayGpuDumpTotalSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_SYS_MEMORY_GPU_WINDOW, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayGpuDumpWindowSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_VM_TRACKER_SMAPS, (sp: SpSystemTrace, row: TraceRow, reject: any) => displaySmapsSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_VMTRACKER_SHM, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayShmSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_PURGEABLE_TOTAL_ABILITY, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayTotalAbilitySheet(sp, row, reject)], + [TraceRow.ROW_TYPE_PURGEABLE_PIN_ABILITY, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayPinAbilitySheet(sp, row, reject)], + [TraceRow.ROW_TYPE_PURGEABLE_TOTAL_VM, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayTotalVMSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_PURGEABLE_PIN_VM, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayPinVMSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_DMA_ABILITY, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayDmaAbilitySheet(sp, row, reject)], + [TraceRow.ROW_TYPE_DMA_VMTRACKER, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayDmaVmTrackerSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayGpuMemoryAbilitySheet(sp, row, reject)], + [TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayGpuMemoryVmTrackerSheet(sp, row, reject)], + [TraceRow.ROW_TYPE_GPU_RESOURCE_VMTRACKER, (sp: SpSystemTrace, row: TraceRow, reject: any) => displayGpuResourceSheet(sp)], +]) +export function SnapshotStructOnClick(clickRowType: string, sp: SpSystemTrace, row: TraceRow) { return new Promise((resolve, reject) => { - if (SnapshotStruct.hoverSnapshotStruct) { - if (clickRowType === TraceRow.ROW_TYPE_SYS_MEMORY_GPU_TOTAL) { - displayGpuDumpTotalSheet(sp, reject); - } else if (clickRowType === TraceRow.ROW_TYPE_SYS_MEMORY_GPU_WINDOW) { - displayGpuDumpWindowSheet(sp, reject); - } else if (clickRowType === TraceRow.ROW_TYPE_VM_TRACKER_SMAPS) { - displaySmapsSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_VMTRACKER_SHM) { - displayShmSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_ABILITY) { - displayTotalAbilitySheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_ABILITY) { - displayPinAbilitySheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_TOTAL_VM) { - displayTotalVMSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_PURGEABLE_PIN_VM) { - displayPinVMSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_DMA_ABILITY) { - displayDmaAbilitySheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_DMA_VMTRACKER) { - displayDmaVmTrackerSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_GPU_MEMORY_ABILITY) { - displayGpuMemoryAbilitySheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_GPU_MEMORY_VMTRACKER) { - displayGpuMemoryVmTrackerSheet(sp, reject); - } - if (clickRowType === TraceRow.ROW_TYPE_GPU_RESOURCE_VMTRACKER) { - displayGpuResourceSheet(sp); - } else { - resolve(null); - } + if (snapshotTypeHandlerMap.has(clickRowType)) { + SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct || row.getHoverStruct(); + snapshotTypeHandlerMap.get(clickRowType)?.(sp, row ,reject); + reject(new Error()); + } else { + resolve(null); } }); } -function displayGpuDumpTotalSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let gpuDumpTotalRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='Skia Gpu Dump Total']` - ); +function displayGpuDumpTotalSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; sp.traceSheetEL?.displayGpuSelectedData( 'total', SnapshotStruct.selectSnapshotStruct!.startNs, - gpuDumpTotalRow!.dataListCache + row!.dataListCache ); sp.timerShaftEL?.modifyFlagList(undefined); reject(); } -function displayGpuDumpWindowSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let gpuDumpWindowRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='Skia Gpu Dump Window']` - ); +function displayGpuDumpWindowSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; sp.traceSheetEL?.displayGpuSelectedData( 'window', SnapshotStruct.selectSnapshotStruct!.startNs, - gpuDumpWindowRow!.dataListCache + row!.dataListCache ); sp.timerShaftEL?.modifyFlagList(undefined); reject(); } -function displaySmapsSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let smapsRow = sp.shadowRoot?.querySelector>(`trace-row[row-id='Dirty']`); +function displaySmapsSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displaySmapsData(SnapshotStruct.selectSnapshotStruct!, smapsRow!.dataListCache); + sp.traceSheetEL?.displaySmapsData(SnapshotStruct.selectSnapshotStruct!, row!.dataListCache); reject(); } -function displayShmSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let shmRow = sp.shadowRoot?.querySelector>(`trace-row[row-id='SHM']`); +function displayShmSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayShmData(SnapshotStruct.selectSnapshotStruct!, shmRow!.dataListCache); + sp.traceSheetEL?.displayShmData(SnapshotStruct.selectSnapshotStruct!, row!.dataListCache); reject(); } -function displayTotalAbilitySheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let totalAbilityRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='System Purgeable Total']` - ); +function displayTotalAbilitySheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayPurgTotalAbilityData(SnapshotStruct.hoverSnapshotStruct!, totalAbilityRow!.dataListCache); + sp.traceSheetEL?.displayPurgTotalAbilityData(SnapshotStruct.hoverSnapshotStruct!, row!.dataListCache); reject(); } -function displayPinAbilitySheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let pinAbilityRow = sp.shadowRoot?.querySelector>( - `trace-row[row-id='System Purgeable Pin']` - ); +function displayPinAbilitySheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayPurgPinAbilityData(SnapshotStruct.hoverSnapshotStruct!, pinAbilityRow!.dataListCache); + sp.traceSheetEL?.displayPurgPinAbilityData(SnapshotStruct.hoverSnapshotStruct!, row!.dataListCache); reject(); } -function displayTotalVMSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let totalVMRow = sp.shadowRoot?.querySelector>(`trace-row[row-id='Purgeable Total']`); +function displayTotalVMSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayPurgTotalVMData(SnapshotStruct.hoverSnapshotStruct!, totalVMRow!.dataListCache); + sp.traceSheetEL?.displayPurgTotalVMData(SnapshotStruct.hoverSnapshotStruct!, row!.dataListCache); reject(); } -function displayPinVMSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let pinVMRow = sp.shadowRoot?.querySelector>(`trace-row[row-id='Purgeable Pin']`); +function displayPinVMSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayPurgPinVMData(SnapshotStruct.hoverSnapshotStruct!, pinVMRow!.dataListCache); + sp.traceSheetEL?.displayPurgPinVMData(SnapshotStruct.hoverSnapshotStruct!, row!.dataListCache); reject(); } -function displayDmaAbilitySheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let dmaAbilityRow = sp.shadowRoot?.querySelector>(`trace-row[row-id='abilityMonitorDma']`); +function displayDmaAbilitySheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayDmaAbility(SnapshotStruct.selectSnapshotStruct!.startNs, dmaAbilityRow!.dataListCache); + sp.traceSheetEL?.displayDmaAbility(SnapshotStruct.selectSnapshotStruct!.startNs, row!.dataListCache); reject(); } -function displayDmaVmTrackerSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let dmaVmTracker = sp.shadowRoot?.querySelector>(`trace-row[row-type='dma-vmTracker']`); +function displayDmaVmTrackerSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; - sp.traceSheetEL?.displayDmaVmTracker(SnapshotStruct.selectSnapshotStruct!.startNs, dmaVmTracker!.dataListCache); + sp.traceSheetEL?.displayDmaVmTracker(SnapshotStruct.selectSnapshotStruct!.startNs, row!.dataListCache); reject(); } -function displayGpuMemoryAbilitySheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let gpuMemoryAbilityMonitor = sp.shadowRoot?.querySelector>( - `trace-row[row-id='abilityMonitorGpuMemory']` - ); +function displayGpuMemoryAbilitySheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; sp.traceSheetEL?.displayGpuMemoryAbility( SnapshotStruct.selectSnapshotStruct!.startNs, - gpuMemoryAbilityMonitor!.dataListCache + row!.dataListCache ); reject(); } -function displayGpuMemoryVmTrackerSheet(sp: SpSystemTrace, reject: (reason?: any) => void) { - let gpuMemoryVmTracker = sp.shadowRoot?.querySelector>( - `trace-row[row-id='Skia Gpu Memory']` - ); +function displayGpuMemoryVmTrackerSheet(sp: SpSystemTrace, row: TraceRow, reject: (reason?: any) => void) { SnapshotStruct.selectSnapshotStruct = SnapshotStruct.hoverSnapshotStruct; sp.traceSheetEL?.displayGpuMemoryVmTracker( SnapshotStruct.selectSnapshotStruct!.startNs, - gpuMemoryVmTracker!.dataListCache + row!.dataListCache ); reject(); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts index 875afa1f1d4e4c29dafd88b488e89011090bbfa6..0f8bc2aa8a81889ae4f122438e256625167c2902 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts @@ -114,7 +114,7 @@ export function SoStructOnClick(clickRowType: string, sp: SpSystemTrace, scrollT SoStruct.selectSoStruct = SoStruct.hoverSoStruct; sp.traceSheetEL?.displayStaticInitData(SoStruct.selectSoStruct, scrollToFuncHandler); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts index f9ab36d3050725db918824eafa6e776c4406dd26..82364ed786b65b7ca7cf9ee877fed4ff033fc6f1 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts @@ -73,7 +73,7 @@ export function ThreadStructOnClick(clickRowType:string,sp:SpSystemTrace,threadC sp.timerShaftEL?.drawTriangle(ThreadStruct.selectThreadStruct!.startTime || 0, 'inverted'); sp.traceSheetEL?.displayThreadData(ThreadStruct.selectThreadStruct, threadClickHandler, cpuClickHandler); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } @@ -88,29 +88,42 @@ export class ThreadStruct extends BaseThreadStruct { static hoverThreadStruct: ThreadStruct | undefined; static selectThreadStruct: ThreadStruct | undefined; static selectThreadStructList: Array = new Array(); + static firstselectThreadStruct: ThreadStruct | undefined; argSetID: number | undefined; translateY: number | undefined; textMetricsWidth: number | undefined; + static startCycleTime: number = 0; + static endTime: number = 0; static drawThread(threadContext: CanvasRenderingContext2D, data: ThreadStruct) { if (data.frame) { - threadContext.globalAlpha = 1; - let stateText = ThreadStruct.getEndState(data.state || ''); - threadContext.fillStyle = Utils.getStateColor(data.state || ''); - if ('S' === data.state) { + if (data.name === 'all-state') { + threadContext.globalAlpha = 0.8; + } else { + threadContext.globalAlpha = 1; + }; + if (!ThreadStruct.selectThreadStruct && data.start_ts! + data.dur! > ThreadStruct.startCycleTime && data.start_ts! + data.dur! < ThreadStruct.endTime) { + threadContext.globalAlpha = 1; + }; + let stateText = ThreadStruct.getEndState(data.state === 'S' && data.name === 'Sleeping' ? data.name : data.state || ''); + if (data.name === 'all-state' && data.state === 'S') { + stateText = 'Sleeping'; + }; + threadContext.fillStyle = Utils.getStateColor(data.state === 'S' && data.name === 'all-state' ? 'Sleeping' : data.state || ''); + if ('S' === data.state && data.name !== 'all-state') { threadContext.globalAlpha = 0.2; - } - threadContext.fillRect(data.frame.x, data.frame.y + padding, data.frame.width, data.frame.height - padding * 2); + }; + threadContext.fillRect(data.frame.x, data.frame.y + padding, data.frame.width > 1 ? data.frame.width : 1, data.frame.height - padding * 2); threadContext.fillStyle = '#fff'; threadContext.textBaseline = 'middle'; threadContext.font = '8px sans-serif'; - if ('S' !== data.state) { + if ('S' !== data.state || (data.name === 'all-state' && data.state === 'S')) { data.frame.width > 7 && drawString(threadContext, stateText, 2, data.frame, data); - } + }; if ( ThreadStruct.selectThreadStruct && ThreadStruct.equals(ThreadStruct.selectThreadStruct, data) && - ThreadStruct.selectThreadStruct.state != 'S' + (ThreadStruct.selectThreadStruct.state !== 'S'|| data.name === 'all-state') ) { threadContext.strokeStyle = '#232c5d'; threadContext.lineWidth = 2; diff --git a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts index 71d3a84cb0becfe68e09ea82a2557d8674becddb..d2e05ff628bfae2ccb2a4285d92f2112c4a78d44 100644 --- a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts +++ b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts @@ -207,7 +207,7 @@ export function CpuStructOnClick(rowType: string, sp: SpSystemTrace, cpuClickHan cpuClickHandler ); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits.ts b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits.ts index 18a38516a1c51f5dbb5a2c1822eb3cac1dd77f11..980f8c7f50623223ed4fdb1776e34da661526682 100644 --- a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits.ts +++ b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits.ts @@ -87,7 +87,7 @@ export function CpuFreqLimitsStructOnClick(clickRowType: string, sp: SpSystemTra CpuFreqLimitsStruct.selectCpuFreqLimitsStruct = CpuFreqLimitsStruct.hoverCpuFreqLimitsStruct; sp.traceSheetEL?.displayFreqLimitData(); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState.ts b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState.ts index 926ca1017498f87a3274f3f8c8824e59261f5696..2110d20b001b18d9977ac2f80d8967d9fcbacfda 100644 --- a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState.ts +++ b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState.ts @@ -171,7 +171,7 @@ export function CpuStateStructOnClick(clickRowType: string, sp: SpSystemTrace) { CpuStateStruct.selectStateStruct = CpuStateStruct.hoverStateStruct; sp.traceSheetEL?.displayCpuStateData(); sp.timerShaftEL?.modifyFlagList(undefined); - reject(); + reject(new Error()); }else{ resolve(null); } diff --git a/ide/src/trace/database/ui-worker/procedureWorkerBinder.ts b/ide/src/trace/database/ui-worker/procedureWorkerBinder.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b8e15fd29904ee8254442d6e768e292ba98490b --- /dev/null +++ b/ide/src/trace/database/ui-worker/procedureWorkerBinder.ts @@ -0,0 +1,122 @@ + +/* + * 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 { ColorUtils } from '../../component/trace/base/ColorUtils'; +import { BaseStruct, dataFilterHandler, isFrameContainPoint, Render, RequestMessage } from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; +import { drawString, Rect } from './ProcedureWorkerCommon'; +export class BinderRender extends Render { + renderMainThread( + freqReq: { + context: CanvasRenderingContext2D; + useCache: boolean; + type: string; + }, + row: TraceRow + ) { + let binderList = row.dataList; + let binderFilter = row.dataListCache; + dataFilterHandler(binderList, binderFilter, { + startKey: 'startNS', + durKey: 'dur', + startNS: TraceRow.range?.startNS ?? 0, + endNS: TraceRow.range?.endNS ?? 0, + totalNS: TraceRow.range?.totalNS ?? 0, + frame: row.frame, + paddingTop: 5, + useCache: freqReq.useCache || !(TraceRow.range?.refresh ?? false), + }); + freqReq.context.beginPath(); + for (let re of binderFilter) { + if (row.isHover && re.frame && isFrameContainPoint(re.frame, row.hoverX, row.hoverY)) { + BinderStruct.hoverCpuFreqStruct = re; + } + if (!row.isHover) { + BinderStruct.hoverCpuFreqStruct = undefined; + } + BinderStruct.draw(freqReq.context, re); + } + freqReq.context.closePath(); + } +} +export class BinderStruct extends BaseStruct { + static hoverCpuFreqStruct: BinderStruct | undefined; + static selectCpuFreqStruct: BinderStruct | undefined; + static maxHeight: number = 0; + static hoverCycle: number = -1; + value: number = 0; + cycle: number = 0; + startNS: number | undefined; + dur: number | undefined; //自补充,数据库没有返回 + name: string | undefined; + depth: number = 0; + static draw(freqContext: CanvasRenderingContext2D, data: BinderStruct) { + if (data.frame) { + let color = ''; + if (data.name === 'binder transaction') { + color = '#e86b6a'; + } + if (data.name === 'binder transaction async') { + color = '#36baa4'; + } + if (data.name === 'binder reply') { + color = '#8770d3'; + } + if (data.name === 'binder async rcv') { + color = '#0cbdd4'; + } + freqContext.fillStyle = color; + if ( + data === BinderStruct.hoverCpuFreqStruct || + data === BinderStruct.selectCpuFreqStruct || + data.cycle === BinderStruct.hoverCycle + ) { + freqContext.globalAlpha = 1; + freqContext.lineWidth = 1; + freqContext.fillRect( + data.frame.x, + BinderStruct.maxHeight * 20 - data.depth * 20 + 20, + data.frame.width, + data.value * 20 + ); + } else { + freqContext.globalAlpha = 0.6; + freqContext.lineWidth = 1; + freqContext.fillRect( + data.frame.x, + BinderStruct.maxHeight * 20 - data.depth * 20 + 20, + data.frame.width, + data.value * 20 + ); + } + if (data.frame.width > 8) { + freqContext.lineWidth = 1; + freqContext.fillStyle = ColorUtils.funcTextColor( + ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', 0, ColorUtils.FUNC_COLOR.length)] + ); + freqContext.textBaseline = 'middle'; + drawString( + freqContext, + `${data.name || ''}`, + 6, + new Rect(data.frame.x, BinderStruct.maxHeight * 20 - data.depth * 20 + 20, data.frame.width, data.value * 20), + data + ); + } + freqContext.globalAlpha = 1.0; + freqContext.lineWidth = 1; + } + } +} diff --git a/ide/test/base-ui/modal/LitModal.test.ts b/ide/test/base-ui/modal/LitModal.test.ts deleted file mode 100644 index ffda1afd0a3f5604c895c2e7c3479d4aea896581..0000000000000000000000000000000000000000 --- a/ide/test/base-ui/modal/LitModal.test.ts +++ /dev/null @@ -1,186 +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 { LitModal } from '../../../src/base-ui/modal/LitModal'; - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); - -describe('LitModal Test', () => { - it('LitModalTest01', function () { - let litModal = new LitModal(); - expect(litModal).not.toBeUndefined(); - }); - - it('LitModalTest02', function () { - let litModal = new LitModal(); - litModal.resizeable = true; - expect(litModal).not.toBeUndefined(); - }); - - it('LitModalTest03', function () { - let litModal = new LitModal(); - litModal.resizeable = false; - expect(litModal).not.toBeUndefined(); - }); - - it('LitModalTest04', function () { - let litModal = new LitModal(); - litModal.moveable = false; - expect(litModal).not.toBeUndefined(); - }); - - it('LitModalTest05', function () { - let litModal = new LitModal(); - litModal.moveable = true; - expect(litModal).not.toBeUndefined(); - }); - - it('LitModalTest06', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - litmode.resizing = true; - let mouseOutEvent: MouseEvent = new MouseEvent('mousemove', { movementX: 1, movementY: 2 }); - litmode.dispatchEvent(mouseOutEvent); - }); - - it('LitModalTest19', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - - let mouseOutEvent: MouseEvent = new MouseEvent('mousedown', { movementX: 1, movementY: 2 }); - litmode.dispatchEvent(mouseOutEvent); - }); - - it('LitModalTest07', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - - let mouseOutEvent: MouseEvent = new MouseEvent('mouseleave', { movementX: 1, movementY: 2 }); - litmode.dispatchEvent(mouseOutEvent); - }); - - it('LitModalTest08', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - let mouseOutEvent: MouseEvent = new MouseEvent('mousemove', { clientX: 1, clientY: 2 }); - litmode.dispatchEvent(mouseOutEvent); - }); - it('LitModalTest08', function () { - let litModal = new LitModal(); - litModal.okText = 'ok-text'; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest09', function () { - let litModal = new LitModal(); - litModal.cancelText = 'cancel-text'; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest10', function () { - let litModal = new LitModal(); - litModal.title = 'title'; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest11', function () { - let litModal = new LitModal(); - litModal.visible = 'visible'; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest12', function () { - let litModal = new LitModal(); - litModal.visible = true; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest17', function () { - let litModal = new LitModal(); - litModal.visible = false; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest13', function () { - let litModal = new LitModal(); - litModal.width = 'width'; - expect(litModal).not.toBeUndefined(); - }); - it('LitModalTest14', function () { - let litModal = new LitModal(); - expect(litModal.adoptedCallback()).toBeUndefined(); - }); - it('LitModalTest15', function () { - let litModal = new LitModal(); - litModal.addEventListener = jest.fn(() => true); - litModal.onOk = true; - expect(litModal).toBeTruthy(); - }); - it('LitModalTest18', function () { - let litModal = new LitModal(); - litModal.addEventListener = jest.fn(() => true); - litModal.onCancel = true; - expect(litModal).toBeTruthy(); - }); - it('LitModalTest19', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - let mouseClickEvent: MouseEvent = new MouseEvent('click', { clientX: 1, clientY: 2 }); - litmode.resizeable = false; - litmode.dispatchEvent(mouseClickEvent); - }); - it('LitModalTest20', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - let mouseClickEvent: MouseEvent = new MouseEvent('click', { clientX: 1, clientY: 2 }); - litmode.cancelElement.dispatchEvent(mouseClickEvent); - }); - it('LitModalTest21', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - let mouseClickEvent: MouseEvent = new MouseEvent('click', { clientX: 1, clientY: 2 }); - litmode.okElement.dispatchEvent(mouseClickEvent); - }); - it('LitModalTest22', function () { - document.body.innerHTML = ` -
        - -
        `; - let litmode = document.getElementById('lit-modal') as LitModal; - let mouseDownEvent: MouseEvent = new MouseEvent('mousedown', { clientX: 1, clientY: 2 }); - litmode.dispatchEvent(mouseDownEvent); - }); -}); diff --git a/ide/test/base-ui/select/LitSelect.test.ts b/ide/test/base-ui/select/LitSelect.test.ts index d069d58a4bd434682e1961042a54225b3a6eff17..6f497778827101305fc57808ce53696caf696ffd 100644 --- a/ide/test/base-ui/select/LitSelect.test.ts +++ b/ide/test/base-ui/select/LitSelect.test.ts @@ -13,8 +13,7 @@ * limitations under the License. */ -import { LitButton, LitSelect } from '../../../src/base-ui/select/LitSelect'; -import { LitSelectOption } from '../../../src/base-ui/select/LitSelectOption'; +import { LitSelect } from '../../../src/base-ui/select/LitSelect'; describe('LitSelect Test', () => { it('LitSelectTest01', function () { @@ -75,7 +74,6 @@ describe('LitSelect Test', () => { it('LitSelectTest10', function () { document.body.innerHTML = ``; let select = document.querySelector('#litSelect') as LitSelect; - // select.inputElement.value = '3333'; select.click(); expect(select.focused).toBe(true); }); diff --git a/ide/test/base-ui/table/LitTable.test.ts b/ide/test/base-ui/table/LitTable.test.ts index 1d01e2c0bd966d8dcd72907ba3193d4177902ba4..8cbe10b0f93ab52f146cef7cd140dba241343a69 100644 --- a/ide/test/base-ui/table/LitTable.test.ts +++ b/ide/test/base-ui/table/LitTable.test.ts @@ -139,17 +139,17 @@ describe('LitTable Test', () => { expect(litTable.renderTable()).toBeUndefined(); }); - it('LitTableTest04', () => { + it('LitTableTest03', () => { litTable.switch = document.querySelector('#switch') as HTMLInputElement; expect(litTable.connectedCallback()).toBeUndefined(); }); - it('LitTableTest05', () => { + it('LitTableTest04', () => { let rowLength = litTable.getCheckRows().length == 0; expect(rowLength).toBeTruthy(); }); - it('LitTableTest06', () => { + it('LitTableTest05', () => { expect( litTable.deleteRowsCondition(() => { return true; @@ -157,44 +157,36 @@ describe('LitTable Test', () => { ).toBeUndefined(); }); - it('LitTableTest07', () => { + it('LitTableTest06', () => { expect(litTable.selectable).not.toBeUndefined(); }); - it('LitTableTest08', () => { + it('LitTableTest07', () => { litTable.selectable = true; expect(litTable.selectable).toBeTruthy(); }); - it('LitTableTest09', () => { + it('LitTableTest08', () => { expect(litTable.scrollY).not.toBeUndefined(); }); - it('LitTableTest10', () => { + it('LitTableTest09', () => { expect(litTable.dataSource).not.toBeUndefined(); }); - it('LitTableTest11', () => { + it('LitTableTest10', () => { expect(litTable.recycleDataSource).not.toBeUndefined(); }); - it('LitTableTest12', () => { - expect(litTable.fixed(td, placement)).toBeUndefined(); - }); - - it('LitTableTest13', () => { - expect(litTable.fixed(td, 'right')).toBe(undefined); - }); - - it('LitTableTest14', () => { + it('LitTableTest11', () => { expect(litTable.meauseElementHeight()).toBe(27); }); - it('LitTableTest15', () => { + it('LitTableTest12', () => { expect(litTable.meauseTreeElementHeight()).toBe(27); }); - it('LitTableTest16', () => { + it('LitTableTest13', () => { document.body.innerHTML = ""; let table = document.querySelector('#tab') as LitTable; let htmlElement = document.createElement('lit-table-column') as LitTableColumn; @@ -219,11 +211,11 @@ describe('LitTable Test', () => { }, 20); }); - it('LitTableTest18', () => { + it('LitTableTest14', () => { expect(litTable.createExpandBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); }); - it('LitTableTest19', () => { + it('LitTableTest15', () => { let newTableElement = document.createElement('div'); newTableElement.classList.add('tr'); newTableElement.style.cursor = 'pointer'; @@ -240,7 +232,7 @@ describe('LitTable Test', () => { expect(litTable.reMeauseHeight()).toBeUndefined(); }); - it('LitTableTest20', () => { + it('LitTableTest15', () => { const rowData = { data: [ { @@ -252,7 +244,7 @@ describe('LitTable Test', () => { expect(litTable.createNewTableElement(rowData)).not.toBeUndefined(); }); - it('LitTableTest21', () => { + it('LitTableTest16', () => { let element = document.createElement('div'); let ch = document.createElement('div'); element.appendChild(ch); @@ -274,13 +266,13 @@ describe('LitTable Test', () => { expect(litTable.freshCurrentLine(element, rowObject)).toBeUndefined(); }); - it('LitTableTest22', () => { + it('LitTableTest16', () => { litTable.recycleDs.length = 1; litTable.setCurrentSelection = jest.fn(() => true); expect(litTable.scrollToData()).toBeUndefined(); }); - it('LitTableTest23', () => { + it('LitTableTest17', () => { litTable.recycleDs = [{ rowHidden: false, data: { isSearch: true } }]; let dataSource = [ { @@ -295,15 +287,15 @@ describe('LitTable Test', () => { expect(litTable.expandList(dataSource)).toBeUndefined(); }); - it('LitTableTest24', () => { + it('LitTableTest18', () => { expect(litTable.clearAllSelection()).toBeUndefined(); }); - it('LitTableTest25', () => { + it('LitTableTest19', () => { expect(litTable.dispatchRowClickEvent({ data: { isSelected: '' } }, [], {button: ''})).toBeUndefined(); }); - it('LitTableTest26', () => { + it('LitTableTest20', () => { litTable.treeElement = jest.fn(() => undefined); litTable.treeElement.children = jest.fn(() => [1]); litTable.columns.forEach = jest.fn(() => true); @@ -312,25 +304,25 @@ describe('LitTable Test', () => { expect(litTable.createNewTreeTableElement({ data: '' })).not.toBeUndefined(); }); - it('LitTableTest27', () => { + it('LitTableTest21', () => { litTable.tableElement = jest.fn(() => undefined); litTable.tableElement.scrollTop = jest.fn(() => 1); expect(litTable.move1px()).toBeUndefined(); }); - it('LitTableTest28', () => { + it('LitTableTest22', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#aaa') as LitTable; expect(litTable.setMouseIn(true, [])).toBeUndefined(); }); - it('LitTableTest29', () => { + it('LitTableTest23', () => { let tableIcon = document.createElement('lit-icon') as LitIcon; let mouseClickEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); tableIcon.dispatchEvent(mouseClickEvent); }); - it('LitTableTest30', () => { + it('LitTableTest24', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#aaa') as LitTable; const data = { @@ -339,22 +331,18 @@ describe('LitTable Test', () => { expect(litTable.setCurrentSelection(data)).toBeUndefined(); }); - it('LitTableTest31', () => { + it('LitTableTest25', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#aaa') as LitTable; litTable.formatName = true; expect(litTable.formatName).toBeTruthy(); }); - it('LitTableTest32', () => { - let litTable = new LitTable(); - expect(litTable.formatName()).toBe(''); - }); - it('LitTableTest33', () => { + it('LitTableTest26', () => { let litTable = new LitTable(); expect(litTable.dataExportInit()).toBeUndefined(); }); - it('LitTableTest34', () => { + it('LitTableTest27', () => { let litTable = new LitTable(); let htmlElement = document.createElement('lit-table-column') as LitTableColumn; htmlElement.setAttribute('title', '41'); @@ -369,34 +357,34 @@ describe('LitTable Test', () => { expect(litTable.exportData()).toBeUndefined(); }); - it('LitTableTest35', () => { + it('LitTableTest28', () => { expect(litTable.formatExportData()).not.toBeUndefined(); }); - it('LitTableTest36', () => { + it('LitTableTest29', () => { expect(litTable.setSelectedRow(true, [])).toBeUndefined(); }); - it('LitTableTest37', () => { + it('LitTableTest30', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#aaa') as LitTable; litTable.setAttribute('tree', true); expect(litTable.dataSource).toStrictEqual([]); }); - it('LitTableTest38', () => { + it('LitTableTest31', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#aaa') as LitTable; litTable.rememberScrollTop = true; expect(litTable.recycleDataSource).toStrictEqual([]); }); - it('LitTableTest39', () => { + it('LitTableTest32', () => { let litTable = new LitTable(); expect(litTable.dataExportInit()).toBeUndefined(); }); - it('LitTableTest40', () => { + it('LitTableTest33', () => { let tableColmn = document.createElement('lit-table-column') as LitTableColumn; tableColmn.setAttribute('title', '21'); tableColmn.setAttribute('data-index', '13'); @@ -430,7 +418,7 @@ describe('LitTable Test', () => { expect(litTable.formatExportData(dataSource)).toBeTruthy(); }); - it('LitTableTest41', () => { + it('LitTableTest34', () => { let list = [ { memoryTap: 'All Heap', @@ -487,7 +475,7 @@ describe('LitTable Test', () => { expect(litTable.meauseTreeRowElement(list)).toBeTruthy(); }); - it('LitTableTest42', () => { + it('LitTableTest35', () => { let list = [ { memoryTap: 'All Heap', @@ -533,7 +521,7 @@ describe('LitTable Test', () => { expect(litTable.meauseAllRowHeight(list)).toBeTruthy(); }); - it('LitTableTest43', () => { + it('LitTableTest36', () => { let tableColmn = document.createElement('lit-table-column') as LitTableColumn; tableColmn.setAttribute('data-index', '14'); tableColmn.setAttribute('key', '141'); @@ -566,7 +554,7 @@ describe('LitTable Test', () => { expect(litTable.formatExportCsvData(dataSource)).toBeTruthy(); }); - it('LitTableTest44', () => { + it('LitTableTest37', () => { let element = document.createElement('div'); litTable.tableElement = document.createElement('div'); let firstElement = document.createElement('div'); @@ -589,25 +577,25 @@ describe('LitTable Test', () => { litTable.columns = [tableColmn, tableColmn1]; expect(litTable.freshCurrentLine(element, rowObject, firstElement)).toBeUndefined(); }); - it('LitTableTest45', () => { + it('LitTableTest38', () => { litTable.hideDownload = true; expect(litTable.hideDownload).toBeTruthy(); }); - it('LitTableTest46', () => { + it('LitTableTest39', () => { litTable.hideDownload = false; expect(litTable.hideDownload).not.toBeUndefined(); }); - it('LitTableTest47', () => { + it('LitTableTest40', () => { expect(litTable.createBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); }); - it('LitTableTest48', () => { + it('LitTableTest41', () => { expect(litTable.mouseOut()).toBeUndefined(); }); - it('LitTableTest49', () => { + it('LitTableTest42', () => { litTable.isRecycleList = true; expect(litTable.setCurrentHover({})).toBeUndefined(); }); - it('LitTableTest50', () => { + it('LitTableTest43', () => { expect(litTable.clearAllHover({})).toBeUndefined(); }); }); diff --git a/ide/test/trace/SpApplication.test.ts b/ide/test/trace/SpApplication.test.ts index 787224e308503664b67368ac50e8721d99d06f39..d86ba84964420c74618559f20fbe2f8391491a2b 100644 --- a/ide/test/trace/SpApplication.test.ts +++ b/ide/test/trace/SpApplication.test.ts @@ -52,86 +52,67 @@ describe('spApplication Test', () => { }); it('spApplicationTest03', function () { - spApplication.vs = true; - expect(spApplication.vs).toBeTruthy(); - }); - - it('spApplicationTest04', function () { - spApplication.vs = false; - expect(spApplication.vs).toBeTruthy(); - }); - - it('spApplicationTest05', function () { spApplication.server = true; expect(spApplication.server).toBeTruthy(); }); - it('spApplicationTest06', function () { + it('spApplicationTest04', function () { spApplication.server = false; expect(spApplication.server).toBeFalsy(); }); - it('spApplicationTest07', function () { + it('spApplicationTest05', function () { spApplication.querySql = true; expect(spApplication.querySql).toBeTruthy(); }); - it('spApplicationTest08', function () { + it('spApplicationTest06', function () { spApplication.querySql = false; expect(spApplication.querySql).toBeFalsy(); }); - it('spApplicationTest09', function () { + it('spApplicationTest07', function () { spApplication.search = true; expect(spApplication.search).toBeTruthy(); }); - it('spApplicationTest10', function () { + it('spApplicationTest08', function () { spApplication.search = false; expect(spApplication.search).toBeFalsy(); }); - it('spApplicationTest11', function () { + it('spApplicationTest09', function () { expect(spApplication.removeSkinListener([])).toBeUndefined(); }); - it('spApplicationTest15', function () { - expect(spApplication.freshMenuDisable()).toBeUndefined(); + it('spApplicationTest10', function () { + expect(spApplication.freshMenuDisable(true)).toBeUndefined(); }); - it('spApplicationTest16', function () { + it('spApplicationTest11', function () { expect(spApplication.addSkinListener()).toBeUndefined(); }); - it('spApplicationTest17', function () { + it('spApplicationTest12', function () { expect(spApplication.removeSkinListener()).toBeUndefined(); }); - it('spApplicationTest18', function () { + it('spApplicationTest13', function () { spApplication.dispatchEvent(new Event('dragleave')); }); - it('spApplicationTest19', function () { + it('spApplicationTest14', function () { spApplication.dispatchEvent(new Event('drop')); spApplication.removeSkinListener = jest.fn(() => undefined); expect(spApplication.removeSkinListener({})).toBeUndefined(); }); - it('spApplicationTest21', function () { - expect(spApplication.vsDownload()).toBeUndefined(); - }); - - it('spApplicationTest22', function () { - spApplication.showConten = false; - expect(spApplication.showContent).toBeFalsy(); - }); - it('spApplicationTest26', function () { + it('spApplicationTest15', function () { spApplication.dark = false; - spApplication.skinChangeArray = ['value']; expect(spApplication.dark).toBeFalsy(); }); - it('spApplicationTest29', function () { + it('spApplicationTest16', function () { spApplication.querySql = false; expect(spApplication.querySql).toBeFalsy(); }); diff --git a/ide/test/trace/bean/BoxSelection.test.ts b/ide/test/trace/bean/BoxSelection.test.ts index a8db62ac6e817060e9f7bfa9aa95b9e74110303d..5ab4691f21286dbc75c9d25ae368fbc4ea56bf65 100644 --- a/ide/test/trace/bean/BoxSelection.test.ts +++ b/ide/test/trace/bean/BoxSelection.test.ts @@ -16,12 +16,8 @@ import { SelectionParam, BoxJumpParam, SelectionData, Counter, Fps } from '../../../src/trace/bean/BoxSelection'; describe('BoxSelection Test', () => { - let selectionParam = new SelectionParam(); - let boxJumpParam = new BoxJumpParam(); - let selectionData = new SelectionData(); - let counter = new Counter(); - let fps = new Fps(); it('BoxSelectionTest01', function () { + let selectionParam: SelectionParam; selectionParam = { cpus: 1, threadIds: 2, @@ -34,19 +30,19 @@ describe('BoxSelection Test', () => { hasFps: true, statisticsSelectData: 1, }; - expect(selectionParam).not.toBeUndefined(); expect(selectionParam).toMatchInlineSnapshot( -{ - cpus: expect.any(Number), - threadIds: expect.any(Number), - trackIds: expect.any(Number), - funTids: expect.any(Number), - heapIds: expect.any(Number), - nativeMemory: expect.any(Number), - leftNs: expect.any(Number), - rightNs: expect.any(Number), - hasFps: expect.any(Boolean) }, ` + { + cpus: expect.any(Number), + threadIds: expect.any(Number), + trackIds: expect.any(Number), + funTids: expect.any(Number), + heapIds: expect.any(Number), + nativeMemory: expect.any(Number), + leftNs: expect.any(Number), + rightNs: expect.any(Number), + hasFps: expect.any(Boolean) + }, ` { "cpus": Any, "funTids": Any, @@ -63,6 +59,7 @@ describe('BoxSelection Test', () => { }); it('BoxSelectionTest02', function () { + let boxJumpParam: BoxJumpParam; boxJumpParam = { leftNs: 0, rightNs: 0, @@ -72,12 +69,13 @@ describe('BoxSelection Test', () => { }; expect(boxJumpParam).not.toBeUndefined(); expect(boxJumpParam).toMatchInlineSnapshot( -{ - leftNs: expect.any(Number), - rightNs: expect.any(Number), - state: expect.any(String), - processId: expect.any(Number), - threadId: expect.any(Number) }, ` + { + leftNs: expect.any(Number), + rightNs: expect.any(Number), + state: expect.any(String), + processId: expect.any(Number), + threadId: expect.any(Number) + }, ` { "leftNs": Any, "processId": Any, @@ -89,6 +87,7 @@ describe('BoxSelection Test', () => { }); it('BoxSelectionTest03', function () { + let selectionData: SelectionData; selectionData = { name: 'name', process: 'process', @@ -112,25 +111,26 @@ describe('BoxSelection Test', () => { }; expect(selectionData).not.toBeUndefined(); expect(selectionData).toMatchInlineSnapshot( -{ - process: expect.any(String), - pid: expect.any(String), - thread: expect.any(String), - tid: expect.any(String), - wallDuration: expect.any(Number), - avgDuration: expect.any(String), - occurrences: expect.any(Number), - state: expect.any(String), - trackId: expect.any(Number), - delta: expect.any(String), - rate: expect.any(String), - avgWeight: expect.any(String), - count: expect.any(String), - first: expect.any(String), - last: expect.any(String), - min: expect.any(String), - max: expect.any(String), - stateJX: expect.any(String) }, ` + { + process: expect.any(String), + pid: expect.any(String), + thread: expect.any(String), + tid: expect.any(String), + wallDuration: expect.any(Number), + avgDuration: expect.any(String), + occurrences: expect.any(Number), + state: expect.any(String), + trackId: expect.any(Number), + delta: expect.any(String), + rate: expect.any(String), + avgWeight: expect.any(String), + count: expect.any(String), + first: expect.any(String), + last: expect.any(String), + min: expect.any(String), + max: expect.any(String), + stateJX: expect.any(String) + }, ` { "avgDuration": Any, "avgWeight": Any, @@ -156,6 +156,7 @@ describe('BoxSelection Test', () => { }); it('BoxSelectionTest04', function () { + let counter: Counter; counter = { id: 0, trackId: 0, @@ -165,12 +166,13 @@ describe('BoxSelection Test', () => { }; expect(counter).not.toBeUndefined(); expect(counter).toMatchInlineSnapshot( -{ - id: expect.any(Number), - trackId: expect.any(Number), - name: expect.any(String), - value: expect.any(Number), - startTime: expect.any(Number) }, ` + { + id: expect.any(Number), + trackId: expect.any(Number), + name: expect.any(String), + value: expect.any(Number), + startTime: expect.any(Number) + }, ` { "id": Any, "name": Any, @@ -182,6 +184,7 @@ describe('BoxSelection Test', () => { }); it('BoxSelectionTest05', function () { + let fps: Fps; fps = { startNS: 0, timeStr: '', @@ -189,10 +192,11 @@ describe('BoxSelection Test', () => { }; expect(fps).not.toBeUndefined(); expect(fps).toMatchInlineSnapshot( -{ - startNS: expect.any(Number), - timeStr: expect.any(String), - fps: expect.any(Number) }, ` + { + startNS: expect.any(Number), + timeStr: expect.any(String), + fps: expect.any(Number) + }, ` { "fps": Any, "startNS": Any, diff --git a/ide/test/trace/bean/FpsStruct.test.ts b/ide/test/trace/bean/FpsStruct.test.ts index 1b9d3ba6911120bc2914713a0b3e71dda4a2ce62..315e84c104318ce4e5b9a3d9447925c035ccf764 100644 --- a/ide/test/trace/bean/FpsStruct.test.ts +++ b/ide/test/trace/bean/FpsStruct.test.ts @@ -13,12 +13,10 @@ * limitations under the License. */ -jest.mock('../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - import { FpsStruct } from '../../../src/trace/bean/FpsStruct'; +jest.mock('../../../src/js-heap/model/DatabaseStruct', () => { +}); jest.mock('../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); diff --git a/ide/test/trace/bean/ProcessStruct.test.ts b/ide/test/trace/bean/ProcessStruct.test.ts index 41bee6303770fbb5b9372d27797a9a9d3215e9af..65466a467be94d5b37ae60a9dc1675c4ca726e19 100644 --- a/ide/test/trace/bean/ProcessStruct.test.ts +++ b/ide/test/trace/bean/ProcessStruct.test.ts @@ -13,16 +13,12 @@ * limitations under the License. */ -jest.mock('../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - import { ProcessStruct } from '../../../src/trace/bean/ProcessStruct'; - -jest.mock('../../../src/trace/database/ui-worker/ProcedureWorker', () => { - return {}; -}); - +jest.mock('../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => ({ + CpuStruct: { + cpuCount: 1, + }, +})); describe('ProcessStruct Test', () => { const canvas = document.createElement('canvas'); canvas.width = 2; diff --git a/ide/test/trace/component/SpInfoAndStas.test.ts b/ide/test/trace/component/SpInfoAndStas.test.ts index d8bf3fb1a162bd0bacafd1744c81b76c13a3c06f..b6086d44444737d76d0b89532c09d3b73b0863a4 100644 --- a/ide/test/trace/component/SpInfoAndStas.test.ts +++ b/ide/test/trace/component/SpInfoAndStas.test.ts @@ -14,8 +14,8 @@ */ import { SpInfoAndStats } from '../../../src/trace/component/SpInfoAndStas'; -const sqlit = require('../../../src/trace/database/SqlLite'); -jest.mock('../../../src/trace/database/SqlLite'); +const sqlit = require('../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ diff --git a/ide/test/trace/component/SpQuerySQL.test.ts b/ide/test/trace/component/SpQuerySQL.test.ts index 3d5deee2c11d8098ccef213229c9f17269210df8..ff1ae22f0ccbcdba85bfc00f5cdb994705b62df9 100644 --- a/ide/test/trace/component/SpQuerySQL.test.ts +++ b/ide/test/trace/component/SpQuerySQL.test.ts @@ -15,8 +15,8 @@ import { SpQuerySQL } from '../../../src/trace/component/SpQuerySQL'; import { SpStatisticsHttpUtil } from '../../../src/statistics/util/SpStatisticsHttpUtil'; -const sqlite = require('../../../src/trace/database/SqlLite'); -jest.mock('../../../src/trace/database/SqlLite'); +const sqlite = require('../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), diff --git a/ide/test/trace/component/SpRecordTrace.test.ts b/ide/test/trace/component/SpRecordTrace.test.ts index 55e27f49507b3194cce4656f3533e94cd9a1f274..ab9182a9485f2c556e80a9e6c8e608f832161c13 100644 --- a/ide/test/trace/component/SpRecordTrace.test.ts +++ b/ide/test/trace/component/SpRecordTrace.test.ts @@ -16,8 +16,7 @@ import { SpRecordTrace } from '../../../src/trace/component/SpRecordTrace'; import { EventCenter } from '../../../src/trace/component/trace/base/EventCenter'; import '../../../src/trace/SpApplication'; -import { SpApplication } from '../../../src/trace/SpApplication'; -import { BaseElement } from '../../../src/base-ui/BaseElement'; +import { LitButton } from '../../../src/base-ui/button/LitButton'; declare global { interface Window { SmartEvent: { @@ -72,7 +71,7 @@ describe('SpRecordTrace Test', () => { expect(SpRecordTrace.initElements).toBeUndefined(); }); - it('SpRecordTraceTest04', function () { + it('SpRecordTraceTest03', function () { let traceEvents = (SpRecordTrace.createTraceEvents = [ 'Scheduling details', 'CPU Frequency and idle states', @@ -84,42 +83,15 @@ describe('SpRecordTrace Test', () => { expect(traceEvents[0].indexOf('binder/binder_lock')).toBe(-1); }); - it('SpRecordTraceTest05', function () { - spRecordTrace.spAllocations = jest.fn(() => undefined); - spRecordTrace.spAllocations.appProcess = jest.fn(() => ''); - spRecordTrace.spAllocations.appProcess.indexOf = jest.fn(() => ''); - spRecordTrace.spAllocations.appProcess.lastIndexOf = jest.fn(() => 1); - spRecordTrace.spAllocations.appProcess.slice = jest.fn(() => 1); - spRecordTrace.spAllocations.expandPids = jest.fn(() => []); - expect(spRecordTrace.createNativePluginConfig(1)).toEqual({ - configData: { - blocked: true, - fileName: '', - filterSize: undefined, - fpUnwind: undefined, - maxStackDepth: undefined, - processName: '', - saveFile: false, - smbPages: undefined, - stringCompressed: true, - }, - pluginName: 'nativehook', - sampleInterval: 1000, - }); - }); - - it('SpRecordTraceTest06', function () { - expect(spRecordTrace.createFpsPluginConfig()).not.toBeUndefined(); - }); - it('SpRecordTraceTest07', function () { + it('SpRecordTraceTest04', function () { expect(spRecordTrace.vs).not.toBeUndefined(); }); - it('SpRecordTraceTest08', function () { + it('SpRecordTraceTest05', function () { spRecordTrace.vs = true; expect(spRecordTrace.vs).toBeTruthy(); }); - it('SpRecordTraceTest10', function () { + it('SpRecordTraceTest06', function () { let devs = { length: 0, }; @@ -128,25 +100,25 @@ describe('SpRecordTrace Test', () => { spRecordTrace.deviceSelect.add(option) expect(spRecordTrace.compareArray(devs)).toBeTruthy(); }); - it('SpRecordTraceTest09', function () { + it('SpRecordTraceTest07', function () { spRecordTrace.vs = false; expect(spRecordTrace.vs).toBeFalsy(); }); - it('SpRecordTraceTest11', function () { + it('SpRecordTraceTest08', function () { let devs = { length: 1, }; expect(spRecordTrace.compareArray(!devs)).toBeTruthy(); }); - it('SpRecordTraceTest12', function () { + it('SpRecordTraceTest09', function () { spRecordTrace.showHint = true; expect(spRecordTrace.showHint).toBeTruthy(); }); - it('SpRecordTraceTest13', function () { + it('SpRecordTraceTest10', function () { spRecordTrace.showHint = false; expect(spRecordTrace.showHint).toBeFalsy(); }); - it('SpRecordTraceTest14', function () { + it('SpRecordTraceTest11', function () { let event = { isTrusted: true, device: { @@ -155,255 +127,52 @@ describe('SpRecordTrace Test', () => { }; expect(spRecordTrace.usbDisConnectionListener(event)).toBeUndefined(); }); - it('SpRecordTraceTest15', function () { + it('SpRecordTraceTest12', function () { let traceResult = { indexOf: jest.fn(() => undefined), }; expect(spRecordTrace.isSuccess(traceResult)).toBe(1); }); - it('SpRecordTraceTest16', function () { - expect(spRecordTrace.createSessionRequest()).toStrictEqual({ - pluginConfigs: [], - requestId: 1, - sessionConfig: { - buffers: [{ pages: 16384, policy: 0 }], - keepAliveTime: 0, - resultMaxSize: 0, - sessionMode: 0, - }, - }); - }); - it('SpRecordTraceTest17', function () { - let that = { - createProcessPlugin: jest.fn(() => undefined), - createCpuPlugin: jest.fn(() => undefined), - createDiskIOPlugin: jest.fn(() => undefined), - createNetworkPlugin: jest.fn(() => undefined), - }; - let request = { - pluginConfigs: { - push: jest.fn(() => undefined), - }, - }; - expect(spRecordTrace.createMonitorPlugin(that, request)).toBeUndefined(); - }); - it('SpRecordTraceTest18', function () { - expect(spRecordTrace.createNetworkPlugin()).toStrictEqual({ - configData: {}, - pluginName: 'network-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest19', function () { - expect(spRecordTrace.createDiskIOPlugin()).toStrictEqual({ - configData: { reportIoStats: 'IO_REPORT' }, - pluginName: 'diskio-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest20', function () { - expect(spRecordTrace.createCpuPlugin()).toStrictEqual({ - configData: { pid: 0, reportProcessInfo: true }, - pluginName: 'cpu-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest21', function () { - expect(spRecordTrace.createProcessPlugin()).toStrictEqual({ - configData: { - report_cpu: true, - report_diskio: true, - report_process_tree: true, - report_pss: true, - }, - pluginName: 'process-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest22', function () { - let traceConfig = { - forEach: jest.fn(() => undefined), - }; - expect(spRecordTrace.createTraceEvents(traceConfig)).toStrictEqual([]); - }); - it('SpRecordTraceTest23', function () { - spRecordTrace.spRecordPerf = jest.fn(() => undefined); - spRecordTrace.spRecordPerf.getPerfConfig = jest.fn(() => undefined); - expect(spRecordTrace.createHiperConfig()).toStrictEqual({ - configData: { - isRoot: false, - outfileName: '/data/local/tmp/perf.data', - recordArgs: '-f undefined -a --cpu-limit undefined -e hw-cpu-cycles --call-stack undefined -j undefined', - }, - pluginName: 'hiperf-plugin', - sampleInterval: NaN, - }); - }); - - it('SpRecordTraceTest24', function () { + it('SpRecordTraceTest13', function () { expect(spRecordTrace.isSuccess('Signal')).toBe(2); }); - it('SpRecordTraceTest25', function () { + it('SpRecordTraceTest14', function () { expect(spRecordTrace.isSuccess('The device is abnormal')).toBe(-1); }); - it('SpRecordTraceTest26', function () { + it('SpRecordTraceTest15', function () { expect(spRecordTrace.isSuccess('')).toBe(0); }); - it('SpRecordTraceTest27', function () { + it('SpRecordTraceTest16', function () { expect(spRecordTrace.synchronizeDeviceList()).toBeUndefined(); }); - it('SpRecordTraceTest28', function () { + it('SpRecordTraceTest17', function () { expect(spRecordTrace.freshMenuItemsStatus('Trace command')).toBeUndefined(); }); - it('SpRecordTraceTest29', function () { + it('SpRecordTraceTest18', function () { + spRecordTrace.recordButtonText = document.createElement('span'); + spRecordTrace.deviceVersion = document.createElement('select'); + spRecordTrace.cancelButton = new LitButton(); + spRecordTrace.disconnectButton = new LitButton(); + spRecordTrace.addButton = new LitButton(); expect(spRecordTrace.buttonDisable(true)).toBeUndefined(); }); - it('SpRecordTraceTest30', function () { + it('SpRecordTraceTest19', function () { expect(spRecordTrace.startRefreshDeviceList()).toBeUndefined(); }); - it('SpRecordTraceTest31', function () { + it('SpRecordTraceTest20', function () { expect(spRecordTrace.freshConfigMenuDisable(true)).toBeUndefined(); }); - it('SpRecordTraceTest31', function () { - expect(spRecordTrace.createSdkConfig()).toStrictEqual({ configData: {}, pluginName: '', sampleInterval: 5000 }); - }); - it('SpRecordTraceTest32', function () { - expect(spRecordTrace.createHtracePluginConfig()).toStrictEqual({ - configData: { - bufferSizeKb: 20480, - clock: 'boot', - debugOn: false, - flushIntervalMs: 1000, - flushThresholdKb: 4096, - ftraceEvents: [ - 'sched/sched_switch', - 'power/suspend_resume', - 'sched/sched_wakeup', - 'sched/sched_wakeup_new', - 'sched/sched_waking', - 'sched/sched_process_exit', - 'sched/sched_process_free', - 'task/task_newtask', - 'task/task_rename', - 'power/cpu_frequency', - 'power/cpu_idle', - ], - hitraceApps: [], - hitraceCategories: [ - 'ability', - 'ace', - 'app', - 'ark', - 'binder', - 'disk', - 'freq', - 'graphic', - 'idle', - 'irq', - 'memreclaim', - 'mmc', - 'multimodalinput', - 'ohos', - 'pagecache', - 'rpc', - 'sched', - 'sync', - 'window', - 'workq', - 'zaudio', - 'zcamera', - 'zimage', - 'zmedia', - ], - parseKsyms: true, - rawDataPrefix: '', - traceDurationMs: 0, - tracePeriodMs: 200, - }, - pluginName: 'ftrace-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest33', function () { - expect(spRecordTrace.createArkTsConfig()).toStrictEqual({ - configData: { - capture_numeric_value: false, - cpu_profiler_interval: 1000, - interval: 0, - enable_cpu_profiler: false, - pid: 0, - track_allocations: false, - type: -1, - }, - pluginName: 'arkts-plugin', - sampleInterval: 5000, - }); - }); - it('SpRecordTraceTest34', function () { - expect(spRecordTrace.createMemoryPluginConfig(1, true, true, true)).toStrictEqual({ - configData: { - pid: [0], - reportAppMemByMemoryService: false, - reportAppMemInfo: false, - reportProcessMemInfo: true, - reportProcessTree: true, - reportSmapsMemInfo: true, - reportSysmemMemInfo: true, - reportDmaMemInfo: true, - reportGpuDumpInfo: true, - reportGpuMemInfo: true, - reportSysmemVmemInfo: true, - reportPurgeableAshmemInfo: true, - sysMeminfoCounters: [ - 'PMEM_MEM_TOTAL', - 'PMEM_MEM_FREE', - 'PMEM_BUFFERS', - 'PMEM_CACHED', - 'PMEM_SHMEM', - 'PMEM_SLAB', - 'PMEM_SWAP_TOTAL', - 'PMEM_SWAP_FREE', - 'PMEM_MAPPED', - 'PMEM_VMALLOC_USED', - 'PMEM_PAGE_TABLES', - 'PMEM_KERNEL_STACK', - 'PMEM_ACTIVE', - 'PMEM_INACTIVE', - 'PMEM_UNEVICTABLE', - 'PMEM_VMALLOC_TOTAL', - 'PMEM_SLAB_UNRECLAIMABLE', - 'PMEM_CMA_TOTAL', - 'PMEM_CMA_FREE', - 'PMEM_KERNEL_RECLAIMABLE', - 'PMEM_ACTIVE_PURG', - 'PMEM_INACTIVE_PURG', - 'PMEM_PINED_PURG' - ], - sysVmeminfoCounters: [], - }, - pluginName: 'memory-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest35', function () { - expect(spRecordTrace.createSystemConfig()).toStrictEqual({ - configData: { cmdLine: 'hiebpf --duration 30 --max_stack_depth 10', outfileName: '/data/local/tmp/ebpf.data' }, - pluginName: 'hiebpf-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest36', function () { - expect(spRecordTrace.createSystemConfig({}, 1)).toStrictEqual({ - configData: { cmdLine: 'hiebpf --duration 30 --max_stack_depth 10', outfileName: '/data/local/tmp/ebpf.data' }, - pluginName: 'hiebpf-plugin', - sampleInterval: 1000, - }); - }); - it('SpRecordTraceTest37', function () { + it('SpRecordTraceTest21', function () { spRecordTrace.record_template = 'record_template'; expect(spRecordTrace.record_template).toBeTruthy(); }); + + it('SpRecordTraceTest22', function () { + spRecordTrace.initConfigPage(); + spRecordTrace.makeRequest(); + expect(spRecordTrace.spVmTracker).not.toBeUndefined(); + }); }); diff --git a/ide/test/trace/component/SpSystemTrace.test.ts b/ide/test/trace/component/SpSystemTrace.test.ts index c010accca432701d1958e489ee44be2fbe41b190..564d6c4d6af23e7c187ccf4d87160f3d2a0fdbc9 100644 --- a/ide/test/trace/component/SpSystemTrace.test.ts +++ b/ide/test/trace/component/SpSystemTrace.test.ts @@ -16,9 +16,12 @@ import { SpSystemTrace } from '../../../src/trace/component/SpSystemTrace'; import { TraceRow } from '../../../src/trace/component/trace/base/TraceRow'; import { procedurePool } from '../../../src/trace/database/Procedure'; +import { RangeSelect } from '../../../src/trace/component/trace/base/RangeSelect'; + jest.mock('../../../src/base-ui/table/lit-table', () => { return { - recycleDataSource: () => {}, + recycleDataSource: () => { + }, }; }); jest.mock('../../../src/js-heap/logic/HeapLoader', () => { @@ -95,11 +98,11 @@ describe('SpSystemTrace Test', () => { }); it('SpSystemTraceTest08', function () { - expect(spSystemTrace.hoverStructNull('')).toBeUndefined(); + expect(spSystemTrace.hoverStructNull()).not.toBeUndefined(); }); it('SpSystemTraceTest09', function () { - expect(spSystemTrace.selectStructNull('')).toBeUndefined(); + expect(spSystemTrace.selectStructNull()).not.toBeUndefined(); }); it('SpSystemTraceTest11', function () { @@ -120,7 +123,13 @@ describe('SpSystemTrace Test', () => { spSystemTrace.rowsPaneEL.scrollTo = jest.fn(() => offset); spSystemTrace.rowsPaneEL.removeEventListener = jest.fn(() => true); spSystemTrace.rowsPaneEL.addEventListener = jest.fn(() => true); - expect(spSystemTrace.scrollToActFunc(offset, callback)).toBeUndefined(); + let funcStract = { + dur: 152, + totalNS: 4252, + startTs: 522, + flag: '' + } + expect(spSystemTrace.scrollToActFunc(funcStract, true)).toBeUndefined(); }); it('SpSystemTraceTest16', function () { @@ -164,6 +173,8 @@ describe('SpSystemTrace Test', () => { spSystemTrace.traceSheetEL = jest.fn(() => true); spSystemTrace.traceSheetEL.clearMemory = jest.fn(() => true); spSystemTrace.traceSheetEL.setAttribute = jest.fn(() => true); + spSystemTrace.traceSheetEL.setMode = jest.fn(() => true); + spSystemTrace.rangeSelect = new RangeSelect(new SpSystemTrace()); expect(spSystemTrace.reset()).toBeUndefined(); }); it('SpSystemTraceTest23', function () { @@ -237,7 +248,7 @@ describe('SpSystemTrace Test', () => { contextId: '2d', isOffScreen: true, }); - expect(spSystemTrace.expansionAllParentRow({ id: 1 })).toBeUndefined(); + expect(spSystemTrace.expansionAllParentRow({id: 1})).toBeUndefined(); }); it('SpSystemTraceTest30', function () { let spSystemTrace = new SpSystemTrace({ @@ -295,6 +306,8 @@ describe('SpSystemTrace Test', () => { contextId: '2d', isOffScreen: true, }); + spSystemTrace.rangeSelect = new RangeSelect(new SpSystemTrace()); + spSystemTrace.traceSheetEL.setMode = jest.fn(() => true); expect(spSystemTrace.clickEmptyArea()).toBeUndefined(); }); it('SpSystemTraceTest34', function () { @@ -346,6 +359,8 @@ describe('SpSystemTrace Test', () => { maxDuration: 1, timestamp: '', }; + spSystemTrace.rangeSelect = new RangeSelect(new SpSystemTrace()); + spSystemTrace.traceSheetEL.setMode = jest.fn(() => true); expect(spSystemTrace.sliceMarkEventHandler(ev)).toBeUndefined(); }); it('SpSystemTraceTest37', function () { diff --git a/ide/test/trace/component/chart/PerfDataQuery.test.ts b/ide/test/trace/component/chart/PerfDataQuery.test.ts index 16cbd288e110a062ff1db24eb43b440574e9c9f9..548bd53e4677daf03f48ada9000e0093b856eb17 100644 --- a/ide/test/trace/component/chart/PerfDataQuery.test.ts +++ b/ide/test/trace/component/chart/PerfDataQuery.test.ts @@ -15,6 +15,9 @@ import { perfDataQuery } from '../../../../src/trace/component/chart/PerfDataQuery'; +jest.mock('../../../../src/trace/component/chart/SpHiPerf', () => { + return true; +}); jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { return {} }); diff --git a/ide/test/trace/component/chart/SpAbilityMonitor.test.ts b/ide/test/trace/component/chart/SpAbilityMonitor.test.ts index 2f48fe51438eac8a32df8a50971f4496eb5e9833..5b70bc68e80dd637fa99a740c912c0685ed4e3ff 100644 --- a/ide/test/trace/component/chart/SpAbilityMonitor.test.ts +++ b/ide/test/trace/component/chart/SpAbilityMonitor.test.ts @@ -12,20 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; import { SpAbilityMonitorChart } from '../../../../src/trace/component/chart/SpAbilityMonitorChart'; import '../../../../src/trace/component/chart/SpAbilityMonitorChart'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { +const sqlit = require('../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../src/trace/database/sql/Ability.sql'); +const MemorySqlite = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/component/chart/SpNativeMemoryChart', () => { return {}; }); -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); -import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; const intersectionObserverMock = () => ({ observe: () => null, }); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +jest.mock('../../../../src/trace/component/trace/base/TraceSheet', () => { + return true; +}); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); // @ts-ignore window.ResizeObserver = window.ResizeObserver || @@ -66,15 +71,14 @@ describe('SpAbilityMonitorChart Test', () => { systemLoad: 1, }, ]); - let memorydata = sqlit.queryMemoryMaxData; + let memorydata = MemorySqlite.queryMemoryMaxData; memorydata.mockResolvedValue([ { maxValue: 1, filter_id: 1, }, ]); - - let queryDiskIo = sqlit.queryDiskIoMaxData; + let queryDiskIo = sqlite.queryDiskIoMaxData; queryDiskIo.mockResolvedValue([ { bytesRead: 1, @@ -84,7 +88,7 @@ describe('SpAbilityMonitorChart Test', () => { }, ]); - let netWorkDiskIo = sqlit.queryNetWorkMaxData; + let netWorkDiskIo = sqlite.queryNetWorkMaxData; netWorkDiskIo.mockResolvedValue([ { maxIn: 1, @@ -146,14 +150,9 @@ describe('SpAbilityMonitorChart Test', () => { value: 0, }, ]); - let manager = new SpChartManager(); - let trace = new SpAbilityMonitorChart(manager); it('SpAbilityMonitorChart01', function () { - trace.init(); - expect(trace).toBeDefined(); - }); - it('SpAbilityMonitorChart02', function () { - let traceRow = new TraceRow(); - expect(trace.initNetworkAbility(traceRow)).toBeDefined(); + let spAbilityMonitor = new SpAbilityMonitorChart(SpSystemTrace); + spAbilityMonitor.init(); + expect(spAbilityMonitor).toBeDefined(); }); }); diff --git a/ide/test/trace/component/chart/SpAllAppStartups.test.ts b/ide/test/trace/component/chart/SpAllAppStartups.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ecfaddb6c78e27cdd70da1a7433b8e26a8dd85bf --- /dev/null +++ b/ide/test/trace/component/chart/SpAllAppStartups.test.ts @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; +import { SpAllAppStartupsChart } from "../../../../src/trace/component/chart/SpAllAppStartups"; + +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +const sqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); +describe('SpAllAppStartupsChart Test', () => { + let appStartUpsChart = new SpAllAppStartupsChart(new SpSystemTrace()); + let ids = sqlite.queryAppStartupProcessIds; + ids.mockResolvedValue([ + { + pid: 12 + } + ]); + let processStartup = sqlite.queryProcessStartup; + processStartup.mockResolvedValue([ + { + pid: 12, + tid: 125, + itid: 56 + } + ]); + let startupsName = sqlite.querySingleAppStartupsName; + startupsName.mockResolvedValue([ + { + name: 'name' + } + ]); + it('SpLtpoChartTest01', function () { + appStartUpsChart.init(); + expect(SpAllAppStartupsChart.APP_STARTUP_PID_ARR).toEqual([]); + }); + it('SpLtpoChartTest02', function () { + appStartUpsChart.initFolder(); + expect(SpAllAppStartupsChart.trace.rowsEL).not.toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/component/chart/SpArkTsChart.test.ts b/ide/test/trace/component/chart/SpArkTsChart.test.ts index fde12c20bd8676607ef224154930de5f247d34c1..ae20058a0ffc4f308657a8cafe7f95d4a2274053 100644 --- a/ide/test/trace/component/chart/SpArkTsChart.test.ts +++ b/ide/test/trace/component/chart/SpArkTsChart.test.ts @@ -13,14 +13,27 @@ * limitations under the License. */ import { SpArkTsChart } from '../../../../src/trace/component/chart/SpArkTsChart'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); - -describe('SpClockChart Test', () => { - let arkTsChart = new SpArkTsChart(new SpChartManager()); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlite = require('../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../src/trace/database/sql/Cpu.sql'); +const JsMemory = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('SpArkTsChart Test', () => { + let arkTsChart = new SpArkTsChart(new SpSystemTrace()); let jsCpuProfilerConfig = sqlite.queryJsCpuProfilerConfig; let cpuProfilerConfigData = [ { @@ -39,17 +52,17 @@ describe('SpClockChart Test', () => { ]; jsCpuProfiler.mockResolvedValue(cpuProfilerData); - let jsMemory = sqlite.queryJsMemoryData; + let jsMemory = JsMemory.queryJsMemoryData; let jsMemoryData = [{}]; jsMemory.mockResolvedValue(jsMemoryData); - it('SpClockChart01', function () { + it('SpArkTsChart01', function () { expect(arkTsChart.initFolder()).not.toBeUndefined(); }); - it('SpClockChart02', function () { + it('SpArkTsChart02', function () { expect(arkTsChart.initTimelineChart()).not.toBeUndefined(); }); - it('SpClockChart03', function () { + it('SpArkTsChart03', function () { expect(arkTsChart.initSnapshotChart()).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/chart/SpChartManager.test.ts b/ide/test/trace/component/chart/SpChartManager.test.ts index 9cc06aceb93c055253bbb1c02f22fd5f77ec9770..dfd5adec582c286fb7925797c851c9db9d2cf408 100644 --- a/ide/test/trace/component/chart/SpChartManager.test.ts +++ b/ide/test/trace/component/chart/SpChartManager.test.ts @@ -17,12 +17,12 @@ const intersectionObserverMock = () => ({ observe: () => null, }); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); - +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); // @ts-ignore window.ResizeObserver = window.ResizeObserver || @@ -32,7 +32,7 @@ window.ResizeObserver = window.ResizeObserver || unobserve: jest.fn(), })); describe('SpChartManager Test', () => { - let chartManager = new SpChartManager(); + let chartManager = new SpChartManager(new SpSystemTrace()); let queryDataDICT = sqlite.queryDataDICT; let dataDICT = [ { diff --git a/ide/test/trace/component/chart/SpClockChart.test.ts b/ide/test/trace/component/chart/SpClockChart.test.ts index a83696a8aeecceaebea66590573c2b01e28cc430..713c92666328513c41bb65f2ece1d1862357e45f 100644 --- a/ide/test/trace/component/chart/SpClockChart.test.ts +++ b/ide/test/trace/component/chart/SpClockChart.test.ts @@ -16,9 +16,9 @@ import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpClockChart } from '../../../../src/trace/component/chart/SpClockChart'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); - +const sqlite = require('../../../../src/trace/database/sql/Clock.sql'); +jest.mock('../../../../src/trace/database/sql/Clock.sql'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ diff --git a/ide/test/trace/component/chart/SpCpuChart.test.ts b/ide/test/trace/component/chart/SpCpuChart.test.ts index 0a834e692719a4449a8136aee6acf3ea107cee37..9c7bd6490d688917fda50056b81b1f1f8b3fa916 100644 --- a/ide/test/trace/component/chart/SpCpuChart.test.ts +++ b/ide/test/trace/component/chart/SpCpuChart.test.ts @@ -17,8 +17,9 @@ import { SpChartManager } from '../../../../src/trace/component/chart/SpChartMan import { SpCpuChart } from '../../../../src/trace/component/chart/SpCpuChart'; import { HeapNode } from '../../../../src/js-heap/model/DatabaseStruct'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../src/trace/database/sql/Cpu.sql'); window.ResizeObserver = window.ResizeObserver || @@ -30,12 +31,13 @@ window.ResizeObserver = jest.mock('../../../../src/js-heap/utils/Utils', () => { return { - HeapNodeToConstructorItem: (node: HeapNode) => {}, + HeapNodeToConstructorItem: (node: HeapNode) => { + }, }; }); describe('SpCpuChart Test', () => { let MockqueryCpuMax = sqlit.queryCpuMax; - MockqueryCpuMax.mockResolvedValue([{ cpu: 1 }]); + MockqueryCpuMax.mockResolvedValue([{cpu: 1}]); let mockCpuSlice = sqlit.queryCpuSchedSlice; mockCpuSlice.mockResolvedValue([]); diff --git a/ide/test/trace/component/chart/SpEBPFChart.test.ts b/ide/test/trace/component/chart/SpEBPFChart.test.ts index a2f6ef95b24bbd08ebf07c6c4fb70bc492497e7f..aeb0b992671970450ac5a5e0955f43b1545d8110 100644 --- a/ide/test/trace/component/chart/SpEBPFChart.test.ts +++ b/ide/test/trace/component/chart/SpEBPFChart.test.ts @@ -12,16 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { SpEBPFChart } from '../../../../src/trace/component/chart/SpEBPFChart'; import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +import { SpEBPFChart } from '../../../../src/trace/component/chart/SpEBPFChart'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -39,7 +40,14 @@ describe('SpFileSystemChart Test', () => { ioCount: 2, }, ]); - + let getDiskIOProcess = sqlite.getDiskIOProcess; + getDiskIOProcess.mockResolvedValue([ + { + name: 'kworker/u8:4', + ipid: 2, + pid: 186, + } + ]); let ss = new SpChartManager(); let spEBPFChart = new SpEBPFChart(ss); spEBPFChart.initFileCallchain = jest.fn(() => true); diff --git a/ide/test/trace/component/chart/SpFpsChart.test.ts b/ide/test/trace/component/chart/SpFpsChart.test.ts index 28f27b29fac15a3a736599d4cba6ddea20e60fa6..77efe05a8893827e64504f5206686ca271686c7e 100644 --- a/ide/test/trace/component/chart/SpFpsChart.test.ts +++ b/ide/test/trace/component/chart/SpFpsChart.test.ts @@ -12,12 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { SpFpsChart } from '../../../../src/trace/component/chart/SpFpsChart'; import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; - -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +import { SpFpsChart } from '../../../../src/trace/component/chart/SpFpsChart'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); diff --git a/ide/test/trace/component/chart/SpFrameTimeChart.test.ts b/ide/test/trace/component/chart/SpFrameTimeChart.test.ts index 74d9b3b6880f71e943c001dd1d76b37045c40af2..ed1b805309c13790c310e958eb7dbffb65a98b78 100644 --- a/ide/test/trace/component/chart/SpFrameTimeChart.test.ts +++ b/ide/test/trace/component/chart/SpFrameTimeChart.test.ts @@ -12,24 +12,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpFrameTimeChart } from '../../../../src/trace/component/chart/SpFrameTimeChart'; import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { FlagsConfig } from '../../../../src/trace/component/SpFlags'; const intersectionObserverMock = () => ({ observe: () => null, }); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); - -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +const jankSqlite = require('../../../../src/trace/database/sql/Janks.sql'); +jest.mock('../../../../src/trace/database/sql/Janks.sql'); +const processSqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -39,9 +44,7 @@ window.ResizeObserver = })); describe('SpFrameTimeChart Test', () => { - let trace = new SpSystemTrace(); - let manager = new SpChartManager(trace); - let spFrameTimeChart = new SpFrameTimeChart(manager); + let spFrameTimeChart = new SpFrameTimeChart(new SpSystemTrace()); let queryFrameTime = sqlite.queryFrameTimeData; let queryFrameTimeData = [ @@ -51,7 +54,7 @@ describe('SpFrameTimeChart Test', () => { ]; queryFrameTime.mockResolvedValue(queryFrameTimeData); - let queryExpectedFrame = sqlite.queryExpectedFrameDate; + let queryExpectedFrame = jankSqlite.queryExpectedFrameDate; let queryExpectedFrameDate = [ { dur: 2585, @@ -64,7 +67,7 @@ describe('SpFrameTimeChart Test', () => { ]; queryExpectedFrame.mockResolvedValue(queryExpectedFrameDate); - let queryActualFrame = sqlite.queryActualFrameDate; + let queryActualFrame = jankSqlite.queryActualFrameDate; let queryActualFrameDate = [ { dur: 6878, @@ -93,7 +96,7 @@ describe('SpFrameTimeChart Test', () => { let frameAnimation = sqlite.queryFrameAnimationData; let frameAnimationData = [ - { animationId: 1, dynamicEndTs: 4774481414, dynamicStartTs: 4091445476, ts: 4091445476 }, + {animationId: 1, dynamicEndTs: 4774481414, dynamicStartTs: 4091445476, ts: 4091445476}, { animationId: 2, dynamicEndTs: 8325095997, @@ -103,11 +106,11 @@ describe('SpFrameTimeChart Test', () => { ]; frameAnimation.mockResolvedValue(frameAnimationData); - let allProcessNames = sqlite.queryAllProcessNames; + let allProcessNames = processSqlite.queryAllProcessNames; let allProcessNameData = [ { id: 12, - name: "test name", + name: 'test name', pid: 255 } ]; @@ -117,7 +120,7 @@ describe('SpFrameTimeChart Test', () => { let data = [ { id: 12, - appName: "name" + appName: 'name' } ]; dynamicIdAndName.mockResolvedValue(data); @@ -125,7 +128,7 @@ describe('SpFrameTimeChart Test', () => { let animationTimeRange = sqlite.queryAnimationTimeRangeData; let rangeData = [ { - status: "Response delay", + status: 'Response delay', startTs: 225, endTs: 6355 } @@ -137,15 +140,15 @@ describe('SpFrameTimeChart Test', () => { let animationIdAndNameData = [ { id: 12, - name: "test", - info: "{}" + name: 'test', + info: '{}' } ]; animationIdAndName.mockResolvedValue(animationIdAndNameData); let frameDynamic = sqlite.queryFrameDynamicData; let frameDynamicData = [ - { alpha: '1.00', appName: 'test0', height: 2772, id: 74, ts: 28565790, width: 1344, x: 0, y: 0 }, + {alpha: '1.00', appName: 'test0', height: 2772, id: 74, ts: 28565790, width: 1344, x: 0, y: 0}, { alpha: '1.00', appName: 'test0', @@ -191,7 +194,7 @@ describe('SpFrameTimeChart Test', () => { frameSpacing.mockResolvedValue(frameSpacingData); let physical = sqlite.queryPhysicalData; - let physicalData = [{ physicalFrameRate: 90, physicalHeight: 2772, physicalWidth: 1344 }]; + let physicalData = [{physicalFrameRate: 90, physicalHeight: 2772, physicalWidth: 1344}]; physical.mockResolvedValue(physicalData); it('TabPaneFramesTest01', function () { diff --git a/ide/test/trace/component/chart/SpFreqChart.test.ts b/ide/test/trace/component/chart/SpFreqChart.test.ts index 67d0649e6e807d676fc4fe9941b212d87ed1f5af..79fe6d9f80a12c1199773fa770328ea90a30431f 100644 --- a/ide/test/trace/component/chart/SpFreqChart.test.ts +++ b/ide/test/trace/component/chart/SpFreqChart.test.ts @@ -1,4 +1,4 @@ -/* + /* * 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. @@ -12,9 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { queryCpuCount } from '../../../../src/trace/database/SqlLite'; - window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), @@ -23,9 +20,9 @@ window.ResizeObserver = window.ResizeObserver || })); import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpFreqChart } from '../../../../src/trace/component/chart/SpFreqChart'; - -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../src/trace/database/sql/Cpu.sql'); describe('spFpsChart Test', () => { let spFpsChart = new SpFreqChart(new SpChartManager()); diff --git a/ide/test/trace/component/chart/SpHiPerf.test.ts b/ide/test/trace/component/chart/SpHiPerf.test.ts index e40a0579e45e3b7087c7280ec2967d141f0a29d9..75698c09d0a5dc9f18eaeb70c20441c42f42d5d6 100644 --- a/ide/test/trace/component/chart/SpHiPerf.test.ts +++ b/ide/test/trace/component/chart/SpHiPerf.test.ts @@ -14,19 +14,17 @@ */ import { SpHiPerf } from '../../../../src/trace/component/chart/SpHiPerf'; -import { - queryHiPerfCpuMergeData2, - queryHiPerfEventList, - queryPerfThread, -} from '../../../../src/trace/database/SqlLite'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -import { queryPerfEventType } from '../../../../src/trace/database/SqlLite'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +import { SpSystemTrace } from "../../../../src/trace/component/SpSystemTrace"; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../src/trace/database/sql/Perf.sql'); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +const intersectionObserverMock = () => ({ + observe: () => null, +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -128,14 +126,9 @@ describe('SpHiPerf Test', () => { id:1, report_value:'sched:sched_waking', }]) - let ss = new SpChartManager(); - let spHiPerf = new SpHiPerf(ss); + let spHiPerf = new SpHiPerf(new SpSystemTrace()); it('SpHiPerf01', function () { spHiPerf.init(); expect(spHiPerf).toBeDefined(); }); - it('SpHiPerf02', function () { - ss.displayTip = jest.fn(()=>true); - expect(spHiPerf.hoverTip()).toBeUndefined(); - }); }); diff --git a/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts b/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts index 4ae12593df6046b3cfd3f281ba70c7205a160894..aa1aa75306aa102937245e773676fa0997b4749f 100644 --- a/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts +++ b/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts @@ -12,18 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import '../../../../src/trace/component/chart/SpHiSysEnergyChart'; import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -import '../../../../src/trace/component/chart/SpChartManager'; -import '../../../../src/trace/component/SpSystemTrace'; -import { LitPopover } from '../../../../src/base-ui/popover/LitPopoverV'; import { SpHiSysEnergyChart } from '../../../../src/trace/component/chart/SpHiSysEnergyChart'; - +import { LitPopover } from '../../../../src/base-ui/popover/LitPopoverV'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -32,9 +29,10 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); - +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +const processSqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); describe('SpHiSysEnergyChart Test', () => { let ss = new SpChartManager(); let spHiSysEnergyChart = new SpHiSysEnergyChart(ss); @@ -57,9 +55,17 @@ describe('SpHiSysEnergyChart Test', () => { }, ]; maxStateValue.mockResolvedValue(max); + + let stateInitData = sqlite.queryStateInitValue; + let stateInitInit = [{ + eventName: '', + keyName: '', + }]; + stateInitData.mockResolvedValue(stateInitInit); + let MockExits = sqlite.queryEnergyEventExits; MockExits.mockResolvedValue(['trace_hisys_event']); - let powerData = sqlite.queryPowerData; + let powerData = processSqlite.queryPowerData; let power = [ { startNS: 5999127351, @@ -87,6 +93,7 @@ describe('SpHiSysEnergyChart Test', () => { ]; sysEventAppName.mockResolvedValue(appName); + let querySystemLocationData = sqlite.querySystemLocationData; let querySystemLockData = sqlite.querySystemLockData; let querySystemSchedulerData = sqlite.querySystemSchedulerData; @@ -190,11 +197,11 @@ describe('SpHiSysEnergyChart Test', () => { eventValue: '375,475,255,963', }, ]; - expect(spHiSysEnergyChart.getPowerData(result)).toStrictEqual(Promise.resolve()); + expect(spHiSysEnergyChart.getPowerData(result)).toBeTruthy(); }); it('SpHiSysEnergyChartTest05', function () { - expect(spHiSysEnergyChart.getPowerData([])).toStrictEqual(Promise.resolve()); + expect(spHiSysEnergyChart.getPowerData([])).toBeTruthy(); }); it('SpHiSysEnergyChartTest6', function () { diff --git a/ide/test/trace/component/chart/SpHiSysEventChart.test.ts b/ide/test/trace/component/chart/SpHiSysEventChart.test.ts index ab3091981eb22a70c86197cf81cb6b4c1a79dde2..7579348915887a449d63c50b197669b1a8035337 100644 --- a/ide/test/trace/component/chart/SpHiSysEventChart.test.ts +++ b/ide/test/trace/component/chart/SpHiSysEventChart.test.ts @@ -14,19 +14,34 @@ */ import { SpHiSysEventChart } from '../../../../src/trace/component/chart/SpHiSysEventChart'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlite = require('../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('SpHiSysEventChart Test', () => { - let spHiSysEvent = new SpHiSysEventChart(new SpChartManager()); + let spHiSysEvent = new SpHiSysEventChart(new SpSystemTrace()); let hiSysEventList = sqlite.queryHiSysEventData; let hiSysEventListData = [{ id: 1, - domain:'STARTUP', + domain: 'STARTUP', eventName: 'PROCESS_EXIT', eventType: '4', ts: 1, @@ -40,7 +55,7 @@ describe('SpHiSysEventChart Test', () => { contents: 'APP_PID', dur: 1, depth: 1, - }] + }]; hiSysEventList.mockResolvedValue(hiSysEventListData); it('SpHiSysEventChart01', function () { expect(spHiSysEvent.init()).toBeTruthy(); diff --git a/ide/test/trace/component/chart/SpIrqChart.test.ts b/ide/test/trace/component/chart/SpIrqChart.test.ts index bdee2d2dc32f76a5b7cdfe5409f0056a85bb98a4..c3c24882d013378e47d761bd291a0a87d69164d8 100644 --- a/ide/test/trace/component/chart/SpIrqChart.test.ts +++ b/ide/test/trace/component/chart/SpIrqChart.test.ts @@ -15,8 +15,9 @@ import { SpSystemTrace } from "../../../../src/trace/component/SpSystemTrace"; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../src/trace/database/sql/Irq.sql'); +jest.mock('../../../../src/trace/database/sql/Irq.sql'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); window.ResizeObserver = window.ResizeObserver || @@ -30,12 +31,11 @@ const intersectionObserverMock = () => ({ observe: () => null, }); -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpIrqChart } from '../../../../src/trace/component/chart/SpIrqChart'; describe('SpIrqChart Test', () => { let trace = new SpSystemTrace(); - let irqChart = new SpIrqChart(new SpChartManager(trace)); + let irqChart = new SpIrqChart(trace); let irqList = sqlite.queryIrqList; let irqListData = [ { diff --git a/ide/test/trace/component/chart/SpJsMemoryChart.test.ts b/ide/test/trace/component/chart/SpJsMemoryChart.test.ts index 99c2a4ca21490cfd796ccf5e3dd136386ee38e3a..f1426025779372d600a87eaa58d16901fbe11501 100644 --- a/ide/test/trace/component/chart/SpJsMemoryChart.test.ts +++ b/ide/test/trace/component/chart/SpJsMemoryChart.test.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); - +const sqlite = require('../../../../src/trace/database/sql/Irq.sql'); +jest.mock('../../../../src/trace/database/sql/Irq.sql'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); // @ts-ignore window.ResizeObserver = window.ResizeObserver || @@ -26,7 +26,6 @@ window.ResizeObserver = })); import { SpArkTsChart } from '../../../../src/trace/component/chart/SpArkTsChart'; -import { SpIrqChart } from '../../../../src/trace/component/chart/SpIrqChart'; jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; diff --git a/ide/test/trace/component/chart/SpLogChart.test.ts b/ide/test/trace/component/chart/SpLogChart.test.ts index 3bfb61f0e7b50085e014a3a0558c8be3920070ec..9a58f1ebe37b370fabbe3688259ae22dc26c5343 100644 --- a/ide/test/trace/component/chart/SpLogChart.test.ts +++ b/ide/test/trace/component/chart/SpLogChart.test.ts @@ -16,8 +16,9 @@ import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpLogChart } from '../../../../src/trace/component/chart/SpLogChart'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || diff --git a/ide/test/trace/component/chart/SpLtpoChart.test.ts b/ide/test/trace/component/chart/SpLtpoChart.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..71ad8f3c0588a641c422d429b51d2c3d1e1ab931 --- /dev/null +++ b/ide/test/trace/component/chart/SpLtpoChart.test.ts @@ -0,0 +1,112 @@ +/* + * 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 { SpLtpoChart } from '../../../../src/trace/component/chart/SpLTPO'; +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; +import { LtpoStruct } from "../../../../src/trace/database/ui-worker/ProcedureWorkerLTPO"; +import { Rect } from "../../../../src/trace/database/ui-worker/ProcedureWorkerCommon"; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +const sqlit = require('../../../../src/trace/database/sql/Ltpo.sql'); +jest.mock('../../../../src/trace/database/sql/Ltpo.sql'); + +describe('SpLtpoChart Test', () => { + let ltPoChart = new SpLtpoChart(new SpSystemTrace()); + let fanceNameList = sqlit.queryFanceNameList; + fanceNameList.mockResolvedValue([ + { + ts: 122, + dur: 245, + name:'Present Fence' + } + ]); + + let fpsNameList = sqlit.queryFpsNameList; + fpsNameList.mockResolvedValue([ + { + ts: 1224, + dur: 2445, + name: 'Layers rate' + } + ]); + + let realFpsList = sqlit.queryRealFpsList; + realFpsList.mockResolvedValue([ + { + ts: 124, + dur: 445, + name:'CommitAndReleaseLayers SetScreenRefreshRate' + } + ]); + let ltpoArr: LtpoStruct[] = [{ + translateY:2, + frame: new Rect(0, 14, 10, 40), + isHover:true, + dur: 2122, + name: 'name', + presentId: 125, + ts: 258, + fanceId: 1245, + fps: 52, + startTs: 125, + nextStartTs: 12, + nextDur: 321, + value: 10, + pid: 1, + itid: 23, + startTime: 0 + }] + let presentInfo = sqlit.queryPresentInfo; + presentInfo.mockResolvedValue([ + { + ts: 124, + dur: 445, + name: 'Present Fence' + } + ]); + it('SpLtpoChartTest01', function () { + ltPoChart.init(); + expect(SpLtpoChart.ltpoDataArr).toEqual([]); + }); + it('SpLtpoChartTest02', function () { + expect(ltPoChart.setRealFps()).toBeUndefined(); + }); + it('SpLtpoChartTest03', function () { + expect(ltPoChart.sendDataHandle(ltpoArr, ltpoArr).length).toEqual(0); + }); + + it('SpLtpoChartTest04', function () { + ltPoChart.initHitchTime(); + expect(SpLtpoChart.presentArr).toEqual([]); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts b/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts index 01be3a6e16de62d17aeaa312c39b006299f7524f..0f23bce6424c82e0e88aad4745f484173274a832 100644 --- a/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts +++ b/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts @@ -15,9 +15,16 @@ import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; import { SpNativeMemoryChart } from '../../../../src/trace/component/chart/SpNativeMemoryChart'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); + +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/NativeHook.sql'); +jest.mock('../../../../src/trace/database/sql/NativeHook.sql'); +const memSqlite = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); +const clockSqlite = require('../../../../src/trace/database/sql/Clock.sql'); +jest.mock('../../../../src/trace/database/sql/Clock.sql'); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); const intersectionObserverMock = () => ({ observe: () => null, @@ -30,8 +37,7 @@ window.ResizeObserver = window.ResizeObserver || observe: jest.fn(), })); describe('SpNativeMemoryChart Test', () => { - let chartManager = new SpSystemTrace(); - let spNativeMemoryChart = new SpNativeMemoryChart(chartManager); + let spNativeMemoryChart = new SpNativeMemoryChart(new SpSystemTrace()); let queryNativeHookStatisticsCount = sqlit.queryNativeHookStatisticsCount; queryNativeHookStatisticsCount.mockResolvedValue([ @@ -40,7 +46,7 @@ describe('SpNativeMemoryChart Test', () => { }, ]); - let queryNativeMemoryRealTime = sqlit.queryNativeMemoryRealTime; + let queryNativeMemoryRealTime = memSqlite.queryNativeMemoryRealTime; queryNativeMemoryRealTime.mockResolvedValue([ { ts: 1502013097360370200, @@ -48,7 +54,7 @@ describe('SpNativeMemoryChart Test', () => { }, ]); - let queryBootTime = sqlit.queryBootTime; + let queryBootTime = clockSqlite.queryBootTime; queryBootTime.mockResolvedValue([ { ts: -557295431, @@ -65,7 +71,7 @@ describe('SpNativeMemoryChart Test', () => { }, ]); - let heapGroupByEvent = sqlit.queryHeapGroupByEvent; + let heapGroupByEvent = sqlite.queryHeapGroupByEvent; heapGroupByEvent.mockResolvedValue([ { eventType: 'AllocEvent', diff --git a/ide/test/trace/component/chart/SpProcessChart.test.ts b/ide/test/trace/component/chart/SpProcessChart.test.ts index cf8c49a95a39f3705711854eac97cbc78434642e..5eb7815d957395bc99a7771f1b53c5a02229395f 100644 --- a/ide/test/trace/component/chart/SpProcessChart.test.ts +++ b/ide/test/trace/component/chart/SpProcessChart.test.ts @@ -12,11 +12,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; import { SpProcessChart } from '../../../../src/trace/component/chart/SpProcessChart'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +import { TraceRow } from "../../../../src/trace/component/trace/base/TraceRow"; +import { ProcessStruct } from "../../../../src/trace/database/ui-worker/ProcedureWorkerProcess"; +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../src/trace/database/sql/Func.sql'); +const processSqlite = require('../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../src/trace/database/sql/ProcessThread.sql'); +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +const jankSqlite = require('../../../../src/trace/database/sql/Janks.sql'); +jest.mock('../../../../src/trace/database/sql/Janks.sql'); +const memSqlite = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); @@ -25,7 +36,6 @@ const intersectionObserverMock = () => ({ observe: () => null, }); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); -import { SpSystemTrace } from "../../../../src/trace/component/SpSystemTrace"; // @ts-ignore window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ observe: jest.fn(), @@ -54,7 +64,7 @@ describe('SpProcessChart Test', () => { argsetid: 6, }, ]); - let processContentCount = sqlit.queryProcessContentCount; + let processContentCount = processSqlite.queryProcessContentCount; processContentCount.mockResolvedValue([ { pid: 1, @@ -64,9 +74,9 @@ describe('SpProcessChart Test', () => { mem_count: 5, }, ]); - let queryProcessThreads = sqlit.queryProcessThreads; + let queryProcessThreads = processSqlite.queryProcessThreads; queryProcessThreads.mockResolvedValue([]); - let queryProcessThreadsByTable = sqlit.queryProcessThreadsByTable; + let queryProcessThreadsByTable = processSqlite.queryProcessThreadsByTable; queryProcessThreadsByTable.mockResolvedValue([ { pid: 1, @@ -75,7 +85,7 @@ describe('SpProcessChart Test', () => { threadName: 'thread', }, ]); - let queryProcessMem = sqlit.queryProcessMem; + let queryProcessMem = processSqlite.queryProcessMem; queryProcessMem.mockResolvedValue([ { trackId: 1, @@ -85,14 +95,14 @@ describe('SpProcessChart Test', () => { processName: 'processName', }, ]); - let queryEventCountMap = sqlit.queryEventCountMap; + let queryEventCountMap = sqlite.queryEventCountMap; queryEventCountMap.mockResolvedValue([ { eventName: 'eventName', count: 1, }, ]); - let queryProcess = sqlit.queryProcess; + let queryProcess = processSqlite.queryProcess; queryProcess.mockResolvedValue([ { pid: 1, @@ -100,7 +110,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryProcessByTable = sqlit.queryProcessByTable; + let queryProcessByTable = processSqlite.queryProcessByTable; queryProcessByTable.mockResolvedValue([ { pid: 2, @@ -119,14 +129,14 @@ describe('SpProcessChart Test', () => { maxDepth: 2, }, ]); - let queryAllJankProcess = sqlit.queryAllJankProcess; + let queryAllJankProcess = jankSqlite.queryAllJankProcess; queryAllJankProcess.mockResolvedValue([ { pid: 1, }, ]); - let queryAllExpectedData = sqlit.queryAllExpectedData; + let queryAllExpectedData = sqlite.queryAllExpectedData; queryAllExpectedData.mockResolvedValue([ { id: 41, @@ -148,7 +158,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryAllActualData = sqlit.queryAllActualData; + let queryAllActualData = jankSqlite.queryAllActualData; queryAllActualData.mockResolvedValue([ { id: 40, @@ -178,7 +188,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryProcessStartup = sqlit.queryProcessStartup; + let queryProcessStartup = processSqlite.queryProcessStartup; queryProcessStartup.mockResolvedValue([ { 'pid': 3913, @@ -284,7 +294,7 @@ describe('SpProcessChart Test', () => { } ]); - let queryProcessSoInitData = sqlit.queryProcessSoInitData; + let queryProcessSoInitData = processSqlite.queryProcessSoInitData; queryProcessSoInitData.mockResolvedValue([ { 'pid': 3913, @@ -497,7 +507,7 @@ describe('SpProcessChart Test', () => { } } ]); - let processData = sqlit.queryProcessData; + let processData = processSqlite.queryProcessData; processData.mockResolvedValue([ { cpu: 0, dur: 199000, startTime: 259730000 @@ -506,24 +516,24 @@ describe('SpProcessChart Test', () => { cpu: 2, dur: 147000, startTime: 307742000 } ]); - let processMemData = sqlit.queryProcessMemData; + let processMemData = processSqlite.queryProcessMemData; processMemData.mockResolvedValue([ { startTime: 593015789, - track_id : 153, - ts : 30150767408970, - type : "measure", - value : 0 + track_id: 153, + ts: 30150767408970, + type: 'measure', + value: 0 }, { startTime: 593360060, - track_id : 153, - ts : 30150767753241, - type : "measure", - value : 1 + track_id: 153, + ts: 30150767753241, + type: 'measure', + value: 1 } ]); - let maxValue = sqlit.queryMemFilterIdMaxValue; + let maxValue = memSqlite.queryMemFilterIdMaxValue; maxValue.mockResolvedValue([ { filterId: 1, @@ -538,40 +548,40 @@ describe('SpProcessChart Test', () => { funcNames.mockResolvedValue([ { id: 0, - name: "test" + name: 'test' } ]); - let soInitNames = sqlit.queryAllSoInitNames; + let soInitNames = sqlite.queryAllSoInitNames; soInitNames.mockResolvedValue([ { id: 1, - name: "soInitName" + name: 'soInitName' } ]); - let allProcessNames = sqlit.queryAllProcessNames; + let allProcessNames = processSqlite.queryAllProcessNames; allProcessNames.mockResolvedValue([ { id: 2, - name: "processName", + name: 'processName', pid: 256 } ]); - let srcSlices = sqlit.queryAllSrcSlices; + let srcSlices = sqlite.queryAllSrcSlices; srcSlices.mockResolvedValue([ { id: 3, - src: "src" + src: 'src' } ]); - let threadNames = sqlit.queryAllThreadName; + let threadNames = processSqlite.queryAllThreadName; threadNames.mockResolvedValue([ { tid: 4, - name: "threadName" + name: 'threadName' } ]); @@ -593,12 +603,14 @@ describe('SpProcessChart Test', () => { }); it('SpProcessChart04', function () { - let startUpRow = spProcessChart.addStartUpRow(spProcessChart); + let row = new TraceRow(); + let startUpRow = spProcessChart.addStartUpRow(row); expect(startUpRow).not.toBeUndefined(); }); it('SpProcessChart05', function () { - let soInitRow = spProcessChart.addSoInitRow(spProcessChart, 1); + let row = new TraceRow(); + let soInitRow = spProcessChart.addSoInitRow(row, 1); expect(soInitRow).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/chart/SpSdkChart.test.ts b/ide/test/trace/component/chart/SpSdkChart.test.ts index 3fa5c0e8faa1b6cfd2b43d74815ad25ad9f7f150..20a93ee6b002ba555b55000880d7efb39ff92d70 100644 --- a/ide/test/trace/component/chart/SpSdkChart.test.ts +++ b/ide/test/trace/component/chart/SpSdkChart.test.ts @@ -15,9 +15,16 @@ import { SpSdkChart } from '../../../../src/trace/component/chart/SpSdkChart'; import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlit = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +const sdkSqlite = require('../../../../src/trace/database/sql/Sdk.sql'); +jest.mock('../../../../src/trace/database/sql/Sdk.sql'); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +const intersectionObserverMock = () => ({ + observe: () => null, +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -27,15 +34,69 @@ window.ResizeObserver = })); describe('SpSdkChart Test', () => { - let spSdkChart = new SpSdkChart(); + let spSdkChart = new SpSdkChart(new SpSystemTrace()); let MockStartTime = sqlit.queryStartTime; MockStartTime.mockResolvedValue([ { start_ts: 0, }, ]); + + let counterMax = sdkSqlite.queryCounterMax; + counterMax.mockResolvedValue([ + { + startTime: 12, + tableName: '', + columns: '' + }, + ]); + + let sdkCount = sdkSqlite.querySdkCount; + sdkCount.mockResolvedValue([ + { + startTime: 15, + tableName: 'tableName', + columns: '' + }, + ]); + + let sdkCounterData = sdkSqlite.querySdkCounterData; + sdkCounterData.mockResolvedValue([ + { + startTime: 15, + tableName: 'tableName', + columns: '' + }, + ]); + + let sdkSliceData = sdkSqlite.querySdkSliceData; + sdkSliceData.mockResolvedValue([ + { + startTime: 152, + tableName: 'tableName', + columns: '' + }, + ]); + let map = new Map(); + let jsoSdknCofigStr = + '{"settingConfig":{"configuration":{"counters":{"enum":["ARM_Mali-TTRx_JS1_ACTIVE","ARM_Mali-TTRx_JS0_ACTIVE","ARM_Mali-TTRx_GPU_ACTIVE","ARM_Mali-TTRx_FRAG_ACTIVE"],\n' + + ' "type":"string"},"stop_gator":{"default":"true","description":"stop_gator","type":"boolean"},"version":{"default":"7","description":"gatordversion","type":"number"}},"name":"mailG77"},\n' + + ' "tableConfig":{"showType":[{"columns":[{"column":"ts","displayName":"TimeStamp","showType":[1,3],"type":"INTEGER"},{"column":"counter_id","displayName":"MonitorValue","showType":[1,3],"type":"INTEGER"},\n' + + ' {"column":"value","displayName":"Value","showType":[1,3],"type":"INTEGER"}],"inner":{"columns":[{"column":"counter_name","displayName":"","showType":[0],"type":"STRING"},\n' + + ' {"column":"counter_id","displayName":"","showType":[96,6],"type":"INTEGER"}],"tableName":"mock_plugin_counterobj_table"},"tableName":"mock_plugin_counter_table"},\n' + + ' {"columns":[{"column":"start_ts","displayName":"startts","showType":[2,3],"type":"INTEGER"},{"column":"end_ts","displayName":"endts","showType":[2,3],"type":"INTEGER"},\n' + + ' {"column":"slice_id","displayName":"slice_id","showType":[2,154,3],"type":"INTEGER"},{"column":"value","displayName":"Value","showType":[2,3],"type":"INTEGER"}],\n' + + ' "inner":{"columns":[{"column":"slice_name","displayName":"","showType":[313],"type":"STRING"},{"column":"slice_id","displayName":"","showType":[0],"type":"INTEGER"}],\n' + + ' "tableName":"mock_plugin_sliceobj_table"},"tableName":"mock_plugin_slice_table"}]}}'; + let dataSdkMap = { + jsonConfig: jsoSdknCofigStr, + disPlayName: 'common_mock', + pluginName: 'mock-plugin', + }; + map.set('1', dataSdkMap); + SpSystemTrace.SDK_CONFIG_MAP = map; it('SpSdkChartTest01', function () { - expect(spSdkChart.createSliceSql(10, 8, [{ length: 5 }], '')).toBe('select undefined from 8 '); + expect(spSdkChart.createSliceSql(10, 8, [{length: 5}], '')).toBe('select undefined from 8 '); }); it('SpSdkChartTest02', function () { @@ -47,11 +108,11 @@ describe('SpSdkChart Test', () => { }); it('SpSdkChartTest04', function () { - expect(spSdkChart.createSql(3, 'c', [{ length: 3 }], 'a')).toBe('select undefined from c a'); + expect(spSdkChart.createSql(3, 'c', [{length: 3}], 'a')).toBe('select undefined from c a'); }); it('SpSdkChartTest05', function () { - expect(spSdkChart.createSql(0, 'c', [{ length: 3 }], '')).toBe('select undefined from c '); + expect(spSdkChart.createSql(0, 'c', [{length: 3}], '')).toBe('select undefined from c '); }); it('SpSdkChartTest06', function () { @@ -60,26 +121,14 @@ describe('SpSdkChart Test', () => { }); it('SpSdkChartTest07', function () { - let spSystemTrace = new SpSdkChart(); - let sdkChart = new SpSdkChart(spSystemTrace); - let map = new Map(); - let jsoSdknCofigStr = - '{"settingConfig":{"configuration":{"counters":{"enum":["ARM_Mali-TTRx_JS1_ACTIVE","ARM_Mali-TTRx_JS0_ACTIVE","ARM_Mali-TTRx_GPU_ACTIVE","ARM_Mali-TTRx_FRAG_ACTIVE"],\n' + - ' "type":"string"},"stop_gator":{"default":"true","description":"stop_gator","type":"boolean"},"version":{"default":"7","description":"gatordversion","type":"number"}},"name":"mailG77"},\n' + - ' "tableConfig":{"showType":[{"columns":[{"column":"ts","displayName":"TimeStamp","showType":[1,3],"type":"INTEGER"},{"column":"counter_id","displayName":"MonitorValue","showType":[1,3],"type":"INTEGER"},\n' + - ' {"column":"value","displayName":"Value","showType":[1,3],"type":"INTEGER"}],"inner":{"columns":[{"column":"counter_name","displayName":"","showType":[0],"type":"STRING"},\n' + - ' {"column":"counter_id","displayName":"","showType":[96,6],"type":"INTEGER"}],"tableName":"mock_plugin_counterobj_table"},"tableName":"mock_plugin_counter_table"},\n' + - ' {"columns":[{"column":"start_ts","displayName":"startts","showType":[2,3],"type":"INTEGER"},{"column":"end_ts","displayName":"endts","showType":[2,3],"type":"INTEGER"},\n' + - ' {"column":"slice_id","displayName":"slice_id","showType":[2,154,3],"type":"INTEGER"},{"column":"value","displayName":"Value","showType":[2,3],"type":"INTEGER"}],\n' + - ' "inner":{"columns":[{"column":"slice_name","displayName":"","showType":[313],"type":"STRING"},{"column":"slice_id","displayName":"","showType":[0],"type":"INTEGER"}],\n' + - ' "tableName":"mock_plugin_sliceobj_table"},"tableName":"mock_plugin_slice_table"}]}}'; - let dataSdkMap = { - jsonConfig: jsoSdknCofigStr, - disPlayName: 'common_mock', - pluginName: 'mock-plugin', - }; - map.set('1', dataSdkMap); - SpSystemTrace.SDK_CONFIG_MAP = map; - sdkChart.parseJson(58512, map); + spSdkChart.parseJson(58512, map); + }); + + it('SpSdkChartTest08', function () { + expect(spSdkChart.initSliceChartRow(true, 2, 3, 'name', 2)).not.toBeUndefined(); + }); + + it('SpSdkChartTest09', function () { + expect(spSdkChart.initCounterChartRow(5, true, 2, 'name')).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/chart/SpVirtualMemChart.test.ts b/ide/test/trace/component/chart/SpVirtualMemChart.test.ts index 4a51934426fc1123d6d008e80d00ea65967bf1e3..9e1f05b5e39ee01ddcbb5412f8e7080fce3206d9 100644 --- a/ide/test/trace/component/chart/SpVirtualMemChart.test.ts +++ b/ide/test/trace/component/chart/SpVirtualMemChart.test.ts @@ -12,30 +12,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// @ts-ignore -window.ResizeObserver = window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), observe: jest.fn(), unobserve: jest.fn(), - })); + +import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpVirtualMemChart } from '../../../../src/trace/component/chart/SpVirtualMemChart'; import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; - +// @ts-ignore +window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), observe: jest.fn(), unobserve: jest.fn(), + })); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); -const sqlit = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); -const intersectionObserverMock = () => ({ - observe: () => null, -}); - +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const memorySqlite = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); describe('SpVirtualMemChart Test', () => { let manager = new SpChartManager(); let spVirtualMemChart = new SpVirtualMemChart(manager); - let MockVirtualMemory = sqlit.queryVirtualMemory; + let MockVirtualMemory = memorySqlite.queryVirtualMemory; MockVirtualMemory.mockResolvedValue([ { id: 0, @@ -43,7 +39,7 @@ describe('SpVirtualMemChart Test', () => { }, ]); - let MockVirtualMemoryData = sqlit.queryVirtualMemoryData; + let MockVirtualMemoryData = memorySqlite.queryVirtualMemoryData; MockVirtualMemoryData.mockResolvedValue([ { startTime: 0, diff --git a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts index 77a5abc53e400b2872ab7ec206a385b00c732814..39af83665994fd329cea50b56ff5bb9318c88a1c 100644 --- a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts +++ b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts @@ -15,11 +15,18 @@ import { VmTrackerChart } from '../../../../src/trace/component/chart/SpVmTrackerChart'; import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { - return {}; -}); + +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +const sqlite = require('../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../src/trace/database/sql/Dma.sql'); +const memorySqlite = require('../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../src/trace/database/sql/Memory.sql'); +const smapsSql = require('../../../../src/trace/database/sql/Smaps.sql'); +jest.mock('../../../../src/trace/database/sql/Smaps.sql'); +const gpuSql = require('../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../src/trace/component/chart/SpHiPerf'); + // @ts-ignore window.ResizeObserver = @@ -31,15 +38,6 @@ window.ResizeObserver = })); describe('SpVmTrackerChart Test', () => { - let smapsData = sqlite.querySmapsData; - let smapsSixData = [ - { - startNs: 0, - value: 1024, - name: 'dirty', - }, - ]; - smapsData.mockResolvedValue(smapsSixData); let dmaSmapsData = sqlite.queryDmaSampsData; let smapsDmaData = [ { @@ -51,7 +49,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; dmaSmapsData.mockResolvedValue(smapsDmaData); - let gpuMemoryData = sqlite.queryGpuMemoryData; + let gpuMemoryData = memorySqlite.queryGpuMemoryData; let gpuData = [ { startNs: 0, @@ -60,14 +58,14 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuMemoryData.mockResolvedValue(gpuData); - let smapsExits = sqlite.querySmapsExits; + let smapsExits = smapsSql.querySmapsExits; let exits = [ { event_name: 'trace_smaps', }, ]; smapsExits.mockResolvedValue(exits); - let vmTrackerShmData = sqlite.queryVmTrackerShmData; + let vmTrackerShmData = memorySqlite.queryVmTrackerShmData; let shmData = [ { startNs: 0, @@ -75,7 +73,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; vmTrackerShmData.mockResolvedValue(shmData); - let purgeableProcessData = sqlite.queryPurgeableProcessData; + let purgeableProcessData = memorySqlite.queryPurgeableProcessData; let processData = [ { startNs: 0, @@ -83,7 +81,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; purgeableProcessData.mockResolvedValue(processData); - let gpuGlData = sqlite.queryGpuData; + let gpuGlData = gpuSql.queryGpuData; let glData = [ { startNs: 0, @@ -91,7 +89,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuGlData.mockResolvedValue(glData); - let gpuTotalData = sqlite.queryGpuTotalData; + let gpuTotalData = gpuSql.queryGpuTotalData; let totalData = [ { startNs: 0, @@ -99,7 +97,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuTotalData.mockResolvedValue(totalData); - let gpuTotalType = sqlite.queryGpuTotalType; + let gpuTotalType = gpuSql.queryGpuTotalType; let totalType = [ { id: 1, @@ -107,7 +105,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuTotalType.mockResolvedValue(totalType); - let gpuWindowData = sqlite.queryGpuWindowData; + let gpuWindowData = gpuSql.queryGpuWindowData; let windowsData = [ { startNs: 0, @@ -115,7 +113,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuWindowData.mockResolvedValue(windowsData); - let gpuWindowType = sqlite.queryGpuWindowType; + let gpuWindowType = gpuSql.queryGpuWindowType; let windowsType = [ { id: 1, diff --git a/ide/test/trace/component/setting/SpAllocations.test.ts b/ide/test/trace/component/setting/SpAllocations.test.ts index 506a15b03c56f62aa28a06ebb353aa5cbbf506ae..4eb225a1891498c2d8538366d25801a2ddf2fbc2 100644 --- a/ide/test/trace/component/setting/SpAllocations.test.ts +++ b/ide/test/trace/component/setting/SpAllocations.test.ts @@ -35,74 +35,36 @@ describe('SpAllocations Test', () => { spEle.filterMemoryUnit = jest.fn(() => true); spEle.filterMemoryUnit.value = jest.fn(() => true); expect(spEle.pid).toEqual(undefined); - expect(spEle.unwind).toBeNaN(); - expect(spEle.shared).toBe(16384); - expect(spEle.filter).toBeNaN(); + expect(spEle.unwind).toBeUndefined(); + expect(spEle.shared).toBeUndefined(); + expect(spEle.filter).toBeUndefined(); }); - - it(' SpAllocations set attrValue', function () { - let spEle = document.querySelector('#sp') as SpAllocations; - spEle.unwindEL.value = '111'; - spEle.shareMemory.value = '222'; - spEle.shareMemoryUnit.value = 'MB'; - spEle.filterMemory.value = '111'; - spEle.filterMemoryUnit.value = 'MB'; - expect(spEle.pid).toEqual(undefined); - expect(spEle.unwind).toEqual(111); - expect(spEle.shared).toEqual(222); - expect(spEle.filter).toEqual(111); - }); - - it(' SpAllocations set attrValue2', function () { - let spEle = document.querySelector('#sp') as SpAllocations; - spEle.unwindEL.value = '1121'; - spEle.shareMemory!.value = '222'; - spEle.shareMemoryUnit.value = 'KB'; - spEle.filterMemory.value = '111'; - spEle.filterMemoryUnit.value = 'KB'; - expect(spEle.pid).toEqual(undefined); - expect(spEle.unwind).toEqual(1121); - expect(spEle.shared).toEqual(222); - expect(spEle.filter).toEqual(111); - }); - - it(' SpAllocations set attrValue03', function () { - let spEle = new SpAllocations(); - spEle.unwindEL.value = '1121'; - spEle.shareMemory.value = '222'; - spEle.filterMemory.value = '111'; - expect(spEle.pid).toEqual(undefined); - expect(spEle.unwind).toEqual(1121); - expect(spEle.shared).toEqual(222); - expect(spEle.filter).toEqual(111); - }); - - it('SpAllocations test05', function () { + it('SpAllocations test01', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.appProcess).toBe(''); + expect(spAllocations.appProcess).toBeUndefined(); }); - it('SpAllocations test09', function () { + it('SpAllocations test02', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.fp_unwind).toBeTruthy(); + expect(spAllocations.fp_unwind).toBeUndefined(); }); - it('SpAllocations test10', function () { + it('SpAllocations test03', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.record_accurately).toBeTruthy(); + expect(spAllocations.record_accurately).toBeUndefined(); }); - it('SpAllocations test11', function () { + it('SpAllocations test04', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.offline_symbolization).toBeTruthy(); + expect(spAllocations.offline_symbolization).toBeUndefined(); }); - it('SpAllocations test12', function () { + it('SpAllocations test05', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.record_statistics).toBeTruthy(); + expect(spAllocations.record_statistics).toBeUndefined(); }); - it('SpAllocations test13', function () { + it('SpAllocations test06', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; - expect(spAllocations.statistics_interval).toEqual(10); + expect(spAllocations.statistics_interval).toBeUndefined(); }); - it('SpAllocations test14', function () { + it('SpAllocations test07', function () { let spAllocations = document.querySelector('#sp') as SpAllocations; expect(spAllocations.startup_mode).toBeFalsy(); }); diff --git a/ide/test/trace/component/setting/SpRecordPerf.test.ts b/ide/test/trace/component/setting/SpRecordPerf.test.ts index a3c446ad6bc24c99d6634bc60acfeaba75b3d749..36bc285cc9bf4353b1ef49d0b0307006874e673a 100644 --- a/ide/test/trace/component/setting/SpRecordPerf.test.ts +++ b/ide/test/trace/component/setting/SpRecordPerf.test.ts @@ -65,6 +65,6 @@ describe('SpRecordPerf Test', () => { expect(spRecordPerf.getPerfConfig()).toBeTruthy(); }); it('SpRecordPerfTest012', function () { - expect(spRecordPerf.parseEvent('adfger')).toBeTruthy(); + expect(spRecordPerf.parseEvent).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/setting/SpWebHdcShell.test.ts b/ide/test/trace/component/setting/SpWebHdcShell.test.ts index c57a213b13b43499ef33e0039a7cc7346c8ce3fa..d93b0e61860af6f54fd23482f943c2478490f9e4 100644 --- a/ide/test/trace/component/setting/SpWebHdcShell.test.ts +++ b/ide/test/trace/component/setting/SpWebHdcShell.test.ts @@ -67,16 +67,14 @@ describe('SpWebHdcShell Test', () => { it('SpWebHdcShell Test03', function () { let arrayBufferA = new Uint8Array(1); arrayBufferA.set([1]); - let arrayBufferB = new Uint8Array(1); - arrayBufferB.set([1]); - expect(spWebHdcShell.arrayBufferCompare(arrayBufferA, arrayBufferB)).toBeTruthy(); + let arrayBufferB = [1, 2]; + expect(spWebHdcShell.arrayBufferCompare(arrayBufferA, arrayBufferB)).toBeFalsy(); }); it('SpWebHdcShell Test05', function () { let arrayBufferA = new Uint8Array(1); arrayBufferA.set([2]); - let arrayBufferB = new Uint8Array(1); - arrayBufferB.set([1]); + let arrayBufferB = [1, 2]; expect(spWebHdcShell.arrayBufferCompare(arrayBufferA, arrayBufferB)).toBeFalsy(); }); diff --git a/ide/test/trace/component/setting/utils/PluginConvertUtils.test.ts b/ide/test/trace/component/setting/utils/PluginConvertUtils.test.ts index 37034e6deb369bb657841df8223b2c983d3f9c1b..ce0cd6d41d7614f5080a27659278a93389e7f669 100644 --- a/ide/test/trace/component/setting/utils/PluginConvertUtils.test.ts +++ b/ide/test/trace/component/setting/utils/PluginConvertUtils.test.ts @@ -79,20 +79,6 @@ describe('PlugConvertUtils Test', () => { reportAppMemByMemoryService: false, pid: [], }; - - SpRecordTrace.MEM_INFO.forEach((va: any) => { - memoryconfig.sysMeminfoCounters.push(sysMeminfoTypeFromJSON(va)); - }); - SpRecordTrace.VMEM_INFO.forEach((me: any) => { - memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); - }); - SpRecordTrace.VMEM_INFO_SECOND.forEach((me: any) => { - memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); - }); - SpRecordTrace.VMEM_INFO_THIRD.forEach((me: any) => { - memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); - }); - let request = { requestId: 1, sessionConfig: sessionConfig, diff --git a/ide/test/trace/component/trace/TimerShaftElement.test.ts b/ide/test/trace/component/trace/TimerShaftElement.test.ts index 42e85af30fe181c9cc340a8b6dc9fb92d71559cc..04084db3990f07e75cc96427d6d4c0465f1e5328 100644 --- a/ide/test/trace/component/trace/TimerShaftElement.test.ts +++ b/ide/test/trace/component/trace/TimerShaftElement.test.ts @@ -12,14 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); jest.mock('../../../../src/trace/component/trace/base/ColorUtils', () => { return {}; }); - +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); import { TimerShaftElement, ns2s, ns2x } from '../../../../src/trace/component/trace/TimerShaftElement'; import { Rect } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; diff --git a/ide/test/trace/component/trace/base/RangeSelect.test.ts b/ide/test/trace/component/trace/base/RangeSelect.test.ts index 52a7297a60c7b6240276b9035d2adad6bc7e8070..6a583dd733f382956557eef13dbbf7e5c8470ebc 100644 --- a/ide/test/trace/component/trace/base/RangeSelect.test.ts +++ b/ide/test/trace/component/trace/base/RangeSelect.test.ts @@ -19,6 +19,12 @@ import { SpSystemTrace } from '../../../../../src/trace/component/SpSystemTrace' jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); const intersectionObserverMock = () => ({ observe: () => null, @@ -37,12 +43,12 @@ describe('RangeSelect Test', () => { beforeAll(() => {}); it('Utils Test01', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); expect(rangeSelect).not.toBeUndefined(); }); it('Utils Test02', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.rowsEL = document.createElement('div'); let mouseEvent = new MouseEvent('mousedown', { button: 1, @@ -54,8 +60,6 @@ describe('RangeSelect Test', () => { }); let htmlElement = document.createElement('div'); rangeSelect.rowsPaneEL = htmlElement; - rangeSelect.timerShaftDragEL = jest.fn(() => true); - rangeSelect.timerShaftDragEL.timerShaftDragEL = jest.fn(() => true); expect(rangeSelect.isInRowsEl(mouseEvent)).toBeFalsy(); }); it('Utils Test09', () => { @@ -69,16 +73,14 @@ describe('RangeSelect Test', () => { screenX: 325, screenY: 325, }); - let htmlElement = document.createElement('div'); - rangeSelect.spacerEL = htmlElement; expect(rangeSelect.isInSpacerEL(mouseEvent)).toBeFalsy(); }); it('Utils Test05', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.rowsEL = { - // offsetTop: 100, + offsetTop: 100, offsetHeight: 71, offsetLeft: 15, offsetWidth: 134, @@ -96,17 +98,13 @@ describe('RangeSelect Test', () => { }); let divElement = document.createElement('div'); rangeSelect.rowsPaneEL = divElement; - rangeSelect.spacerEL = jest.fn(() => true); - rangeSelect.spacerEL.offsetTop = jest.fn(() => true); rangeSelect.rowsPaneEL.scrollTop = 0; rangeSelect.rowsEL.getBoundingClientRect = jest.fn(() => true); - let htmlElement = document.createElement('div'); - rangeSelect.spacerEL = htmlElement; expect(rangeSelect.mouseDown(mouseEvent)).toBeUndefined(); }); it('Utils Test07', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -127,15 +125,7 @@ describe('RangeSelect Test', () => { screenX: 252, screenY: 325, }); - rangeSelect.spacerEL = jest.fn(() => true); - rangeSelect.spacerEL.offsetTop = jest.fn(() => 1); rangeSelect.drag = true; - rangeSelect.rowsEL = jest.fn(() => true); - rangeSelect.rowsEL.getBoundingClientRect = jest.fn(() => true); - rangeSelect.spacerEL.containPoint = jest.fn(() => true); - rangeSelect.spacerEL.getBoundingClientRect = jest.fn(() => true); - rangeSelect.rowsPaneEL = jest.fn(() => true); - rangeSelect.rowsPaneEL.scrollTop = jest.fn(() => true); expect(rangeSelect.mouseUp(mouseEvent)).toBeUndefined(); }); @@ -172,29 +162,15 @@ describe('RangeSelect Test', () => { screenX: 252, screenY: 325, }); - rangeSelect.timerShaftDragEL = jest.fn(() => true); + let traceRowElement = new TraceRow(); rangeSelect.timerShaftEL = jest.fn(() => true); rangeSelect.timerShaftEL.sportRuler = jest.fn(() => true); - rangeSelect.timerShaftEL.sportRuler.isRangeSelect = jest.fn(() => true); rangeSelect.timerShaftEL.sportRuler.draw = jest.fn(() => true); - rangeSelect.timerShaftDragEL.timerShaftDragEL = jest.fn(() => 0); - rangeSelect.spacerEL = jest.fn(() => true); - rangeSelect.spacerEL.offsetTop = jest.fn(() => 1); - rangeSelect.ns2x = jest.fn(() => 1); - rangeSelect.mouseX = jest.fn(() => 10); - rangeSelect.markA = jest.fn(() => 8); - rangeSelect.markB = jest.fn(() => 9); - let htmlElement = document.createElement('div'); - rangeSelect.spacerEL = htmlElement; - let rowElement = document.createElement('div'); - rangeSelect.rowsPaneEL = rowElement; - rangeSelect.favoriteRowsEL = rowElement; - let traceRowElement = new TraceRow() expect(rangeSelect.mouseMove([traceRowElement], mouseEvent)).toBeUndefined(); }); it('Utils Test10', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -217,13 +193,11 @@ describe('RangeSelect Test', () => { }); let htmlElement = document.createElement('div'); rangeSelect.rowsPaneEL = htmlElement; - rangeSelect.timerShaftDragEL = jest.fn(() => true); - rangeSelect.timerShaftDragEL.timerShaftDragEL = jest.fn(() => 0); expect(rangeSelect.isTouchMark(mouseEvent)).toBeFalsy(); }); it('Utils Test06', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isHover = true; let mouseEvent = new MouseEvent('mousedown', { // @ts-ignore @@ -239,7 +213,7 @@ describe('RangeSelect Test', () => { expect(rangeSelect.mouseDown(mouseEvent)).toBeUndefined(); }); it('Utils Test11', () => { - let rangeSelect = new RangeSelect(); + let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -260,14 +234,6 @@ describe('RangeSelect Test', () => { screenX: 45, screenY: 78, }); - rangeSelect.spacerEL = jest.fn(() => true); - rangeSelect.rowsEL = jest.fn(() => true); - rangeSelect.rowsEL.getBoundingClientRect = jest.fn(() => true); - rangeSelect.spacerEL.containPoint = jest.fn(() => true); - rangeSelect.spacerEL.getBoundingClientRect = jest.fn(() => true); - rangeSelect.rowsPaneEL = jest.fn(() => true); - rangeSelect.rowsPaneEL.scrollTop = jest.fn(() => true); - rangeSelect.spacerEL.offsetTop = jest.fn(() => 1); rangeSelect.drag = true; expect(rangeSelect.mouseOut(mouseEvent)).toBeUndefined(); }); @@ -276,8 +242,6 @@ describe('RangeSelect Test', () => { rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); rangeSelect.isMouseDown = false; - let rowsELDiv = document.createElement('div'); - rangeSelect.rowsEL = rowsELDiv; let mouseEvent = new MouseEvent('mousedown', { // @ts-ignore offsetY: 12, @@ -289,23 +253,10 @@ describe('RangeSelect Test', () => { screenX: 9, screenY: 325, }); + let traceRowElement = new TraceRow(); rangeSelect.timerShaftEL = jest.fn(() => true); rangeSelect.timerShaftEL.sportRuler = jest.fn(() => true); - rangeSelect.timerShaftEL.sportRuler.isRangeSelect = jest.fn(() => true); rangeSelect.timerShaftEL.sportRuler.draw = jest.fn(() => true); - rangeSelect.timerShaftDragEL = jest.fn(() => true); - rangeSelect.timerShaftDragEL.timerShaftDragEL = jest.fn(() => 0); - rangeSelect.spacerEL = jest.fn(() => true); - let htmlElement = document.createElement('div'); - rangeSelect.spacerEL = htmlElement; - let rowElement = document.createElement('div'); - rangeSelect.rowsPaneEL = rowElement; - rangeSelect.favoriteRowsEL = rowElement; - let traceRowElement = new TraceRow(); - rangeSelect.ns2x = jest.fn(() => 1); - rangeSelect.mouseX = jest.fn(() => 10); - rangeSelect.markA = jest.fn(() => 8); - rangeSelect.markB = jest.fn(() => 9); expect(rangeSelect.mouseMove([traceRowElement], mouseEvent)).toBeUndefined(); }); }); diff --git a/ide/test/trace/component/trace/base/TraceRow.test.ts b/ide/test/trace/component/trace/base/TraceRow.test.ts index 707ca1ca61d0ca75f79f7d7a706c18ee8831e34a..72e6dddbd8ed1e7ffdbf3448e2e8a5a5f1c60e7b 100644 --- a/ide/test/trace/component/trace/base/TraceRow.test.ts +++ b/ide/test/trace/component/trace/base/TraceRow.test.ts @@ -14,19 +14,19 @@ */ import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; -import { Sptext } from '../../../../../src/trace/component/Sptext'; import { ThreadStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerThread'; jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - - +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('TraceRow Test', () => { - beforeAll(() => {}); - const ctx = { - lineWidth: 1, - strokeStyle: true, - }; + beforeAll(() => { + }); let traceRow = new TraceRow({ canvasNumber: 1, alpha: true, @@ -71,15 +71,12 @@ describe('TraceRow Test', () => { contextId: '2d', isOffScreen: true, }); - traceRow.dataList = { + traceRow.dataList = [{ supplier: true, isLoading: false, - }; - traceRow.supplier = true; + }]; traceRow.isLoading = false; traceRow.name = '111'; - traceRow.height = 201; - traceRow.height = 301; expect(traceRow.clearCanvas(ctx)).toBeUndefined(); }); @@ -94,20 +91,14 @@ describe('TraceRow Test', () => { contextId: '2d', isOffScreen: true, }); - traceRow.supplier = true; traceRow.isLoading = false; traceRow.name = '561'; - traceRow.height = 33; - traceRow.height = 35; - traceRow.dataList = { + traceRow.dataList = [{ supplier: true, isLoading: false, - }; - traceRow.supplier = true; + }]; traceRow.isLoading = false; traceRow.name = '111'; - traceRow.height = 202; - traceRow.height = 302; expect(traceRow.drawLines(ctx)).toBeUndefined(); }); @@ -122,14 +113,12 @@ describe('TraceRow Test', () => { contextId: '2d', isOffScreen: true, }); - traceRow.dataList = { + traceRow.dataList = [{ supplier: true, isLoading: false, - }; - traceRow.supplier = true; + }]; traceRow.isLoading = false; traceRow.name = '1201'; - traceRow.height = 554; expect(traceRow.drawSelection(ctx)).toBeUndefined(); }); @@ -147,7 +136,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test16', () => { - traceRow.rowType = true; + traceRow.rowType = 'cpu'; expect(traceRow.rowType).toBeTruthy(); }); @@ -156,7 +145,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test18', () => { - traceRow.rowId = true; + traceRow.rowId = 'cpu'; expect(traceRow.rowId).toBeTruthy(); }); @@ -165,13 +154,13 @@ describe('TraceRow Test', () => { }); it('TraceRow Test20', () => { - traceRow.rowParentId = true; + traceRow.rowParentId = 'cpu'; expect(traceRow.rowParentId).toBeTruthy(); }); it('TraceRow Test21', () => { traceRow.rowHidden = true; - expect(traceRow.rowHidden).toBeUndefined(); + expect(traceRow.getAttribute('row-hidden')).toBe(''); }); it('TraceRow Test22', () => { @@ -188,31 +177,10 @@ describe('TraceRow Test', () => { expect(traceRow.folder).toBeTruthy(); }); - it('TraceRow Test25', () => { - }); - - it('TraceRow Test26', () => { - }); - - it('TraceRow Test27', () => { - traceRow.tip = true; - traceRow.tipEL = true; - expect(traceRow.tip).toBeUndefined(); - }); - it('TraceRow Test28', () => { expect(traceRow.frame).not.toBeUndefined(); }); - it('TraceRow Test29', () => { - traceRow.frame = [0, 0, 0]; - expect(traceRow.frame).toBeTruthy(); - }); - - it('TraceRow Test62', () => { - expect(traceRow.folderPaddingLeft).toBeUndefined(); - }); - it('TraceRow Test30', () => { expect(traceRow.checkType).not.toBeUndefined(); }); @@ -227,7 +195,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test33', () => { - traceRow.drawType = true; + traceRow.drawType = 1; expect(traceRow.drawType).toBeTruthy(); }); @@ -237,12 +205,6 @@ describe('TraceRow Test', () => { expect(traceRow.updateWidth(1)).toBeUndefined(); }); - it('TraceRow Test36', () => { - traceRow.tipEL = jest.fn(()=>true); - traceRow.tipEL.style = jest.fn(()=>true); - expect(traceRow.onMouseHover()).toBeFalsy(); - }); - it('TraceRow Test37', () => { expect(traceRow.setTipLeft(1, null)).toBeFalsy(); }); @@ -256,12 +218,12 @@ describe('TraceRow Test', () => { }); it('TraceRow Test40', () => { - traceRow.collect = 1; + traceRow.collect = true; expect(traceRow.collect).toBeTruthy(); }); it('TraceRow Test41', () => { - traceRow.collect = 0; + traceRow.collect = false; expect(traceRow.collect).toBeFalsy(); }); @@ -281,15 +243,10 @@ describe('TraceRow Test', () => { }); it('TraceRow Test45', () => { - traceRow.checkType = 0; + traceRow.checkType = ''; expect(traceRow.checkType).toBe(''); }); - it('TraceRow Test46', () => { - traceRow.rowHidden = false; - expect(traceRow.rowHidden).toBeUndefined(); - }); - it('TraceRow Test47', () => { traceRow.highlight = false; expect(traceRow.highlight).toBeFalsy(); @@ -301,7 +258,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test49', () => { - traceRow.setCheckBox = true; + traceRow.setCheckBox(true); expect(traceRow.highlight).toBeFalsy(); }); @@ -311,7 +268,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test51', () => { - expect(traceRow.isInTimeRange()).toBe(false); + expect(traceRow.isInTimeRange(1, 23)).toBe(false); }); it('TraceRow Test52', () => { @@ -319,7 +276,7 @@ describe('TraceRow Test', () => { }); it('TraceRow Test53', () => { - let value = traceRow.attributeChangedCallback('name'); + let value = traceRow.attributeChangedCallback('name', 'old', 'new'); expect(value).toBe(undefined); }); @@ -344,14 +301,6 @@ describe('TraceRow Test', () => { traceRow.rowDiscard = false; expect(traceRow.rowDiscard).toBeFalsy(); }); - it('TraceRow Test59', () => { - traceRow.disabledCheck = false; - expect(traceRow.disabledCheck).toBeFalsy(); - }); - it('TraceRow Test64', () => { - traceRow.folderPaddingLeft = 1; - expect(traceRow.folderPaddingLeft).toBeUndefined(); - }); it('TraceRow Test65', () => { expect(traceRow.getTransferArray()).toStrictEqual([undefined]); }); @@ -365,7 +314,7 @@ describe('TraceRow Test', () => { expect(traceRow.rowSettingPopoverDirection).toBeTruthy(); }); it('TraceRow Test71', () => { - traceRow.rowSettingPopoverDirection = true; + traceRow.rowSettingPopoverDirection = ''; expect(traceRow.rowSettingPopoverDirection).toBeTruthy(); }); it('TraceRow Test70', () => { @@ -377,40 +326,41 @@ describe('TraceRow Test', () => { }); it('TraceRow Test74', () => { let threadRow = TraceRow.skeleton(); - expect(traceRow.addChildTraceRowSpecifyLocation(threadRow,0)).toBeUndefined(); + expect(traceRow.addChildTraceRowSpecifyLocation(threadRow, 0)).toBeUndefined(); }); it('TraceRow Test75', () => { - expect(traceRow.drawLine(false,'top')).toBeUndefined(); + let item = document.createElement('div'); + expect(traceRow.drawLine(item, 'top')).toBeUndefined(); }); it('TraceRow Test76', () => { - let mouseChangeEvent: MouseEvent = new MouseEvent('change', { clientX: 1, clientY: 2 }); - traceRow.setCheckBox = jest.fn(()=>true); + let mouseChangeEvent: MouseEvent = new MouseEvent('change', {clientX: 1, clientY: 2}); + traceRow.setCheckBox = jest.fn(() => true); traceRow.checkBoxEL.dispatchEvent(mouseChangeEvent); }); it('TraceRow Test77', () => { - let mouseClickEvent: MouseEvent = new MouseEvent('click', { clientX: 1, clientY: 2 }); + let mouseClickEvent: MouseEvent = new MouseEvent('click', {clientX: 1, clientY: 2}); traceRow.isComplete = true; traceRow.collectEL.dispatchEvent(mouseClickEvent); }); it('TraceRow Test78', () => { - let mouseChangeEvent: MouseEvent = new MouseEvent('change', { clientX: 1, clientY: 2 }); + let mouseChangeEvent: MouseEvent = new MouseEvent('change', {clientX: 1, clientY: 2}); traceRow.addRowSettingPop(); traceRow.rowSettingTree.dispatchEvent(mouseChangeEvent); }); it('TraceRow Test80', () => { - let mouseDragOverEvent: MouseEvent = new MouseEvent('dragover', { clientX: 1, clientY: 2 }); + let mouseDragOverEvent: MouseEvent = new MouseEvent('dragover', {clientX: 1, clientY: 2}); traceRow.describeEl.dispatchEvent(mouseDragOverEvent); }); it('TraceRow Test81', () => { - let mouseDragendEvent: MouseEvent = new MouseEvent('dragend', { clientX: 1, clientY: 2 }); + let mouseDragendEvent: MouseEvent = new MouseEvent('dragend', {clientX: 1, clientY: 2}); traceRow.describeEl.dispatchEvent(mouseDragendEvent); }); it('TraceRow Test82', () => { - let mouseDragLeaveEvent: MouseEvent = new MouseEvent('dragleave', { clientX: 1, clientY: 2 }); + let mouseDragLeaveEvent: MouseEvent = new MouseEvent('dragleave', {clientX: 1, clientY: 2}); traceRow.describeEl.dispatchEvent(mouseDragLeaveEvent); }); it('TraceRow Test83', () => { - let mouseDragStartEvent: MouseEvent = new MouseEvent('dragstart', { clientX: 1, clientY: 2 }); + let mouseDragStartEvent: MouseEvent = new MouseEvent('dragstart', {clientX: 1, clientY: 2}); traceRow.describeEl.dispatchEvent(mouseDragStartEvent); }); it('TraceRow Test84', () => { diff --git a/ide/test/trace/component/trace/base/TraceRowConfig.test.ts b/ide/test/trace/component/trace/base/TraceRowConfig.test.ts index 4c9f622fe4713b66880df3b62cb2641135b3bd9b..1b1a1f8c0ddf314a77e41d63e9e261032b16a8ef 100644 --- a/ide/test/trace/component/trace/base/TraceRowConfig.test.ts +++ b/ide/test/trace/component/trace/base/TraceRowConfig.test.ts @@ -21,7 +21,7 @@ import { BaseStruct } from '../../../../../src/trace/bean/BaseStruct'; import '../../../../../src/trace/bean/BaseStruct'; import { LitCheckBox } from "../../../../../src/base-ui/checkbox/LitCheckBox"; -jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', () => { +jest.mock('../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { return { CpuStruct: { wakeupBean: undefined @@ -115,7 +115,6 @@ describe('TraceRowConfig Test', () => { scene: [] } traceRowConfig.displayRow(node, checkBox); - console.log('traceRowConfig.subsystemSelectList',traceRowConfig.subsystemSelectList) expect(traceRowConfig.subsystemSelectList.length).toBe(2) }); it('TraceRowConfig Test03', () => { diff --git a/ide/test/trace/component/trace/base/TraceRowRecyclerView.test.ts b/ide/test/trace/component/trace/base/TraceRowRecyclerView.test.ts index 5a9d56eb16ebc294b3590af83255f483873acc4e..37c090ad97a3528120bf571fdac7e6bb27c00a17 100644 --- a/ide/test/trace/component/trace/base/TraceRowRecyclerView.test.ts +++ b/ide/test/trace/component/trace/base/TraceRowRecyclerView.test.ts @@ -14,12 +14,17 @@ */ import { TraceRowRecyclerView } from '../../../../../src/trace/component/trace/base/TraceRowRecyclerView'; +import { TraceRowObject } from "../../../../../src/trace/component/trace/base/TraceRowObject"; jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - - +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('TraceRow Test', () => { beforeAll(() => {}); @@ -36,7 +41,8 @@ describe('TraceRow Test', () => { it('Test03', function () { let traceRow = new TraceRowRecyclerView(); traceRow.measureHeight = jest.fn(() => true); - traceRow.dataSource = true; + let obj = new TraceRowObject(); + traceRow.dataSource = [obj]; expect(traceRow.dataSource).toBeTruthy(); }); @@ -47,8 +53,8 @@ describe('TraceRow Test', () => { it('Test05', function () { let traceRow = new TraceRowRecyclerView(); - traceRow.renderType = false; - expect(traceRow.renderType).toBeFalsy(); + traceRow.renderType = 'type' + expect(traceRow.renderType).toEqual('type'); }); it('Test06', function () { diff --git a/ide/test/trace/component/trace/base/TraceSheet.test.ts b/ide/test/trace/component/trace/base/TraceSheet.test.ts index 800050ddb9efa346a3c138b607d0084e1a7248ca..a75c6600261e193ef2e1bcd2cf491c20f78eeec3 100644 --- a/ide/test/trace/component/trace/base/TraceSheet.test.ts +++ b/ide/test/trace/component/trace/base/TraceSheet.test.ts @@ -14,8 +14,12 @@ */ import { TraceSheet } from '../../../../../src/trace/component/trace/base/TraceSheet'; -const sqlit = require('../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); const intersectionObserverMock = () => ({ observe: () => null, }); @@ -30,54 +34,6 @@ window.ResizeObserver = describe('TraceSheet Test', () => { beforeAll(() => {}); - let val = { - hasFps: 1, - cpus: { length: 1 }, - threadIds: [{ length: 2 }], - funTids: { length: 1 }, - trackIds: { length: 1 }, - heapIds: { length: 1 }, - nativeMemory: { length: 1 }, - cpuAbilityIds: { length: 1 }, - memoryAbilityIds: { length: 1 }, - diskAbilityIds: { length: 1 }, - networkAbilityIds: { length: 1 }, - }; - let e = { - detail: { - title: 1, - state: 0, - threadId: 1, - processId: 2, - }, - }; - let selection = { - hasFps: 1, - cpus: { length: 1 }, - threadIds: [{ length: 2 }], - funTids: { length: 1 }, - trackIds: { length: 1 }, - heapIds: { length: 1 }, - nativeMemory: { length: 1 }, - cpuAbilityIds: { length: 0 }, - memoryAbilityIds: { length: 0 }, - diskAbilityIds: { length: 0 }, - networkAbilityIds: { length: 0 }, - perfSampleIds: { length: 0 }, - processTrackIds: { length: 0 }, - fileSystemType: { length: 0 }, - virtualTrackIds: { length: 0 }, - sdkCounterIds: [ - { - length: 0, - }, - ], - sdkSliceIds: [ - { - length: 0, - }, - ], - }; document.body.innerHTML = ''; it('TraceSheet Test01', () => { let traceSheet = new TraceSheet(); @@ -90,7 +46,7 @@ describe('TraceSheet Test', () => { }); it('TraceSheet Test09', () => { let traceSheet = new TraceSheet(); - expect(traceSheet.loadTabPaneData()).toBeUndefined(); + expect(traceSheet.loadTabPaneData('key')).toBeUndefined(); }); it('TraceSheet Test10', () => { diff --git a/ide/test/trace/component/trace/base/Utils.test.ts b/ide/test/trace/component/trace/base/Utils.test.ts index 3d7437ece7fcd5ff43174598537081b9fcc61f44..add71e6845a92dc084bbc6620abb7750792537d5 100644 --- a/ide/test/trace/component/trace/base/Utils.test.ts +++ b/ide/test/trace/component/trace/base/Utils.test.ts @@ -65,19 +65,19 @@ describe('Utils Test', () => { }); it('Utils Test11', () => { - expect(Utils.getByteWithUnit(2_000_000_000)).toBe('1.86 Gb'); + expect(Utils.getByteWithUnit(2_000_000_000)).toBe('1.86 GB'); }); it('Utils Test12', () => { - expect(Utils.getByteWithUnit(1_000_000_000)).toBe('953.67 Mb'); + expect(Utils.getByteWithUnit(1_000_000_000)).toBe('953.67 MB'); }); it('Utils Test13', () => { - expect(Utils.getByteWithUnit(1000_000)).toBe('976.56 Kb'); + expect(Utils.getByteWithUnit(1000_000)).toBe('976.56 KB'); }); it('Utils Test23', () => { - expect(Utils.getByteWithUnit(-2_000)).toBe('-1.95 Kb'); + expect(Utils.getByteWithUnit(-2_000)).toBe('-1.95 KB'); }); it('Utils Test14', () => { diff --git a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts index f8b7a6c561984460fbfc8f4bdcb4aaa35c245aa1..524734e8636775b8213795a4c953b3f6169af4e2 100644 --- a/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/TabPaneCurrentSelection.test.ts @@ -17,8 +17,12 @@ import { getTimeString, TabPaneCurrentSelection, } from '../../../../../src/trace/component/trace/sheet/TabPaneCurrentSelection'; -const sqlite = require('../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../src/trace/database/SqlLite'); +const processSqlite = require('../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../src/trace/database/sql/ProcessThread.sql'); +const sqlite = require('../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../src/trace/database/sql/SqlLite.sql'); +const gpuSqlite = require('../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../src/trace/database/sql/Gpu.sql'); describe('TabPaneCurrentSelection Test', () => { let tabPaneCurrentSelection = new TabPaneCurrentSelection(); @@ -226,7 +230,7 @@ describe('TabPaneCurrentSelection Test', () => { tabPaneCurrentSelection.queryWakeUpData = jest.fn(() => 'WakeUpData'); tabPaneCurrentSelection.queryWakeUpData.wb = jest.fn(() => null); tabPaneCurrentSelection.setCpuData(cpuData, undefined, 1); - let argsetTest = sqlite.queryBinderArgsByArgset; + let argsetTest = processSqlite.queryBinderArgsByArgset; let argsetIdTest = sqlite.queryBinderByArgsId; let argsetData = [ { @@ -257,7 +261,7 @@ describe('TabPaneCurrentSelection Test', () => { argsetTest.mockResolvedValue(argsetData); argsetIdTest.mockResolvedValue(argsetIdData); - let gpuDur = sqlite.queryGpuDur; + let gpuDur = gpuSqlite.queryGpuDur; let gpuDurData = [ { gpu_dur: 1528, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts index 3d423a41cc0bfcc3d177c07f4f5e66f01073eaad..42dedeeb000d678aa322982c16ee052b684fdc74 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneCpuAbility.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneCpuAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneCpuAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { return {}; @@ -37,7 +37,7 @@ describe('TabPaneCpuAbility Test', () => { leftNs:0, } ]; - let getTabCpuData = sqlite.getTabCpuAbilityData; + let getTabCpuData = abilitySqlite.getTabCpuAbilityData; let cpuData = [ { startTime: 0, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts index 928a1d4432bc2f49bae1b89be4d7d72819cdfa05..007ba5db96b39646e2b678e0572d1f272e7333e4 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDiskAbility.test.ts @@ -16,8 +16,8 @@ import { TabPaneDiskAbility } from '../../../../../../src/trace/component/trace/ jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -35,7 +35,7 @@ describe('TabPaneDiskAbility Test', () => { leftNs:0, } ]; - let getTabDiskAbilityData = sqlite.getTabDiskAbilityData; + let getTabDiskAbilityData = abilitySqlite.getTabDiskAbilityData; let diskAbilityData = [ { startTime: 0, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts index 53f9e332cd3384afeff82d47bc012a7326f1856c..1eaaa1656c58576de1930a9b5a762f816efa3f04 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbility.test.ts @@ -25,11 +25,11 @@ window.ResizeObserver = window.ResizeObserver || observe: jest.fn(), unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const dmaSqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); describe('TabPaneDmaAbility Test', () => { let tabPaneDmaAbility = new TabPaneDmaAbility(); - let getTabDmaAbilityData = sqlit.getTabDmaAbilityData; + let getTabDmaAbilityData = dmaSqlite.getTabDmaAbilityData; getTabDmaAbilityData.mockResolvedValue([ { avgSize: 1111211, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts index 8c2672327be9656186814ef80f8ff673055159bf..5e2c86480f5085bdb11136333c9205eb53ee78e3 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneDmaAbilityComparison } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneDmaAbilityComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const dmaSqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); @@ -41,7 +41,7 @@ window.ResizeObserver = describe('TabPaneDmaAbilityComparison Test', () => { let tabPaneDmaComparisonAbility = new TabPaneDmaAbilityComparison(); - let getTabDmaAbilityComparisonData = sqlite.getTabDmaAbilityComparisonData; + let getTabDmaAbilityComparisonData = dmaSqlite.getTabDmaAbilityComparisonData; let dmaSelectionData = [ { startNs: 0, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts index 59164bf7eeeb56d646f86a639b35ee45f6760a12..0deffb28807e185fcdf180e45124b72cc684c721 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility.test.ts @@ -13,11 +13,14 @@ * limitations under the License. */ import { TabPaneDmaSelectAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneDmaSelectAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const dmaSqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); @@ -35,7 +38,7 @@ window.ResizeObserver = window.ResizeObserver || describe('TabPaneDmaSelectAbility Test', () => { let tabPaneDmaSelectAbility = new TabPaneDmaSelectAbility(); - let getTabDmaSelectionData = sqlite.getTabDmaAbilityClickData; + let getTabDmaSelectionData = dmaSqlite.getTabDmaAbilityClickData; let dmaSelectionData = [ { startNs: 0, 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 8412f209548d00e635f961e7b3a7e3ad30c11f50..70550df1953d0eea695ce72ec6993c8d95d2eea5 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility.test.ts @@ -14,8 +14,8 @@ */ import { TabPaneGpuMemoryAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneGpuMemoryAbility'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const gpuSqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {} }); @@ -33,7 +33,7 @@ window.ResizeObserver = window.ResizeObserver || describe('TabPaneGpuMemoryAbility Test', () => { let tabPaneGpuMemoryAbility = new TabPaneGpuMemoryAbility(); - let getTabGpuMemoryAbilityData = sqlit.getTabGpuMemoryAbilityData; + let getTabGpuMemoryAbilityData = gpuSqlit.getTabGpuMemoryAbilityData; getTabGpuMemoryAbilityData.mockResolvedValue([ { avgSize: 711756458.666667, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts index bfdb43fea5bad0d43c2b42b75e70701bf62488ff..093b5b1152d8a6ed8c6708a9d5e8b0a2d38f1a32 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneGpuMemoryComparison } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneGpuMemoryComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); @@ -39,7 +39,7 @@ jest.mock('../../../../../../src/base-ui/table/lit-table', () => { describe('TabPaneGpuMemoryComparison Test', () => { let tabPaneGpuMemoryComparison = new TabPaneGpuMemoryComparison(); - let getTabGpuMemoryComparisonData = sqlite.getTabGpuMemoryComparisonData; + let getTabGpuMemoryComparisonData = abilitySqlite.getTabGpuMemoryComparisonData; let gpuMemoryComparisonData = [ { startNs: 0, 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 cb8b81687c08ccb2c2555429fe05b1f8b4481c3a..9c0eac3d4b655898dcb58829ce195e22c11fe519 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneGpuMemorySelectAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneGpuMemorySelectAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); @@ -31,7 +31,7 @@ window.ResizeObserver = window.ResizeObserver || describe('TabPaneGpuMemorySelectAbility Test', () => { let tabPaneGpuMemorySelectAbility = new TabPaneGpuMemorySelectAbility(); - let getTabGpuSelectionData = sqlite.getTabGpuMemoryAbilityClickData; + let getTabGpuSelectionData = abilitySqlite.getTabGpuMemoryAbilityClickData; let gpuSelectionData = [ { startNs: 0, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts index 67a3f1f9c562d548e9939422d97726556d74af79..4f67367a4d5a224c74b77625c2b9610a71f2a1ed 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneHistoryProcesses.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneHistoryProcesses } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneHistoryProcesses'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts index 466db6cee12a544c96f57ca403bb55556f943b86..81fc75a686f69af6ebb9f26dd3d1cdbbfb5c571b 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneLiveProcesses.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneLiveProcesses } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneLiveProcesses'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneMemoryAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneMemoryAbility.test.ts index abd3ad2e605f15893efecc07cebc1991030b42f8..16a52e1060720d190ed4fe2bd10d9162b82b4634 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneMemoryAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneMemoryAbility.test.ts @@ -23,8 +23,11 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); +const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); + jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); @@ -38,7 +41,7 @@ describe('TabPaneMemoryAbility Test', () => { }, ]); - let queryMemoryAbilityData = sqlit.getTabMemoryAbilityData; + let queryMemoryAbilityData = abilitySqlite.getTabMemoryAbilityData; queryMemoryAbilityData.mockResolvedValue([ { startTime: 0, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPaneNetworkAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPaneNetworkAbility.test.ts index 7d91e7be1491048aae6ef1fa53ca5b1fd30fe135..8e37bab03809114febedd47923e2405fabb7650b 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPaneNetworkAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPaneNetworkAbility.test.ts @@ -23,8 +23,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts index ccfcd8e736681a32bc3b4a83be6ba12cee7144bd..fd28cb3de319031a4a3b5eb392fc78eedf2680ae 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPin.test.ts @@ -14,8 +14,8 @@ */ import { TabPanePurgPin } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgPin'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts index bd5efcb8ee898e70c2a37a167f6aa37aba6f1cb8..7af8b95cb3f1a7e05f32d8c2324933404765d625 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility.test.ts @@ -20,8 +20,8 @@ jest.mock('../../../../../../src/base-ui/table/lit-table', () => { }); import { TabPanePurgPinComparisonAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility'; import '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts index 3649357fda30fe135aa77fd85a089f689c7522d0..1a6c778add91c96b26153d607da4fcb308464cdf 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgPinSelection.test.ts @@ -14,8 +14,11 @@ */ import { TabPanePurgPinSelection } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgPinSelection'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); + +const processSqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); @@ -45,7 +48,7 @@ describe('TabPanePurgPin Test', () => { name: '24.00MB', }, ]); - let queryProcessPurgeableSelectionTab = sqlit.queryProcessPurgeableSelectionTab; + let queryProcessPurgeableSelectionTab = processSqlite.queryProcessPurgeableSelectionTab; queryProcessPurgeableSelectionTab.mockResolvedValue([ { value: 25165824, diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotal.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotal.test.ts index 6f4c8a2374af7b2b261fb00cd994531953c16b75..4555b50f349f0597d2b87465a30ad7c1c9a694ad 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotal.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotal.test.ts @@ -14,8 +14,8 @@ */ import { TabPanePurgTotal } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgTotal'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts index bc1c63ec16746ba293622381cc4ee8c8e48b5590..a8002c0805ae14c99846ac6095e89684460c8585 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPanePurgTotalComparisonAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgTotalComparisonAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts index 34c5288d58dffe4acb8de80549e5525e54ab9a5d..0734fe8edaed96a2eb404fb50cc82cc93d7881cc 100644 --- a/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/ability/TabPanePurgTotalSelection.test.ts @@ -14,8 +14,10 @@ */ import { TabPanePurgTotalSelection } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgTotalSelection'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); +jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); +const processSqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); @@ -44,7 +46,7 @@ describe('TabPanePurgTotalSelection Test', () => { name: "34.47MB", }, ]); - let queryProcessPurgeableSelectionTab = sqlit.queryProcessPurgeableSelectionTab; + let queryProcessPurgeableSelectionTab = processSqlite.queryProcessPurgeableSelectionTab; queryProcessPurgeableSelectionTab.mockResolvedValue([ { value: 15445, diff --git a/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts b/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts index 36a881231b93f1d8bdc88a16e0f91480abf9bb5b..03ecc3bbd15b36b3c5e872cb9827ba8088db9a71 100644 --- a/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics.test.ts @@ -14,13 +14,24 @@ */ import { TabPaneJsCpuStatistics } from '../../../../../../src/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics'; import '../../../../../../src/trace/component/trace/sheet/ark-ts/TabPaneJsCpuStatistics'; -import { JsCpuProfilerStatisticsStruct } from '../../../../../../src/trace/bean/JsStruct'; - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +import crypto from 'crypto'; +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {} }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {} +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +Object.defineProperty(global.self, 'crypto', { + value: { + getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), + }, +}); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return { recycleDataSource: () => {}, diff --git a/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts b/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts deleted file mode 100644 index ec4b5f4f9a796f02c6cf8825f85e1466bf5bff70..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts +++ /dev/null @@ -1,77 +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 { TabPaneBinders } from '../../../../../../src/trace/component/trace/sheet/binder/TabPaneBinders'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -import { queryBinderByThreadId } from '../../../../../../src/trace/database/SqlLite'; -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); -jest.mock('../../../../../../src/base-ui/table/lit-table'); -describe('TabPaneBinders Test', () => { - let tabPaneBinders; - let threadBindersTbl; - beforeEach(() => { - jest.clearAllMocks(); - tabPaneBinders = new TabPaneBinders(); - threadBindersTbl = new LitTable(); - tabPaneBinders['threadBindersTbl'] = threadBindersTbl; - }); - it('TabPaneBindersTest01', () => { - const data = [ - { - pid: undefined, - tid: undefined, - title: 'P-undefined', - totalCount: undefined, - children: [ - { - binderAsyncRcvCount: 0, - binderReplyCount: 0, - binderTransactionAsyncCount: 0, - binderTransactionCount: 0, - pid: undefined, - tid: undefined, - title: 'T-undefined', - totalCount: undefined - } - ] - } - ]; - queryBinderByThreadId.mockResolvedValue(data); - const threadStatesParam = { - threadIds: [1, 2], - processIds: [1, 2], - leftNs: 0, - rightNs: 100 - }; - tabPaneBinders.initBinderData(threadStatesParam); - tabPaneBinders.data = data; - expect(tabPaneBinders.data).toBeUndefined(); - expect(queryBinderByThreadId).toHaveBeenCalledWith([1, 2], [1, 2], 0, 100); - expect(threadBindersTbl.recycleDataSource).toEqual([]); - expect(tabPaneBinders['threadBindersTblSource']).toEqual([]); - expect(threadBindersTbl.loading).toBe(true); - }); -}); \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts b/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts deleted file mode 100644 index b8c8a75fc6387c1b679474f9a33cb2124f26d80c..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts +++ /dev/null @@ -1,178 +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 { TabPaneBinderDataCut } from '../../../../../../src/trace/component/trace/sheet/binder/TabPaneBinderDataCut'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { -}); -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); -describe('TabPaneBinderDataCut Test', () => { - let tabPaneBinderDataCut = new TabPaneBinderDataCut(); - tabPaneBinderDataCut.threadBindersTbl = jest.fn(() => { - return new LitTable(); - }); - let threadIdInput = document.createElement('input'); - threadIdInput.value = 'threadIdInput'; - let threadFuncInput = document.createElement('input'); - threadFuncInput.value = 'threadFuncInput'; - let threadStatesParam = { - cpus: [], - threadIds: [1, 2, 3], - trackIds: [23, 56, 77], - funTids: [675, 75], - heapIds: [11, 223], - processIds: [114, 23], - nativeMemory: [], - leftNs: 12222, - rightNs: 654233, - hasFps: false, - statisticsSelectData: undefined - }; - let binderItem = [{ - title: 'test title', - name: 'name', - count: 2, - ts: 2536, - dur: 3666, - startTime: 3655, - endTime: 83663, - tid: 363, - pid: 523, - cycleDur: 366, - cycleStartTime: 3652, - funcName: 'funcName', - id: 12, - thread: 'thread', - process: 'process', - totalCount: 12, - idx: 366 - }]; - - let bindGroup = [{ - title: 'title', - count: 3, - totalCount: 3, - binderAsyncRcvCount: 2, - binderReplyCount: 6, - binderTransactionAsyncCount: 2, - binderTransactionCount: 1, - tid: 5, - pid: 36, - thread: 'thread', - process: 'process', - name: 'name', - cycleStartTime: 1222, - cycleDur: 366, - id: 65, - children: [], - type: 'loop', - status: false, - idx: 2, - isSelected: true - }] - tabPaneBinderDataCut.data = threadStatesParam; - let loopFuncNameCycle = sqlite.queryLoopFuncNameCycle; - let loopFuncNameCycleData = [{ - funcName: 'funcName', - cycleStartTime: 1233, - cycleDur: 0, - id: 123, - tid: 254, - pid: 258 - }]; - loopFuncNameCycle.mockResolvedValue(loopFuncNameCycleData); - - let queryBinder = sqlite.queryBinderByThreadId; - let binderData = [{ - name: 'test', - count: 1, - ts: 2533, - dur: 563, - startTime: 22554, - endTime: 2633333, - tid: 122, - pid: 36 - }]; - queryBinder.mockResolvedValue(binderData); - - let querySingle = sqlite.querySingleFuncNameCycle; - let querySingleData = [{ - funcName: 'funcName', - cycleStartTime: 2553, - cycleDur: 36633, - id: 253, - tid: 366, - pid: 369, - endTime: 366922 - }]; - querySingle.mockResolvedValue(querySingleData); - - it('TabPaneBinderDataCutTest01 ', async () => { - tabPaneBinderDataCut.dataLoopCut(threadIdInput, threadFuncInput); - expect(tabPaneBinderDataCut.threadBindersTbl.loading).toBeTruthy(); - }); - - it('TabPaneBinderDataCutTest02 ', async () => { - tabPaneBinderDataCut.dataSingleCut(threadIdInput, threadFuncInput); - expect(tabPaneBinderDataCut.currentThreadId).toEqual(''); - }); - - it('TabPaneBinderDataCutTest03 ', async () => { - tabPaneBinderDataCut.verifyInputIsEmpty('', '', threadIdInput, threadFuncInput); - expect(tabPaneBinderDataCut.threadBindersTbl.loading).toBeFalsy(); - }); - - it('TabPaneBinderDataCutTest04 ', async () => { - expect(tabPaneBinderDataCut.completionCycleName(binderItem, 'loop').length).toBe(0); - }); - - it('TabPaneBinderDataCutTest05 ', async () => { - expect(tabPaneBinderDataCut.transferToTreeData(binderItem).length).toBe(1); - }); - - it('TabPaneBinderDataCutTest06 ', async () => { - expect(tabPaneBinderDataCut.addCycleNumber(bindGroup)[0].title).toEqual('title'); - }); - - it('TabPaneBinderDataCutTest07 ', async () => { - expect(tabPaneBinderDataCut.timeUnitConversion(bindGroup).length).toEqual(1); - }); - - it('TabPaneBinderDataCutTest08 ', async () => { - expect(tabPaneBinderDataCut.binderWithCountList(bindGroup).length).not.toBeUndefined(); - }); - - it('TabPaneBinderDataCutTest09 ', async () => { - expect(tabPaneBinderDataCut.findThreadByThreadId(bindGroup, 5)).not.toBeUndefined(); - }); - - it('TabPaneBinderDataCutTest10 ', async () => { - tabPaneBinderDataCut.clearCycleRange(); - expect(tabPaneBinderDataCut.cycleAStartRangeDIV.value).toEqual(''); - }); -}); \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/clock/TabPaneClockCounter.test.ts b/ide/test/trace/component/trace/sheet/clock/TabPaneClockCounter.test.ts index 00aed0daa0de5f70a505a13297fe96f50d3a7204..8a53c243c8d6180c6451ab621e8ab1133dd39b12 100644 --- a/ide/test/trace/component/trace/sheet/clock/TabPaneClockCounter.test.ts +++ b/ide/test/trace/component/trace/sheet/clock/TabPaneClockCounter.test.ts @@ -13,12 +13,13 @@ * limitations under the License. */ -// @ts-ignore import { TabPaneClockCounter } from '../../../../../../src/trace/component/trace/sheet/clock/TabPaneClockCounter'; -jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { return {}; }); - window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneBoxChild.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneBoxChild.test.ts index 3d432742c091560af40140bf828289c160c570aa..6e67d836400eef723e18282d44a7f18dd6e65686 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneBoxChild.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneBoxChild.test.ts @@ -13,12 +13,10 @@ * limitations under the License. */ -// @ts-ignore -// import { it } from "mocha" import { TabPaneBoxChild } from '../../../../../../src/trace/component/trace/sheet/cpu/TabPaneBoxChild'; -const sqlit = require('../../../../../../src/trace/database/SqlLite.js'); -jest.mock('../../../../../../src/trace/database/SqlLite.js'); -jest.mock('../../../../../../src/trace/bean/NativeHook.js', () => { +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneCounterSample.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneCounterSample.test.ts index c2f49db6444b1af39ef83d2462eeff61055a2436..6c3e78b536ed5ed6ff3d5fa1a02fedadde966082 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneCounterSample.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneCounterSample.test.ts @@ -20,9 +20,17 @@ jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { }); import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - +const sqlit = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {} +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByProcess.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByProcess.test.ts index 101b732923f215294c60ead50548356ea21d5ca3..5b98a82bee0c0c7a4ecd7a1d7afd4aed644c1994 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByProcess.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByProcess.test.ts @@ -14,8 +14,6 @@ */ import { TabPaneCpuByProcess } from '../../../../../../src/trace/component/trace/sheet/cpu/TabPaneCpuByProcess'; -import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; window.ResizeObserver = window.ResizeObserver || @@ -24,9 +22,15 @@ window.ResizeObserver = observe: jest.fn(), unobserve: jest.fn(), })); - -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByThread.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByThread.test.ts index c0e83433d61ceb48cce4ad1583567e38b355fb1d..6375a0ab9ae0500d63c9ba9d3191e5fe0fa8956b 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByThread.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuByThread.test.ts @@ -23,8 +23,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuUsage.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuUsage.test.ts index b16ee2503aff2827265c2cec2fff7d6c637a6e49..bc1ad49d8a16138acd3334916632269e8386f746 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuUsage.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneCpuUsage.test.ts @@ -14,8 +14,8 @@ */ import { TabPaneCpuUsage } from '../../../../../../src/trace/component/trace/sheet/cpu/TabPaneCpuUsage'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneFrequencySample.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneFrequencySample.test.ts index 352e165a36426f59f63159925c898ca8b4975133..1d24d15f0fcdaccfc05d447ce12bce8d7a375aaa 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneFrequencySample.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneFrequencySample.test.ts @@ -17,11 +17,20 @@ import { TabPaneFrequencySample } from '../../../../../../src/trace/component/tr jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {} +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || @@ -102,8 +111,8 @@ describe('TabPaneFrequencySample Test', () => { }; it('TabPaneCounterSampleTest01', function () { - let getTabPaneFrequencySampleData = sqlit.getTabPaneFrequencySampleData; - getTabPaneFrequencySampleData.mockResolvedValue([ + let sampleData = sqlit.getTabPaneFrequencySampleData; + sampleData.mockResolvedValue([ { value: 'process', filterId: 1, diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPanePTS.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPanePTS.test.ts index b7b9065c1268fd2134da110294e7368d0092df9f..47cef606d20145e17b440bb2faaa50038cd9d291 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPanePTS.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPanePTS.test.ts @@ -15,7 +15,6 @@ import { TabPanePTS } from '../../../../../../src/trace/component/trace/sheet/cpu/TabPanePTS'; import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); window.ResizeObserver = diff --git a/ide/test/trace/component/trace/sheet/cpu/TabPaneSPT.test.ts b/ide/test/trace/component/trace/sheet/cpu/TabPaneSPT.test.ts index 9e3aae657245557e0f7b58719d0b091c1280c5af..786b15b4200475f3cd2485d97974f09565e71f62 100644 --- a/ide/test/trace/component/trace/sheet/cpu/TabPaneSPT.test.ts +++ b/ide/test/trace/component/trace/sheet/cpu/TabPaneSPT.test.ts @@ -17,9 +17,7 @@ import { TabPaneSPT } from '../../../../../../src/trace/component/trace/sheet/cp import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -jest.mock('../../../../../../src/trace/database/SqlLite'); jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/energy/TabPaneEnergyAnomaly.test.ts b/ide/test/trace/component/trace/sheet/energy/TabPaneEnergyAnomaly.test.ts index 3ce378f93772fe0b87a46d3303568a58eb7dc472..d8c5fe201638f8f4827553a01193d05f6d767840 100644 --- a/ide/test/trace/component/trace/sheet/energy/TabPaneEnergyAnomaly.test.ts +++ b/ide/test/trace/component/trace/sheet/energy/TabPaneEnergyAnomaly.test.ts @@ -27,9 +27,12 @@ window.ResizeObserver = jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('TabPanePowerBattery Test', () => { it('TabPaneEnergyAnomalyTest01', function () { let tabPaneEnergyAnomaly = new TabPaneEnergyAnomaly(); diff --git a/ide/test/trace/component/trace/sheet/energy/TabPanePowerBattery.test.ts b/ide/test/trace/component/trace/sheet/energy/TabPanePowerBattery.test.ts index 455b56eba12d2276e0d92d5e509f3d3e4daa22a3..339fc39a154c61da81def5b99551c8848048dbc2 100644 --- a/ide/test/trace/component/trace/sheet/energy/TabPanePowerBattery.test.ts +++ b/ide/test/trace/component/trace/sheet/energy/TabPanePowerBattery.test.ts @@ -27,8 +27,12 @@ window.ResizeObserver = jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('TabPanePowerBattery Test', () => { it('TabPanePowerBatteryTest01', function () { diff --git a/ide/test/trace/component/trace/sheet/energy/TabPanePowerDetails.test.ts b/ide/test/trace/component/trace/sheet/energy/TabPanePowerDetails.test.ts index a5cfab31d3a3c8f6ef58f8bd95041afd5ca91c7c..69710e11a462d82ed4af01ca834cd599fa468511 100644 --- a/ide/test/trace/component/trace/sheet/energy/TabPanePowerDetails.test.ts +++ b/ide/test/trace/component/trace/sheet/energy/TabPanePowerDetails.test.ts @@ -29,9 +29,12 @@ window.ResizeObserver = observe: jest.fn(), unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('TabPanePowerDetails Test', () => { document.body.innerHTML = ``; let litTable = document.querySelector('#tb-power-details-energy') as LitTable; diff --git a/ide/test/trace/component/trace/sheet/energy/TabPaneSystemDetails.test.ts b/ide/test/trace/component/trace/sheet/energy/TabPaneSystemDetails.test.ts index 504b57ef9e3132ab3c860a0be3de5dc07469c012..ef3efb7e3887e6a83550257c13aebad403f3cd34 100644 --- a/ide/test/trace/component/trace/sheet/energy/TabPaneSystemDetails.test.ts +++ b/ide/test/trace/component/trace/sheet/energy/TabPaneSystemDetails.test.ts @@ -15,8 +15,6 @@ import { TabPaneSystemDetails } from '../../../../../../src/trace/component/trace/sheet/energy/TabPaneSystemDetails'; import '../../../../../../src/trace/component/trace/sheet/energy/TabPaneSystemDetails'; - -import { querySysLocationDetailsData, querySysLockDetailsData } from '../../../../../../src/trace/database/SqlLite'; import { SpHiSysEventChart } from '../../../../../../src/trace/component/chart/SpHiSysEventChart'; import '../../../../../../src/trace/component/chart/SpHiSysEventChart'; @@ -26,11 +24,15 @@ window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() unobserve: jest.fn(), disconnect: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -jest.mock('../../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); describe('TabPanePowerBattery Test', () => { it('TabPaneSystemDetailsTest01', function () { 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 8c9b78bd83def669828a9abcd774f95fa7d0eb32..95a624f99ee00d12f7aae0ecbe37222bc978b42d 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 @@ -16,8 +16,6 @@ import '../../../../../../src/trace/component/trace/sheet/file-system/TabpaneFilesystemCalltree'; import { TabpaneFilesystemCalltree } from '../../../../../../src/trace/component/trace/sheet/file-system/TabpaneFilesystemCalltree'; import { TabPaneFilter } from '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; -import { FrameChart } from '../../../../../../src/trace/component/chart/FrameChart'; -import { NativeHookStatisticsTableData } from '../../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU'; jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; @@ -25,7 +23,7 @@ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { return { cpuCount: 1, CpuRender: Object, 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 0a54a44cdfaf17b6b167377571a2dd0c1dbaff4f..08b48398630a659d6671382ddf85f28562295509 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 @@ -24,8 +24,8 @@ import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; import '../../../../../../src/base-ui/table/lit-table'; import { TabPaneFilter } from '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; import '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); Object.defineProperty(global.self, 'crypto', { value: { getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), 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 56746522a434d919af9cc25e72b8046ab0a2623a..e9e17d3859364c0ad1b2680148a7782ab7a43862 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 @@ -157,7 +157,7 @@ describe('TabPaneFilesystemStatisticsAnalysis Test', () => { }); it('systemStatisticsAnalysis06', function () { - tabPane.fileStatisticsAnalysisProcessData = processData; + tabPane.fileStatisticsAnalysisFunctionData = processData; tabPane.getFilesystemFunction(item, param); expect(tabPane.currentLevel).toEqual(4); }); 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 5dc806797db76d13a406c8bcda7f47f86c78bc51..8205574bee4b6a62307707bbf20727f2f91f80cd 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 @@ -15,10 +15,9 @@ import { TabPaneIOTierStatistics } from '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics'; import '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneIOTierStatistics'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; import crypto from 'crypto'; -import { TabPaneFilter } from '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; -import { getTabPaneIOTierStatisticsData } from '../../../../../../src/trace/database/SqlLite'; +import { LitTable } from "../../../../../../src/base-ui/table/lit-table"; +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); // @ts-ignore window.ResizeObserver = window.ResizeObserver || @@ -28,8 +27,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); Object.defineProperty(global.self, 'crypto', { value: { @@ -40,6 +39,7 @@ Object.defineProperty(global.self, 'crypto', { describe('TabPaneIOTierStatistics Test', () => { document.body.innerHTML = ''; let tabPane = document.querySelector('#io-tier-statistics'); + tabPane.ioTierStatisticsTbl = new LitTable(); let param = { anomalyEnergy: [], @@ -137,6 +137,7 @@ describe('TabPaneIOTierStatistics Test', () => { avgDuration: 4625375.71428571, }, ]); + tabPane.theadClick = jest.fn(() => true); 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 index 1c3a7acb4c43866245c351e53f82d0041bf7bfbc..7249087e72b3f41b28216ab3e8ff11304f2ffc6a 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneIoCompletionTimes } from '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneIoCompletionTimes'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); 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 index c0ca1d425834bdd038ee4c0348fc1bc5060a6693..7dac8d479dc31d9e09999bcd4be998044193ad0b 100644 --- a/ide/test/trace/component/trace/sheet/file-system/TabPaneVMEvents.test.ts +++ b/ide/test/trace/component/trace/sheet/file-system/TabPaneVMEvents.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneVirtualMemoryEvents } from '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneVMEvents'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); 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 8fca4f017fa8ce8cc8ff6119b7a5b2422054c179..d2582c95d1eb5f998897ab96ddd37adcf8fd0ea0 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 @@ -15,8 +15,8 @@ import { TabPaneVirtualMemoryStatistics } from '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics'; import '../../../../../../src/trace/component/trace/sheet/file-system/TabPaneVirtualMemoryStatistics'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); window.ResizeObserver = window.ResizeObserver || @@ -57,6 +57,7 @@ describe('TabPaneVirtualMemoryStatistics Test', () => { expect(tabPaneVirtualMemoryStatistics).toBeDefined(); }); it('TabPaneVirtualMemoryStatisticsTest02', function () { + tabPaneVirtualMemoryStatistics.theadClick = jest.fn(() => true); expect(tabPaneVirtualMemoryStatistics.queryDataByDB(val)).toBeUndefined(); }); }); diff --git a/ide/test/trace/component/trace/sheet/fps/TabPaneFps.test.ts b/ide/test/trace/component/trace/sheet/fps/TabPaneFps.test.ts index 9cb733eebf1bebd2bb94c16fe8d35731a36d6cfb..fc4eb193e2bd90aa1b1bb7444422d50b389ddf8b 100644 --- a/ide/test/trace/component/trace/sheet/fps/TabPaneFps.test.ts +++ b/ide/test/trace/component/trace/sheet/fps/TabPaneFps.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneFps } from '../../../../../../src/trace/component/trace/sheet/fps/TabPaneFps'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { return {}; diff --git a/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.test.ts b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.test.ts deleted file mode 100644 index e965f05f37b158e2af933b4cf73b2cc4870bc3a4..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.test.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2023 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 { TabPaneFreqDataCut } from '../../../../../../src/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut'; - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/base-ui/table/lit-table', () => { - return { - snapshotDataSource: () => { - }, - removeAttribute: () => { - }, - }; -}); -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); -jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { - return {}; -}); - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); -describe('TabPaneFreqDataCut Test', () => { - let data = { - leftNs: 0, - rightNs: 0, - processIds: [1, 2], - }; - let getTabRunningPercent = sqlite.getTabRunningPercent; - getTabRunningPercent.mockResolvedValue([ - { - pid: 1, - tid: 1, - state: 'Running', - cpu: 0, - dur: 0, - ts: 1, - } - ]); - let queryCpuFreqFilterId = sqlite.queryCpuFreqFilterId; - queryCpuFreqFilterId.mockResolvedValue([{ - id: 1, - cpu: 0, - }]); - let queryCpuFreqUsageData = sqlite.queryCpuFreqUsageData; - queryCpuFreqUsageData.mockResolvedValue([{ - value: '', - dur: '', - startNS: 0, - filter_id: 1, - }]); - it('TabPaneFreqDataCutTest01 ', function () { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - tabPaneFreqDataCut.data = data; - expect(tabPaneFreqDataCut.data).toBeUndefined(); - }); - it('TabPaneFreqDataCutTest02', () => { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - const arr = [ - {percent: 50, children: []}, - {percent: 75.123456, children: [{percent: 80, children: []}]}, - ]; - tabPaneFreqDataCut.fixedDeal(arr); - expect(arr[0].percent).toBe('50.00'); - expect(arr[1].percent).toBe('75.12'); - expect(arr[1].children[0].percent).toBe('80.00'); - }); - it('TabPaneFreqDataCutTest03', () => { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - const threadArr = [ - {pid: 1, tid: 1, children: []}, - {pid: 2, tid: 2, children: []}, - ]; - const totalData = [ - {pid: 1, tid: 1}, - ]; - tabPaneFreqDataCut.mergeTotalData(threadArr, totalData); - expect(threadArr).toEqual([ - {pid: 1, tid: 1, children: [{pid: 1, tid: 1, thread: 'TotalData'}]}, - {pid: 2, tid: 2, children: []}, - ]); - }); - it('TabPaneFreqDataCutTest04 ', function () { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - const obj = { - children: [], - count: 0, - dur: 0, - percent: 0 - }; - const arr = [ - {count: 1, dur: 10, percent: 10}, - {count: 2, dur: 20, percent: 20}, - {count: 0, dur: 0, percent: 0}, - {count: 3, dur: 30, percent: 30} - ]; - tabPaneFreqDataCut.mergeCycleData(obj, arr); - expect(obj.children.length).toBe(3); - expect(obj.children).toContainEqual({count: 1, dur: 10, percent: 10}); - expect(obj.children).toContainEqual({count: 2, dur: 20, percent: 20}); - expect(obj.children).toContainEqual({count: 3, dur: 30, percent: 30}); - expect(obj.count).toBe(6); - expect(obj.dur).toBe(60); - expect(obj.percent).toBe(60); - }); - it('TabPaneFreqDataCutTest05 ', function () { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - const resList = [ - {cpu: 'A', freq: 1, id: 1, dur: 10, percent: 50, count: 1}, - {cpu: 'A', freq: 1, id: 1, dur: 20, percent: 30, count: 2}, - {cpu: 'B', freq: 2, id: 2, dur: 15, percent: 40, count: 1}, - {cpu: 'B', freq: 2, id: 2, dur: 25, percent: 20, count: 2}, - ]; - tabPaneFreqDataCut.mergeData(resList); - expect(resList).toEqual([ - {cpu: 'A', freq: 1, id: 1, dur: 30, percent: 80, count: 3}, - {cpu: 'B', freq: 2, id: 2, dur: 40, percent: 60, count: 3} - ]); - }); -}); diff --git a/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.test.ts b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.test.ts index 8467d1c76827846496faf0318db8341075be829e..efe71fef53a8ea043b3369f76e0d6c509fd437c6 100644 --- a/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.test.ts +++ b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsage.test.ts @@ -32,11 +32,10 @@ window.ResizeObserver = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { - return {}; -}); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const cpuSqlite = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); +const sqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); describe('TabPaneFreqUsage Test', () => { let tabPaneFreqUsage = new TabPaneFreqUsage(); let data = { @@ -55,12 +54,12 @@ describe('TabPaneFreqUsage Test', () => { ts: 1, } ]); - let queryCpuFreqFilterId = sqlite.queryCpuFreqFilterId; + let queryCpuFreqFilterId = cpuSqlite.queryCpuFreqFilterId; queryCpuFreqFilterId.mockResolvedValue([{ id: 1, cpu: 0, }]); - let queryCpuFreqUsageData = sqlite.queryCpuFreqUsageData; + let queryCpuFreqUsageData = cpuSqlite.queryCpuFreqUsageData; queryCpuFreqUsageData.mockResolvedValue([{ value: '', dur: '', 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 5ef119bb2c0cd8f7d35c6941ea982d8113d87b53..aa126c608a26549e25df35d2e239b28255a3a48e 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts @@ -20,8 +20,8 @@ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () = jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); jest.mock('../../../../../../src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts index 58b5835ce8392f534317b8921a36de06818d51ee..9550017e020899eb86eb4a6d1652b08d8f3e8094 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneGpuClickSelectComparison } from '../../../../../../src/trace/component/trace/sheet/gpu/TabPaneGpuClickSelectComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); 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 5a80e585bd1971dec3670873335c5aeb89f91291..9c75ab6ccfed0313f0a75512a0cd9af1c64c2379 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuGL.test.ts @@ -14,8 +14,8 @@ */ import { TabPaneGpuGL } from '../../../../../../src/trace/component/trace/sheet/gpu/TabPaneGpuGL'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; 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 924f71a52d212e0e4130b78bbddc270676cc933d..13c01e99e6fb328fd536268b802b5444285496f9 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect.test.ts @@ -17,11 +17,14 @@ import { TabPaneGpuTotalBoxSelect } from '../../../../../../src/trace/component/ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); // @ts-ignore window.ResizeObserver = 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 f66774b0b0cd1d01b73695b49dea9bc502e691e2..d5101203513bcc1a017c59403c56253aa2255137 100644 --- a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts +++ b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect.test.ts @@ -12,14 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); import { TabPaneGpuWindowBoxSelect } from '../../../../../../src/trace/component/trace/sheet/gpu/TabPaneGpuWindowBoxSelect'; jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); + jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts b/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts deleted file mode 100644 index 4ae3ceb947dc75c7e6fd5b319fb63a1503209093..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts +++ /dev/null @@ -1,150 +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 { TabPaneGpufreqDataCut } from '../../../../../../src/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut'; -import '../../../../../../src/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -import '../../../../../../src/base-ui/table/lit-table'; -import { SpSegmentationChart } from "../../../../../../src/trace/component/chart/SpSegmentationChart"; - -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - -describe('TabPaneSchedSwitch Test', () => { - let threadStatesParam = { - cpus: [], - threadIds: [1, 2, 3], - trackIds: [23, 56, 77], - funTids: [675, 75], - heapIds: [11, 223], - processIds: [114, 23], - nativeMemory: [], - leftNs: 12222, - rightNs: 654233, - hasFps: false, - statisticsSelectData: undefined, - } - - let dataCut = [{ - funName: 'funName', - startTime: 0, - dur: 2155, - endTime: 0, - depth: 2, - threadName: '', - pid: 5256 - }] - - let initData = [{ - filterId: '12', - freq: 'freq', - count: '4', - value: '45', - ts: '2255', - startNS: '4455', - dur: '58547', - endTime: '1255858', - thread: 'thread', - parentIndex: 0, - leve: 0, - name: 'name' - }] - - let gpufreq = sqlite.getGpufreqData; - let gpufreqData = [{ - filterId: '12', - freq: 'freq', - count: '4', - value: '45', - ts: '2255', - startNS: '4455', - dur: '58547', - endTime: '1255858', - thread: 'thread', - parentIndex: 0, - leve: 0, - name: 'name' - }]; - gpufreq.mockResolvedValue(gpufreqData); - - let dataFreqCut = sqlite.getGpufreqDataCut; - let gpufreqCut = [{ - funName: 'funName', - startTime: 0, - dur: 2155, - endTime: 0, - depth: 2, - threadName: '', - pid: 5256 - }]; - dataFreqCut.mockResolvedValue(gpufreqCut); - - let gpufreqDataCut = new TabPaneGpufreqDataCut(); - gpufreqDataCut.threadStatesTbl = jest.fn(() => { - return new LitTable(); - }); - it('TabPaneSchedSwitchTest01', function () { - gpufreqDataCut.data = threadStatesParam; - expect(gpufreqDataCut.threadStatesTbl.loading).toBeTruthy(); - }); - - it('TabPaneSchedSwitchTest02', function () { - gpufreqDataCut.data = threadStatesParam; - gpufreqDataCut.validationFun('', '', '', '', '', '', ''); - expect(gpufreqDataCut._threadId.getAttribute('placeholder')).toEqual('Please input thread id'); - }); - - it('TabPaneSchedSwitchTest03', function () { - gpufreqDataCut.data = threadStatesParam; - gpufreqDataCut.validationFun('1', 'name', '1px solid red', '1px solid green', 'placeholder', 'placeholder', 'single'); - expect(gpufreqDataCut._threadId.getAttribute('placeholder')).toEqual('placeholder'); - }); - - it('TabPaneSchedSwitchTest04', function () { - gpufreqDataCut.data = threadStatesParam; - gpufreqDataCut.validationFun('1', 'name', '1px solid red', '1px solid green', 'placeholder', 'thread function placeholder', 'loop'); - expect(gpufreqDataCut._threadFunc.getAttribute('placeholder')).toEqual('thread function placeholder'); - }); - - it('TabPaneSchedSwitchTest05', function () { - gpufreqDataCut.filterData(initData, dataCut, initData); - expect(gpufreqDataCut.threadStatesTbl.loading).toBeFalsy(); - }); - - it('TabPaneSchedSwitchTest06', function () { - expect(gpufreqDataCut.segmentationData(initData[0], dataCut,1).length).toBe(0); - }); - - it('TabPaneSchedSwitchTest07', function () { - SpSegmentationChart.setChartData = jest.fn(); - expect(gpufreqDataCut.createTree(initData)).not.toBeUndefined(); - }); - - it('TabPaneSchedSwitchTest08', function () { - expect(gpufreqDataCut.updateValueMap(initData[0], 0, '', {}, 1)).toBeUndefined(); - }); -}); diff --git a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts b/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts deleted file mode 100644 index 6f558d62c7093c07d51302b313fba9535ed7a371..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts +++ /dev/null @@ -1,98 +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 { TabPaneGpufreq } from '../../../../../../src/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; - -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - -describe('tabPaneGpufreqUsage Test', () => { - let tabGpuFreq = new TabPaneGpufreq(); - tabGpuFreq.threadStatesTbl = jest.fn(() => { - return new LitTable(); - }); - let gpuCountBean = { - filterId: '12', - freq: 'freq', - count: '4', - value: '45', - ts: '2255', - startNS: '4455', - dur: '58547', - endTime: '1255858', - thread: 'thread', - parentIndex: 0, - leve: 0, - name: 'name', - leftNs: 48555, - rightNs: 58555 - } - let threadStatesParam = { - cpus: [], - threadIds: [1, 2, 3], - trackIds: [23, 56, 77], - funTids: [675, 75], - heapIds: [11, 223], - processIds: [114, 23], - nativeMemory: [], - leftNs: 12222, - rightNs: 654233, - hasFps: false, - statisticsSelectData: undefined, - } - - let gpufreq = sqlite.getGpufreqData; - let gpufreqData = [{ - filterId: '12', - freq: 'freq', - count: '4', - value: '45', - ts: '2255', - startNS: '4455', - dur: '58547', - endTime: '1255858', - thread: 'thread', - parentIndex: 0, - leve: 0, - name: 'name' - }]; - gpufreq.mockResolvedValue(gpufreqData); - - it('tabPaneGpufreqUsageTest01', function () { - tabGpuFreq.data = threadStatesParam; - expect(tabGpuFreq.threadStatesTbl.loading).toBeTruthy(); - }); - - it('tabPaneGpufreqUsageTest02', function () { - expect(tabGpuFreq.createTree([gpuCountBean])).not.toBeUndefined(); - }); - - it('tabPaneGpufreqUsageTest03', function () { - expect(tabGpuFreq.updateValueMap(gpuCountBean, '', {})).toBeUndefined(); - }); -}); diff --git a/ide/test/trace/component/trace/sheet/hi-sysevent/TabPaneHisysEvents.test.ts b/ide/test/trace/component/trace/sheet/hi-sysevent/TabPaneHisysEvents.test.ts index 903474261ccc5b2620010d0387a06cdb8d1e0923..79be3e3faf7221bdbe73c7ab2fb48bcca00f055f 100644 --- a/ide/test/trace/component/trace/sheet/hi-sysevent/TabPaneHisysEvents.test.ts +++ b/ide/test/trace/component/trace/sheet/hi-sysevent/TabPaneHisysEvents.test.ts @@ -13,12 +13,15 @@ * limitations under the License. */ import { TabPaneHisysEvents } from '../../../../../../src/trace/component/trace/sheet/hisysevent/TabPaneHisysEvents'; +import { LitPageTable } from '../../../../../../src/base-ui/table/LitPageTable'; jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); +const clockSqlite = require('../../../../../../src/trace/database/sql/Clock.sql'); +jest.mock('../../../../../../src/trace/database/sql/Clock.sql'); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -49,14 +52,20 @@ describe('TabPaneHisysEvents Test', () => { }, ]; hiSysEvent.mockResolvedValue(eventTabData); + let MockRealTime = clockSqlite.queryRealTime; + let Realtime = [ + { + ts: 1000, + clock_name: 'realtime', + }, + { + ts: 2000, + clock_name: 'boottime', + }]; + MockRealTime.mockResolvedValue(Realtime); it('TabPaneHisysEvents01 ', function () { let tabPaneHisysEvents = new TabPaneHisysEvents(); - let MockRealTime = sqlite.queryRealTime; - let Realtime = [{ - ts: 1000, - clock_name: '', - }]; let tabData = { hiSysEvents: [{ id: 1, @@ -76,7 +85,7 @@ describe('TabPaneHisysEvents Test', () => { depth: 0, }] }; - MockRealTime.mockResolvedValue(Realtime); + tabPaneHisysEvents.hiSysEventTable = new LitPageTable(); tabPaneHisysEvents.data = tabData.hiSysEvents; expect(tabPaneHisysEvents.data).toBeUndefined(); }); @@ -108,21 +117,21 @@ describe('TabPaneHisysEvents Test', () => { it('TabPaneHisysEvents06', () => { let tabPaneHisysEvents = new TabPaneHisysEvents(); let hisysEventSource = [ - { key: 'A', sort: 1 }, - { key: 'B', sort: 2 }, - { key: 'C', sort: 3 }, + {key: 'A', sort: 1}, + {key: 'B', sort: 2}, + {key: 'C', sort: 3}, ] - let hiSysEventTable = { recycleDataSource: [] }; - tabPaneHisysEvents.sortByColumn.call({ hisysEventSource, hiSysEventTable }, { key: 'key', sort: 1, type: 'number' }); + let hiSysEventTable = {recycleDataSource: []}; + tabPaneHisysEvents.sortByColumn.call({hisysEventSource, hiSysEventTable}, {key: 'key', sort: 1, type: 'number'}); expect(hisysEventSource).toEqual([ - { key: 'A', sort: 1 }, - { key: 'B', sort: 2 }, - { key: 'C', sort: 3 }, + {key: 'A', sort: 1}, + {key: 'B', sort: 2}, + {key: 'C', sort: 3}, ]); expect(hiSysEventTable.recycleDataSource).toEqual([ - { key: 'A', sort: 1 }, - { key: 'B', sort: 2 }, - { key: 'C', sort: 3 }, + {key: 'A', sort: 1}, + {key: 'B', sort: 2}, + {key: 'C', sort: 3}, ]); }); it('TabPaneHisysEvents07', () => { @@ -146,17 +155,17 @@ describe('TabPaneHisysEvents Test', () => { }) }; tabPaneHisysEvents.convertData(data); - expect(tabPaneHisysEvents.baseTime).toBe('1234567890000000'); - expect(tabPaneHisysEvents.changeInput.value).toBe('1234567890000000'); + expect(tabPaneHisysEvents.baseTime).toBe('1234567890000000000'); + expect(tabPaneHisysEvents.changeInput.value).toBe('1234567890000000000'); expect(tabPaneHisysEvents.slicerTrack.style.visibility).toBe('visible'); expect(tabPaneHisysEvents.detailsTbl.style.paddingLeft).toBe('20px'); expect(tabPaneHisysEvents.boxDetails.style.width).toBe('65%'); expect(tabPaneHisysEvents.detailbox.style.display).toBe('block'); expect(tabPaneHisysEvents.detailsTbl.recycleDataSource).toEqual([ - { key: 'key', value: 'value' }, - { key: 'key1', value: 'value1' }, - { key: 'key2', value: 'value2' }, - { key: 'INPUT_TIME', value: '1234567890000000' } + {key: 'key', value: 'value'}, + {key: 'key1', value: 'value1'}, + {key: 'key2', value: 'value2'}, + {key: 'INPUT_TIME', value: '1234567890000000000'} ]); }); it('TabPaneHisysEvents08 ', function () { @@ -166,7 +175,7 @@ describe('TabPaneHisysEvents Test', () => { }; let mockUpdateDetail = jest.fn(); changeInput.value = 'abc'; - tabPaneHisysEvents.changeInputEvent.call({ changeInput: changeInput, updateDetail: mockUpdateDetail }); + tabPaneHisysEvents.changeInputEvent.call({changeInput: changeInput, updateDetail: mockUpdateDetail}); expect(changeInput.value).toEqual('abc'); }); }); diff --git a/ide/test/trace/component/trace/sheet/hilog/TabPaneHilogs.test.ts b/ide/test/trace/component/trace/sheet/hilog/TabPaneHilogs.test.ts index af431569542ad3ce15f326f982b7b93490c54173..a370c33221f08ffbf8914aee2be0e237531e78af 100644 --- a/ide/test/trace/component/trace/sheet/hilog/TabPaneHilogs.test.ts +++ b/ide/test/trace/component/trace/sheet/hilog/TabPaneHilogs.test.ts @@ -17,7 +17,6 @@ import { TabPaneHiLogs } from '../../../../../../src/trace/component/trace/sheet import { TraceSheet } from '../../../../../../src/trace/component/trace/base/TraceSheet'; import '../../../../../../src/base-ui/table/LitPageTable' import { TraceRow } from '../../../../../../src/trace/component/trace/base/TraceRow'; -import { queryLogAllData } from "../../../../../../src/trace/database/SqlLite"; jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return { @@ -36,8 +35,13 @@ window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverM jest.mock('../../../../../../src/trace/component/trace/base/TraceSheet', () => { return {}; }); - -jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { return { cpuCount: 1, CpuRender: Object, @@ -45,8 +49,8 @@ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', ( }; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); window.ResizeObserver = window.ResizeObserver || diff --git a/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts b/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts index 910c3f4f4d88afddd3162fdf24732363f5e407c7..675b747b0dc92d7f7a08c03628e1de34232b1436 100644 --- a/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts +++ b/ide/test/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis.test.ts @@ -15,8 +15,6 @@ import { TabPanePerfAnalysis } from '../../../../../../src/trace/component/trace/sheet/hiperf/TabPanePerfAnalysis'; import crypto from 'crypto'; -import { queryHiPerfProcessCount } from '../../../../../../src/trace/database/SqlLite'; -import { TabPaneFilter } from '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; import '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; @@ -44,8 +42,8 @@ jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); @@ -286,6 +284,33 @@ describe('TabPanePerfAnalysis Test', () => { perfThread: [4, 5, 6], perfProcess: [4, 5, 6], }; + let processArr = [ + { + pid: 233, + time: 7978660718, + threadName: 'hilogd', + tid: 235, + id: 19165, + callchain_id: 7492, + }, + { + pid: 233, + time: 8092040146, + threadName: 'hilogd', + tid: 235, + id: 19408, + callchain_id: 7578, + }, + { + pid: 233, + time: 8117205732, + threadName: 'hilogd', + tid: 235, + id: 19496, + callchain_id: 7618, + }, + ]; + tabPanePerfAnalysis.processData = processArr; tabPanePerfAnalysis.perfTableProcess.reMeauseHeight = jest.fn(() => true); tabPanePerfAnalysis.getHiperfProcess(para); expect(tabPanePerfAnalysis.clearData()).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 index 24a6ea9d388c1aa9318965454b85f88917b16ada..7a6ef786f4dd89d53032630c832071e4f05639b0 100644 --- a/ide/test/trace/component/trace/sheet/hiperf/TabPerfBottomUp.test.ts +++ b/ide/test/trace/component/trace/sheet/hiperf/TabPerfBottomUp.test.ts @@ -14,7 +14,6 @@ */ import { TabpanePerfBottomUp } from '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfBottomUp'; -import { showButtonMenu } from '../../../../../../src/trace/component/trace/sheet/SheetUtils'; jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; diff --git a/ide/test/trace/component/trace/sheet/hiperf/TabPerfSampleList.test.ts b/ide/test/trace/component/trace/sheet/hiperf/TabPerfSampleList.test.ts index c69e021faba8c5eb5bb26abc8477134261d953d8..b335fa46021f7dd5eb1fc36add29d97c3a2b2482 100644 --- a/ide/test/trace/component/trace/sheet/hiperf/TabPerfSampleList.test.ts +++ b/ide/test/trace/component/trace/sheet/hiperf/TabPerfSampleList.test.ts @@ -13,13 +13,22 @@ * limitations under the License. */ -import { TabPerfSampleList } from '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfSampleList'; +import { + TabPanePerfSample +} from '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfSampleList'; import '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfSampleList'; jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +const sqlite = require('../../../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); // @ts-ignore window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -28,7 +37,7 @@ window.ResizeObserver = window.ResizeObserver || describe('TabPerfSampleList Test', () => { document.body.innerHTML = ``; - let sampleList = document.querySelector('#sampleList') as TabPerfSampleList; + let sampleList = document.querySelector('#sampleList') as TabPanePerfSample; let sampleListData = { leftNs: 1222, rightNs: 5286, diff --git a/ide/test/trace/component/trace/sheet/irq/TabPaneIrqCounter.test.ts b/ide/test/trace/component/trace/sheet/irq/TabPaneIrqCounter.test.ts index 2f3685d9f9948df8e512be4212b465bce5f64cb1..306c53c08ce882643c4caef7c33276ad0454c883 100644 --- a/ide/test/trace/component/trace/sheet/irq/TabPaneIrqCounter.test.ts +++ b/ide/test/trace/component/trace/sheet/irq/TabPaneIrqCounter.test.ts @@ -18,13 +18,8 @@ import { IrqStruct } from '../../../../../../src/trace/database/ui-worker/Proced jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { - return { - initSort: ()=>{} - }; -}); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Irq.sql'); +jest.mock('../../../../../../src/trace/database/sql/Irq.sql'); window.ResizeObserver = window.ResizeObserver || @@ -35,7 +30,8 @@ window.ResizeObserver = })); describe('TabPaneIrqCounter Test', () => { - let tabPaneIrqCounter = new TabPaneIrqCounter(); + document.body.innerHTML = `
        `; + let tabPaneIrqCounter = document.querySelector('#irq'); let map = new Map(); map.set('irq', [new IrqStruct()]); let frameData = { @@ -85,14 +81,6 @@ describe('TabPaneIrqCounter Test', () => { it('TabPaneIrqCounterTest01', function () { tabPaneIrqCounter.data = frameData; - expect(tabPaneIrqCounter.data).toBeUndefined(); - }); - - it('TabPaneIrqCounterTest02', function () { - expect( - tabPaneIrqCounter.sortByColumn({ - key: 'jankType', - }) - ).toBeUndefined(); + expect(tabPaneIrqCounter.data).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/trace/sheet/jank/TabPaneFrames.test.ts b/ide/test/trace/component/trace/sheet/jank/TabPaneFrames.test.ts index fa55216933f0994958be7a9def38e42a809f9263..e137388c5a0c49eb53e4d45cce1dbfdcf9f3e755 100644 --- a/ide/test/trace/component/trace/sheet/jank/TabPaneFrames.test.ts +++ b/ide/test/trace/component/trace/sheet/jank/TabPaneFrames.test.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +const sqlite = require('../../../../../../src/trace/database/sql/Janks.sql'); +jest.mock('../../../../../../src/trace/database/sql/Janks.sql'); jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { return {}; }); @@ -144,6 +146,22 @@ describe('TabPaneFrames Test', () => { ], ], }; + let rangeData = sqlite.querySelectRangeData; + rangeData.mockResolvedValue([ + { + id: 12, + startTs: 2563, + name: '', + type: '', + dur: 256, + src_slice: '253', + jank_tag: 1, + dst_slice: '633', + pid: 52, + cmdline: 'render_service', + frame_type: 'render_service' + } + ]); it('TabPaneFramesTest01', function () { tabPaneFrames.data = frameData; 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 792818b961a6dfa539fb4cd81a1b8f12b62e2fcf..1d688cda80ed6f2e295565f9b51fb9307880f9db 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 @@ -13,14 +13,18 @@ * limitations under the License. */ import '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree'; -import { TabPaneNMCallTree } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree'; -import { TabPaneFilter } from '../../../../../../src/trace/component/trace/sheet/TabPaneFilter'; +import { TabpaneNMCalltree } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree'; import { FrameChart } from '../../../../../../src/trace/component/chart/FrameChart'; -jest.mock('../../../../../../src/trace/database/SqlLite'); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); // @ts-ignore window.ResizeObserver = @@ -33,11 +37,9 @@ window.ResizeObserver = describe('TabPaneNMCallTree Test', () => { document.body.innerHTML = '
        '; - let tabPaneNMCallTree = document.querySelector('#tree'); + let tabPaneNMCallTree = document.querySelector('#tree'); let dom = new FrameChart(); dom.setAttribute('id', 'framechart'); - tabPaneNMCallTree.frameChart = dom; - tabPaneNMCallTree.filter = new TabPaneFilter(); it('TabPaneNMCallTreeTest01', function () { let hookLeft = { @@ -48,7 +50,6 @@ describe('TabPaneNMCallTree Test', () => { type: 0, children: [], }; - tabPaneNMCallTree.dataSource = []; let groupByWithTid = tabPaneNMCallTree.setRightTableData(hookLeft); expect(groupByWithTid).toBeUndefined(); }); @@ -85,10 +86,6 @@ describe('TabPaneNMCallTree Test', () => { document.body.innerHTML = "
        "; let table = document.querySelector('#filter'); table!.setAttribute('tree', '1'); - tabPaneNMCallTree.filter = table; - tabPaneNMCallTree.filter.showThird = jest.fn(() => { - false; - }); expect(tabPaneNMCallTree.showBottomMenu()).toBeUndefined(); }); it('TabPaneNMCallInfoTest08', function () { @@ -96,17 +93,11 @@ describe('TabPaneNMCallTree Test', () => { document.body.innerHTML = "
        "; let table = document.querySelector('#filter'); table!.setAttribute('tree', '1'); - tabPaneNMCallTree.filter = table; - tabPaneNMCallTree.filter.showThird = jest.fn(() => { - false; - }); expect(tabPaneNMCallTree.showBottomMenu(isShow)).toBeUndefined(); }); it('TabPaneNMCallInfoTest09', function () { - tabPaneNMCallTree.filter.initializeFilterTree = jest.fn(); tabPaneNMCallTree.initFilterTypes = jest.fn(); - tabPaneNMCallTree.native_type = jest.fn(() => ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM']); tabPaneNMCallTree.getDataByWorkerQuery = jest.fn(); tabPaneNMCallTree.data = { leftNs: 0, 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 1088587994bf942625ad70b03165f6d3a88f02e8..e89385ac99bb617735bb60704cbac5ffc0f1af4d 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 @@ -12,16 +12,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMSampleList'; import { TabPaneNMSampleList } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMSampleList'; import { NativeHookSamplerInfo, NativeMemory } from '../../../../../../src/trace/bean/NativeHook'; import { NativeHookSampleQueryInfo } from '../../../../../../src/trace/bean/NativeHook'; +import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/NativeHook.sql'); +jest.mock('../../../../../../src/trace/database/sql/NativeHook.sql'); // @ts-ignore window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -30,8 +37,8 @@ window.ResizeObserver = window.ResizeObserver || observe: jest.fn(), })); describe('TabPaneNMSampleList Test', () => { - document.body.innerHTML = ''; - let tabPaneNMSampleList = document.querySelector('#ddt'); + let tabPaneNMSampleList = new TabPaneNMSampleList(); + tabPaneNMSampleList.sampleTbl = new LitTable(); TabPaneNMSampleList.samplerInfoSource = [ { current: '', 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 f7ac73bd71ad9a6109811e0a8e335e29cfa2c7db..fabe58a7c130acb99ebe9ad8c8f7fed9f59f65a0 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 @@ -15,7 +15,6 @@ import crypto from 'crypto'; import { TabPaneNMStatisticAnalysis } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis'; -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; window.ResizeObserver = window.ResizeObserver || 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 40ad2a710b363eb430a9f40f60599cb607f32f8a..6dbb4829d52a29db466241d6344c1ae4182e3f19 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 @@ -14,11 +14,10 @@ */ import { TabPaneNMStatstics } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics'; -import { - NativeHookMalloc, - NativeHookStatistics, - NativeHookStatisticsTableData, -} from '../../../../../../src/trace/bean/NativeHook'; +import { NativeHookMalloc, NativeHookStatisticsTableData, } from '../../../../../../src/trace/bean/NativeHook'; + +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { +}); window.ResizeObserver = window.ResizeObserver || @@ -31,387 +30,96 @@ window.ResizeObserver = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); - +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); describe('TabPaneNMStatstics Test', () => { let tabPaneNMStatstics = new TabPaneNMStatstics(); document.body.innerHTML = '
        '; + let valData = { + cpus: [0], + threadIds: [2, 90, 0], + trackIds: [], + funTids: [23, 44], + heapIds: [2, 9], + nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM'], + cpuAbilityIds: [33, 22], + memoryAbilityIds: [], + diskAbilityIds: [56, 87, 45], + networkAbilityIds: [], + leftNs: 52540, + rightNs: 9654120, + hasFps: false, + statisticsSelectData: undefined, + perfSampleIds: [12, 45, 87], + perfCpus: [1, 3], + perfProcess: [], + perfThread: [], + perfAll: true, + }; + let nativeHookMalloc: Array = [ + { + eventType: '', + subType: '', + subTypeId: 0, + heapSize: 0, + allocByte: 0, + allocCount: 0, + freeByte: 0, + freeCount: 0, + max: 0, + }, + ]; + let nativeHookStatisticsTableData: Array = [ + { + memoryTap: '12', + existing: 50, + existingString: '', + freeByteString: '', + allocCount: 254, + freeCount: 43, + freeByte: 23, + totalBytes: 1, + totalBytesString: '', + maxStr: '', + max: 110, + totalCount: 1150, + existingValue: [], + }, + ]; it('TabPaneNMStatsticsTest01', function () { - expect(tabPaneNMStatstics.setMallocTableData([1], [1])).toBeUndefined(); - }); - it('TabPaneNMStatsticsTest09', function () { - expect(tabPaneNMStatstics.setSubTypeTableData([1], [1])).toBeUndefined(); + expect(tabPaneNMStatstics.setMallocTableData(nativeHookMalloc, nativeHookStatisticsTableData, 0)).toBeUndefined(); }); it('TabPaneNMStatsticsTest02', function () { - let nativeHookMalloc: Array = [ - { - eventType: '', - subType: '', - subTypeId: 0, - heapSize: 0, - allocByte: 0, - allocCount: 0, - freeByte: 0, - freeCount: 0, - max: 0, - }, - ]; - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '12', - existing: 50, - existingString: '', - freeByteString: '', - allocCount: 254, - freeCount: 43, - freeByte: 23, - totalBytes: 1, - totalBytesString: '', - maxStr: '', - max: 110, - totalCount: 1150, - existingValue: [], - }, - ]; - expect(tabPaneNMStatstics.setSubTypeTableData(nativeHookMalloc, nativeHookStatisticsTableData)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest04', function () { - let valData = { - cpus: [], - threadIds: [], - trackIds: [21, 45, 6], - funTids: [111, 4, 43], - heapIds: [5, 77, 67, 0], - nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM'], - cpuAbilityIds: [], - memoryAbilityIds: [], - diskAbilityIds: [88, 56, 7], - networkAbilityIds: [], - leftNs: 1110, - rightNs: 15600, - hasFps: false, - statisticsSelectData: undefined, - perfSampleIds: [], - perfCpus: [], - perfProcess: [], - perfThread: [], - perfAll: true, - }; - let nativeHookStatistics: Array = [ - { - eventId: 0, - eventType: 'AllocEvent', - subType: '', - subTypeId: 0, - heapSize: 0, - addr: '', - startTs: 0, - endTs: 0, - sumHeapSize: 0, - max: 100000, - count: 0, - tid: 0, - threadName: '', - isSelected: false, - }, - ]; - - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '', - existing: 540, - existingString: '', - freeByteString: '', - allocCount: 20, - freeCount: 10, - freeByte: 20, - totalBytes: 20, - totalBytesString: '', - maxStr: '', - max: 50, - totalCount: 40, - existingValue: [], - }, - ]; - - expect( - tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) - ).toBeUndefined(); - }); - - it('TabPaneNMStatsticsTest05', function () { - let valData = { - cpus: [3], - threadIds: [], - trackIds: [12,4], - funTids: [12,345], - heapIds: [], - nativeMemory: ['All Heap'], - cpuAbilityIds: [10,56,1], - memoryAbilityIds: [], - diskAbilityIds: [12,76], - networkAbilityIds: [], - leftNs: 2330, - rightNs: 56670, - hasFps: false, - statisticsSelectData: undefined, - perfSampleIds: [], - perfCpus: [0,3], - perfProcess: [], - perfThread: [], - perfAll: false, - }; - let nativeHookStatistics: Array = [ - { - eventId: 980, - eventType: 'FreeEvent', - subType: '', - subTypeId: 0, - heapSize: 7, - addr: '', - startTs: 77, - endTs: 6, - sumHeapSize: 0, - max: 100654, - count: 40, - tid: 660, - threadName: '', - isSelected: false, - }, - ]; - - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '', - existing: 20, - existingString: '', - freeByteString: '', - allocCount: 12, - freeCount: 121, - freeByte: 221, - totalBytes: 21, - totalBytesString: '', - maxStr: '', - max: 220, - totalCount: 465, - existingValue: [], - }, - ]; - - expect( - tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) - ).toBeUndefined(); - }); - - it('TabPaneNMStatsticsTest06', function () { - let valData = { - cpus: [1,3], - threadIds: [], - trackIds: [], - funTids: [543,76], - heapIds: [], - nativeMemory: ['All Anonymous VM'], - cpuAbilityIds: [], - memoryAbilityIds: [], - diskAbilityIds: [23, 56, 7], - networkAbilityIds: [100, 156], - leftNs: 450, - rightNs: 5210, - hasFps: false, - statisticsSelectData: undefined, - perfSampleIds: [12, 56], - perfCpus: [0], - perfProcess: [], - perfThread: [], - perfAll: false, - }; - let nativeHookStatistics: Array = [ - { - eventId: 90, - eventType: 'MmapEvent', - subType: '', - subTypeId: 21, - heapSize: 97, - addr: '', - startTs: 77, - endTs: 6, - sumHeapSize: 0, - max: 10114, - count: 10, - tid: 611, - threadName: '', - isSelected: false, - }, - ]; - - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '', - existing: 510, - existingString: '', - freeByteString: '', - allocCount: 2312, - freeCount: 51, - freeByte: 321, - totalBytes: 90, - totalBytesString: '', - maxStr: '02', - max: 2082, - totalCount: 55, - existingValue: [], - }, - ]; - - expect( - tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) - ).toBeUndefined(); - }); - - it('TabPaneNMStatsticsTest07', function () { - let valData = { - cpus: [], - threadIds: [12, 43, 5], - trackIds: [], - funTids: [22,29,20], - heapIds: [], - nativeMemory: ['All Anonymous VM'], - cpuAbilityIds: [133,54,5], - memoryAbilityIds: [], - diskAbilityIds: [13, 14, 19], - networkAbilityIds: [], - leftNs: 2211, - rightNs: 433111, - hasFps: false, - statisticsSelectData: undefined, - perfSampleIds: [520, 88, 1], - perfCpus: [], - perfProcess: ['ssioncontroller', 'ndroid.settings'], - perfThread: ['ndroid.settings'], - perfAll: false, - }; - let nativeHookStatistics: Array = [ - { - eventId: 60, - eventType: 'MmapEvent', - subType: '', - subTypeId: 13, - heapSize: 31, - addr: '', - startTs: 137, - endTs: 61, - sumHeapSize: 34, - max: 214, - count: 10, - tid: 64, - threadName: '', - isSelected: false, - }, - ]; - - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '', - existing: 210, - existingString: '', - freeByteString: '', - allocCount: 92, - freeCount: 51, - freeByte: 2, - totalBytes: 23, - totalBytesString: '', - maxStr: '20', - max: 232, - totalCount: 9, - existingValue: [], - }, - ]; - expect( - tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) - ).toBeUndefined(); - }); - - it('TabPaneNMStatsticsTest08', function () { - let valData = { - cpus: [0], - threadIds: [2,90,0], - trackIds: [], - funTids: [23,44], - heapIds: [2,9], - nativeMemory: ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM'], - cpuAbilityIds: [33,22], - memoryAbilityIds: [], - diskAbilityIds: [56,87,45], - networkAbilityIds: [], - leftNs: 52540, - rightNs: 9654120, - hasFps: false, - statisticsSelectData: undefined, - perfSampleIds: [12,45,87], - perfCpus: [1,3], - perfProcess: [], - perfThread: [], - perfAll: true, - }; - let nativeHookStatistics: Array = [ - { - eventId: 30, - eventType: 'FreeEvent', - subType: '', - subTypeId: 13, - heapSize: 31, - addr: 'test/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.test.ts', - startTs: 33, - endTs: 31, - sumHeapSize: 90, - max: 4, - count: 40, - tid: 14, - threadName: 'NativeNemory', - isSelected: true, - }, - ]; - - let nativeHookStatisticsTableData: Array = [ - { - memoryTap: '', - existing: 330, - existingString: 'nativeHookStatistics', - freeByteString: '', - allocCount: 72, - freeCount: 23, - freeByte: 11, - totalBytes: 3, - totalBytesString: '', - maxStr: '33', - max: 3, - totalCount: 42, - existingValue: [], - }, - ]; - + it('TabPaneNMStatsticsTest03', function () { expect( - tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookStatistics, nativeHookStatisticsTableData) + tabPaneNMStatstics.setMemoryTypeData(valData, nativeHookMalloc, nativeHookStatisticsTableData) ).toBeUndefined(); }); - it('TabPaneNMStatsticsTest11', function () { + it('TabPaneNMStatsticsTest04', function () { tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); expect(tabPaneNMStatstics.sortByColumn('', 0)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest12', function () { + it('TabPaneNMStatsticsTest105', function () { tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); expect(tabPaneNMStatstics.sortByColumn('existingString', 1)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest13', function () { + it('TabPaneNMStatsticsTest06', function () { tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); expect(tabPaneNMStatstics.sortByColumn('allocCount', 1)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest14', function () { + it('TabPaneNMStatsticsTest07', 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 ad61bc53d67dd5cc8cdd54e5c79b7ec065dede02..31c2cb42ca8713dcfc843b3b8b803ce68057363a 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 @@ -17,22 +17,21 @@ import crypto from 'crypto'; import { TabPaneNMemory, - initFilterTypes, } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMemory'; import { TabPaneNMSampleList } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMSampleList'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); -import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -import { - queryNativeHookEventTid, - queryNativeHookSnapshotTypes, -} from '../../../../../../src/trace/database/SqlLite'; - +const sqlit = require('../../../../../../src/trace/database/sql/NativeHook.sql'); +jest.mock('../../../../../../src/trace/database/sql/NativeHook.sql'); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); - +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); Object.defineProperty(global.self, 'crypto', { value: { getRandomValues: (arr: string | any[]) => crypto.randomBytes(arr.length), @@ -69,7 +68,6 @@ describe('TabPaneNMemory Test', () => { subType: '', }, ]); - let tab = new TabPaneNMSampleList(); tabPaneNMemory.startWorker = jest.fn(() => true); expect(tabPaneNMemory.initFilterTypes()).toBeUndefined(); }); diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneCounter.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneCounter.test.ts index 74adeb6aa209c64d0d183ba5a635c643cfc0d94f..449bb48c74cac04a12654e1054bf9caea172b068 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneCounter.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneCounter.test.ts @@ -14,7 +14,12 @@ */ import { TabPaneCounter } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneCounter'; - +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -23,8 +28,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); @@ -81,19 +86,23 @@ describe('TabPaneCounter Test', () => { }); it('TabPaneCounterTest04', function () { + document.body.innerHTML = `
        `; + let tableCount = document.querySelector('#count'); let mockgetTabCounters = sqlit.getTabCounters; mockgetTabCounters.mockResolvedValue( { trackId: 11, name: 'test', value: 111, startTime: 142445 }, { trackId: 11, name: 'test', value: 222, startTime: 142446 } ); let a = { rightNs: 1, trackIds: [11, 12, 13] }; - expect((tabPaneCounter.data = a)).toBeTruthy(); + expect((tableCount.data = a)).toBeTruthy(); }); it('TabPaneCounterTest05', function () { + document.body.innerHTML = `
        `; + let tableCount = document.querySelector('#count'); let mockgetTabCounters = sqlit.getTabCounters; mockgetTabCounters.mockResolvedValue([]); let a = { rightNs: 1, trackIds: [11, 12, 13] }; - expect((tabPaneCounter.data = a)).toBeTruthy(); + expect((tableCount.data = a)).toBeTruthy(); }); }); diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneSlices.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneSlices.test.ts index a6541b34b166868a4d548c8cd39c045e78fbcb29..6b86c80cca86f2e742797266d9b770ee5a3d8662 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneSlices.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneSlices.test.ts @@ -14,9 +14,20 @@ */ import { TabPaneSlices } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneSlices'; - -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +jest.mock('../../../../../../src/base-ui/table/lit-table', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +const sqlit = require('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/trace/database/sql/Func.sql'); +const processSqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); window.ResizeObserver = window.ResizeObserver || @@ -33,7 +44,7 @@ jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { describe('TabPaneSlices Test', () => { let tabPaneSlices = new TabPaneSlices(); sqlit.getTabSlicesAsyncFunc.mockResolvedValue([]); - sqlit.getTabSlices.mockResolvedValue([ + processSqlite.getTabSlices.mockResolvedValue([ { name: 'binder reply', wallDuration: 61.847, diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneStartup.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneStartup.test.ts index 3a9a08ca4606a44df58f24995a905d1afca6c8aa..38d3bfab98b879713189d4b94f4d6cd844a61ae8 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneStartup.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneStartup.test.ts @@ -23,8 +23,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneStaticInit.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneStaticInit.test.ts index 7801672ef6691af0eff64492eaf4366815066a80..20862260f28ae022d44489f5df18c043cfb436c6 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneStaticInit.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneStaticInit.test.ts @@ -23,8 +23,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneThreadStates.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneThreadStates.test.ts index 89604709991f04b228d067d715297d3076d913f6..7f9447e0aabf70a520456faa16e55f04fcd0cebd 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneThreadStates.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneThreadStates.test.ts @@ -13,7 +13,6 @@ * limitations under the License. */ -// @ts-ignore import { TabPaneThreadStates } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneThreadStates'; window.ResizeObserver = @@ -24,8 +23,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/process/TabPaneThreadUsage.test.ts b/ide/test/trace/component/trace/sheet/process/TabPaneThreadUsage.test.ts index dabd14651f241864914813509730acd2a6c2f40a..5a79e9351cc5c3e8d974b2823fef1cb91a6ebb10 100644 --- a/ide/test/trace/component/trace/sheet/process/TabPaneThreadUsage.test.ts +++ b/ide/test/trace/component/trace/sheet/process/TabPaneThreadUsage.test.ts @@ -14,7 +14,6 @@ */ import { TabPaneThreadUsage } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneThreadUsage'; -import sqlite, { getTabRunningPersent } from "../../../../../../src/trace/database/SqlLite"; window.ResizeObserver = window.ResizeObserver || @@ -24,12 +23,12 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/trace/bean/NativeHook', () => { return {}; }); -jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { return { CpuStruct: { cpuCount: 0, diff --git a/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts b/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts deleted file mode 100644 index b8a222735754c79dc63a044a8f89464393a007bd..0000000000000000000000000000000000000000 --- a/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts +++ /dev/null @@ -1,204 +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 '../../../../../../src/base-ui/table/lit-table'; -import { TabPaneSchedSwitch } from '../../../../../../src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch'; - -jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { - return {}; -}); - -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - -describe('TabPaneSchedSwitch Test', () => { - let threadStatesParam = { - cpus: [], - threadIds: [1, 2, 3], - trackIds: [23, 56, 77], - funTids: [675, 75], - heapIds: [11, 223], - processIds: [114, 23], - nativeMemory: [], - leftNs: 12222, - rightNs: 654233, - hasFps: false, - statisticsSelectData: undefined, - } - let single = sqlite.querySingleCutData; - let singleCutData = [ - { - id: 12, - name: 'name', - cycleStartTime: 25, - cycleEndTime: 25877, - depth: 2, - tid: 25, - pid: 12, - dur: 2544 - } - ]; - single.mockResolvedValue(singleCutData); - - let threadState = sqlite.querySchedThreadStates; - let threadStateData = [ - { - id: 12, - pid: 15, - tid: 589, - state: "test", - type: "test", - dur: 15552, - ts: 526, - endTs: 63965 - } - ]; - threadState.mockResolvedValue(threadStateData); - - let loopCut = sqlite.queryLoopCutData; - let loopCutData = [ - { - id: 12, - pid: 15, - tid: 589, - name: "name", - cycleStartTime: 526, - depth: 1 - } - ]; - loopCut.mockResolvedValue(loopCutData); - - let tabPaneSchedSwitch = new TabPaneSchedSwitch(); - tabPaneSchedSwitch.schedSwitchTbl = jest.fn(() => { - return new LitTable(); - }); - it('TabPaneSchedSwitchTest01', function () { - tabPaneSchedSwitch.data = threadStatesParam; - expect(tabPaneSchedSwitch.schedSwitchTbl.loading).toBeFalsy(); - }); - - it('TabPaneSchedSwitchTest02', function () { - tabPaneSchedSwitch.queryCycleRangeData() - expect(tabPaneSchedSwitch.histogramSource.length).toBe(1); - }); - - it('TabPaneSchedSwitchTest03', function () { - let data = { - title: 'title', - count: 6, - cycleNum: 1, - state: 'state', - tid: 122, - pid: 58, - thread: 'thread', - process: 'process', - cycleStartTime: 254, - duration: 2573, - level: 'thread', - children: [], - }; - let customEvent = new CustomEvent('click', { - bubbles: true, - cancelable: true, - detail: {data: data} - }); - tabPaneSchedSwitch.schedSwitchTbl.clearAllSelection = jest.fn(); - tabPaneSchedSwitch.schedSwitchTbl.setCurrentSelection = jest.fn(); - tabPaneSchedSwitch.clickTreeRowEvent(customEvent); - expect(tabPaneSchedSwitch.cycleALeftInput.value).toEqual(''); - }); - - it('TabPaneSchedSwitchTest04', function () { - let firstInput = document.createElement('input'); - firstInput.value = '11'; - let secondInput = document.createElement('input'); - secondInput.value = '22'; - let thirdInput = document.createElement('input'); - let fourInput = document.createElement('input'); - tabPaneSchedSwitch.checkInputRangeFn(firstInput, secondInput, thirdInput, fourInput, '2', '36'); - expect(tabPaneSchedSwitch.getAttribute('isQueryButton')).toEqual(''); - }); - - it('TabPaneSchedSwitchTest05', function () { - tabPaneSchedSwitch.data = threadStatesParam; - tabPaneSchedSwitch.queryCutInfoFn('Single'); - expect(tabPaneSchedSwitch.threadIdInput.getAttribute('placeholder')).toEqual('Please input thread id'); - }); - - it('TabPaneSchedSwitchTest06', function () { - tabPaneSchedSwitch.data = threadStatesParam; - tabPaneSchedSwitch.threadIdInput.value = '12'; - tabPaneSchedSwitch.funcNameInput.value = 'name'; - tabPaneSchedSwitch.queryCutInfoFn('Single'); - expect(tabPaneSchedSwitch.getAttribute('isSingleButton')).toEqual(''); - }); - - it('TabPaneSchedSwitchTest07', function () { - tabPaneSchedSwitch.data = threadStatesParam; - tabPaneSchedSwitch.threadIdInput.value = '12'; - tabPaneSchedSwitch.funcNameInput.value = 'name'; - tabPaneSchedSwitch.queryCutInfoFn('Loop'); - expect(tabPaneSchedSwitch.getAttribute('isLoopButton')).toEqual(''); - }); - - it('TabPaneSchedSwitchTest08', function () { - let groupItem = [{ - count: 0, - cycleNum: 1, - duration: 125, - isHover: false, - isSelected: false, - cycle: 0, - level: '', - pid: -1, - process: '', - state: '', - status: false, - thread: '', - tid: -1, - title: '', - ts: '', - cycleStartTime: 152, - children: [] - }]; - expect(tabPaneSchedSwitch.addCycleNumber(groupItem)).toBeUndefined(); - }); - - it('TabPaneSchedSwitchTest09', function () { - let data = [{ - title: 'title', - count: 6, - cycleNum: 1, - state: 'state', - tid: 122, - pid: 58, - thread: 'thread', - process: 'process', - cycleStartTime: 254, - duration: 2573, - level: 'cycle', - children: [], - }]; - expect(tabPaneSchedSwitch.clickTreeTitleFn(data)).toBeUndefined(); - }); -}); diff --git a/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts b/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts index a57a6c872678a43ec213c7b11dc757ba0841be06..3b1babfd2c251d87d26407d8a9f6c6cc24be6840 100644 --- a/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts +++ b/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts @@ -19,6 +19,7 @@ import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTra import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; import {TabUtil} from "../../../../../../src/trace/component/trace/sheet/sdk/TabUtil.js"; +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); window.ResizeObserver = window.ResizeObserver || @@ -28,8 +29,10 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sdkSqlite = require('../../../../../../src/trace/database/sql/Sdk.sql'); +jest.mock('../../../../../../src/trace/database/sql/Sdk.sql'); +const sqlite = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); describe('TabPaneSdkCounter Test', () => { document.body.innerHTML = ``; @@ -63,7 +66,7 @@ describe('TabPaneSdkCounter Test', () => { ]; startTime.mockResolvedValue(dataTime); - let tabSdkCounterLeftData = sqlite.getTabSdkCounterLeftData; + let tabSdkCounterLeftData = sdkSqlite.getTabSdkCounterLeftData; let data = [ { max_value: 1000, @@ -77,7 +80,7 @@ describe('TabPaneSdkCounter Test', () => { ]; tabSdkCounterLeftData.mockResolvedValue(data); - let tabSdkCounterData = sqlite.getTabSdkCounterData; + let tabSdkCounterData = sdkSqlite.getTabSdkCounterData; let counter = [ { ts: 1000, diff --git a/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkSlice.test.ts b/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkSlice.test.ts index fd9ba76d49e91611bd1e4857bd62b63566914f0a..6ca632c5f34225805e3adaf0c70e99c69e335327 100644 --- a/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkSlice.test.ts +++ b/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkSlice.test.ts @@ -18,6 +18,7 @@ import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; import { TabUtil } from '../../../../../../src/trace/component/trace/sheet/sdk/TabUtil'; +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); window.ResizeObserver = window.ResizeObserver || @@ -27,8 +28,10 @@ window.ResizeObserver = unobserve: jest.fn(), })); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); +const sdkSqlite = require('../../../../../../src/trace/database/sql/Sdk.sql'); +jest.mock('../../../../../../src/trace/database/sql/Sdk.sql'); describe('TabPaneSdkSlice Test', () => { let tabPaneSdkSlice = new TabPaneSdkSlice(); @@ -51,7 +54,7 @@ describe('TabPaneSdkSlice Test', () => { }, ]; totalTime.mockResolvedValue(totalData); - let mockSdkSliceData = sqlite.getTabSdkSliceData; + let mockSdkSliceData = sdkSqlite.getTabSdkSliceData; let sliceData = [ { start_ts: 1000, diff --git a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts index f89696c7ad518cb2289976d8001eae0ed4e30d73..4ab5072917aada285ed33d70d624e5ae963c5efd 100644 --- a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsComparison.test.ts @@ -13,15 +13,12 @@ * limitations under the License. */ -// @ts-ignore - import { TabPaneSmapsComparison, - SmapsCompareStruct, } from '../../../../../../src/trace/component/trace/sheet/smaps/TabPaneSmapsComparison'; -import { Smaps, SmapsTreeObj } from '../../../../../../src/trace/bean/SmapsStruct'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +import { Smaps } from '../../../../../../src/trace/bean/SmapsStruct'; +const sqlit = require('../../../../../../src/trace/database/sql/Smaps.sql'); +jest.mock('../../../../../../src/trace/database/sql/Smaps.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return { snapshotDataSource: () => {}, diff --git a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts index 0dce84a5c0ad449858163a9863b5f770a0def84a..7ec9f4a35e2989d7e99fd0021dd997477d234c24 100644 --- a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsRecord.test.ts @@ -16,13 +16,15 @@ import { TabPaneSmapsRecord } from '../../../../../../src/trace/component/trace/sheet/smaps/TabPaneSmapsRecord'; import { Smaps } from '../../../../../../src/trace/bean/SmapsStruct'; -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Smaps.sql'); +jest.mock('../../../../../../src/trace/database/sql/Smaps.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); - +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); 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 775be9fe553d1dbe549a14a7098d6f19bcaa3e2c..1872a6875f1fed7b978791c31f4f2c4129459543 100644 --- a/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts +++ b/ide/test/trace/component/trace/sheet/smaps/TabPaneSmapsStatistics.test.ts @@ -18,13 +18,15 @@ import { Smaps, SmapsTreeObj } from '../../../../../../src/trace/bean/SmapsStruc jest.mock('../../../../../../src/trace/component/trace/sheet/smaps/TabPaneSmapsComparison', () => { return {}; }); -const sqlit = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlit = require('../../../../../../src/trace/database/sql/Smaps.sql'); +jest.mock('../../../../../../src/trace/database/sql/Smaps.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); - +jest.mock('.../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/task/TabPaneTaskFrames.test.ts b/ide/test/trace/component/trace/sheet/task/TabPaneTaskFrames.test.ts index 1e285e667fe9434485088b37311e6cd72863542e..872d4874956b2ecf50958f79da11089cc084521e 100644 --- a/ide/test/trace/component/trace/sheet/task/TabPaneTaskFrames.test.ts +++ b/ide/test/trace/component/trace/sheet/task/TabPaneTaskFrames.test.ts @@ -14,17 +14,22 @@ */ import { TabPaneTaskFrames } from '../../../../../../src/trace/component/trace/sheet/task/TabPaneTaskFrames'; -import { FuncStruct } from '../../../../../../src/trace/database/ui-worker/ProcedureWorkerFunc'; import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; -import { queryTaskListByExecuteTaskIds } from '../../../../../../src/trace/database/SqlLite'; jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); - -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - +jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); +const sqlite = require('../../../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../../../src/trace/database/sql/SqlLite.sql'); +const perfSqlite = require('../../../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -48,7 +53,7 @@ describe('TabPaneTaskFrames Test', () => { }, ]); - let mockQueryConcurrencyTask = sqlite.queryConcurrencyTask; + let mockQueryConcurrencyTask = perfSqlite.queryConcurrencyTask; mockQueryConcurrencyTask.mockResolvedValue([ { tid: 28573, 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 0f97a0d8a697d00827e92259018df28f774ec6fa..cb4af5c110903659e704dacc24cb4ff7b40f4487 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaSelectVmTracker.test.ts @@ -29,9 +29,11 @@ jest.mock('../../../../../../src/base-ui/table/lit-table', () => { jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); - +const sqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); // @ts-ignore window.ResizeObserver = window.ResizeObserver || 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 450f294ed19c7ec57e6634091e3da3e1d5c0cf88..9c271bec9a404bbb5451f1180617ea264d7af39b 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker.test.ts @@ -15,8 +15,8 @@ import { TabPaneDmaVmTracker } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTracker'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts index 5bade1e4ac137aec23269533b30e65b2249080a6..7187a74fcc5f2e2b7eff53997b1e6cdc7dfbec95 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneDmaVmTrackerComparison } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); +jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); 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 05870a6607a67bd019faa3d8ad59db09475363c6..f80b31f28f758e623dfca1e7d2760f4da29fd30f 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemorySelectVmTracker.test.ts @@ -20,8 +20,8 @@ jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts index f9e48e4b9324aaa11e1338c3db0e5decb25f29ac..36890d25a4a3a665fcf31b5d8211ac6884bf4374 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTracker.test.ts @@ -23,11 +23,14 @@ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); // @ts-ignore window.ResizeObserver = diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts index 81a853ab3a4e7a59ede8788fce654891bf92a7b5..ff227fee8dcddd7c9a06d6c14a4034b699919a94 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPaneGpuMemoryVmTrackerComparison } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneGpuMemoryVmTrackerComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); @@ -66,12 +66,9 @@ describe('TabPaneGpuMemoryVmTrackerComparison Test', () => { expect(tabPaneGpuMemoryVmTrackerComparison.queryDataByDB(10)).toBeTruthy(); }); it('TabPaneGpuMemoryVmTrackerComparison02', function () { - expect(tabPaneGpuMemoryVmTrackerComparison.getComparisonData(10)).toBeTruthy(); - }); - it('TabPaneGpuMemoryVmTrackerComparison03', function () { expect(tabPaneGpuMemoryVmTrackerComparison.sortGpuMemoryByColumn(0, '')).toBeUndefined(); }); - it('TabPaneGpuMemoryVmTrackerComparison04', function () { + it('TabPaneGpuMemoryVmTrackerComparison03', function () { expect(tabPaneGpuMemoryVmTrackerComparison.sortGpuMemoryByColumn(1, 'thread')).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 index d0f18463a22fe4c62b067c626943bfb556e44c0b..ac97a9657d4606c50d9877bee591e0f7b6ac6e6e 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM.test.ts @@ -13,8 +13,8 @@ * limitations under the License. */ import { TabPanePurgPinComparisonVM } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPanePurgPinComparisonVM'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts index 163377042859d24b481026d941d3607b3eef8c4f..578aada1cdb494657411a897d0732989374a009e 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM.test.ts @@ -15,8 +15,8 @@ import { TabPanePurgTotalComparisonVM } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPanePurgTotalComparisonVM'; import '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgPinComparisonAbility'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); @@ -82,9 +82,6 @@ describe('TabPanePurgTotalComparisonVM Test', () => { 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 a8af595fcaf058d31f17aaa305980df3f0d2f8a6..46a1e9137fd69d7d899d2ec71b8ff62c8f63c4e3 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShm.test.ts @@ -26,8 +26,8 @@ jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); diff --git a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts index 0ca119c740633010b79cc0ab3cfc0950db825b32..5ed2aec2a236fd2ca02605fb1b2e089fd2504284 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison.test.ts @@ -14,8 +14,8 @@ */ import { TabPaneVmTrackerShmComparison } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); 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 3582e7c27d19f1ca2351eda3932c5d27fde8837f..827a733d03be2fe42662fc7390ae8d1b1640d8ba 100644 --- a/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts +++ b/ide/test/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmSelection.test.ts @@ -20,8 +20,8 @@ jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { return {}; }); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql'); +jest.mock('../../../../../../src/trace/database/sql/Memory.sql'); jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; @@ -29,6 +29,9 @@ jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return {}; }); diff --git a/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts b/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts index 04053165e6a8529f1e08c37d87c76e02afbfebbf..5ee094ebfc21aa7a0998ca23ef235e0b9ce65258 100644 --- a/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/RangeRuler.test.ts @@ -21,7 +21,10 @@ import { SpSystemTrace } from '../../../../../src/trace/component/SpSystemTrace' jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); const intersectionObserverMock = () => ({ observe: () => null, }); @@ -59,7 +62,7 @@ describe('RangeRuler Test', () => { }, () => {} ); - let mark = new Mark(canvas, ctx, '', { + let mark = new Mark(canvas, 'name',ctx, { x: 20, y: 20, width: 100, @@ -75,7 +78,10 @@ describe('RangeRuler Test', () => { ]; mark.isHover = true; - + let currentSlicesTime = { + startTime: 1, + endTime: 200 + } it('RangeRulerTest01', function () { expect(rangeRuler.drawCpuUsage()).toBeUndefined(); }); @@ -110,7 +116,7 @@ describe('RangeRuler Test', () => { expect( rangeRuler.keyPress({ key: 'w', - }) + }, currentSlicesTime) ).toBeUndefined(); }); @@ -118,7 +124,7 @@ describe('RangeRuler Test', () => { expect( rangeRuler.keyPress({ key: 's', - }) + }, currentSlicesTime) ).toBeUndefined(); }); @@ -187,21 +193,8 @@ describe('RangeRuler Test', () => { }); it('RangeRulerTest13', function () { - rangeRuler.markA = jest.fn(() => true); rangeRuler.rangeRect = jest.fn(() => true); rangeRuler.rangeRect.containsWithPadding = jest.fn(() => true); - - rangeRuler.markA = jest.fn(() => { - return { - frame: { - x: 20, - }, - }; - }); - rangeRuler.markA.isHover = jest.fn(() => true); - rangeRuler.markA.frame = jest.fn(() => []); - rangeRuler.markA.frame.x = jest.fn(() => true); - expect( rangeRuler.mouseDown({ key: '', @@ -210,18 +203,11 @@ describe('RangeRuler Test', () => { }); it('RangeRulerTest14', function () { - rangeRuler.markA = jest.fn(() => true); rangeRuler.rangeRect = jest.fn(() => true); rangeRuler.rangeRect.containsWithPadding = jest.fn(() => false); rangeRuler.frame = jest.fn(() => false); rangeRuler.frame.containsWithMargin = jest.fn(() => true); rangeRuler.rangeRect.containsWithMargin = jest.fn(() => false); - rangeRuler.markB = jest.fn(() => { - return {}; - }); - rangeRuler.markB.isHover = jest.fn(() => true); - rangeRuler.markB.frame = jest.fn(() => true); - rangeRuler.markB.frame.x = jest.fn(() => true); expect( rangeRuler.mouseDown({ key: '', @@ -230,12 +216,6 @@ describe('RangeRuler Test', () => { }); it('RangeRulerTest15', function () { - rangeRuler.markA = jest.fn(() => true); - rangeRuler.markA.inspectionFrame = jest.fn(() => true); - rangeRuler.markA.inspectionFrame.contains = jest.fn(() => true); - rangeRuler.markA.frame = jest.fn(() => true); - rangeRuler.markA.frame.x = jest.fn(() => true); - rangeRuler.markA.draw = jest.fn(() => true); rangeRuler.centerXPercentage = jest.fn(() => -1); expect( rangeRuler.mouseMove({ @@ -245,12 +225,6 @@ describe('RangeRuler Test', () => { }); it('RangeRulerTest16', () => { - rangeRuler.markA = jest.fn(() => false); - rangeRuler.markA.draw = jest.fn(() => true); - rangeRuler.markA.frame = jest.fn(() => true); - rangeRuler.markA.frame.x = jest.fn(() => true); - rangeRuler.markA.inspectionFrame = jest.fn(() => false); - rangeRuler.markA.inspectionFrame.contains = jest.fn(() => false); rangeRuler.movingMark = jest.fn(() => false); rangeRuler.movingMark.frame = jest.fn(() => false); rangeRuler.movingMark.frame.x = jest.fn(() => false); @@ -278,7 +252,6 @@ describe('RangeRuler Test', () => { expect(mark.isHover).toBeTruthy(); }); it('RangeRulerTest19', function () { - rangeRuler.clearRect = jest.fn(() => true); expect(rangeRuler.draw()).toBeUndefined(); }); @@ -294,12 +267,9 @@ describe('RangeRuler Test', () => { expect(rangeRuler.keyPressF()).toBeUndefined(); }); it('RangeRulerTest27', function () { - expect(rangeRuler.zoomFit('100', '200')).toBeUndefined(); - }); - it('RangeRulerTest28', function () { expect(Mark.draw).toBeUndefined(); }); - it('RangeRulerTest29', function () { + it('RangeRulerTest28', function () { expect(rangeRuler.drawSelectionRange()).toBeUndefined(); }); }); 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 3f7711fd86750b8cbadc55c472ec02681c9dc023..0ad8abd0e4d363461ee0cc0e1d37a7aa3201dae0 100644 --- a/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/SportRuler.test.ts @@ -27,9 +27,7 @@ jest.mock('../../../../../src/trace/component/SpSystemTrace', () => { }); import { SportRuler } from '../../../../../src/trace/component/trace/timer-shaft/SportRuler'; -import { TimerShaftElement } from '../../../../../src/trace/component/trace/TimerShaftElement'; import { Flag } from '../../../../../src/trace/component/trace/timer-shaft/Flag'; -import { TraceRow, RangeSelectStruct } from '../../../../../src/trace/component/trace/base/TraceRow'; const intersectionObserverMock = () => ({ observe: () => null, diff --git a/ide/test/trace/component/trace/timer-shaft/TabPaneFlag.test.ts b/ide/test/trace/component/trace/timer-shaft/TabPaneFlag.test.ts index 11ca5de182a9269e9d10768dadde88a946b84cae..581b4597599e208dc278b6166c01a96f3711a226 100644 --- a/ide/test/trace/component/trace/timer-shaft/TabPaneFlag.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/TabPaneFlag.test.ts @@ -20,7 +20,9 @@ jest.mock('../../../../../src/trace/component/trace/base/TraceRow', () => { jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); import { TabPaneFlag } from '../../../../../src/trace/component/trace/timer-shaft/TabPaneFlag'; describe('TabPaneFlag Test', () => { diff --git a/ide/test/trace/component/trace/timer-shaft/TimeRuler.test.ts b/ide/test/trace/component/trace/timer-shaft/TimeRuler.test.ts index 9fc1d6e428843cfc0e29945eac7266ee8a23404f..af9ef428ba5579d94c80499199fffe8483256e2d 100644 --- a/ide/test/trace/component/trace/timer-shaft/TimeRuler.test.ts +++ b/ide/test/trace/component/trace/timer-shaft/TimeRuler.test.ts @@ -16,7 +16,6 @@ import { EventCenter } from '../../../../../src/trace/component/trace/base/EventCenter'; import { TimeRuler } from '../../../../../src/trace/component/trace/timer-shaft/TimeRuler'; import { TimerShaftElement } from '../../../../../src/trace/component/trace/TimerShaftElement'; - declare global { interface Window { SmartEvent: { @@ -38,6 +37,10 @@ declare global { jest.mock('../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); diff --git a/ide/test/trace/database/data-trafic/AbilityMonitorReceiver.test.ts b/ide/test/trace/database/data-trafic/AbilityMonitorReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..42464968f7365f3bb8c1418fc5c7769e98d70b9d --- /dev/null +++ b/ide/test/trace/database/data-trafic/AbilityMonitorReceiver.test.ts @@ -0,0 +1,105 @@ +/* + * 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 { + abilityBytesInTraceDataProtoSql, abilityBytesInTraceDataReceiver, + abilityBytesOutTraceDataProtoSql, abilityBytesOutTraceDataReceiver, + abilityBytesReadDataProtoSql, abilityBytesReadDataReceiver, + abilityBytesWrittenDataProtoSql, abilityBytesWrittenDataReceiver, + abilityMemoryDataProtoSql, abilityMemoryUsedDataReceiver, + abilityPacketInDataProtoSql, abilityPacketInTraceDataReceiver, + abilityPacketsOutDataProtoSql, abilityPacketsOutTraceDataReceiver, + abilityReadOpsDataProtoSql, abilityReadOpsDataReceiver, + abilityWrittenOpsDataProtoSql, abilityWrittenOpsDataReceiver, + cpuAbilityMonitorDataProtoSql, cpuAbilityMonitorDataReceiver, + cpuAbilitySystemDataProtoSql, cpuAbilitySystemDataReceiver, + cpuAbilityUserDataProtoSql, cpuAbilityUserDataReceiver +} from '../../../../src/trace/database/data-trafic/AbilityMonitorReceiver'; +import { TraficEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; + +describe('AbilityMonitorReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + proc = jest.fn((sql) => [ + {abilityData: {id: 4, startNs: 4.4, pid: 40, tid: 400, dur: 40000, depth: 4}}, + {abilityData: {id: 5, startNs: 5.5, pid: 50, tid: 500, dur: 50000, depth: 5}}, + ]); + }); + it('AbilityMonitorReceiverTest01', () => { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(cpuAbilityMonitorDataProtoSql(args)).toBeTruthy(); + expect(cpuAbilityUserDataProtoSql(args)).toBeTruthy(); + expect(cpuAbilitySystemDataProtoSql(args)).toBeTruthy(); + expect(abilityMemoryDataProtoSql(args)).toBeTruthy(); + expect(abilityBytesReadDataProtoSql(args)).toBeTruthy(); + expect(abilityBytesWrittenDataProtoSql(args)).toBeTruthy(); + expect(abilityReadOpsDataProtoSql(args)).toBeTruthy(); + expect(abilityWrittenOpsDataProtoSql(args)).toBeTruthy(); + expect(abilityBytesInTraceDataProtoSql(args)).toBeTruthy(); + expect(abilityBytesOutTraceDataProtoSql(args)).toBeTruthy(); + expect(abilityPacketInDataProtoSql(args)).toBeTruthy(); + expect(abilityPacketsOutDataProtoSql(args)).toBeTruthy(); + }); + it('AbilityMonitorReceiverTest02', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + abilityMemoryUsedDataReceiver(data, proc); + abilityBytesReadDataReceiver(data, proc); + abilityBytesWrittenDataReceiver(data, proc); + abilityReadOpsDataReceiver(data, proc); + abilityWrittenOpsDataReceiver(data, proc); + abilityBytesInTraceDataReceiver(data, proc); + abilityBytesOutTraceDataReceiver(data, proc); + abilityPacketInTraceDataReceiver(data, proc); + abilityPacketsOutTraceDataReceiver(data, proc); + + expect(mockPostMessage).toHaveBeenCalledTimes(9); + }); + it('AbilityMonitorReceiverTest03', () => { + let cpuAbilityData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let cpuAbilityProc = jest.fn((sql) => [ + {cpuAbilityData: {id: 4, startNs: 4.4, pid: 40, tid: 400, dur: 40000, depth: 4}}, + {cpuAbilityData: {id: 5, startNs: 5.5, pid: 50, tid: 500, dur: 50000, depth: 5}}, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + cpuAbilityMonitorDataReceiver(cpuAbilityData, cpuAbilityProc); + cpuAbilityUserDataReceiver(cpuAbilityData, cpuAbilityProc); + cpuAbilitySystemDataReceiver(cpuAbilityData, cpuAbilityProc); + expect(mockPostMessage).toHaveBeenCalledTimes(3); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/AbilityMonitorSender.test.ts b/ide/test/trace/database/data-trafic/AbilityMonitorSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fc619c3f37f598212b3ce79f024dcacfbd3cba1 --- /dev/null +++ b/ide/test/trace/database/data-trafic/AbilityMonitorSender.test.ts @@ -0,0 +1,196 @@ + +/* + * 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 '../../../../src/trace/component/trace/base/TraceRow'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + cpuAbilityUserDataSender, + abilityMemoryUsedDataSender, + abilityBytesReadDataSender, + abilityBytesInTraceDataSender +} from '../../../../src/trace/database/data-trafic/AbilityMonitorSender'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { DiskAbilityMonitorStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerDiskIoAbility'; +import { NetworkAbilityMonitorStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerNetworkAbility'; +import { CpuAbilityMonitorStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuAbility'; +import { MemoryAbilityMonitorStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerMemoryAbility'; +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +describe('AbilityMonitorSender Test', () => { + let traceRowData = { + dur: 9928, + frame: + {x: 16, y: 5, width: 17, height: 30}, + startNS: 9928, + value: 6 + } + let useTraceRowData = { + dur: 9928, + frame: + {x: 16, y: 5, width: 17, height: 30}, + startNS: 9928, + value: 2.62424 + } + let sysTraceRowData = { + dur: 92876, + frame: + {x: 16, y: 5, width: 17, height: 30}, + startNS: 6648, + value: 3.474 + } + let memoryUsedData = { + dur: 877, + frame: + {x: 68, y: 5, width: 83, height: 30}, + startNS: 2089, + value: 2012 + } + let bytesReadData = { + dur: 9961, + frame: + {x: 16, y: 5, width: 17, height: 30}, + startNS: 147, + value: 4 + } + let bytesInTraceRowData = { + dur: 1768, + frame: + {x: 16, y: 5, width: 18, height: 30}, + startNS: 21817, + value: 24 + } + it('AbilityMonitorSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(traceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + cpuAbilityUserDataSender(traceRow,'CpuAbilityMonitorData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest02', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(useTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + cpuAbilityUserDataSender(traceRow,'CpuAbilityUserData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest03', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(sysTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + cpuAbilityUserDataSender(traceRow,'CpuAbilitySystemData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest04', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(memoryUsedData, 1, true); + }); + let memoryUsedTraceRow = TraceRow.skeleton(); + abilityMemoryUsedDataSender('2241',memoryUsedTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest05', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(memoryUsedData, 1, true); + }); + let memoryUsedTraceRow = TraceRow.skeleton(); + abilityMemoryUsedDataSender('2241',memoryUsedTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest06', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesReadData, 1 , true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesReadDataSender(traceRow,'AbilityBytesReadData').then(res => { + expect(Array.isArray(res)).toBe(true); + }); + }); + it('AbilityMonitorSenderTest07', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesReadData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesReadDataSender(traceRow,'AbilityBytesWrittenData').then(res => { + expect(Array.isArray(res)).toBe(true); + }); + }); + it('AbilityMonitorSenderTest08', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesReadData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesReadDataSender(traceRow,'AbilityReadOpsData').then(res => { + expect(Array.isArray(res)).toBe(true); + }); + }); + it('AbilityMonitorSenderTest08', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesReadData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesReadDataSender(traceRow,'AbilityWrittenOpsData').then(res => { + expect(Array.isArray(res)).toBe(true); + }); + }); + it('AbilityMonitorSenderTest09', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesInTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesInTraceDataSender(traceRow, 'AbilityBytesInTraceData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest10', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesInTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesInTraceDataSender(traceRow, 'AbilityBytesOutTraceData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest11', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesInTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesInTraceDataSender(traceRow, 'AbilityPacketInTraceData').then(res => { + expect(res).toHaveLength(1); + }); + }); + it('AbilityMonitorSenderTest12', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(bytesInTraceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + abilityBytesInTraceDataSender(traceRow, 'AbilityPacketsOutTraceData').then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/ArkTsReceiver.test.ts b/ide/test/trace/database/data-trafic/ArkTsReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c9930428cfa0bd391fde42a6e71c33d87cf5793 --- /dev/null +++ b/ide/test/trace/database/data-trafic/ArkTsReceiver.test.ts @@ -0,0 +1,52 @@ +/* + * 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 { + cpuProfilerDataReceiver, + initCallChainDataSql, + queryChartDataSqlMem +} from '../../../../src/trace/database/data-trafic/ArkTsReceiver'; + +describe('ArkTsReceiver Test', () => { + let data = { + id: "d460ac73-bcff-4021-9680-f4672b083e25", + name: 162, + action: "exec-proto", + params: { + startNS: 0, + endNS: 30108564984, + recordStartNS: 203639463442, + recordEndNS: 233748028426, + width: 507, + trafic: 3 + } + } + it('ArkTsReceiverTest01', () => { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(initCallChainDataSql(args)).toBeTruthy(); + expect(queryChartDataSqlMem(args)).toBeTruthy(); + }); + it('ArkTsReceiverTest02', () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(cpuProfilerDataReceiver(data,()=>{ + return 0 + })).toBeUndefined() + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/ArkTsSender.test.ts b/ide/test/trace/database/data-trafic/ArkTsSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fade7798c073c54889bbf3ec5749a22b6dc6434 --- /dev/null +++ b/ide/test/trace/database/data-trafic/ArkTsSender.test.ts @@ -0,0 +1,46 @@ +/* + * 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 { cpuProfilerDataSender } from '../../../../src/trace/database/data-trafic/ArkTsSender'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { JsCpuProfilerStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuProfiler'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('cpuProfilerDataSender Test', () => { + let cpuProfilerData = { + column: [25, 30], + depth: [0, 1], + samplesIds: [[1, 2], [3, 4]], + childrenIds: [[5, 6], [7, 8]], + maxDepth: 5, + }; + it('cpuProfilerDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(cpuProfilerData, 1, true); + }); + let cpuProfilerDataTraceRow = TraceRow.skeleton(); + cpuProfilerDataSender(cpuProfilerDataTraceRow).then(result => { + expect(result).toBeTruthy(); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/ClockDataReceiver.test.ts b/ide/test/trace/database/data-trafic/ClockDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bd18fc80e0b3cae1d1feac3a22687e49593ba01 --- /dev/null +++ b/ide/test/trace/database/data-trafic/ClockDataReceiver.test.ts @@ -0,0 +1,86 @@ +/* + * 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 { + chartClockDataSql, + chartClockDataSqlMem, + clockDataReceiver +} from '../../../../src/trace/database/data-trafic/ClockDataReceiver'; + +describe('ClockDataReceiver Test', () => { + let data; + let proc; + beforeEach(() => { + data = { + id: 'bfcedc13-f545-434e-9914-c7823f1a6c17', + name: 4, + action: 'exec-proto', + params: { + clockName: 'cluster0_temp', + sqlType: 'clockFrequency', + startNS: 0, + endNS: 9427688540, + totalNS: 9427688540, + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + t: 1703747964987, + width: 491, + trafic: 2, + } + }; + proc = jest.fn((sql) => [ + {ClockData: {filterId: 89, startNs: 197364063, type: 'measure', value: 48000, dur: 230475000, px: 11}}, + {ClockData: {filterId: 0, startNs: 197364063, type: 'measure', value: 48000, dur: 230475000, px: 11}}, + ]); + }); + it('ClockDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + sqlType: 'clockFrequency' + }; + expect(chartClockDataSql(args)).toBeTruthy(); + expect(chartClockDataSqlMem(args)).toBeTruthy(); + }); + it('ClockDataReceiverTest02 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + sqlType: 'screenState' + }; + expect(chartClockDataSql(args)).toBeTruthy(); + expect(chartClockDataSqlMem(args)).toBeTruthy(); + }); + it('hiSysEventDataReceiverTest03 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + sqlType: 'clockState' + }; + expect(chartClockDataSql(args)).toBeTruthy(); + expect(chartClockDataSqlMem(args)).toBeTruthy(); + }); + it('hiSysEventDataReceiverTest04', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + clockDataReceiver(data,proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/ClockDataSender.test.ts b/ide/test/trace/database/data-trafic/ClockDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..9691705b4af4ccf346e3e3024218c6165f31dc09 --- /dev/null +++ b/ide/test/trace/database/data-trafic/ClockDataSender.test.ts @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { ClockStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerClock'; +import { clockDataSender } from '../../../../src/trace/database/data-trafic/ClockDataSender'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ClockDataSender Test',()=>{ + let clockData = { + filterId: 89, + value: 48000, + startNS: 19733, + dur: 230475, + type: "measure", + delta: 0, + frame: { + y: 5, + height: 30, + x: 11, + width: 14 + } + } + it('ClockDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(clockData, 1, true); + }); + let clockTraceRow = TraceRow.skeleton(); + clockDataSender( '','screenState',clockTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/CpuDataReceiver.test.ts b/ide/test/trace/database/data-trafic/CpuDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..705f36e305037af9382469211feabd0bd8ebc8c9 --- /dev/null +++ b/ide/test/trace/database/data-trafic/CpuDataReceiver.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. + */ + +import { + chartCpuDataProtoSql, + chartCpuDataProtoSqlMem, cpuDataReceiver +} from '../../../../src/trace/database/data-trafic/CpuDataReceiver'; + +describe('CpuDataReceiver Test', () => { + let data; + let proc; + let data2; + beforeEach(() => { + data = { + id: 'b1ba1ace-8f2b-4ce4-b27e-7a3bf2ff8499', + name: 0, + action: 'exec-proto', + params: { + cpu: 0, + startNS: 0, + endNS: 74946716780, + recordStartNS: 1395573006744, + recordEndNS: 1470519723524, + width: 491, + t: 1703729410566, + trafic: 0, + sharedArrayBuffers: { + processId: {}, + id: {}, + tid: {}, + cpu: {}, + dur: {}, + startTime: {}, + argSetId: {} + } + } + }; + data2 = { + id: 'b1ba1ace-8f2b-4ce4-b27e-7a3bf2ff8499', + name: 0, + action: 'exec-proto', + params: { + cpu: 0, + startNS: 0, + endNS: 74946716780, + recordStartNS: 1395573006744, + recordEndNS: 1470519723524, + width: 491, + t: 1703729410566, + trafic: 1, + sharedArrayBuffers: { + processId: {}, + id: {}, + tid: {}, + cpu: {}, + dur: {}, + startTime: {}, + argSetId: {} + } + } + }; + proc = jest.fn((sql) => [ + {CpuData: {id: 4, startTime: 4.4, processId: 40, tid: 400, cpu: 0, argSetId: 1, dur: 40000}}, + {CpuData: {id: 5, startTime: 5.5, processId: 50, tid: 500, cpu: 0, argSetId: 2, dur: 50000}}, + ]); + }); + it('CpuDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + cpu:0, + }; + expect(chartCpuDataProtoSql(args)).toBeTruthy(); + expect(chartCpuDataProtoSqlMem(args)).toBeTruthy(); + }); + it('CpuDataReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + cpuDataReceiver(data, proc); + cpuDataReceiver(data2,proc) + expect(mockPostMessage).toHaveBeenCalledTimes(2); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/CpuDataSender.test.ts b/ide/test/trace/database/data-trafic/CpuDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c782b7d79acd591cb7343e7fa1505020aa0f7485 --- /dev/null +++ b/ide/test/trace/database/data-trafic/CpuDataSender.test.ts @@ -0,0 +1,59 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { CpuStruct } from '../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU'; +import { cpuDataSender } from '../../../../src/trace/database/data-trafic/CpuDataSender'; +import { QueryEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('CpuDataSender Test', () => { + let CpuData = { + processId: 182, + cpu: 0, + tid: 182, + id: 76, + dur: 198041, + startTime: 6670, + end_state: 'S', + priority: 4294, + processName: 'sugov:0', + processCmdLine: 'sugov:0', + name: 'sugov:0', + type: 'thread', + frame: { + y: 5, + height: 30, + x: 4, + width: 1 + }, + translateY: 0 + } + it('CpuDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(CpuData, 1, true); + }); + let CpuDataTraceRow = TraceRow.skeleton(); + cpuDataSender(QueryEnum.CpuData, CpuDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/EBPFReceiver.test.ts b/ide/test/trace/database/data-trafic/EBPFReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..38498b5a89b6e98f17e44617b35b516e7db02022 --- /dev/null +++ b/ide/test/trace/database/data-trafic/EBPFReceiver.test.ts @@ -0,0 +1,81 @@ +/* + * 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 { + diskIoDataGroupBy10MSProtoSql, + diskIoDataProtoSql, + diskIoReceiver, + eBPFVmDataGroupBy10MSProtoSql, + eBPFVmDataProtoSql, + eBPFVmReceiver, + fileSystemDataGroupBy10MSProtoSql, + fileSystemDataProtoSql, + fileSystemDataReceiver +} from '../../../../src/trace/database/data-trafic/EBPFReceiver'; +import { TraficEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; + +describe('EBPFReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + typeArr:[] + }, + }; + proc = jest.fn((sql) => [ + {EBPFVm: {startNs: 440000000, endNs: 450000000, size: 4, px: 172}}, + {EBPFVm: {startNs: 450000000, endNs: 460000000, size: 3, px: 176}}, + ]); + }); + it('EBPFReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + typeArr:[] + }; + expect(fileSystemDataGroupBy10MSProtoSql(args)).toBeTruthy(); + expect(fileSystemDataProtoSql(args)).toBeTruthy(); + expect(diskIoDataGroupBy10MSProtoSql (args)).toBeTruthy(); + expect(diskIoDataProtoSql (args)).toBeTruthy(); + expect(eBPFVmDataGroupBy10MSProtoSql (args)).toBeTruthy(); + expect(eBPFVmDataProtoSql (args)).toBeTruthy(); + }); + it('EBPFReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + fileSystemDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EBPFReceiverTest03 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + diskIoReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EBPFReceiverTest04 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + eBPFVmReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/EBPFSender.test.ts b/ide/test/trace/database/data-trafic/EBPFSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec88c12dd64c996f4fcaa944fdc47953fe1bb5fa --- /dev/null +++ b/ide/test/trace/database/data-trafic/EBPFSender.test.ts @@ -0,0 +1,80 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { EBPFChartStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEBPF'; +import { + diskIoSender, + fileSystemSender, + fileSysVMSender +} from '../../../../src/trace/database/data-trafic/EBPFSender.js'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('EBPFSender Test', () => { + let EBPFData = { + size: 3, + dur: null, + endNS: 107000, + startNS: 106000, + height: 1, + frame: { + y: 0, + height: 1, + x: 403, + width: 4 + }, + group10Ms: true, + } + it('EBPFSenderTest01 ', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(EBPFData, 1, true); + }); + let type = 1; + let scale = 1; + let fileSystemTraceRow = TraceRow.skeleton(); + fileSystemSender(type, scale, fileSystemTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); + it('EBPFSenderTest02 ', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(EBPFData, 1, true); + }); + let scale = 1; + let all = true; + let ipid = 5; + let typeArr = [1, 2, 3, 4]; + let DiskIoDataTraceRow = TraceRow.skeleton(); + diskIoSender(all, ipid, typeArr, scale, DiskIoDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); + it('EBPFSenderTest03 ', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(EBPFData, 1, true); + }); + let scale = 1; + let DiskIoDataTraceRow = TraceRow.skeleton(); + fileSysVMSender(scale, DiskIoDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/EnergySysEventReceiver.test.ts b/ide/test/trace/database/data-trafic/EnergySysEventReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..a862413f010ed56bd28a082450a46c063a80ffbe --- /dev/null +++ b/ide/test/trace/database/data-trafic/EnergySysEventReceiver.test.ts @@ -0,0 +1,226 @@ +/* + * 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 { + systemDataSql, + chartEnergyAnomalyDataSql, + queryPowerValueSql, + queryStateDataSql, + queryStateProtoDataSql, + energySysEventReceiver, + hiSysEnergyAnomalyDataReceiver, + hiSysEnergyStateReceiver, + hiSysEnergyPowerReceiver +} from '../../../../src/trace/database/data-trafic/EnergySysEventReceiver'; +import { TraficEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; + +describe('EnergySysEventReceiver Test', () => { + let data; + let proc; + beforeEach(() => { + data = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + proc = jest.fn((sql) => [ + {energyData: {id: 1, startNs: 4.4, eventName: '', appKey: '', eventValue: ''}}, + {energyData: {id: 2, startNs: 5.5, eventName: '', appKey: '', eventValue: ''}}, + {energyData: {id: 3, startNs: 5.5, eventName: '', appKey: '', eventValue: ''}}, + {energyData: {id: 4, startNs: 5.5, eventName: '', appKey: '', eventValue: ''}}, + {energyData: {id: 5, startNs: 5.5, eventName: '', appKey: '', eventValue: ''}}, + ]); + }); + it('EnergySysEventReceiverTest01', () => { + let args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(systemDataSql(args)).toBeTruthy(); + expect(chartEnergyAnomalyDataSql(args)).toBeTruthy(); + expect(queryPowerValueSql(args)).toBeTruthy(); + expect(queryStateDataSql(args)).toBeTruthy(); + expect(queryStateProtoDataSql(args)).toBeTruthy(); + }); + it('EnergySysEventReceiverTest02', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiSysEnergyAnomalyDataReceiver(data, proc); + hiSysEnergyPowerReceiver(data, proc); + hiSysEnergyStateReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(3); + }); + it('EnergySysEventReceiverTest03', () => { + let systemData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let systemEventvalue = { + 'LOG_LEVEL': 2, + 'MESSAGE': 'token=548210734912', + 'NAME': 'backGround', + 'PID': 4192, + 'STATE': 1, + 'TAG': 'DUBAI_TAG_RUNNINGLOCK_ADD', + 'TYPE': 1, + 'UID': 20010034 + }; + let systemEventvalueJson = JSON.stringify(systemEventvalue); + let systemProc = jest.fn((sql) => [ + { + energyData: { + id: 1, + startNs: 4.4, + eventName: 'POWER_RUNNINGLOCK', + appKey: '1', + eventValue: systemEventvalueJson + } + }, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + energySysEventReceiver(systemData, systemProc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EnergySysEventReceiverTest04', () => { + let systemData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let systemEventvalue = { + 'LOG_LEVEL': 2, + 'MESSAGE': 'token=548210734912', + 'NAME': 'backGround', + 'PID': 4192, + 'STATE': 1, + 'TAG': 'DUBAI_TAG_RUNNINGLOCK', + 'TYPE': 1, + 'UID': 20010034 + }; + let systemEventvalueJson = JSON.stringify(systemEventvalue); + let systemProc = jest.fn((sql) => [ + { + energyData: { + id: 1, + startNs: 4.4, + eventName: 'POWER_RUNNINGLOCK', + appKey: '1', + eventValue: systemEventvalueJson + } + }, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + energySysEventReceiver(systemData, systemProc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EnergySysEventReceiverTest05', () => { + let systemData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let systemEventvalue = { + 'LOG_LEVEL': 2, + 'MESSAGE': 'token=548210734912', + 'NAME': 'backGround', + 'PID': 4192, + 'STATE': 'stop', + 'TAG': 'DUBAI_TAG_RUNNINGLOCK', + 'TYPE': 1, + 'UID': 20010034 + }; + let systemEventvalueJson = JSON.stringify(systemEventvalue); + let systemProc = jest.fn((sql) => [ + {energyData: {id: 1, startNs: 4.4, eventName: 'GNSS_STATE', appKey: '1', eventValue: systemEventvalueJson}}, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + energySysEventReceiver(systemData, systemProc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EnergySysEventReceiverTest06', () => { + let systemData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let systemEventvalue = { + 'LOG_LEVEL': 2, + 'MESSAGE': 'token=548210734912', + 'NAME': 'backGround', + 'PID': 4192, + 'STATE': 'stop', + 'TAG': 'DUBAI_TAG_RUNNINGLOCK', + 'TYPE': 1, + 'UID': 20010034 + }; + let systemEventvalueJson = JSON.stringify(systemEventvalue); + let systemProc = jest.fn((sql) => [ + {energyData: {id: 1, startNs: 4.4, eventName: 'GNSS_STATE', appKey: '1', eventValue: systemEventvalueJson}}, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + energySysEventReceiver(systemData, systemProc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('EnergySysEventReceiverTest07', () => { + let systemData = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + let systemEventvalue = { + 'LOG_LEVEL': 2, + 'MESSAGE': 'token=548210734912', + 'NAME': 'WORK_START', + 'PID': 4192, + 'STATE': 'stop', + 'TAG': 'DUBAI_TAG_RUNNINGLOCK', + 'TYPE': 1, + 'UID': 20010034 + }; + let systemEventvalueJson = JSON.stringify(systemEventvalue); + let systemProc = jest.fn((sql) => [ + {energyData: {id: 1, startNs: 4.4, eventName: 'WORK_START', appKey: '1', eventValue: systemEventvalueJson}}, + ]); + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + energySysEventReceiver(systemData, systemProc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/EnergySysEventSender.test.ts b/ide/test/trace/database/data-trafic/EnergySysEventSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..06745ab1581bb75571094d9db5897fbcfc80876e --- /dev/null +++ b/ide/test/trace/database/data-trafic/EnergySysEventSender.test.ts @@ -0,0 +1,114 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + energySysEventSender, + hiSysEnergyAnomalyDataSender, + hiSysEnergyPowerSender, + hiSysEnergyStateSender +} from '../../../../src/trace/database/data-trafic/EnergySysEventSender'; +import { EnergySystemStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergySystem'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { EnergyAnomalyStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly'; +import { EnergyPowerStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergyPower'; +import { EnergyStateStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergyState'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('EnergySysEventSender Test', () => { + let systemData = { + count: 2, + dataType: 1, + dur: 13200, + frame: + {x: 70, y: 45, width: 11, height: 10}, + id: 73, + startNs: 89300, + token: 54668, + type: 1 + } + + let anomalyData = + { + id: 126, + startNs: 23840, + eventName: "ANOMALY_SCREEN_OFF_ENERGY", + appKey: "APPNAME", + eventValue: "bt_switch" + } + + let powerData = { + appKey: "APPNAME", + eventName: "POWER_IDE_BLUETOOTH", + eventValue: "bt_switch", + id: 8940, + startNS: 1110 + } + + let stateData = { + dur: 3000, + frame: {x: 394, y: 5, width: 1, height: 30}, + id: 5807, + startNs: 49686, + type: "WIFI_EVENT_RECEIVED", + value: 4 + } + + it('EnergySysEventSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(systemData, 1, true); + }); + let systemTraceRow = TraceRow.skeleton(); + energySysEventSender(systemTraceRow).then(result => { + expect(result).toHaveLength(1); + }) + }); + + it('EnergySysEventSenderTest02', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(anomalyData, 1, true); + }); + let anomalyTraceRow = TraceRow.skeleton(); + hiSysEnergyAnomalyDataSender(anomalyTraceRow).then(result => { + expect(result).toHaveLength(1); + }) + }); + + it('EnergySysEventSenderTest03', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(powerData, 1, true); + }); + let powerTraceRow = TraceRow.skeleton(); + hiSysEnergyPowerSender(powerTraceRow).then(result => { + expect(Array.isArray(result)).toBe(true); + }) + }); + + it('EnergySysEventSenderTest04', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(stateData, 1, true); + }); + let eventName = ['WIFI_EVENT_RECEIVED']; + let stateTraceRow = TraceRow.skeleton(); + hiSysEnergyStateSender(eventName, 0, stateTraceRow).then(result => { + expect(result).toHaveLength(1); + }) + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/FrameDynamicEffectReceiver.test.ts b/ide/test/trace/database/data-trafic/FrameDynamicEffectReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9a60e8ded0c61e173364ff4364c2bb1e350549b --- /dev/null +++ b/ide/test/trace/database/data-trafic/FrameDynamicEffectReceiver.test.ts @@ -0,0 +1,104 @@ +/* + * 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 { + frameAnimationReceiver, + frameDynamicReceiver, + frameSpacingReceiver +} from '../../../../src/trace/database/data-trafic/FrameDynamicEffectReceiver'; + +describe('FrameDynamicEffectReceiver Test', () => { + let data = { + action: "exec-proto", + id: "1", + name: 18, + params: { + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + startNS: 0, + t: 1703474011224, + width: 1407, + trafic: 3 + } + }; + let animationData = [{ + frameAnimationData: { + depth: 0, + dur: 79379165, + endTs: 1451353646, + name: "H:APP_LIST_FLING, com.tencent.mm", + startTs: 1371974481 + } + }] + let dynamicData = [{ + frameDynamicData: { + alpha: "0.08", + appName: "WindowScene_mm37", + height: "1119", + ts: 179994792, + width: "543", + x: "513", + y: "1017" + } + }, { + frameDynamicData: { + alpha: "0.26", + appName: "WindowScene_mm37", + height: "1293", + ts: 196844792, + width: "627", + x: "459", + y: "938" + } + }] + let frameSpacingData = [{ + frameSpacingData: { + currentFrameHeight: "1119", + currentFrameWidth: "543", + currentTs: 179994792, + frameSpacingResult: 0, + nameId: "WindowScene_mm37", + preFrameHeight: 0, + preFrameWidth: 0, + preTs: 0, + preX: 0, + preY: 0, + x: "513", + y: "1017" + } + }] + it('FrameDynamicEffectReceiverTest01', function () { + const mockCallback = jest.fn(() => animationData); + const mockPostMessage = jest.fn(); + (self as unknown as Worker).postMessage = mockPostMessage; + frameAnimationReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('FrameDynamicEffectReceiverTest02', function () { + const mockCallback = jest.fn(() => dynamicData); + const mockPostMessage = jest.fn(); + (self as unknown as Worker).postMessage = mockPostMessage; + frameDynamicReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + it('FrameDynamicEffectReceiverTest03', function () { + let mockCallback = jest.fn(() => frameSpacingData); + (self as unknown as Worker).postMessage = jest.fn(); + frameSpacingReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/FrameDynamicEffectSender.test.ts b/ide/test/trace/database/data-trafic/FrameDynamicEffectSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..464f6cc7dcd34e255167c73a37e809c816c01a43 --- /dev/null +++ b/ide/test/trace/database/data-trafic/FrameDynamicEffectSender.test.ts @@ -0,0 +1,112 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { FrameAnimationStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFrameAnimation'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + frameAnimationSender, + frameDynamicSender, + frameSpacingSender +} from '../../../../src/trace/database/data-trafic/FrameDynamicEffectSender'; +import { FrameDynamicStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFrameDynamic'; +import { FrameSpacingStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFrameSpacing'; +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { +}); +describe('FrameDynamicEffectSender Test', () => { + let animationData = + { + animationId: 0, + depth: 0, + dur: 79379, + endTs: 145133, + frame: {x: 204, y: 2, width: 12, height: 16}, + frameInfo: "0", + name: "H:APP_LIST_FLING, com.tencent.mm", + startTs: 137, + status: "Response delay", + textMetricsWidth: 120.1328125 + } + + let dynamicCurveData = { + alpha: 1, + appName: "WindowScene_mm37", + frame: {x: 295, y: 97, width: 0, height: 100}, + groupId: 1371974481, + height: 2772, + id: 100, + ts: 197, + typeValue: 0, + width: 1344, + x: 0, + y: 0 + } + + let frameSpacingData = { + currentFrameHeight: 2772, + currentFrameWidth: 1344, + currentTs: 32952, + frame: {x: 491, y: 137, width: 0, height: 0}, + frameSpacingResult: [2.33], + groupId: 1371974481, + id: 218, + nameId: "WindowScene_mm37", + physicalHeight: 2772, + physicalWidth: 1344, + preFrameHeight: 2772, + preFrameWidth: 1344, + preTs: 32811, + preX: 0, + preY: 0, + x: 0, + y: 0 + } + it('FrameDynamicEffectSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(animationData, 1, true); + }); + let animationTraceRow = TraceRow.skeleton(); + frameAnimationSender(animationTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); + + it('FrameDynamicEffectSenderTest02', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(dynamicCurveData, 1, true); + }); + let frameDynamicTraceRow = TraceRow.skeleton(); + frameDynamicSender(frameDynamicTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); + + it('FrameDynamicEffectSenderTest03', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(frameSpacingData, 1, true); + }); + let frameSpacingTraceRow = TraceRow.skeleton(); + frameSpacingSender(1255, 5255, frameSpacingTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(Array.isArray(result)).toBe(true); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/FrameJanksReceiver.test.ts b/ide/test/trace/database/data-trafic/FrameJanksReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..659a6a1e4749e24e89767f1ab5c0a08c2595996f --- /dev/null +++ b/ide/test/trace/database/data-trafic/FrameJanksReceiver.test.ts @@ -0,0 +1,94 @@ +/* + * 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 { + frameActualReceiver, + frameExpectedReceiver +} from "../../../../src/trace/database/data-trafic/FrameJanksReceiver"; + +describe('FrameJanksReceiver Test', () => { + let data = { + action: "exec-proto", + id: "5", + name: 16, + params: { + endNS: 8711323000, + queryEnum: 16, + recordEndNS: 512261248000, + recordStartNS: 503549925000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703484466189, + trafic: 3, + width: 1407 + } + } + + let expectData = { + frameData: { + appDur: 16634548, + cmdline: "com.huawei.wx", + depth: 2, + dur: 33269438, + frameType: "frameTime", + id: 1007, + ipid: 135, + jankTag: -1, + name: 2299, + pid: 3104, + rsDur: 16634548, + rsIpid: 15, + rsPid: 994, + rsTs: 4996898311, + rsVsync: 1279, + ts: 4980263421, + type: "1" + } + } + + let actualData = { + frameData: { + appDur: 1697000, + cmdline: "com.ohos.launch", + depth: 0, + dur: 24662000, + frameType: "frameTime", + id: 918, + ipid: 19, + name: 2280, + pid: 2128, + rsDur: 11082000, + rsIpid: 15, + rsPid: 994, + rsTs: 4681218000, + rsVsync: 1260, + ts: 4667638000, + type: "0" + } + } + it('FrameJanksReceiverTest01', function () { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(frameExpectedReceiver(data, () => { + return expectData; + })).toBeUndefined(); + }); + + it('FrameJanksReceiverTest02', function () { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(frameActualReceiver(data, () => { + return actualData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/FrameJanksSender.test.ts b/ide/test/trace/database/data-trafic/FrameJanksSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..6098a285b36d97d205d1f63145739f34d04afad2 --- /dev/null +++ b/ide/test/trace/database/data-trafic/FrameJanksSender.test.ts @@ -0,0 +1,93 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { frameJanksSender } from '../../../../src/trace/database/data-trafic/FrameJanksSender'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { JanksStruct } from '../../../../src/trace/bean/JanksStruct'; +import { QueryEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('FrameJanksSender Test', () => { + let expectedData = { + app_dur: 16603333, + cmdline: "com.ohos.launch", + depth: 0, + dur: 16603333, + frame: {x: 167, y: 0, width: 3, height: 20}, + frame_type: "frameTime", + id: 157, + ipid: 19, + jank_tag: 65535, + name: 2087, + pid: 2128, + rs_dur: 16603333, + rs_ipid: 15, + rs_name: "swapper", + rs_pid: 994, + rs_ts: 1038812, + rs_vsync: 1080, + ts: 1038812 + } + + let actualData = { + app_dur: 3403000, + cmdline: "com.ohos.launch", + depth: 0, + dur: 17569000, + frame: {x: 739, y: 0, width: 3, height: 20}, + frame_type: "frameTime", + id: 898, + ipid: 19, + jank_tag: 0, + name: 2275, + pid: 2128, + rs_dur: 1192000, + rs_ipid: 15, + rs_name: "swapper", + rs_pid: 994, + rs_ts: 4598062, + rs_vsync: 1255, + ts: 4581685, + type: "0" + } + + it('FrameJanksSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(expectedData, 1, true); + }); + let expectedTraceRow = TraceRow.skeleton(); + frameJanksSender(QueryEnum.FrameExpectedData, expectedTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); + + it('FrameJanksSenderTest02', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(actualData, 1, true); + }); + let actualTraceRow = TraceRow.skeleton(); + frameJanksSender(QueryEnum.FrameActualData, actualTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(Array.isArray(result)).toBe(true); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/HiSysEventDataReciver.test.ts b/ide/test/trace/database/data-trafic/HiSysEventDataReciver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffb8bda0f787b16d8077f48480374d5318e58bb3 --- /dev/null +++ b/ide/test/trace/database/data-trafic/HiSysEventDataReciver.test.ts @@ -0,0 +1,55 @@ +/* + * 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 { + hiSysEventDataReceiver, + chartHiSysEventDataSql +} from '../../../../src/trace/database/data-trafic/HiSysEventDataReceiver'; +import { TraficEnum } from '../../../../src/trace/database/data-trafic/utils/QueryEnum'; + +describe('hiSysEventDataReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + proc = jest.fn((sql) => [ + {hiSysEventData: {id: 4, ts: 4.4, pid: 40, tid: 400, seq: 0.4, uid: 4000, dur: 40000, depth: 4}}, + {hiSysEventData: {id: 5, ts: 5.5, pid: 50, tid: 500, seq: 0.5, uid: 5000, dur: 50000, depth: 5}}, + ]); + }); + it('hiSysEventDataReceiverTest01', () => { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartHiSysEventDataSql(args)).toBeTruthy(); + }); + it('hiSysEventDataReceiverTest02', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiSysEventDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/HiSysEventDataSender.test.ts b/ide/test/trace/database/data-trafic/HiSysEventDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb02dc9e46628465a77da04b70ed91769804b9ca --- /dev/null +++ b/ide/test/trace/database/data-trafic/HiSysEventDataSender.test.ts @@ -0,0 +1,59 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { HiSysEventStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiSysEvent'; +import { hiSysEventDataSender } from '../../../../src/trace/database/data-trafic/HiSysEventDataSender'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('hiSysEventDataSender Test', () => { + let hiSysEventData = { + id: 808, + ts: 78977, + pid: 491, + tid: 25, + uid: 66, + dur: 1, + depth: 0, + seq: 1, + domain: 'MULTIMODALINPUT', + eventName: 'TARGET_POINTER_EVENT_SUCCESS', + info: '', + level: 'MINOR', + contents: '{"AGENT_WINDOWID":16,"EVENTTYPE":131072,"FD":33,"MSG":"The window manager successfully update target pointer","PID":4192,"TARGET_WINDOWID":16}', + frame: { + y: 10, + height: 20, + x: 168, + width: 1 + }, + v: true + } + it('hiSysEventDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(hiSysEventData, 1, true); + }); + let hiSysEventTraceRow = TraceRow.skeleton(); + hiSysEventDataSender(hiSysEventTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/IrqDataReceiver.test.ts b/ide/test/trace/database/data-trafic/IrqDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f5984db34ad31e34a4f5beadf0f7779019847ea2 --- /dev/null +++ b/ide/test/trace/database/data-trafic/IrqDataReceiver.test.ts @@ -0,0 +1,104 @@ +/* + * 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 { + chartIrqDataSql, + chartIrqDataSqlMem, + irqDataReceiver, +} from '../../../../src/trace/database/data-trafic/IrqDataReceiver'; +import { TraficEnum } from "../../../../src/trace/database/data-trafic/utils/QueryEnum"; + +describe('IrqReceiver Test', () => { + let data1; + let data2; + let proc; + + beforeEach(() => { + data1 = { + params: { + trafic: TraficEnum.ProtoBuffer, + cpu: 0, + endNS: 19473539059, + name: 'irq', + recordEndNS: 30167849973030, + recordStartNS: 30148376433971, + startNS: 0, + t: 1703665514720, + width: 708, + sharedArrayBuffers: {}, + }, + }; + data2 = { + params: { + trafic: TraficEnum.Memory, + cpu: 0, + endNS: 19473539059, + name: 'irq', + recordEndNS: 30167849973030, + recordStartNS: 30148376433971, + startNS: 0, + t: 1703665514720, + width: 708, + sharedArrayBuffers: {}, + }, + }; + proc = jest.fn((sql) => [ + { irqData: { argSetId: 74, dur: 3646, id: 74, startNs: 4255208 } }, + { irqData: { argSetId: 400, dur: 3125, id: 397, startNs: 38229687 } }, + ]); + }); + test('IrqReceiverTest01', () => { + const args = { + trafic: TraficEnum.ProtoBuffer, + cpu: 0, + endNS: 19473539059, + name: 'irq', + recordEndNS: 30167849973030, + recordStartNS: 30148376433971, + startNS: 0, + t: 1703665514720, + width: 708, + sharedArrayBuffers: {}, + }; + expect(chartIrqDataSql(args)).toBeTruthy(); + }); + test('IrqReceiverTest02', () => { + const args = { + trafic: TraficEnum.Memory, + cpu: 0, + endNS: 19473539059, + name: 'irq', + recordEndNS: 30167849973030, + recordStartNS: 30148376433971, + startNS: 0, + t: 1703665514720, + width: 708, + sharedArrayBuffers: {}, + }; + expect(chartIrqDataSqlMem(args)).toBeTruthy(); + }); + test('IrqReceiverTest03', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + irqDataReceiver(data1, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + test('IrqReceiverTest04', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + irqDataReceiver(data2, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); diff --git a/ide/test/trace/database/data-trafic/IrqDataSender.test.ts b/ide/test/trace/database/data-trafic/IrqDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce2e56e34dd7011d184b31e6f579f5c0151d1ce1 --- /dev/null +++ b/ide/test/trace/database/data-trafic/IrqDataSender.test.ts @@ -0,0 +1,46 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { irqDataSender } from '../../../../src/trace/database/data-trafic/IrqDataSender'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { IrqStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerIrq'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('irqDataSender Test', () => { + let IrqData = + { + argSetId: 74, + depth: 0, + dur: 364, + frame: { x: 0, y: 5, width: 1, height: 30 }, + id: 74, + name: 'IPI', + startNS: 4255, + } + it('IrqDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(IrqData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + irqDataSender(0, 'irq', traceRow).then((res) => { + expect(res).toHaveLength(1); + }); + }); +}); diff --git a/ide/test/trace/database/data-trafic/LogDataReceiver.test.ts b/ide/test/trace/database/data-trafic/LogDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f03e83615d4a8b43d5a4507d43afef824017597 --- /dev/null +++ b/ide/test/trace/database/data-trafic/LogDataReceiver.test.ts @@ -0,0 +1,55 @@ +/* + * 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 { + logDataReceiver, + chartLogDataSql +} from '../../../../src/trace/database/data-trafic/LogDataReceiver'; +import { TraficEnum } from "../../../../src/trace/database/data-trafic/utils/QueryEnum"; + +describe('logDataReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: { + id: new Uint16Array([1, 2, 3]), + }, + }, + }; + proc = jest.fn((sql) => [ + {logData: {id: 4, startTs: 4.4, pid: 40, tid: 400, dur: 40000, depth: 4}}, + {logData: {id: 5, startTs: 5.5, pid: 50, tid: 500, dur: 50000, depth: 5}}, + ]); + }); + it('logDataReceiverTest01', () => { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartLogDataSql(args)).toBeTruthy(); + }); + it('logDataReceiverTest02', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + logDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/LogDataSender.test.ts b/ide/test/trace/database/data-trafic/LogDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b03ee1067a2b07bb5710d06bafc57e4672d1c0dd --- /dev/null +++ b/ide/test/trace/database/data-trafic/LogDataSender.test.ts @@ -0,0 +1,57 @@ +/* + * 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 { LogDataSender } from '../../../../src/trace/database/data-trafic/LogDataSender'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { LogStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerLog'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); + +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('LogDataSender Test', () => { + let logData = { + id: 4, + startTs: 16276, + pid: 2082, + tid: 2082, + dur: 1, + depth: 1, + tag: 'C02c01/Init', + context: '[param_request.c:53]Can not get log level from param, keep the original loglevel.', + originTime: '08-06 15:43:19.954', + processName: 'hilog', + level: 'Info', + frame: { + 'x': 1, + 'y': 7, + 'width': 1, + 'height': 7 + } + } + it('LogDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(logData, 1, true); + }); + let logTraceRow = TraceRow.skeleton(); + LogDataSender(logTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/NativeMemoryDataReceiver.test.ts b/ide/test/trace/database/data-trafic/NativeMemoryDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f94640c3f6fc7e7155ced6cd5950d9e5ba66957 --- /dev/null +++ b/ide/test/trace/database/data-trafic/NativeMemoryDataReceiver.test.ts @@ -0,0 +1,74 @@ +/* + * 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 { + filterNativeMemoryChartData, + nativeMemoryDataHandler +} from '../../../../src/trace/database/data-trafic/NativeMemoryDataReceiver.js'; + +describe(' NativeMemoryDataReceiver Test', () => { + let data; + let proc; + const dataCache = { + normalCache: new Map(), + statisticsCache: new Map(), + }; + beforeEach(() => { + data = { + id: 'c07094fb-5340-4f1e-be9d-cd4071a77e24', + name: 206, + action: 'exec-proto', + params: { + totalNS: 108952700947, + recordStartNS: 8406282873525, + recordEndNS: 8515235574472, + model: 'native_hook', + processes: [ + 1 + ], + trafic: 1, + isCache: true + } + }; + proc = jest.fn((sql) => [ + {data: {id: 4, startTs: 4.4, pid: 40, tid: 400, dur: 40000, depth: 4}}, + {data: {id: 5, startTs: 5.5, pid: 50, tid: 500, dur: 50000, depth: 5}}, + ]); + }); + afterEach(() => { + dataCache.normalCache.clear(); + dataCache.statisticsCache.clear(); + }); + it(' NativeMemoryDataReceiver01', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + nativeMemoryDataHandler(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it(' NativeMemoryDataReceiver02', () => { + const model = 'native_hook'; + const startNS = 0; + const endNS = 100; + const totalNS = 200; + const drawType = 0; + const frame = 1; + const key = 'testKey'; + const result = filterNativeMemoryChartData(model, startNS, endNS, totalNS, drawType, frame, key); + expect(result.startTime).toEqual([]); + expect(result.dur).toEqual([]); + expect(result.heapSize).toEqual([]); + expect(result.density).toEqual([]); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/NativeMemoryDataSender.test.ts b/ide/test/trace/database/data-trafic/NativeMemoryDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7066a62d4f37455aae246fe64934ff3e7a5219b --- /dev/null +++ b/ide/test/trace/database/data-trafic/NativeMemoryDataSender.test.ts @@ -0,0 +1,71 @@ +/* + * 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 { threadPool } from '../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + nativeMemoryChartDataCacheSender, + nativeMemoryChartDataSender +} from '../../../../src/trace/database/data-trafic/NativeMemoryDataSender'; +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('NativeMemoryDataSender Test',()=>{ + let NativeMemoryData = { + startTime: 3384, + dur: 369, + heapsize: 173, + density: 193, + maxHeapSize: 58, + maxDensity: 4993, + minHeapSize: 0, + minDensity: 0, + frame: { + x: 17, + y: 5, + width: 2, + height: 30 + } + } + it('NativeMemoryDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(NativeMemoryData, 1, true); + }); + let nativeMemoryChartDataTraceRow = TraceRow.skeleton(); + let setting = { + eventType: 0, + ipid: 1, + model: "native_hook", + drawType: 0 + } + nativeMemoryChartDataSender(nativeMemoryChartDataTraceRow,setting).then(res => { + expect(res).toHaveLength(1); + }); + }); + it('NativeMemoryDataSenderTest02 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(NativeMemoryData, 1, true); + }); + let processes = [1]; + let model = 'native_hook'; + nativeMemoryChartDataCacheSender(processes,model).then(res => { + expect(res).toHaveLength(2); + }); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/VirtualMemoryDataReceiver.test.ts b/ide/test/trace/database/data-trafic/VirtualMemoryDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..d23f5c1845b022e1968fee9ce8fb0abe63fd284e --- /dev/null +++ b/ide/test/trace/database/data-trafic/VirtualMemoryDataReceiver.test.ts @@ -0,0 +1,58 @@ +/* + * 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 { virtualMemoryDataReceiver } from '../../../../src/trace/database/data-trafic/VirtualMemoryDataReceiver'; + +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('VirtualMemoryDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "30", + name: 12, + params: + { + endNS: 109726762483, + filterId: 6347, + recordEndNS: 490640100187894, + recordStartNS: 490530373425411, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703643817436, + trafic: 3, + width: 1407 + } + } + + let vmData = [{ + virtualMemData: { + delta: -1, + duration: 252, + filterId: 6347, + maxValue: -1, + startTime: 19680640101, + value: 423440 + } + }] + it('VirtualMemoryReceiverTest01', async () => { + const mockCallback = jest.fn(() => vmData); + const mockPostMessage = jest.fn(); + (self as unknown as Worker).postMessage = mockPostMessage; + virtualMemoryDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/VirtualMemoryDataSender.test.ts b/ide/test/trace/database/data-trafic/VirtualMemoryDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..38b25d806d20926f7cc4ceea5ee3c5de939cf4af --- /dev/null +++ b/ide/test/trace/database/data-trafic/VirtualMemoryDataSender.test.ts @@ -0,0 +1,47 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { virtualMemoryDataSender } from '../../../../src/trace/database/data-trafic/VirtualMemoryDataSender'; +import { VirtualMemoryStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerVirtualMemory'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('VirtualMemoryDataSender Test', () => { + let resultVm = { + delta: 1, + duration: 4830101562, + filterID: 202, + frame: {x: 190, y: 5, width: 62, height: 30}, + maxValue: 144753, + startTime: 148505, + value: 124362 + } + it('VirtualMemorySenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(resultVm, 1, true); + }); + let virtualMemoryTraceRow = TraceRow.skeleton(); + virtualMemoryDataSender(6346, virtualMemoryTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/VmTrackerDataReceiver.test.ts b/ide/test/trace/database/data-trafic/VmTrackerDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..69e533c02fa5f8dca267290715f2d3f21aad1a2b --- /dev/null +++ b/ide/test/trace/database/data-trafic/VmTrackerDataReceiver.test.ts @@ -0,0 +1,136 @@ +/* + * 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 { + abilityDmaDataReceiver, abilityGpuMemoryDataReceiver, + abilityPurgeableDataReceiver, + dmaDataReceiver, + gpuDataReceiver, + gpuMemoryDataReceiver, + gpuResourceDataReceiver, + gpuTotalDataReceiver, + gpuWindowDataReceiver, + purgeableDataReceiver, + shmDataReceiver, + sMapsDataReceiver +} from "../../../../src/trace/database/data-trafic/VmTrackerDataReceiver"; + +describe('VmTrackerDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "6", + name: 82, + params: { + endNs: 109726762483, + ipid: 1, + recordEndNS: 490640100187894, + recordStartNS: 490530373425411, + sharedArrayBuffers: undefined, + startNs: 0, + trafic: 3, + width: 1424 + } + }; + let res = [{ + trackerData: { + startNs: 4762581249, + value: 108232704 + } + }] + it('VmTrackerDataReceiverTest01', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + sMapsDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest02', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + dmaDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest03', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + gpuMemoryDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest04', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + gpuDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest05', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + gpuResourceDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest06', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + gpuTotalDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest07', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + gpuWindowDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest08', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + shmDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest09', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + purgeableDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest10', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + abilityPurgeableDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest11', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + abilityDmaDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); + + it('VmTrackerDataReceiverTest12', function () { + const mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + abilityGpuMemoryDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/VmTrackerDataSender.test.ts b/ide/test/trace/database/data-trafic/VmTrackerDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..05036bbca98516d16f026b877235a97b915bf6bb --- /dev/null +++ b/ide/test/trace/database/data-trafic/VmTrackerDataSender.test.ts @@ -0,0 +1,181 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../src/trace/database/SqlLite'; +import { + abilityDmaDataSender, + abilityGpuMemoryDataSender, + abilityPurgeableDataSender, + dmaDataSender, + gpuGpuDataSender, + gpuMemoryDataSender, + gpuResourceDataSender, + gpuTotalDataSender, + gpuWindowDataSender, + purgeableDataSender, + shmDataSender, + sMapsDataSender +} from '../../../../src/trace/database/data-trafic/VmTrackerDataSender'; +import { SnapshotStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('VmTrackerDataSender Test', () => { + let data = { + dur: 1000, + endNs: 576258, + frame: {x: 61, y: 3, width: 13, height: 33}, + name: "SnapShot 1", + startNs: 476258, + textWidth: 54.6826, + value: 21313 + } + it('VmTrackerDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let sMapsTraceRow = TraceRow.skeleton(); + sMapsDataSender('dirty', sMapsTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest02', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let dmaTraceRow = TraceRow.skeleton(); + dmaDataSender(1, dmaTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest03', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let gpuMemoryTraceRow = TraceRow.skeleton(); + gpuMemoryDataSender(1, gpuMemoryTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest04', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let gpuResourceTraceRow = TraceRow.skeleton(); + gpuResourceDataSender(13, gpuResourceTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest05', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let gpuGpuTraceRow = TraceRow.skeleton(); + gpuGpuDataSender(13, "'mem.graph_pss'", gpuGpuTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest06', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let gpuTotalTraceRow = TraceRow.skeleton(); + gpuTotalDataSender(13, gpuTotalTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest07', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let gpuWindowTraceRow = TraceRow.skeleton(); + gpuWindowDataSender(13, 15, gpuWindowTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest08', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let shmTraceRow = TraceRow.skeleton(); + shmDataSender(13, shmTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest09', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let purgeableTraceRow = TraceRow.skeleton(); + purgeableDataSender(13, purgeableTraceRow).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest10', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let abilityPurgeablTraceRow = TraceRow.skeleton(); + abilityPurgeableDataSender(abilityPurgeablTraceRow, 1000000000, false).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest11', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let abilityDmaTraceRow = TraceRow.skeleton(); + abilityDmaDataSender(abilityDmaTraceRow, 1000000000).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); + + it('VmTrackerDataSenderTest12', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(data, 1, true); + }); + let abilityGpuMemoryTraceRow = TraceRow.skeleton(); + abilityGpuMemoryDataSender(abilityGpuMemoryTraceRow, 1000000000).then(result => { + expect(result).toHaveLength(1); + expect(threadPool.submitProto).toHaveBeenCalled(); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuFreqDataReceiver.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuFreqDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..4213f7b110007dbbd05df835b677f79e4ef258f3 --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuFreqDataReceiver.test.ts @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + chartCpuFreqDataSql, + chartCpuFreqDataSqlMem, cpuFreqDataReceiver +} from '../../../../../src/trace/database/data-trafic/cpu/CpuFreqDataReceiver'; + +describe('CpuFreqDataReceiver Test',()=>{ + let data; + let proc; + + beforeEach(() => { + data = { + id: "6a41c242-3e3e-4c3f-82f3-eab7102f0e9f", + name: 2, + action: "exec-proto", + params: { + cpu: 0, + startNS: 0, + endNS: 9427688540, + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + t: 1703754730919, + width: 549, + trafic: 2 + } + }; + proc = jest.fn((sql) => [ + {cpuFreqData: {cpu: 4, value: 826000, dur: 0, startNs: 8252840103}}, + {cpuFreqData: {cpu: 4, value: 826000, dur: 0, startNs: 8252840103}}, + ]); + }); + it('CpuFreqDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartCpuFreqDataSql (args)).toBeTruthy(); + expect(chartCpuFreqDataSqlMem (args)).toBeTruthy(); + }); + it('CpuFreqDataReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + cpuFreqDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuFreqDataSender.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuFreqDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..eeb9386de73c7e3c3e97e2d5d8269834490087df --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuFreqDataSender.test.ts @@ -0,0 +1,50 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { CpuFreqStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerFreq'; +import { cpuFreqDataSender } from '../../../../../src/trace/database/data-trafic/cpu/CpuFreqDataSender'; +import { QueryEnum } from '../../../../../src/trace/database/data-trafic/utils/QueryEnum'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +describe('CpuFreqDataSender Test', () => { + let CpuFreqData = { + cpu: 1, + value: 88400, + dur: 566, + startNS: 9400, + frame: { + y: 5, + height: 30, + x: 547, + width: 1 + } + } + it('CpuFreqDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(CpuFreqData, 1, true); + }); + let cpuFreqDataTraceRow = TraceRow.skeleton(); + cpuFreqDataSender(QueryEnum.CpuData, cpuFreqDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataReceiver.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..def074f64ef78cd84fae7269a7a0e92874b33957 --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataReceiver.test.ts @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + chartCpuFreqLimitDataSql, + chartCpuFreqLimitDataSqlMem, cpuFreqLimitReceiver +} from '../../../../../src/trace/database/data-trafic/cpu/CpuFreqLimitDataReceiver'; + +describe('CpuFreqLimitDataReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + id: '6a41c242-3e3e-4c3f-82f3-eab7102f0e9f', + name: 2, + action: 'exec-proto', + params: { + cpu: 0, + startNS: 0, + endNS: 9427688540, + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + t: 1703754730919, + width: 549, + trafic: 2 + } + }; + proc = jest.fn((sql:any) => [ + {cpuFreqLimitData: {cpu: 4, value: 826000, dur: 0, startNs: 8252840103}}, + {cpuFreqLimitData: {cpu: 4, value: 826000, dur: 0, startNs: 8252840103}}, + ]); + }); + it('CpuFreqLimitDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartCpuFreqLimitDataSql(args)).toBeTruthy(); + expect(chartCpuFreqLimitDataSqlMem(args)).toBeTruthy(); + }); + it('CpuFreqLimitDataReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + cpuFreqLimitReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataSender.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..43ba4dc1f81a36a49aaea069ff80e211c4a95474 --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataSender.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { CpuFreqLimitsStruct } from '../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits'; +import { cpuFreqLimitSender } from '../../../../../src/trace/database/data-trafic/cpu/CpuFreqLimitDataSender'; +import { QueryEnum } from '../../../../../src/trace/database/data-trafic/utils/QueryEnum'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe(' CpuFreqLimitDataSender Test', () => { + let CpuFreqLimitData = [{ + cpu: 1, + value: 884000, + dur: -1, + startNS: 94001, + frame: { + y: 5, + height: 30, + x: 547, + width: 1 + } + }]; + it(' CpuFreqLimitDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(CpuFreqLimitData, CpuFreqLimitData.length, true); + }); + let CpuFreqLimitDataTraceRow = TraceRow.skeleton(); + let maxId = 0; + let minId = 0; + let cpu = 1; + cpuFreqLimitSender(maxId,minId,QueryEnum.CpuFreqLimitData, CpuFreqLimitDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuStateReceiver.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuStateReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..fab30ebbfb5b0349ceb21ca0e53bcc83431d5f60 --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuStateReceiver.test.ts @@ -0,0 +1,67 @@ +/* + * 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 { + chartCpuStateDataSql, + chartCpuStateDataSqlMem, cpuStateReceiver +} from '../../../../../src/trace/database/data-trafic/cpu/CpuStateReceiver'; + +describe('CpuStateReceiver Test', () => { + let data = { + id: '55348b85-5aa9-4e99-86fc-acb2d6f438fe', + name: 1, + action: 'exec-proto', + params: { + startTs: 1, + filterId: 3, + startNS: 0, + endNS: 9427688540, + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + width: 491, + trafic: 2, + } + }; + let CpuStateData = [{ + value: 0, + dur: 193229, + height: 4, + startTs: 6992644791, + cpu: 1, + frame: { + y: 5, + height: 30, + x: 364, + width: 1 + } + }] + it('CpuStateReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10, + filterId: 1, + }; + expect(chartCpuStateDataSql(args)).toBeTruthy(); + expect(chartCpuStateDataSqlMem(args)).toBeTruthy(); + }); + it('CpuStateReceiverTest02 ', function () { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(cpuStateReceiver(data, () => { + return CpuStateData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/cpu/CpuStateSender.test.ts b/ide/test/trace/database/data-trafic/cpu/CpuStateSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebb270d222b29a81d91bb81a6e74a6a6e464b4bf --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuStateSender.test.ts @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { cpuStateSender } from '../../../../../src/trace/database/data-trafic/cpu/CpuStateSender'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { CpuStateStruct } from '../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('CpuStateSender Test', () => { + let cpuStateData = { + value: 0, + dur: 193229, + height: 4, + startTs: 69926, + cpu: 1, + frame: { + y: 5, + height: 30, + x: 364, + width: 1 + } + } + it('CpuStateSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(cpuStateData, 1, true); + }); + let filterId = 1; + let CpustataDataTraceRow = TraceRow.skeleton(); + cpuStateSender(filterId,CpustataDataTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfCallChartReceiver.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfCallChartReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bc4b799e8a12d3c7ef25d8f12164d9fa83e7ac5 --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfCallChartReceiver.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. + */ + + +import { + chartHiperfCallChartDataSql, + hiPerfCallChartDataHandler, hiPerfCallStackCacheHandler +} from '../../../../../src/trace/database/data-trafic/hiperf/HiperfCallChartReceiver'; + +describe('HiperfCallChartReceiver Test', () => { + let data; + let proc; + let data2; + beforeEach(() => { + data = { + id: "817fccf0-76a8-41f3-86d6-6282b1208b58", + name: 203, + action: "exec-proto", + params: { + recordStartNS: 1395573006744, + trafic: 2, + isCache: true + } + }; + data2 = { + id: "817fccf0-76a8-41f3-86d6-6282b1208b58", + name: 203, + action: "exec-proto", + params: { + recordStartNS: 1395573006744, + trafic: 2, + isCache: false + } + }; + proc = jest.fn((sql) => [ + {HiperfCallChartData: {callchainId: 4, startTs: 4.4, eventCount: 40, threadId: 400, cpuId: 40000, eventTypeId: 4}}, + {HiperfCallChartData: {callchainId: 5, startTs: 5.5, eventCount: 50, threadId: 500, cpuId: 50000, eventTypeId: 5}}, + ]); + }); + it('HiperfCallChartReceiver01', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartHiperfCallChartDataSql(args)).toBeTruthy(); + }); + it('HiperfCallChartReceiver02', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiPerfCallChartDataHandler(data, proc); + hiPerfCallChartDataHandler(data2, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('HiperfCallChartReceiver03', () => { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiPerfCallStackCacheHandler(data, proc); + hiPerfCallStackCacheHandler(data2, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataReceiver.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c1071e7117a0453166dfe75262ef059fb5d8cbb --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataReceiver.test.ts @@ -0,0 +1,64 @@ +/* + * 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 { + chartHiperfCpuData10MSProtoSql, chartHiperfCpuDataProtoSql, hiperfCpuDataReceiver +} from '../../../../../src/trace/database/data-trafic/hiperf/HiperfCpuDataReceiver'; + +describe(' HiperfCpuDataReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + id: '87cc16a3-5dc7-4202-9ac9-4f038b2979ee', + name: 200, + action: 'exec-proto', + params: { + cpu: -1, + scale: 2000000000, + maxCpuCount: 4, + drawType: -2, + intervalPerf: 1, + startNS: 0, + endNS: 30230251246, + recordStartNS: 1596201782236, + recordEndNS: 1626432033482, + width: 549, + trafic: 3 + } + }; + proc = jest.fn((sql: any) => [ + {hiperfData: {startNs: 5600000000, eventCount: 58513886, sampleCount: 42, callchainId: 2279}}, + {hiperfData: {startNs: 5630000000, eventCount: 60359281, sampleCount: 36, callchainId: 5147}} + ]); + }); + it('HiperfCpuDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartHiperfCpuData10MSProtoSql(args)).toBeTruthy(); + expect(chartHiperfCpuDataProtoSql(args)).toBeTruthy(); + }); + it('HiperfCpuDataReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiperfCpuDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataSender.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..93321c500692e182ae772531a260474f1b78b5d4 --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfCpuDataSender.test.ts @@ -0,0 +1,58 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { HiPerfCpuStruct } from '../../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfCPU2'; +import { hiperfCpuDataSender } from '../../../../../src/trace/database/data-trafic/hiperf/HiperfCpuDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('HiperfCpuDataSender Test',()=>{ + let HiperfCpuData = { + startNS: 0, + eventCount: 26655990, + sampleCount: 63, + event_type_id: 0, + callchain_id: 3, + height: 63, + dur: 10000000, + frame: { + y: 0, + height: 63, + x: 0, + width: 1 + } + } + it('HiperfCpuDataTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(HiperfCpuData, 1, true); + }); + let cpu = -1; + let drawType = -2; + let maxCpuCount = 4; + let intervalPerf = 1; + let scale = 2000000000; + let HiperfCpuDataTraceRow = TraceRow.skeleton(); + hiperfCpuDataSender(cpu,drawType,maxCpuCount,intervalPerf,scale,HiperfCpuDataTraceRow).then(res => { + expect(res).toHaveLength(1); + }); + }); +}) + diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataReceiver.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac804bf49670a0bb8202c386a46140006f191ac2 --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataReceiver.test.ts @@ -0,0 +1,85 @@ +/* + * 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 { TraficEnum } from '../../../../../src/trace/database/data-trafic/utils/QueryEnum'; +import { + chartHiperfProcessData10MSProtoSql, chartHiperfProcessDataProtoSql, hiperfProcessDataReceiver +} from '../../../../../src/trace/database/data-trafic/hiperf/HiperfProcessDataReceiver'; + +describe('HiperfProcess Test', () => { + let data1; + let data2; + let proc1; + let proc2; + + beforeEach(() => { + data1 = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: {}, + drawType: -2, + endNS: 49171193732, + intervalPerf: 1, + maxCpuCount: -1, + pid: 11, + recordEndNS: 30418971157414, + recordStartNS: 30369799963682, + scale: 2000000000, + startNS: 0, + width: 1407, + }, + }; + data2 = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: {}, + drawType: -2, + endNS: 10360520695.855345, + intervalPerf: 1, + maxCpuCount: -1, + pid: 11, + recordEndNS: 30418971157414, + recordStartNS: 30369799963682, + scale: 20000000, + startNS: 9901354882.564587, + width: 888, + }, + }; + proc1 = jest.fn((sql) => [ + { hiperfData: { callchainId: 262, eventCount: 14, eventTypeId: 1, sampleCount: 1, startNs: 130000000 } }, + { hiperfData: { callchainId: 422, eventCount: 24, eventTypeId: 2, sampleCount: 1, startNs: 170000000 } }, + ]); + proc2 = jest.fn((sql) => [ + { hiperfData: { callchainId: 12515, eventCount: 191077, eventTypeId: 1, sampleCount: 1, startNs: 10017921673 } }, + { hiperfData: { callchainId: 94, eventCount: 140815, eventTypeId: 1, sampleCount: 1, startNs: 10022069465 } }, + ]); + }); + it('HiperfProcessReceiverTest01', () => { + expect(chartHiperfProcessData10MSProtoSql(data1.params)).toBeTruthy(); + expect(chartHiperfProcessDataProtoSql(data2.params)).toBeTruthy(); + }); + it('HiperfProcessReceiverTest02', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiperfProcessDataReceiver(data1, proc1); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('HiperfProcessReceiverTest03', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiperfProcessDataReceiver(data2, proc2); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataSender.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..704316322a09062ab5685da2fd2676d1d0b839f5 --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfProcessDataSender.test.ts @@ -0,0 +1,48 @@ +/* + * 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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { HiPerfProcessStruct } from '../../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfProcess2'; +import { hiperfProcessDataSender } from '../../../../../src/trace/database/data-trafic/hiperf/HiperfProcessDataSender'; + +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('HiperfProcessSender Test', () => { + let traceRowData = + { + dur: 10000000, + frame: {x: 2, y: 0, width: 1, height: 4}, + startNS: 170000000, + callchain_id: 422, + event_count: 24, + event_type_id: 2, + height: 4, + sampleCount: 1, + } + it('HiperfProcessSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(traceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + hiperfProcessDataSender(11, -2, 1, 200000, 1,traceRow).then((res) => { + expect(res).toHaveLength(1); + }); + }); +}); diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataReceiver.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..b305fe2acc8b278d3dd32273df0329a955f35856 --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataReceiver.test.ts @@ -0,0 +1,85 @@ +/* + * 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 { TraficEnum } from '../../../../../src/trace/database/data-trafic/utils/QueryEnum'; +import { + chartHiperfThreadData10MSProtoSql, chartHiperfThreadDataProtoSql, hiperfThreadDataReceiver +} from '../../../../../src/trace/database/data-trafic/hiperf/HiperfThreadDataReceiver'; + +describe('HiperfThread Test', () => { + let data1; + let data2; + let proc1; + let proc2; + + beforeEach(() => { + data1 = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: {}, + drawType: -2, + endNS: 49171193732, + intervalPerf: 1, + maxCpuCount: -1, + recordEndNS: 30418971157414, + recordStartNS: 30369799963682, + scale: 2000000000, + startNS: 0, + tid: 28917, + width: 841, + }, + }; + data2 = { + params: { + trafic: TraficEnum.ProtoBuffer, + sharedArrayBuffers: {}, + drawType: -2, + endNS: 38843292896.21842, + intervalPerf: 1, + maxCpuCount: -1, + recordEndNS: 30418971157414, + recordStartNS: 30369799963682, + scale: 20000000, + startNS: 38410507602.73825, + tid: 28917, + width: 841, + }, + }; + proc1 = jest.fn((sql) => [ + { hiperfData: { callchainId: 12, eventCount: 3603585, sampleCount: 11, startNs: 0 } }, + { hiperfData: { callchainId: 128, eventCount: 728632, sampleCount: 1, startNs: 70000000 } }, + ]); + proc2 = jest.fn((sql) => [ + { hiperfData: { callchainId: 1114, eventCount: 106450, sampleCount: 1, startNs: 38427936069 } }, + { hiperfData: { callchainId: 94, eventCount: 140815, sampleCount: 1, startNs: 38428328069 } }, + ]); + }); + it('HiperfThreadReceiverTest01', () => { + expect(chartHiperfThreadData10MSProtoSql(data1.params)).toBeTruthy(); + expect(chartHiperfThreadDataProtoSql(data2.params)).toBeTruthy(); + }); + it('HiperfThreadReceiverTest02', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiperfThreadDataReceiver(data1, proc1); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); + it('HiperfThreadReceiverTest03', () => { + let mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + hiperfThreadDataReceiver(data2, proc2); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); diff --git a/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataSender.test.ts b/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..94c5f34255b9bcc5dcdddeaf4d2f06466ce30d9e --- /dev/null +++ b/ide/test/trace/database/data-trafic/hiperf/HiperfThreadDataSender.test.ts @@ -0,0 +1,47 @@ +/* + * 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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { HiPerfThreadStruct } from '../../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfThread2'; +import { hiperfThreadDataSender } from '../../../../../src/trace/database/data-trafic/hiperf/HiperfThreadDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('HiperfThreadSender Test', () => { + let traceRowData = + { + dur: 10000000, + frame: {x: 0, y: 0, width: 1, height: 44}, + startNS: 0, + callchain_id: 12, + event_count: 3603585, + event_type_id: 0, + height: 44, + sampleCount: 11, + } + it('HiperfThreadSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(traceRowData, 1, true); + }); + let traceRow = TraceRow.skeleton(); + hiperfThreadDataSender(28917, -2, 1, 2000000000,1, traceRow).then((res) => { + expect(res).toHaveLength(1); + }); + }); +}); diff --git a/ide/test/trace/database/data-trafic/process/FuncDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/FuncDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..eadb4f494d9e4e4b521bedac8eb162e6800d8641 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/FuncDataReceiver.test.ts @@ -0,0 +1,82 @@ +/* + * 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 { + chartFuncDataSql, + chartFuncDataSqlMem, funcDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/FuncDataReceiver'; + +describe('FuncDataReceiver Test', () => { + let data; + let proc; + + beforeEach(() => { + data = { + id: '55febc1a-1eea-4c9f-ad29-33cd10b95b39', + name: 31, + action: 'exec-proto', + params: { + tid: 8182, + ipid: 52, + startNS: 0, + endNS: 9427688540, + recordStartNS: 4049847357191, + recordEndNS: 4059275045731, + width: 549, + trafic: 0 + } + }; + proc = jest.fn((sql: any) => [ + { + FuncData: { + startTs: 129966146, + dur: 0, + argsetid: 2128, + depth: 0, + id: 1090, + px: 7, + durTmp: 0 + } + }, + { + FuncData: { + startTs: 155282292, + dur: 0, + argsetid: 3260, + depth: 0, + id: 1778, + px: 9, + durTmp: 0 + } + }, + ]); + }); + it('FuncDataReceiverTest01 ', function () { + const args = { + recordStartNS: 1000, + endNS: 3000, + startNS: 2000, + width: 10 + }; + expect(chartFuncDataSql(args)).toBeTruthy(); + expect(chartFuncDataSqlMem(args)).toBeTruthy(); + }); + it('FuncDataReceiverTest02 ', function () { + const mockPostMessage = jest.fn(); + global.postMessage = mockPostMessage; + funcDataReceiver(data, proc); + expect(mockPostMessage).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/FuncDataSender.test.ts b/ide/test/trace/database/data-trafic/process/FuncDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..547f1ff1f6ae55546f97ace55b8ca90d324fc799 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/FuncDataSender.test.ts @@ -0,0 +1,55 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { FuncStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerFunc'; +import { funcDataSender } from '../../../../../src/trace/database/data-trafic/process/FuncDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('FuncDataSender Test',()=>{ + let FuncData = { + startTs: 1115, + dur: 0, + argsetid: 1462, + depth: 0, + id: 633, + itid: 120, + ipid: 52, + funName: "binder transaction async", + frame: { + x: 6, + y: 0, + width: 1, + height: 20 + } + } + it('FuncDataSenderTest01 ', function () { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(FuncData, 1, true); + }); + let tid = 1; + let ipid = 52; + let FuncDataTraceRow = TraceRow.skeleton(); + funcDataSender(tid,ipid,FuncDataTraceRow).then(res=>{ + expect(res).toHaveLength(1); + }) + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessActualDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessActualDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ad26556a04491f611a650966320013d493f419b --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessActualDataReceiver.test.ts @@ -0,0 +1,59 @@ +/* + * 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 { + processActualDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/ProcessActualDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessActualDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "5", + name: 27, + params: + { + endNS: 8711323000, + pid: 994, + recordEndNS: 512261248000, + recordStartNS: 503549925000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703558234327, + trafic: 3, + width: 1407 + } + } + let actualData = [{ + processJanksActualData: { + dstSlice: -1, + dur: 6769000, + id: 1296, + name: 1336, + pid: 994, + ts: 5945218000 + } + }] + + it('ActualDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processActualDataReceiver(data, () => { + return actualData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessActualDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessActualDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..d484a3b4b34f95d1b50684089e5a33f02b1c9467 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessActualDataSender.test.ts @@ -0,0 +1,56 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { JankStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerJank'; +import { processActualDataSender } from '../../../../../src/trace/database/data-trafic/process/ProcessActualDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessActualDataSender Test', () => { + let actualData = + { + cmdline: "com.ohos.launch", + depth: 0, + dst_slice: 506, + dur: 2, + frame: {x: 393, y: 0, width: 1, height: 20}, + frame_type: "app", + id: 502, + jank_tag: 0, + name: 2171, + pid: 2128, + src_slice: "", + ts: 24350, + type: 0 + } + it('ActualDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(actualData, 1, true); + }); + let actualTraceRow = TraceRow.skeleton(); + processActualDataSender(2128, actualTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a19021dc6aded892d4d0b5ec81a23eb20561bf0 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessDataReceiver.test.ts @@ -0,0 +1,59 @@ +/* + * 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 { processDataReceiver } from '../../../../../src/trace/database/data-trafic/process/ProcessDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "6", + name: 6, + params: + { + endNS: 8711323000, + pid: 431, + recordEndNS: 512261248000, + recordStartNS: 503549925000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703560455293, + trafic: 0, + width: 1407 + } + } + let processData = [ + { + cpu: 1, + dur: 1136000, + startTime: 3650382000, + v: true, + }, + { + cpu: 1, + dur: 104000, + startTime: 3665355000 + } + ] + it('ProcessDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processDataReceiver(data, () => { + return processData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..00599d2d271d6dd3cf95ecfef38b898fc50d634d --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessDataSender.test.ts @@ -0,0 +1,43 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { ProcessStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerProcess'; +import { processDataSender } from '../../../../../src/trace/database/data-trafic/process/ProcessDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessDataSender Test', () => { + let processData = + { + cpu: 0, + dur: 1400, + startTime: 8339, + } + it('ProcessDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(processData, 1, true); + }); + let processTraceRow = TraceRow.skeleton(); + processDataSender(994, processTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a6ecbdc1ec081dc48bddc0d7a21dcc1845e5300 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataReceiver.test.ts @@ -0,0 +1,63 @@ +/* + * 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 { + processDeliverInputEventDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/ProcessDeliverInputEventDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('DeliverInputEventDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "52", + name: 28, + params: + { + endNS: 20000305000, + recordEndNS: 168778663166000, + recordStartNS: 168758662861000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703561897634, + tid: "1298", + trafic: 3, + width: 1407 + } + } + let res = [ + { + processInputEventData: { + argsetid: -1, + cookie: 10350, + dur: 83000, + id: 41459, + isMainThread: 1, + parentId: -1, + pid: 1298, + startTs: 7379559000, + tid: 1298, + trackId: 14 + } + }] + it('DeliverInputEventDataReceiverTest01', async () => { + let mockCallback = jest.fn(() => res); + (self as unknown as Worker).postMessage = jest.fn(); + processDeliverInputEventDataReceiver(data, mockCallback); + expect(mockCallback).toHaveBeenCalled(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..48507a81522a8d2ccb16feb1cacd9df4cf6e9e7c --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessDeliverInputEventDataSender.test.ts @@ -0,0 +1,55 @@ +/* + * 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 { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { FuncStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerFunc'; +import { + processDeliverInputEventDataSender +} from '../../../../../src/trace/database/data-trafic/process/ProcessDeliverInputEventDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessDataSender Test', () => { + let inputEventData = { + argsetid: 12, + cookie: 684, + depth: 0, + dur: 7810, + frame: {x: 516, y: 0, width: 1, height: 20}, + funName: "deliverInputEvent", + id: 408, + is_main_thread: 1, + parent_id: 725, + pid: 756, + startTs: 740, + threadName: "ndroid.settings", + tid: 725, + track_id: 136 + } + it('ProcessDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(inputEventData, 1, true); + }); + let inputEventTraceRow = TraceRow.skeleton(); + processDeliverInputEventDataSender(7256, inputEventTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessExpectedDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessExpectedDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..622913605978f8522b69348d81301fd203f5e2fe --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessExpectedDataReceiver.test.ts @@ -0,0 +1,58 @@ +/* + * 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 { + processExpectedDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/ProcessExpectedDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessExpectedDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "966", + name: 26, + params: + { + endNS: 8711323000, + pid: 994, + recordEndNS: 512261248000, + recordStartNS: 503549925000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703572989578, + trafic: 3, + width: 1407 + } + } + let expectedData = [{ + processJanksFramesData: { + dur: 16627734, + id: 415, + name: 1143, + pid: 994, + ts: 2086211199, + type: 1 + } + }] + it('ExpectedDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processExpectedDataReceiver(data, () => { + return expectedData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessExpectedDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessExpectedDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..82b644977325c77036c81043d893adc1ccd23180 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessExpectedDataSender.test.ts @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { JankStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerJank'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { + processExpectedDataSender +} from '../../../../../src/trace/database/data-trafic/process/ProcessExpectedDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessExpectedDataSender Test', () => { + let expectedData = { + cmdline: "render_service", + depth: 0, + dur: 166, + frame: {x: 336, y: 0, width: 3, height: 20}, + frame_type: "render_service", + id: 415, + name: 1143, + pid: 994, + ts: 20862, + type: 1143 + } + it('ExpectedDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(expectedData, 1, true); + }); + let expectedTraceRow = TraceRow.skeleton(); + processExpectedDataSender(994, expectedTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessMemDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessMemDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..411c9c4ecf77677afdbb8c885672fa58ab5213a2 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessMemDataReceiver.test.ts @@ -0,0 +1,54 @@ +/* + * 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 { processMemDataReceiver } from '../../../../../src/trace/database/data-trafic/process/ProcessMemDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessMemDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "71", + name: 7, + params: + { + endNS: 20000305000, + recordEndNS: 168778663166000, + recordStartNS: 168758662861000, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703574363518, + trackId: 543, + trafic: 3, + width: 1407 + } + } + let memData = [{ + processMemData: { + startTime: 7578590000, + trackId: 545, + ts: 168766241451000, + value: 1728 + } + }] + it('ProcessMemDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processMemDataReceiver(data, () => { + return memData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessMemDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessMemDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..2430a1f3ae1d450d09aaaa6b1359b5b265e37b75 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessMemDataSender.test.ts @@ -0,0 +1,47 @@ +/* + * 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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { ProcessMemStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerMem'; +import { processMemDataSender } from '../../../../../src/trace/database/data-trafic/process/ProcessMemDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessMemDataSender Test', () => { + let memData = { + delta: 0, + duration: 4077000, + frame: {x: 645, y: 5, width: 1, height: 30}, + maxValue: 5, + startTime: 917868, + track_id: 31, + ts: 1687, + value: 3 + } + it('ProcessMemDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(memData, 1, true); + }); + let memTraceRow = TraceRow.skeleton(); + processMemDataSender(543, memTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/base-ui/chart/scatter/LitChartScatter.test.ts b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataReceiver.test.ts similarity index 42% rename from ide/test/base-ui/chart/scatter/LitChartScatter.test.ts rename to ide/test/trace/database/data-trafic/process/ProcessSoInitDataReceiver.test.ts index 17f15189179a140681f2fae8f625c31a5b42f8b2..9292b503718eaf0dfdcf6d342f3775ae05cb51e1 100644 --- a/ide/test/base-ui/chart/scatter/LitChartScatter.test.ts +++ b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataReceiver.test.ts @@ -13,17 +13,36 @@ * limitations under the License. */ -import { LitChartScatter } from '../../../../src/base-ui/chart/scatter/LitChartScatter'; -window.ResizeObserver = - window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); -describe('LitChartScatter Test',()=>{ - it('LitChartScatterTest01 ', function () { - let litChartScatter = new LitChartScatter(); - expect(litChartScatter).not.toBeUndefined(); +import { + processSoInitDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/ProcessSoInitDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessSoInitDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "81", + name: 8, + params: + { + endNS: 29372913537, + pid: 4794, + recordEndNS: 262379203084, + recordStartNS: 233006289547, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703581047560, + trafic: 3, + width: 1407 + } + } + it('SoInitDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processSoInitDataReceiver(data, () => { + return []; + })).toBeUndefined(); }); -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessSoInitDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..d5cfae5408241d720c54bcb3005d1ec286aaa226 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataSender.test.ts @@ -0,0 +1,37 @@ +/* + * 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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { SoStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerSoInit'; +import { processSoInitDataSender } from '../../../../../src/trace/database/data-trafic/process/ProcessSoInitDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ProcessSoInitDataSender Test', () => { + it('ProcessSoInitDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback({}, 0, true); + }); + let soInitTraceRow = TraceRow.skeleton(); + processSoInitDataSender(543, soInitTraceRow).then(result => { + expect(result).toHaveLength(0); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessStartupDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessStartupDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c62573e45799a4854d84efaab8c7554edc0ca2a5 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessStartupDataReceiver.test.ts @@ -0,0 +1,58 @@ +/* + * 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 { + processStartupDataReceiver +} from '../../../../../src/trace/database/data-trafic/process/ProcessStartupDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessStartupDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "81", + name: 8, + params: + { + endNS: 29372913537, + pid: 4794, + recordEndNS: 262379203084, + recordStartNS: 233006289547, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703581047560, + trafic: 3, + width: 1407 + } + } + let startUpData = [{ + processStartupData: { + dur: 6055208, + itid: 76, + pid: 4794, + startName: 1, + startTime: 266994271, + tid: 4794 + } + }] + it('StartupDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(processStartupDataReceiver(data, () => { + return startUpData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ProcessStartupDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ProcessStartupDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..494f76f1a5cd61ee42583146fa57b33b55310868 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessStartupDataSender.test.ts @@ -0,0 +1,48 @@ +/* + * 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 { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { AppStartupStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerAppStartup'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +import { processStartupDataSender } from '../../../../../src/trace/database/data-trafic/process/ProcessStartupDataSender'; +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ProcessStartupDataSender Test', () => { + let startupData = { + dur: 60558, + endItid: 167, + frame: {y: 5, height: 20, x: 12, width: 2}, + itid: 76, + pid: 4794, + startName: 1, + startTs: 266, + tid: 4794 + } + it('ProcessStartupDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(startupData, 1, true); + }); + let startupTraceRow = TraceRow.skeleton(); + processStartupDataSender(4794, startupTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ThreadDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ThreadDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ad44655c97b88ac8f6e936f3f3e10d371278490c --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ThreadDataReceiver.test.ts @@ -0,0 +1,71 @@ +/* + * 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 { threadDataReceiver } from '../../../../../src/trace/database/data-trafic/process/ThreadDataReceiver'; + +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); + +describe('ThreadDataReceiver Test', () => { + let data = { + action: "exec-proto", + id: "258", + name: 30, + params: + { + endNS: 29372913537, + pid: 1668, + recordEndNS: 262379203084, + recordStartNS: 233006289547, + sharedArrayBuffers: undefined, + startNS: 0, + t: 1703581047560, + trafic: 2, + width: 1407 + } + } + + let threadData = [ + { + argSetId: -1, + cpu: null, + dur: 2327000, + id: 16, + pid: 590, + px: 285, + startTime: 2029133000, + state: "D", + tid: 590 + }, + { + argSetId: -1, + cpu: 3, + dur: 14494000, + id: 6, + pid: 1668, + px: 1331, + startTime: 9464658000, + state: "Running", + tid: 1699 + } + ] + it('ThreadDataReceiverTest01', async () => { + (self as unknown as Worker).postMessage = jest.fn(() => true); + expect(threadDataReceiver(data, () => { + return threadData; + })).toBeUndefined(); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/process/ThreadDataSender.test.ts b/ide/test/trace/database/data-trafic/process/ThreadDataSender.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fcf289a802cdd7ca5dcd5a0059214e2c1cf3970 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ThreadDataSender.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. + */ + +import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; +import { threadPool } from '../../../../../src/trace/database/SqlLite'; +import { ThreadStruct } from '../../../../../src/trace/database/ui-worker/ProcedureWorkerThread'; +import { threadDataSender } from '../../../../../src/trace/database/data-trafic/process/ThreadDataSender'; +jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +describe('ThreadDataSender Test', () => { + let threadData = { + argSetID: 12, + cpu: 2, + dur: 496000, + frame: {y: 5, height: 20, x: 369, width: 1}, + id: 23, + pid: 1668, + startTime: 2629548, + state: "Running", + tid: 1693, + translateY: 650 + } + it('ThreadDataSenderTest01', () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(threadData, 1, true); + }); + let threadTraceRow = TraceRow.skeleton(); + threadDataSender(543, 12, threadTraceRow).then(result => { + expect(result).toHaveLength(1); + }); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/data-trafic/utils/DataFilter.test.ts b/ide/test/trace/database/data-trafic/utils/DataFilter.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..432b2fe0e1cc10585fe5a515dc347f210f00820b --- /dev/null +++ b/ide/test/trace/database/data-trafic/utils/DataFilter.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. + */ + +import { + filterData, + filterDataByGroup, + filterDataByGroupLayer, + filterDataByLayer +} from '../../../../../src/trace/database/data-trafic/utils/DataFilter'; + +describe('DataFilter Test', () => { + it('DataFilterTest01', () => { + let list = [ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000}, + ]; + let startKey = 'startKey'; + let durKey = 'durKey'; + let startNS = 0; + let endNS = 2000; + let width = 100; + let result = filterData(list, startKey, durKey, startNS, endNS, width); + expect(result).toEqual([ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000, v: true}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000, v: true}, + ]); + }); + it('DataFilterTest02', () => { + let list = [ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000}, + ]; + let layerKey = 'layerKey'; + let startKey = 'startKey'; + let durKey = 'durKey'; + let startNS = 0; + let endNS = 2000; + let width = 100; + let result = filterDataByLayer(list, layerKey, startKey, durKey, startNS, endNS, width); + expect(result).toEqual([ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000, v: true}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000, v: true}, + ]); + }); + it('DataFilterTest03', () => { + let list = [ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000}, + ]; + let startKey = 'startKey'; + let durKey = 'durKey'; + let startNS = 0; + let endNS = 2000; + let width = 100; + let result = filterDataByGroup(list, startKey, durKey, startNS, endNS, width, null); + expect(result).toEqual([ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000, px: 0,}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000, px: 5,}, + ]); + }); + it('DataFilterTest0304', () => { + let list = [ + {layerKey: 1, startKey: 0, durKey: 100, startNS: 0, endNS: 1000}, + {layerKey: 2, startKey: 100, durKey: 200, startNS: 1001, endNS: 2000}, + ]; + let layerKey = 'layerKey'; + let startKey = 'startKey'; + let durKey = 'durKey'; + let startNS = 0; + let endNS = 2000; + let width = 100; + let result = filterDataByGroupLayer(list, layerKey, startKey, durKey, startNS, endNS, width); + expect(result).toEqual([ + {startKey: 0, durKey: 100, startNS: 0, endNS: 1000, px: 100, durTmp: 100, layerKey: 1,}, + {startKey: 100, durKey: 200, startNS: 1001, endNS: 2000, px: 205, durTmp: 200, layerKey: 2,}, + ]); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerCommon.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerCommon.test.ts index 03418b18aeea28a70b30414d783926fd3a005623..9205c4ccc4579296c7383b26453f1327adb1749e 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerCommon.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerCommon.test.ts @@ -79,15 +79,15 @@ describe('ProcedureLogicWorkerCommon Test', () => { }); it('MerageBeanTest30', function () { - expect(getByteWithUnit(-1_000_000_001)).toBe('-953.67 Mb'); + expect(getByteWithUnit(-1_000_000_001)).toBe('-953.67 MB'); }); it('MerageBeanTest08', function () { - expect(getByteWithUnit(1_000_000_001)).toBe('953.67 Mb'); + expect(getByteWithUnit(1_000_000_001)).toBe('953.67 MB'); }); it('MerageBeanTest09', function () { - expect(getByteWithUnit(1_000_001)).toBe('976.56 Kb'); + expect(getByteWithUnit(1_000_001)).toBe('976.56 KB'); }); it('MerageBeanTest10', function () { @@ -95,7 +95,7 @@ describe('ProcedureLogicWorkerCommon Test', () => { }); it('MerageBeanTest11', function () { - expect(getByteWithUnit(1_000_000_000_1)).toBe('9.31 Gb'); + expect(getByteWithUnit(1_000_000_000_1)).toBe('9.31 GB'); }); it('MerageBeanTest12', function () { diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts index 2859e2de77a8563563c3e738dfe596fa57f56592..727375ac9a6df7fc18095d929e2d2ce8b0b194db 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerFileSystem.test.ts @@ -471,7 +471,7 @@ describe('ProcedureLogicWorkerFileSystem Test', () => { join: jest.fn(() => true), }, fileSystemType: { - length: 1, + length: 2, join: jest.fn(() => true), }, }; @@ -486,14 +486,14 @@ describe('ProcedureLogicWorkerFileSystem Test', () => { it('procedureLogicWorkerFileSystemTest59', function () { let handlerMap = procedureLogicWorkerF.handlerMap.get('fileSystem'); let selectionParam = { - diskIOipids: { + fileSystemType: { length: 1, join: jest.fn(() => true), }, - fileSystemType: { + diskIOipids: { length: 1, join: jest.fn(() => true), - }, + }, }; window.postMessage = jest.fn(() => true); expect(handlerMap.queryPageFaultSamples(selectionParam)).toBeUndefined(); @@ -534,11 +534,11 @@ describe('ProcedureLogicWorkerFileSystem Test', () => { it('procedureLogicWorkerFileSystemTest64', function () { let handlerMap = procedureLogicWorkerF.handlerMap.get('virtualMemory'); let selectionParam = { - diskIOipids: { + diskIOReadIds: { length: 3, join: jest.fn(() => true), }, - diskIOReadIds: { + diskIOipids: { length: 3, join: jest.fn(() => true), }, diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.test.ts index 430bf20338f1b7dca6e67a329a899479c99842b6..8d6166e2940716dfef334624d407460e7322f79a 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerJsCpuProfiler.test.ts @@ -89,10 +89,10 @@ describe('ProcedureLogicWorkerJsCpuProfiler Test', () => { type: 'jsCpuProfiler-bottom-up', params: [ { - startTime: 0, - endTime: 0, children: [], samplesIds: [], + startTime: 0, + endTime: 0, isSelect: false, }, ], diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.test.ts index 39f0543cab6e278b9e058a5bfbc6f241fdc11fe2..36a3ac249dd32dfe91533e6fe0b99f97afafb2b8 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.test.ts @@ -610,13 +610,13 @@ describe('ProcedureLogicWorkerNativeNemory Test', () => { let params = [ { length: 1, - funcName: 'splitAllProcess', funcArgs: [ { get: jest.fn(() => true), forEach: jest.fn(() => true), }, ], + funcName: 'splitAllProcess', }, ]; expect(procedureLogicWorkerNativeMemory.resolvingNMCallAction(params)).toStrictEqual([]); diff --git a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts index fc9657f961d86886f21e2bc6e75809ac11e4a258..6a7b22f32b384013d4f433b94bb1635e028f6346 100644 --- a/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts +++ b/ide/test/trace/database/logic-worker/ProcedureLogicWorkerPerf.test.ts @@ -596,12 +596,12 @@ describe('ProcedureLogicWorkerPerf Test', () => { let params = [ { length: 2, - funcName: 'resotreAllNode', funcArgs: [ { forEach: jest.fn(() => true), }, ], + funcName: 'resotreAllNode', }, ]; window.postMessage = jest.fn(() => true); @@ -612,12 +612,12 @@ describe('ProcedureLogicWorkerPerf Test', () => { let params = [ { length: 2, - funcName: 'clearSplitMapData', funcArgs: [ { forEach: jest.fn(() => true), }, ], + funcName: 'clearSplitMapData', }, ]; window.postMessage = jest.fn(() => true); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerAllAppStartup.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerAllAppStartup.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..53a9fa6a27d0d8758459e69045455af3e4cb5702 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerAllAppStartup.test.ts @@ -0,0 +1,101 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + AllAppStartupRender, + AllAppStartupStruct +} from '../../../../src/trace/database/ui-worker/ProcedureWorkerAllAppStartup'; + +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerAllAppStartup Test',()=>{ + it('ProcedureWorkerAllAppStartup01 ', function () { + const data = { + frame: { + x: 20, + y: 19, + width: 10, + height: 3, + }, + dur: 1, + value: 'aa', + startTs: 12, + pid: 2, + process: 'null', + itid: 12, + endItid: 13, + tid: 3, + startName: '23', + stepName: 'st', + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(AllAppStartupStruct.draw(ctx, data)).toBeUndefined(); + }); + it('ProcedureWorkerAllAppStartup02 ',()=>{ + let allAppStartupRender = new AllAppStartupRender() + let allAppStartupReq = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + appStartupContext: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + }; + window.postMessage = jest.fn(() => true); + expect(allAppStartupRender.renderMainThread(allAppStartupReq,new TraceRow())).toBeUndefined() + }) +}) \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts index a5a2fd3922daaa3a0b4bf75f9a881ff1d8fe6f11..776cc79e6ab8f300df6660d14d6a908a04b05265 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { AppStartupRender, AppStartupStruct, @@ -21,6 +19,9 @@ import { jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { + return {}; +}); describe('ProcedureWorkerAppStartup Test', () => { it('AppStartupStructTest01', () => { @@ -55,15 +56,4 @@ describe('ProcedureWorkerAppStartup Test', () => { it('AppStartupStructTest03', () => { expect(AppStartupStruct).not.toBeUndefined(); }); - it('AppStartupStructTest04', () => { - let canvas = document.createElement('canvas') as HTMLCanvasElement; - let context = canvas.getContext('2d'); - const data = { - useCache: true, - appStartupContext: context, - type: '', - }; - 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 258df5b82d6b11200d5f616838113561853530b2..df42f1bd03e71e64707ec986d1a08bb72b8d6db6 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCPU.test.ts @@ -16,14 +16,10 @@ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { - cpu, CpuStruct, CpuRender, - rtCpu, EmptyRender, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerCPU'; -import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; -import { drawWakeUp } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; +} from '../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU'; jest.mock('../../../../src/trace/component/trace/timer-shaft/RangeRuler', () => { return {}; @@ -31,7 +27,9 @@ jest.mock('../../../../src/trace/component/trace/timer-shaft/RangeRuler', () => jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe(' Test', () => { const dataSource = { frame: { @@ -52,13 +50,13 @@ describe(' Test', () => { const data = { frame: { - x: 203, - y: 203, - width: 100, - height: 100, + x: 205, + y: 205, + width: 101, + height: 101, }, - startNS: 200, - value: 50, + startNS: 201, + value: 51, }; expect(CpuStruct.draw(ctx, data)).toBeUndefined(); }); @@ -238,56 +236,7 @@ describe(' Test', () => { window.postMessage = jest.fn(() => true); expect(emptyRender.render(req, [], [])).toBeUndefined(); }); - it('CPUTest11', function () { - let cpuRender = new CpuRender(); - let cpuReq = { - lazyRefresh: true, - type: '1', - startNS: 1, - endNS: 4, - totalNS: 3, - frame: { - x: 334, - y: 442, - width: 230, - height: 330, - }, - useCache: false, - range: { - refresh: '', - }, - canvas: 'a', - context: { - font: '11px sans-serif', - fillStyle: '#221786', - globalAlpha: 0.6, - closePath: jest.fn(() => true), - beginPath: jest.fn(() => true), - stroke: jest.fn(() => true), - measureText: jest.fn(() => true), - clearRect: jest.fn(() => true), - fillText: jest.fn(() => true), - fillRect: jest.fn(() => true), - }, - lineColor: '#112d7d', - isHover: '', - hoverX: 1, - params: '', - wakeupBean: undefined, - flagMoveInfo: '', - flagSelectedInfo: '', - slicesTime: 1113, - id: 111, - x: 212, - y: 2230, - width: 156, - height: 600, - }; - window.postMessage = jest.fn(() => true); - expect(cpuRender.render(cpuReq, [], [])).toBeUndefined(); - }); - it('CPUTest12', function () { let emptyRender = new EmptyRender(); let canvas = document.createElement('canvas') as HTMLCanvasElement; let context = canvas.getContext('2d'); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts index 17e1325c55a1a54d127474154d95090a4f818371..be638bfd0015345374abdf051911f968a25d6e9d 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts @@ -19,7 +19,9 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); import { ClockStruct, ClockRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerClock'; - +jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { + return {}; +}); describe('ProcedureWorkerClock Test', () => { it('ProcedureWorkerClock01', () => { const canvas = document.createElement('canvas'); @@ -42,16 +44,4 @@ 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 d4833017d52cc7cd90cb496f5331d6cc7ad36db0..594a27708b9dae84fc1c601377d213fa1b5e6c2e 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCommon.test.ts @@ -13,13 +13,6 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerCPU', () => {}); -jest.mock('../../../../src/trace/component/trace/base/TraceSheet', () => {}); -jest.mock('../../../../src/trace/component/SpSystemTrace', () => { - return { - CurrentSlicesTime: () => {}, - }; -}); import { drawFlagLine, drawLines, @@ -55,10 +48,15 @@ declare global { TimeRange: string; //Set the timeline range }; }; + subscribeOnce(evt: string, fn: (b: any) => void): void; + clearTraceRowComplete(): void; + unsubscribe(evt: string, fn: (b: any) => void): void; + publish(evt: string, data: any): void; + subscribe(evt: string, fn: (b: any) => void): void; } } @@ -77,7 +75,19 @@ Window.prototype.subscribe = (ev, fn) => EventCenter.subscribe(ev, fn); Window.prototype.publish = (ev, data) => EventCenter.publish(ev, data); Window.prototype.subscribeOnce = (ev, data) => EventCenter.subscribeOnce(ev, data); Window.prototype.clearTraceRowComplete = () => EventCenter.clearTraceRowComplete(); - +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { + TraceRow:{ + range:{ + startNS: 64; + endNS: 25453; + totalNS: 333; + } + ; + } +}); describe('ProcedureWorkerCommon Test', () => { let rect = new Rect(); let fullData = [ @@ -106,7 +116,7 @@ describe('ProcedureWorkerCommon Test', () => { cpu: 0, dur: 69444, end_state: 'sR', - frame: { y: 15, height: 10, x: 13, width: 34 }, + frame: {y: 15, height: 10, x: 13, width: 34}, id: 4, name: 'test', priority: 23, @@ -127,16 +137,12 @@ describe('ProcedureWorkerCommon Test', () => { startNS: 20, endNS: 1000, totalNS: 2000, - frame: { x: 10, y: 10 }, + frame: {x: 10, y: 10}, paddingTop: 5, useCache: true, }; let timerShaftElement = document.createElement('timer-shaft-element'); - timerShaftElement.totalNS = 1000; - timerShaftElement.startNS = 1000; - timerShaftElement.endNS = 2000; - timerShaftElement.setRangeNS(1522, 5222); timerShaftElement.getBoundingClientRect = jest.fn(() => { return { width: 648, @@ -240,11 +246,11 @@ describe('ProcedureWorkerCommon Test', () => { }); it('ProcedureWorkerCommon26', function () { - expect(ns2x(10, 1, 0, 1, { width: 2 })).toBe(2); + expect(ns2x(10, 1, 0, 1, {width: 2})).toBe(2); }); it('ProcedureWorkerCommon27', function () { - expect(ns2x(-10, 1, 0, 1, { width: 2 })).toBe(0); + expect(ns2x(-10, 1, 0, 1, {width: 2})).toBe(0); }); it('ProcedureWorkerCommon28', function () { @@ -311,7 +317,7 @@ describe('ProcedureWorkerCommon Test', () => { cpu: 3, dur: 9031110, end_state: 'R', - frame: { y: 0, height: 60, x: 31, width: 3 }, + frame: {y: 0, height: 60, x: 31, width: 3}, id: 9, name: 'test', priority: 120, @@ -346,123 +352,30 @@ describe('ProcedureWorkerCommon Test', () => { startNS: 20, endNS: 1000, totalNS: 2000, - frame: { x: 10, y: 10 }, + frame: {x: 10, y: 10}, paddingTop: 5, useCache: false, }; let dataFilter = dataFilterHandler(fullData, filterData, condition); expect(dataFilter).toBeUndefined(); }); - - it('ProcedureWorkerCommon34', function () { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - const hoverFlag = { - x: 300, - y: 300, - width: 1300, - height: 1030, - time: 2550, - color: 'red', - selected: false, - text: 'test', - hidden: false, - type: 'type', - }; - const selectFlag = { - x: 180, - y: 180, - width: 800, - height: 80, - time: 258, - color: 'green', - selected: false, - text: 'test', - hidden: false, - type: 'type', - }; - TraceRow.range = { - startNS: 64, - endNS: 25453, - totalNS: 333, - }; - let data = { - sportRuler: { - slicesTimeList: [ - { - startTime: 11, - endTime: 22, - color: '#dadada', - }, - { - startTime: 33, - endTime: 66, - color: '#dadada', - }, - ], - }, - }; - expect( - drawFlagLineSegment( - ctx, - hoverFlag, - selectFlag, - { - y: 15, - height: 10, - x: 11, - width: 53, - }, - data - ) - ).toBeUndefined(); - }); - - it('ProcedureWorkerCommon35', function () { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const context = canvas.getContext('2d'); - let params = { - rangeSelect: true, - rangeSelectObject: { - startX: 71, - endX: 100, - startNS: 61, - endNS: 100, - }, - startNS: 401, - endNS: 190, - totalNS: 999, - frame: { - y: 3, - }, - }; - TraceRow.rangeSelectObject = { - startX: 125, - endX: 25226, - }; - expect(drawSelectionRange(context, params)).toBeUndefined(); - }); it('ProcedureWorkerCommon37', function () { const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; const context = canvas.getContext('2d'); let tm = { - getRange:jest.fn(()=>true), - getBoundingClientRect:jest.fn(()=>true), + getRange: jest.fn(() => true), + getBoundingClientRect: jest.fn(() => true), }; - expect(drawLinkLines(context,[],tm,true)).toBeUndefined(); + expect(drawLinkLines(context, [], tm, true)).toBeUndefined(); }); it('ProcedureWorkerCommon38', function () { const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; const context = canvas.getContext('2d'); - expect(drawString2Line(context,[],[],2,[],[])).toBeUndefined(); + expect(drawString2Line(context, [], [], 2, [], [])).toBeUndefined(); }); it('ProcedureWorkerCommon39', function () { const canvas = document.createElement('canvas'); @@ -470,9 +383,9 @@ describe('ProcedureWorkerCommon Test', () => { canvas.height = 1; const context = canvas.getContext('2d'); let wake = { - wakeupTime:23, + wakeupTime: 23, }; let frame = new Rect(20, 30, 10, 30); - expect(drawWakeUpList(context,wake,0,1000,1000,frame,true,undefined,false)).toBeUndefined(); + expect(drawWakeUpList(context, wake, 0, 1000, 1000, frame, true, undefined, false)).toBeUndefined(); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts index 825b8fd2ff3c96d2a9f9f1e34c29a0e347396b7f..d47b01747a97cd432b4b2eb7c56c57eca905cbbe 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuAbility.test.ts @@ -14,6 +14,7 @@ */ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; + jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); @@ -21,8 +22,11 @@ import { CpuAbilityMonitorStruct, CpuAbilityRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuAbility'; -import { dataFilterHandler } from "../../../../src/trace/database/ui-worker/ProcedureWorkerCommon"; +import { dataFilterHandler } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('CpuAbilityMonitorStruct Test', () => { const canvas = document.createElement('canvas'); canvas.width = 14; @@ -68,10 +72,10 @@ describe('CpuAbilityMonitorStruct Test', () => { dataList.push({ startNs: 0, dur: 10, - frame: { x: 0, y: 9, width: 10, height: 10 }, + frame: {x: 0, y: 9, width: 10, height: 10}, }); - dataList.push({ startNs: 1, dur: 111 }); - dataFilterHandler(dataList, [{ length: 0 }], { + dataList.push({startNs: 1, dur: 111}); + dataFilterHandler(dataList, [{length: 0}], { startKey: 'startNS', durKey: 'dur', startNS: TraceRow.range?.startNS ?? 0, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts index 327f6225966f70adcdf033eb763fcd57d3adbb05..35cf8a04eea90e50ff3f7256138a45e33868cb82 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits.test.ts @@ -21,9 +21,12 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { import { CpuFreqLimitRender, CpuFreqLimitsStruct, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuFreqLimits'; -import { dataFilterHandler } from "../../../../src/trace/database/ui-worker/ProcedureWorkerCommon"; +} from '../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCpuFreqLimits'; +import { dataFilterHandler } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerCpuFreqLimits Test', () => { let cpuFreqLimits = { frame: { @@ -133,7 +136,7 @@ describe('ProcedureWorkerCpuFreqLimits Test', () => { width: 100, height: 100, }; - expect(dataFilterHandler(req, [{ length: 0 }], { + expect(dataFilterHandler(req, [{length: 0}], { startKey: 'startNS', durKey: 'dur', startNS: TraceRow.range?.startNS ?? 0, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts index 5b14bd034b368cc0cd97dc7cd53f4897b76613a2..fdadc67f878f4ebb131b856311396280f0ac795b 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts @@ -23,7 +23,9 @@ import { jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerCpuProfiler Test', () => { let jsCpuProfilerRender = new JsCpuProfilerRender(); let traceRow = new TraceRow(); @@ -73,19 +75,19 @@ describe('ProcedureWorkerCpuProfiler Test', () => { it('JsCpuProfilerStructTest01', () => { const data = { - cpu: 1, - startNs: 1, - value: 1, frame: { x: 20, y: 20, - width: 100, - height: 100, + width: 101, + height: 101, }, + filterID: 2, + startNs: 1, + value: 1, maxValue: undefined, startTime: 1, - filterID: 2, size: 102, + cpu: 1, }; const canvas = document.createElement('canvas'); canvas.width = 1; diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts index 2b966b77e563ef7b3b95a6136d513febf6f9f22f..d960124504fd3bf19ad72d1612fea0f78dff37a5 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuState.test.ts @@ -22,8 +22,10 @@ import { CpuStateRender, CpuStateStruct, cpuState, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerCpuState'; - +} from '../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCpuState'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerCpuState Test', () => { it('ProcedureWorkerCpuStateTest01', function () { let node = { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts index 9b4d601b71be46b58c17da580a080d276086cba3..03e2e19d11756390c95ba79607d28222419c9e68 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerDiskIoAbility.test.ts @@ -23,8 +23,9 @@ import { diskIoAbility, DiskIoAbilityRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerDiskIoAbility'; -import { Rect } from '../../../src/trace/database/ProcedureWorkerCommon'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerDiskIoAbility Test', () => { const canvas = document.createElement('canvas'); canvas.width = 6; @@ -139,7 +140,7 @@ describe('ProcedureWorkerDiskIoAbility Test', () => { height: 100, }; window.postMessage = jest.fn(() => true); - expect(diskIoAbilityRender.render(diskIoReq, [], [])).toBeUndefined(); + expect(diskIoAbilityRender.renderMainThread(diskIoReq, new TraceRow())).toBeUndefined(); }); it('CpuAbilityMonitorStructTest05', function () { let diskIoAbilityRender = new DiskIoAbilityRender(); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts index 582678d2b17260f7756b6c27d9f72dac2b12b561..9ba7a01bfcea7b4801d8fac69d955338eb9210c2 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts @@ -13,10 +13,17 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; + +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - import { EnergyPowerStruct, EnergyPowerRender, @@ -53,6 +60,10 @@ describe('ProcedureWorkerEnergyPower Test', () => { let row = { frame: 20 }; EnergyPowerStruct.drawHistogram = jest.fn(() => true); EnergyPowerStruct.drawPolyline = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range!.startNS = jest.fn(() => 0); + TraceRow.range!.endNS = jest.fn(() => 27763331331); + TraceRow.range!.totalNS = jest.fn(() => 27763331331); expect(EnergyPowerStruct.draw(req, 3, data, row)).toBeUndefined(); }); @@ -135,58 +146,6 @@ describe('ProcedureWorkerEnergyPower Test', () => { }); it('ProcedureWorkerEnergyPowerTest14', function () { - let energyPowerRender = new EnergyPowerRender(); - let energyPowerReq = { - lazyRefresh: true, - type: '', - startNS: 1, - endNS: 8, - totalNS: 7, - frame: { - x: 90, - y: 20, - width: 1011, - height: 100, - }, - useCache: false, - range: { - refresh: '', - }, - canvas: 'c', - context: { - font: '10px sans-serif', - fillStyle: '#ec407a', - globalAlpha: 0.8, - canvas: { - clientWidth: 14, - }, - clearRect: jest.fn(() => true), - beginPath: jest.fn(() => true), - stroke: jest.fn(() => true), - fillRect: jest.fn(() => false), - closePath: jest.fn(() => true), - measureText: jest.fn(() => true), - fillText: jest.fn(() => true), - }, - lineColor: '#ffffff', - isHover: '', - hoverX: 1, - params: '21', - wakeupBean: undefined, - flagMoveInfo: '', - flagSelectedInfo: '', - slicesTime: 5, - id: 1, - x: 20, - y: 20, - width: 80, - height: 80, - }; - window.postMessage = jest.fn(() => true); - expect(energyPowerRender.render(energyPowerReq, [], [])).toBeUndefined(); - }); - - it('ProcedureWorkerEnergyPowerTest15', function () { let frame = { x: 50, y: 33, @@ -204,7 +163,7 @@ describe('ProcedureWorkerEnergyPower Test', () => { power(energyPowerDataList, [{ length: 1 }], 1, 3, 2, frame, true, ''); }); - it('ProcedureWorkerEnergyPowerTest16', function () { + it('ProcedureWorkerEnergyPowerTest15', function () { let frame = { x: 98, y: 90, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts index 1aa2d20c3006be57e7ede85b13d0ea25a3900c02..b02e6fc8025bd3d2481e0665ba3bd3c8b27aa543 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyState.test.ts @@ -13,17 +13,27 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - import { state, EnergyStateStruct, EnergyStateRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergyState'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerEnergyState Test', () => { + let energyStateRender: EnergyStateRender; + beforeEach(() => { + energyStateRender = new EnergyStateRender(); + }); + afterEach(() => { + jest.resetAllMocks(); + }); it('ProcedureWorkerEnergyStateTest01', function () { let frame = { x: 40, @@ -36,10 +46,10 @@ describe('ProcedureWorkerEnergyState Test', () => { startNS: 0, dur: 20, length: 51, - frame: { x: 0, y: 9, width: 105, height: 110 }, + frame: {x: 0, y: 9, width: 105, height: 110}, }); - energyStateDataList.push({ startNS: 1, dur: 42, length: 32 }); - state(energyStateDataList, [{ length: 1 }], 1, 3, 2, frame, true); + energyStateDataList.push({startNS: 1, dur: 42, length: 32}); + state(energyStateDataList, [{length: 1}], 1, 3, 2, frame, true); }); it('ProcedureWorkerEnergyStateTest02', function () { @@ -54,18 +64,21 @@ describe('ProcedureWorkerEnergyState Test', () => { startNS: 0, dur: 10, length: 15, - frame: { x: 50, y: 59, width: 177, height: 70 }, + frame: {x: 50, y: 59, width: 177, height: 70}, }); - energyStateDataList.push({ startNS: 15, dur: 23, length: 17 }); - state(energyStateDataList, [{ length: 0 }], 1, 3, 2, frame, false); + energyStateDataList.push({startNS: 15, dur: 23, length: 17}); + state(energyStateDataList, [{length: 0}], 1, 3, 2, frame, false); }); it('ProcedureWorkerEnergyStateTest03', function () { const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; - const ctx = canvas.getContext('2d'); - + const ctx = { + globalAlpha: 0.5, + fillStyle: '#666666', + fillRect: jest.fn(() => true), + }; const data = { type: '', value: 0, @@ -113,7 +126,7 @@ describe('ProcedureWorkerEnergyState Test', () => { }); it('ProcedureWorkerEnergyStateTest12', function () { - let energyStateRender = new EnergyStateRender(); + let row = new TraceRow(); let energyStateReq = { lazyRefresh: true, type: '', @@ -147,10 +160,10 @@ describe('ProcedureWorkerEnergyState Test', () => { stroke: jest.fn(() => true), closePath: jest.fn(() => true), beginPath: jest.fn(() => true), - arc:jest.fn(() => true), - fill:jest.fn(() => true), - moveTo:jest.fn(() => true), - lineTo:jest.fn(() => true), + arc: jest.fn(() => true), + fill: jest.fn(() => true), + moveTo: jest.fn(() => true), + lineTo: jest.fn(() => true), }, lineColor: '#1a4dff', isHover: '', @@ -173,6 +186,8 @@ describe('ProcedureWorkerEnergyState Test', () => { }, }; window.postMessage = jest.fn(() => true); - expect(energyStateRender.render(energyStateReq, [{}], [])).toBeUndefined(); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(energyStateRender.renderMainThread(energyStateReq, row)).toBeUndefined(); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts index 478b9420b21f4c2320ad17f5f0341db658701e3f..bf4f8a8d840739c81d753166410cc6556ceec1ca 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergySystem.test.ts @@ -189,64 +189,4 @@ describe('ProcedureWorkerEnergySystem Test', () => { }; expect(EnergySystemStruct.setSystemFrame(node, 1, 1, 3, 2, frame)).toBeUndefined(); }); - - it('ProcedureWorkerEnergyStateTest10', function () { - let energySystemRender = new EnergySystemRender(); - let energySystemReq = { - lazyRefresh: true, - type: '', - startNS: 1, - endNS: 22, - totalNS: 21, - frame: { - x: 23, - y: 30, - width: 190, - height: 960, - }, - useCache: false, - range: { - refresh: '', - }, - canvas: 'sd', - context: { - font: '11px sans-serif', - fillStyle: '#320011', - globalAlpha: 0.6, - height: 50, - width: 100, - canvas: { - clientWidth: 10, - }, - beginPath: jest.fn(() => true), - clearRect: jest.fn(() => true), - stroke: jest.fn(() => true), - fillText: jest.fn(() => true), - closePath: jest.fn(() => true), - fillRect: jest.fn(() => false), - measureText: jest.fn(() => []), - }, - lineColor: '#655f01', - isHover: '', - hoverX: 31, - wakeupBean: undefined, - flagMoveInfo: '', - flagSelectedInfo: '', - slicesTime: 39, - id: 98, - x: 80, - y: 80, - width: 400, - height: 140, - params: { - isLive: true, - maxHeight: 20, - dpr: 21, - hoverFuncStruct: '', - selectFuncStruct: undefined, - }, - }; - window.postMessage = jest.fn(() => true); - expect(energySystemRender.render(energySystemReq, [{}], [])).toBeUndefined(); - }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts index c7de66d3ed4a74da48da0a69f379e7c8e245e3ae..53823ade6adb8b733ea1f8ee1bcf85ee40163292 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFPS.test.ts @@ -30,7 +30,7 @@ describe(' FPSTest', () => { dataList.push({ startTime: 0, dur: 10, - frame: { x: 0, y: 9, width: 10, height: 10 }, + frame: { x: 0, y: 10, width: 10, height: 10 }, }); dataList.push({ startTime: 1, dur: 111 }); let rect = new Rect(0, 10, 10, 10); @@ -113,61 +113,4 @@ describe(' FPSTest', () => { }; expect(FpsStruct.draw(ctx, Sourcedate)).toBeUndefined(); }); - - it('FpsTest06', function () { - let fpsRender = new FpsRender(); - let fpsReq = { - lazyRefresh: true, - type: '', - startNS: 1, - endNS: 32, - totalNS: 31, - frame: { - x: 54, - y: 50, - width: 133, - height: 133, - }, - useCache: false, - range: { - refresh: '', - }, - canvas: 'a', - context: { - font: '12px sans-serif', - fillStyle: '#af919b', - globalAlpha: 0.56, - height: 120, - width: 100, - clearRect: jest.fn(() => true), - beginPath: jest.fn(() => true), - measureText: jest.fn(() => true), - closePath: jest.fn(() => true), - fillRect: jest.fn(() => []), - fillText: jest.fn(() => true), - stroke: jest.fn(() => true), - }, - lineColor: '', - isHover: '', - hoverX: 21, - wakeupBean: undefined, - flagMoveInfo: '', - flagSelectedInfo: '', - slicesTime: 34, - id: 1, - x: 220, - y: 203, - width: 1030, - height: 890, - params: { - isLive: false, - maxHeight: 52, - dpr: 41, - hoverFuncStruct: '', - selectFuncStruct: undefined, - }, - }; - window.postMessage = jest.fn(() => true); - expect(fpsRender.render(fpsReq, [], [])).toBeUndefined(); - }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts index be86a765d4d7608a4ac0d8c585b7b0ab67dd8086..3ca0e8240dfb04adfc6ded27419310a62e11baf7 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameAnimation.test.ts @@ -22,6 +22,9 @@ import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { FrameAnimationStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFrameAnimation'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('FrameAnimation Test', () => { let frameAnimationRender = new FrameAnimationRender(); let rect = new Rect(341, 2, 10, 10); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts index 3c5ba8dd75093cd934fa76a350bb0b9cfcadcb7d..37162b44433657c5232ce645aefc2dedd0583298 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameDynamic.test.ts @@ -24,7 +24,9 @@ import { import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { AnimationRanges } from '../../../../src/trace/bean/FrameComponentBean'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('FrameDynamic Test', () => { let frameDynamicRender = new FrameDynamicRender(); let rect = new Rect(341, 2, 10, 10); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts index abf1f9df4a0d8a09f69f86530c5c1e587f3df28b..5f8fb75643963c8e87461b7e83e0150ca08abea0 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFrameSpacing.test.ts @@ -16,7 +16,9 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { FrameSpacingRender, @@ -74,19 +76,19 @@ describe('FrameSpacing Test', () => { y: 4, }, { + frameSpacingResult: 0.1, + groupId: 11095334538, currentFrameHeight: 2755, currentFrameWidth: 1340, currentTs: 11640114746, frame: new Rect(), - frameSpacingResult: 0.1, - groupId: 11095334538, + x: 0, + y: 4, id: 710, nameId: 'test', preFrameHeight: 2753, preFrameWidth: 1339, preTs: 11629160579, - x: 0, - y: 4, }, ]; it('FrameSpacingTest01', function () { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts index 9629dc53b04eee0b339057ae9122af7946ae53cf..0c2d16d19c0d1fe21d2a2681b9a96047dd895473 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts @@ -20,7 +20,9 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { }); import { CpuFreqStruct, FreqRender, freq } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFreq'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('freqTest', () => { it('freqTest01', () => { const canvas = document.createElement('canvas'); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFreqExtend.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFreqExtend.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..db724599d15e5f95a6bf502b9eda6c4bb04cec4b --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFreqExtend.test.ts @@ -0,0 +1,100 @@ +/* + * 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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { + CpuFreqExtendStruct, + FreqExtendRender +} from '../../../../src/trace/database/ui-worker/ProcedureWorkerFreqExtend'; +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerFreqExtend Test',()=>{ + it('ProcedureWorkerFreqExtendTest01 ', function () { + const data = { + frame: { + x: 20, + y: 19, + width: 10, + height: 3, + }, + dur: 1, + value: 'aa', + startTs: 12, + pid: 2, + process: 'null', + itid: 12, + endItid: 13, + tid: 3, + startName: '23', + stepName: 'st', + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(CpuFreqExtendStruct.draw(ctx,data)).toBeUndefined() + }); + it('ProcedureWorkerFreqExtendTest02 ', function () { + let freqExtendRender = new FreqExtendRender(); + let freqReq = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + }; + window.postMessage = jest.fn(() => true); + expect(freqExtendRender.renderMainThread(freqReq,new TraceRow())) + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts index 8e7fd5d29a1f97748729498dab676033883886c9..d8dc66381a77cc204ea2b6994e4f7cd9561dcf75 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts @@ -20,7 +20,9 @@ jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { import { func, FuncStruct, FuncRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFunc'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { markAsUntransferable } from 'worker_threads'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe(' ProcedureWorkerFuncTest', () => { it('FuncTest01', () => { let funcDataList = new Array(); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts index b84d5707bd7fd1042dccb474ed077000964905ac..2d304722923aae986c4eda75a419f121f906cfd1 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeap.test.ts @@ -24,7 +24,9 @@ import { HeapRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHeap'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe(' Test', () => { it('HeapTest01', () => { let heapDataList = new Array(); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts index 7d583cb4632f45f86d8b85ed0532c86e686f92a9..276c2dc2cc2b006fc2c0d01dac791738353e5179 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapSnapshot.test.ts @@ -23,7 +23,9 @@ import { jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerHeapTimeline Test', () => { it('HeapSnapshotTest', () => { const canvas = document.createElement('canvas'); @@ -33,34 +35,34 @@ describe('ProcedureWorkerHeapTimeline Test', () => { let dataList = new Array(); dataList.push({ startTime: 0, - dur: 10, frame: { x: 0, y: 9, width: 10, height: 10 }, + dur: 10, }); dataList.push({ startTime: 1, dur: 111 }); let rect = new Rect(0, 10, 10, 10); let filter = [ { + frame: { x: 0, y: 0, width: 25, height: 40 }, end_time: 50, end_ts: 1520000, file_name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 40 }, + start_ts: 88473061693464, + start_time: 0, 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 }, pid: 4243, start_time: 0, start_ts: 88473061693464, textMetricsWidth: 50.5810546875, - file_name: 'Snapshot0', - frame: { x: 0, y: 0, width: 6222, height: 62222 }, + end_time: 50, + end_ts: 1520000, id: 0, }, ]; diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts index 1b06e6c1d5a0ca532976c85c0446411749f86f84..bde9a9e9ea67cb3b9067bd9580afd1b89c4bd265 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts @@ -13,19 +13,18 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow.js'; import { HiPerfCpuStruct, - HiperfCpuRender, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiPerfCPU'; + HiperfCpuRender2, +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfCPU2'; import { hiPerf } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerHiPerfCPU Test', () => { let frame = { x: 0, @@ -92,20 +91,20 @@ describe('ProcedureWorkerHiPerfCPU Test', () => { }, lineColor: '', isHover: '', - hoverX: 1, params: '', wakeupBean: undefined, flagMoveInfo: '', + width: 100, flagSelectedInfo: '', slicesTime: 3, id: 1, x: 20, y: 20, - width: 100, height: 100, scale: 100_000_001, + hoverX: 1, }; - let hiperfCpuRender = new HiperfCpuRender(); + let hiperfCpuRender = new HiperfCpuRender2(); window.postMessage = jest.fn(() => true); expect(hiperfCpuRender.render(req, [], [], [])).toBeUndefined(); }); @@ -113,11 +112,60 @@ describe('ProcedureWorkerHiPerfCPU Test', () => { let dataList = new Array(); dataList.push({ startNS: 0, - dur: 10, length: 1, frame: { x: 0, y: 9, width: 10, height: 10 }, + dur: 10, }); dataList.push({ startNS: 1, dur: 2, length: 1 }); hiPerf(dataList, [{ length: 0 }], dataList, 8, 3, '', true, 1, true); }); + it('ProcedureWorkerHiPerfCPUTest09 ', function () { + let req = { + lazyRefresh: true, + type: 'a', + startNS: 1, + endNS: 1, + totalNS: 1, + frame: { + x: 20, + y: 20, + width: 100, + height: 300, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#ec407a', + globalAlpha: 0.7, + fill: jest.fn(() => true), + 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: '', + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + width: 100, + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 20, + y: 20, + height: 100, + scale: 100_000_001, + hoverX: 1, + }; + let hiperfCpuRender = new HiperfCpuRender2(); + window.postMessage = jest.fn(() => true); + expect(hiperfCpuRender.renderMainThread(req,new TraceRow())) + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e48a7959683d454a589e52af1f2b025653a4a604 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.test.ts @@ -0,0 +1,133 @@ +/* + * 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 { + HiPerfCallChartRender, + HiPerfCallChartStruct +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfCallChart'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow.js'; + +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerHiPerfCallChart Test',()=>{ + it('ProcedureWorkerHiPerfCallChartTest01 ', function () { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + const data = { + frame: { + x: 120, + y: 120, + width: 100, + height: 100, + }, + id: 21, + ts: 254151, + dur: 1201, + name: '1583', + depth: 6, + jank_tag: true, + cmdline: 'render.test', + type: '0', + pid: 21, + frame_type: 'render_service', + src_slice: '5', + rs_ts: 3, + rs_vsync: '2561', + rs_dur: 965, + rs_pid: 320, + rs_name: 'name', + gpu_dur: 102, + }; + expect(HiPerfCallChartStruct.draw(ctx,data)).toBeUndefined() + }); + it('ProcedureWorkerHiPerfCallChartTest02 ', function () { + let node = { + frame: { + x: 65, + y: 20, + width: 99, + height: 330, + }, + startNS: 200, + length: 1, + height: 90, + startTime: 0, + dur: 31, + }; + let frame= { + x: 65, + y: 20, + width: 99, + height: 330, + } + expect(HiPerfCallChartStruct.setPerfFrame(node,1,2,3,frame)).toBeUndefined() + }); + it('ProcedureWorkerHiPerfCallChartTest03', function () { + let hiPerfCallChartRender = new HiPerfCallChartRender(); + const hiPerfCallReq = { + lazyRefresh: true, + type: '', + startNS: 2, + endNS: 45, + totalNS: 43, + frame: { + x: 130, + y: 210, + width: 200, + height: 120, + }, + useCache: false, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '11px sans-serif', + fillStyle: '#408dec', + globalAlpha: 0.29, + clearRect: jest.fn(() => true), + fillRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => []), + fillText: jest.fn(() => true), + }, + lineColor: '#d90606', + isHover: '', + hoverX: 2, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 3, + id: 1, + x: 66, + y: 66, + width: 100, + height: 101, + }; + TraceRow.range = jest.fn(() => true); + TraceRow.range!.startNS = jest.fn(() => 0); + TraceRow.range!.endNS = jest.fn(() => 27763331331); + TraceRow.range!.totalNS = jest.fn(() => 27763331331); + expect(hiPerfCallChartRender.renderMainThread(hiPerfCallReq,new TraceRow())).toBeUndefined() + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts index 532750427b4b6d2303250b8e626a77904eab0bf0..d456b6c4ca6738a06fadb5cabf6b321724edf450 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfEvent.test.ts @@ -15,7 +15,7 @@ import { HiPerfEventStruct, HiperfEventRender, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiPerfEvent'; +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfEvent'; import { hiPerf } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { @@ -130,15 +130,15 @@ describe('ProcedureWorkerHiPerfEvent Test', () => { stroke: jest.fn(() => true), closePath: jest.fn(() => true), }, - lineColor: '', isHover: '', hoverX: 1, + id: 1, params: '', wakeupBean: undefined, flagMoveInfo: '', flagSelectedInfo: '', slicesTime: 3, - id: 1, + lineColor: '', x: 20, y: 20, width: 100, @@ -151,10 +151,10 @@ describe('ProcedureWorkerHiPerfEvent Test', () => { it('ProcedureWorkerHiPerfEventTest09', function () { let dataList = new Array(); dataList.push({ - startNS: 0, - dur: 10, length: 1, + dur: 10, frame: { x: 0, y: 9, width: 10, height: 10 }, + startNS: 0, }); 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 02b4b4fdb2a868f58f218429242bd3c39a28d970..0ad78aab2402cb666b50ba3511807d42e1c6a2fd 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfProcess.test.ts @@ -19,10 +19,12 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { }); import { HiPerfProcessStruct, - HiperfProcessRender, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiPerfProcess'; + HiperfProcessRender2, +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfProcess2'; import { hiPerf } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerHiPerfProcess Test', () => { it('ProcedureWorkerHiPerfProcessTest01', () => { const data = { @@ -69,7 +71,7 @@ describe('ProcedureWorkerHiPerfProcess Test', () => { }); it('ProcedureWorkerHiPerfProcessTest05', function () { - let hiperfProcessRender = new HiperfProcessRender(); + let hiperfProcessRender = new HiperfProcessRender2(); let hiperfProcessReq = { lazyRefresh: true, type: '', @@ -119,7 +121,7 @@ describe('ProcedureWorkerHiPerfProcess Test', () => { expect(hiperfProcessRender.render(hiperfProcessReq, [], [], [])).toBeUndefined(); }); it('ProcedureWorkerHiPerfProcessTest06', function () { - let hiperfProcessRender = new HiperfProcessRender(); + let hiperfProcessRender = new HiperfProcessRender2(); let canvas = document.createElement('canvas') as HTMLCanvasElement; let context = canvas.getContext('2d'); const data = { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts index d0727add721a4647adea09b930afedc903b1ad67..ed43c88775d7a1102486ba574c4cdfee49af16c7 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfReport.test.ts @@ -21,9 +21,9 @@ import { HiPerfReport, HiPerfReportStruct, HiperfReportRender, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiPerfReport'; +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfReport'; import { Rect } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; -import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; + describe('ProcedureWorkerHiPerfReport Test', () => { it('ProcedureWorkerHiPerfReportTest01', () => { @@ -212,18 +212,18 @@ describe('ProcedureWorkerHiPerfReport Test', () => { measureText: jest.fn(() => true), }, lineColor: '', - isHover: '', hoverX: 1, params: '', - wakeupBean: undefined, + isHover: '', flagMoveInfo: '', + height: 100, flagSelectedInfo: '', slicesTime: 3, id: 1, x: 20, y: 20, width: 100, - height: 100, + wakeupBean: undefined, scale: 100_000_001, }; window.postMessage = jest.fn(() => true); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts index 704044f709a792079af68d3df21e67dfc9ef6a10..ccb85beaeb7c72bfc85301e24df8743c884bd51e 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfThread.test.ts @@ -19,11 +19,13 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); import { - HiperfThreadRender, + HiperfThreadRender2, HiPerfThreadStruct, -} from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiPerfThread'; +} from '../../../../src/trace/database/ui-worker/hiperf/ProcedureWorkerHiPerfThread2'; import { hiPerf } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerHiPerfThread Test', () => { let res = [ { @@ -94,7 +96,7 @@ describe('ProcedureWorkerHiPerfThread Test', () => { }); it('ProcedureWorkerHiPerfThreadTest05', function () { - let hiperfThreadRender = new HiperfThreadRender(); + let hiperfThreadRender = new HiperfThreadRender2(); let hiperfThreadReq = { lazyRefresh: true, type: '', @@ -165,7 +167,7 @@ describe('ProcedureWorkerHiPerfThread Test', () => { expect(hiperfThreadRender.render(hiperfThreadReq, [], [], [])).toBeUndefined(); }); it('ProcedureWorkerHiPerfThreadTest06', function () { - let hiperfThreadRender = new HiperfThreadRender(); + let hiperfThreadRender = new HiperfThreadRender2(); window.postMessage = jest.fn(() => true); let canvas = document.createElement('canvas') as HTMLCanvasElement; let context = canvas.getContext('2d'); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiSysEvent.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiSysEvent.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c916518458d7015807ab77dbf3b2d40ccf37f8a --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHiSysEvent.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. + */ +import { HiSysEventStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHiSysEvent'; +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerHiSysEvent Test',()=>{ + it('ProcedureWorkerHiSysEventTest01 ', function () { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + const data = { + frame: { + x: 120, + y: 120, + width: 100, + height: 100, + }, + id: 21, + ts: 254151, + dur: 1201, + name: '1583', + depth: 6, + jank_tag: true, + cmdline: 'render.test', + type: '0', + pid: 21, + frame_type: 'render_service', + src_slice: '5', + rs_ts: 3, + rs_vsync: '2561', + rs_dur: 965, + rs_pid: 320, + rs_name: 'name', + gpu_dur: 102, + }; + expect(HiSysEventStruct.draw(ctx,data)).toBeUndefined() + }); + it('ProcedureWorkerHiSysEventTest02 ', function () { + let node = { + frame: { + x: 65, + y: 20, + width: 99, + height: 330, + }, + startNS: 200, + length: 1, + height: 90, + startTime: 0, + dur: 31, + }; + let frame= { + x: 65, + y: 20, + width: 99, + height: 330, + } + expect(HiSysEventStruct.setSysEventFrame(node,1,2,3,frame)).toBeUndefined() + }); +}) \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHitchTime.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHitchTime.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e15157ba116d386a87cecc62158894180fd547eb --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHitchTime.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. + */ + +import { HitchTimeStruct, hitchTimeRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHitchTime'; +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; + +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerHitchTime Test', () => { + it('ProcedureWorkerHitchTimeTest01 ', function () { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + const data = { + frame: { + x: 10, + y: 10, + width: 110, + height: 10, + }, + }; + expect(HitchTimeStruct.draw(ctx, data)).toBeUndefined(); + }); + it('ProcedureWorkerHitchTimeTest02 ', function () { + let hitchRender = new hitchTimeRender(); + let hitchReq = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + appStartupContext: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + } + window.postMessage = jest.fn(() => true); + expect(hitchRender.renderMainThread(hitchReq,new TraceRow())).toBeUndefined() + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts index e864ae8bd738252f1e31734ad1d4981552abe9fb..6e018a343c7472ba073c3f4cddc8784a622c2dc1 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerIrq.test.ts @@ -13,12 +13,11 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { IrqRender, IrqStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerIrq'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { return {}; }); - -import { IrqRender, IrqStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerIrq'; - describe('ProcedureWorkerIrq Test', () => { it('ProcedureWorkerIrq01', () => { const canvas = document.createElement('canvas'); @@ -63,4 +62,54 @@ describe('ProcedureWorkerIrq Test', () => { ) ).toBeUndefined(); }); + it('ProcedureWorkerIrq03', () => { + let irqRender = new IrqRender(); + let req = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 170, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'b', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.5, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + }; + window.postMessage = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(irqRender.renderMainThread(req,new TraceRow())); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerJank.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerJank.test.ts index 5b65e811c9caccf9fbcf027657feafc972661e34..77424e27c24314320314fa2fa97b6f0a498b9b10 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerJank.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerJank.test.ts @@ -14,12 +14,12 @@ */ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { jank, JankRender, JankStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerJank'; -import { ColorUtils } from '../../../../src/trace/component/trace/base/ColorUtils'; - jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerJank Test', () => { const jankData = { frame: { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerLTPO.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerLTPO.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9821d6b26df22c4f1a05a8a436cacf85c3abbac --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerLTPO.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. + */ + +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +import { LtpoRender, LtpoStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerLTPO'; + +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('ProcedureWorkerLTPO Test', () => { + it('ProcedureWorkerLTPOTest01 ', function () { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + const data = { + frame: { + x: 10, + y: 10, + width: 110, + height: 10, + }, + }; + expect(LtpoStruct.draw(ctx, data)).toBeUndefined(); + }); + it('ProcedureWorkerLTPOTest02 ', function () { + let ltpoRender = new LtpoRender(); + let ltpoReq = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + appStartupContext: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + } + window.postMessage = jest.fn(() => true); + expect(ltpoRender.renderMainThread(ltpoReq,new TraceRow())).toBeUndefined() + }); +}); \ No newline at end of file diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerLog.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerLog.test.ts index ece7ce4a2b2f0db13cc593be9647a15d281c06a0..01366b4bd533ab77d1ec3beec68d25aacea659fb 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerLog.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerLog.test.ts @@ -12,12 +12,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); import { LogStruct, LogRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerLog'; describe('ProcedureWorkerLog Test', () => { @@ -25,89 +33,98 @@ describe('ProcedureWorkerLog Test', () => { canvas.width = 12; canvas.height = 12; const ctx = canvas.getContext('2d'); + let data = { + id: 5230, + startTs: 27351020209, + level: 'E', + depth: 3, + tag: 'C01510/BinderInvoker1', + context: '124: SendRequest: handle=0 result = 2', + time: 15020293020884055, + pid: 577, + tid: 967, + processName: 'distributeddata', + dur: 1, + frame: { + x: 1385, + y: 22, + width: 1, + height: 7, + }, + }; it('ProcedureWorkerLog01', () => { - let data = { - id: 5230, - startTs: 27351020209, - level: 'E', - depth: 3, - tag: 'C01510/BinderInvoker1', - context: '124: SendRequest: handle=0 result = 2', - time: 15020293020884055, - pid: 577, - tid: 967, - processName: 'distributeddata', - dur: 1, - frame: { - x: 1385, - y: 22, - width: 1, - height: 7, - }, - }; expect(LogStruct.draw(ctx!, data)).toBeUndefined(); }); - it('ProcedureWorkerLog02', () => { - let data = { - id: 36, - startTs: 76402676, - level: 'W', - depth: 2, - tag: 'C01300/AbilityManagerService2', - context: '[ability_manager_service.cpp(UpdateCallerInfo:6178)]UpdateCallerInfo.', - time: 15020292748137880, - pid: 559, - tid: 559, - processName: 'foundation', - dur: 1, + let logRender = new LogRender(); + let logReq = { + lazyRefresh: true, + type: 'log', + startNS: 5, + endNS: 9, + totalNS: 3, frame: { - x: 3, - y: 16, - width: 1, - height: 7, + x: 32, + y: 20, + width: 130, + height: 180, }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100 }; - expect(LogStruct.draw(ctx!, data)).toBeUndefined(); + window.postMessage = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(logRender.renderMainThread(logReq, new TraceRow())); }); - - it('ProcedureWorkerLog03', () => { - let data = { - id: 3, - startTs: 1, - level: 'I', - depth: 1, - tag: 'C02d0c/Hiprofiler1', - context: 'ParseTimeExtend: update ts with 0 to 337274', - time: 15020292747373852, - pid: 1119, - tid: 1172, - processName: 'hiprofiler_plug', - dur: 1, + it('ProcedureWorkerLog03 ', function () { + let logNode = { frame: { - x: 0, - y: 8, - width: 1, - height: 7, + x: 60, + y: 24, + width: 430, + height: 460, }, + startNS: 100, + value: 980, + startTs: 53, + dur: 21, + height: 222, }; - expect(LogStruct.draw(ctx!, data)).toBeUndefined(); - }); - - it('ProcedureWorkerLog04', () => { - let canvas = document.createElement('canvas') as HTMLCanvasElement; - let context = canvas.getContext('2d'); - let data = { - context: context!, - useCache: true, - type: 'logs', - traceRange: [], + let frame = { + x: 2, + y: 20, + width: 15, + height: 84, }; - TraceRow.range = jest.fn(() => true); - TraceRow.range!.startNS = jest.fn(() => 0); - TraceRow.range!.endNS = jest.fn(() => 27763331331); - TraceRow.range!.totalNS = jest.fn(() => 27763331331); - let logRender = new LogRender(); - expect(logRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + expect(LogStruct.setLogFrame(logNode,1,1,1,1,frame)).toBeUndefined() }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts index 4d1486dbc7668de84fb75075250ec14340a6b4de..624076d7c59e82fde63a48484e2cb47491f563f4 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerMem.test.ts @@ -13,22 +13,21 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { ProcessMemStruct, MemRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerMem'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { mem } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; - +jest.mock('../../../../src/trace/component/SpSystemTrace',()=>{ + return {} +}) describe(' Test', () => { - let frame = { - x: 0, - y: 9, - width: 10, - height: 10, - }; it('MemTest01', () => { + let frame = { + x: 0, + y: 9, + width: 10, + height: 10, + }; let memDataList = new Array(); memDataList.push({ startTime: 10, @@ -45,6 +44,12 @@ describe(' Test', () => { }); it('MemTest02', () => { + let frame = { + x: 0, + y: 9, + width: 10, + height: 10, + }; let memDataList = new Array(); memDataList.push({ startTime: 0, @@ -125,6 +130,10 @@ describe(' Test', () => { height: 100, }; window.postMessage = jest.fn(() => true); - expect(memRender.render(memReq, [], [])).toBeUndefined(); + TraceRow.range = jest.fn(() => true); + TraceRow.range!.startNS = jest.fn(() => 0); + TraceRow.range!.endNS = jest.fn(() => 27763331331); + TraceRow.range!.totalNS = jest.fn(() => 27763331331); + expect(memRender.renderMainThread(memReq,new TraceRow())).toBeUndefined(); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts index ceec00c883a0cb752d044853b628300a3af16002..e42618043532468bd95e9ef0a6e3adb2479cfbe7 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerMemoryAbility.test.ts @@ -22,7 +22,9 @@ import { MemoryAbilityMonitorStruct, MemoryAbilityRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerMemoryAbility'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerMemoryAbility Test', () => { let frame = { x: 0, @@ -117,7 +119,7 @@ describe('ProcedureWorkerMemoryAbility Test', () => { height: 140, }; window.postMessage = jest.fn(() => true); - expect(memoryAbilityRender.render(memoryAbilityReq, [], [])).toBeUndefined(); + expect(memoryAbilityRender.renderMainThread(memoryAbilityReq, new TraceRow())).toBeUndefined(); }); it('ProcedureWorkerMemoryAbilityTest04', function () { let memoryAbilityRender = new MemoryAbilityRender(); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts index 6d002720c2396904000424abb28061af1efb2a04..113fdc0a62ca188ee3ed683d361314ab19f578a4 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerNetworkAbility.test.ts @@ -23,7 +23,9 @@ import { NetworkAbilityMonitorStruct, NetworkAbilityRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerNetworkAbility'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerNetworkAbility Test', () => { const canvas = document.createElement('canvas'); canvas.width = 1; diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerPerfCallchains.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerPerfCallchains.test.ts index 597a98fff5d8f06b9d25ae110729ff881bf86dae..7db3da1d60c419f7d04336a0480c0994f67b8e41 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerPerfCallchains.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerPerfCallchains.test.ts @@ -14,7 +14,6 @@ */ import { - PerfCallChainThread, PerfCallChainPool, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerPerfCallchains'; diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts index 33cbc8690d86817530534bfca20f52c077247e69..919cd500722d040c18e8f54522e11a0024350f8a 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts @@ -16,7 +16,10 @@ jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); - +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); import { proc, ProcessStruct, @@ -112,53 +115,4 @@ describe(' ProcessTest', () => { }; expect(ProcessStruct.setFrame(node, 1, 1, 1, frame)).toBeUndefined(); }); - - it('ProcessTest06', function () { - let processRender = new ProcessRender(); - let processReq = { - lazyRefresh: true, - type: '', - startNS: 15, - endNS: 16, - totalNS: 1, - frame: { - x: 55, - y: 55, - width: 125, - height: 105, - }, - useCache: false, - range: { - refresh: '', - }, - canvas: 'a', - context: { - font: '11px sans-serif', - fillStyle: '#26e2c5', - globalAlpha: 0.7, - clearRect: jest.fn(() => true), - beginPath: jest.fn(() => false), - closePath: jest.fn(() => true), - measureText: jest.fn(() => true), - fillRect: jest.fn(() => true), - stroke: jest.fn(() => []), - fill: jest.fn(() => true), - }, - lineColor: '#a50101', - isHover: '', - hoverX: 34, - params: '', - wakeupBean: undefined, - flagMoveInfo: '', - flagSelectedInfo: '', - slicesTime: 55, - id: 1, - x: 20, - y: 20, - width: 123, - height: 123, - }; - window.postMessage = jest.fn(() => true); - expect(processRender.render(processReq, [], [])).toBeUndefined(); - }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerSnapshot.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerSnapshot.test.ts index ca7878d7031cb733de780c2f7c37eeeec5bb24e2..37fe05ce510ee8589eb535b4a7e6bddcf8dc84af 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerSnapshot.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerSnapshot.test.ts @@ -19,7 +19,9 @@ import { snapshot, SnapshotRender, SnapshotStruct} from '../../../../src/trace/d jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerSnapshot Test', () => { it('HeapSnapshotTest', () => { const snapshotCanvas = document.createElement('canvas'); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts index 44d413426ac8a9d74fee706f94f8b6c6a6af1d10..0222b8c94db2b894b13ad71c78170076e3aeebac 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerSoInit.test.ts @@ -14,114 +14,163 @@ */ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; -import { soDataFilter, SoRender, SoStruct} from '../../../../src/trace/database/ui-worker/ProcedureWorkerSoInit'; +import { soDataFilter, SoRender, SoStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerSoInit'; -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { - return {}; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; }); -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; }); - describe('ProcedureWorkerSoInit Test', () => { - it('soDataFilterTest', () => { - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - let rect = new Rect(0, 10, 10, 10); - let filter = [ - { - startTs: 520, - dur: 15400, - soName: 'Snapshot0', - tid: 0, - pid: 21, - depth: 5, - itid: 42, - textMetricsWidth: 52.875, - process: '' - }, - ]; - let list = [ - { - startTs: 32, - dur: 1320000, - soName: 'Snapshot1', - tid: 120, - pid: 213, - depth: 21, - itid: 22, - textMetricsWidth: 54.6875, - process: '' - }, - ]; - soDataFilter(list, filter, 100254, 100254, rect, { height: 40, width: 1407, x: 0, y: 0 },true); - }); + it('soDataFilterTest', () => { + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + let rect = new Rect(0, 10, 10, 10); + let filter = [ + { + startTs: 520, + dur: 15400, + soName: 'Snapshot0', + tid: 0, + pid: 21, + depth: 5, + itid: 42, + textMetricsWidth: 52.875, + process: '' + }, + ]; + let list = [ + { + startTs: 32, + dur: 1320000, + soName: 'Snapshot1', + tid: 120, + pid: 213, + depth: 21, + itid: 22, + textMetricsWidth: 54.6875, + process: '' + }, + ]; + soDataFilter(list, filter, 100254, 100254, rect, {height: 40, width: 1407, x: 0, y: 0}, true); + }); - it('SoStructTest01', () => { - const data = { - frame: { - x: 432, - y: 222, - width: 340, - height: 100, - }, - startTs: 50, - dur: 1544000, - soName: 'Snapshot0', - tid: 0, - pid: 4243, - depth: 6, - itid: 2, - textMetricsWidth: 55.75, - process: '' - }; - const canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - const ctx = canvas.getContext('2d'); - expect(SoStruct.draw(ctx, data)).toBeUndefined(); - }); + it('SoStructTest01', () => { + const data = { + frame: { + x: 432, + y: 222, + width: 340, + height: 100, + }, + startTs: 50, + dur: 1544000, + soName: 'Snapshot0', + tid: 0, + pid: 4243, + depth: 6, + itid: 2, + textMetricsWidth: 55.75, + process: '' + }; + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + expect(SoStruct.draw(ctx, data)).toBeUndefined(); + }); - it('SoStructTest02', () => { - const data = { - frame: { - x: 20, - y: 43, - width: 120, - height: 100, - }, - startTs: 50, - dur: 152500, - soName: 'Snapshot1', - tid: 240, - pid: 45, - depth: 35, - itid: 2, - textMetricsWidth: 66.650546875, - process: '' - }; - let node = { - frame: { - x: 20, - y: 90, - width: 100, - height: 500, - }, - startTs: 3200, - dur: 42000, - soName: 'Snapshot2', - tid: 240, - pid: 210, - depth: 10, - itid: 2, - textMetricsWidth: 96.2646875, - process: '' - }; - expect(SoStruct.setSoFrame(node, 2, 0, 1, 2, data)).toBeUndefined(); - }); - it('SoStructTest03', () => { - expect(SoStruct).not.toBeUndefined(); - }); + it('SoStructTest02', () => { + const data = { + frame: { + x: 20, + y: 43, + width: 120, + height: 100, + }, + startTs: 50, + dur: 152500, + soName: 'Snapshot1', + tid: 240, + pid: 45, + depth: 35, + itid: 2, + textMetricsWidth: 66.650546875, + process: '' + }; + let node = { + frame: { + x: 20, + y: 90, + width: 100, + height: 500, + }, + startTs: 3200, + dur: 42000, + soName: 'Snapshot2', + tid: 240, + pid: 210, + depth: 10, + itid: 2, + textMetricsWidth: 96.2646875, + process: '' + }; + expect(SoStruct.setSoFrame(node, 2, 0, 1, 2, data)).toBeUndefined(); + }); + it('SoStructTest03', () => { + expect(SoStruct).not.toBeUndefined(); + }); + it('SoStructTest04 ', function () { + let soRender = new SoRender(); + let req = { + lazyRefresh: true, + type: '', + startNS: 5, + endNS: 9, + totalNS: 4, + frame: { + x: 32, + y: 20, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'a', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.3, + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + beginPath: jest.fn(() => true), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + }, + lineColor: '', + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, + }; + window.postMessage = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(soRender.renderMainThread(req,new TraceRow())); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts index 95052958f87563ff74908565e65c50d5e9e8f66d..1409fbd4ca873a2f344171ad364d6432ab67ba12 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerThread.test.ts @@ -20,8 +20,9 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { }); import { thread, ThreadStruct, ThreadRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerThread'; -import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerThread Test', () => { let frame = { x: 0, diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerTimeline.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerTimeline.test.ts index 732784104b9d657c64158490c37368f0687aca8a..5c3ba5f42ef01f6bc993b84fa223d7b72efceb93 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerTimeline.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerTimeline.test.ts @@ -16,7 +16,9 @@ jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); - +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); import { RangeRuler, SportRuler, @@ -24,7 +26,9 @@ import { TimelineRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerTimeline'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; - +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); @@ -42,7 +46,8 @@ describe(' ProcedureWorkerTimelineTest', () => { }); dataList.push({ startTime: 1, dur: 111 }); let rect = new Rect(0, 10, 10, 10); - timeline(timelineCanvas, ctx, 1, 100254, 100254, rect, null, null, null, null, null, null, 0, 0, (e: any) => {}); + let keyboardEvent: KeyboardEvent = new KeyboardEvent('w', { ctrlKey: true, keyCode: 13 }); + timeline(timelineCanvas, ctx, 1, 100254, keyboardEvent, rect, null, null, null, null, null, null, 0, 0, (e: any) => {}); }); it('SportRulerTest01', () => { diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts index 8ffe501db500dc764a42c70dcc0ba5442c1e3415..7d18caac001d0886c8c7d9da45586862e3b8e76e 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerVirtualMemory.test.ts @@ -14,18 +14,14 @@ */ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; - -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { - return {}; -}); - import { - setMemFrame, VirtualMemoryStruct, VirtualMemoryRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerVirtualMemory'; import { mem } from '../../../../src/trace/database/ui-worker/ProcedureWorkerCommon'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerVirtualMemory Test', () => { it('ProcedureWorkerVirtualMemoryTest01', function () { let frame = { @@ -128,7 +124,7 @@ describe('ProcedureWorkerVirtualMemory Test', () => { height: 121, }; window.postMessage = jest.fn(() => true); - expect(virtualMemoryRender.render(virtualMemoryReq, [], [])).toBeUndefined(); + expect(virtualMemoryRender.renderMainThread(virtualMemoryReq, new TraceRow())).toBeUndefined(); }); it('ProcedureWorkerVirtualMemoryTest05', function () { let virtualMemoryRender = new VirtualMemoryRender(); diff --git a/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts b/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts index bd55b6b7a827bba0f83b22f58825b9b68a81463a..3a63113751b9e584823d0e30ea994b5ad0270152 100644 --- a/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts +++ b/ide/test/trace/database/ui-worker/ProduceWorkerSdkCounter.test.ts @@ -20,7 +20,9 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { }); import { SdkCounterRender, CounterStruct } from '../../../../src/trace/database/ui-worker/ProduceWorkerSdkCounter'; - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProduceWorkerSdkCounter Test', () => { it('ProduceWorkerSdkCounterTest01', function () { let sdkCounterRender = new SdkCounterRender(); @@ -190,7 +192,7 @@ describe('ProduceWorkerSdkCounter Test', () => { height: 135, }; window.postMessage = jest.fn(() => true); - expect(sdkCounterRender.render(sdkCounterReq, [], [])).toBeUndefined(); + expect(sdkCounterRender.renderMainThread(sdkCounterReq, new TraceRow())).toBeUndefined(); }); it('ProduceWorkerSdkCounterTest06', function () { let sdkCounterRender = new SdkCounterRender(); diff --git a/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts b/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts index a0771b449751394b04cd6491764d03930b6236f8..6e8a9c26b9c392c80104966f0159d3cdcd6e05b7 100644 --- a/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts +++ b/ide/test/trace/database/ui-worker/ProduceWorkerSdkSlice.test.ts @@ -18,7 +18,9 @@ import { SdkSliceRender, SdkSliceStruct } from '../../../../src/trace/database/u jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProduceWorkerSdkSlice Test', () => { it('ProduceWorkerSdkSliceTest01', function () { let sdkSliceRender = new SdkSliceRender(); @@ -173,7 +175,7 @@ describe('ProduceWorkerSdkSlice Test', () => { height: 15, }; window.postMessage = jest.fn(() => true); - expect(sdkSliceRender.render(sdkSliceReq, [], [])).toBeUndefined(); + expect(sdkSliceRender.renderMainThread(sdkSliceReq, new TraceRow())).toBeUndefined(); }); it('ProduceWorkerSdkSliceTest07', function () { let sdkSliceRender = new SdkSliceRender(); diff --git a/ide/tsconfig_test.json b/ide/tsconfig_test.json new file mode 100644 index 0000000000000000000000000000000000000000..16754ab1ec1275be20b741b0a3be77e565874529 --- /dev/null +++ b/ide/tsconfig_test.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "target": "es6", + "module": "ES2022", + "allowJs": false, + "strict": true, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + }, + "exclude": [ + "src/trace/proto/", + "src/trace/grpc/*.ts" + ], + "include": [ + "src/**/*.ts" + ] +} diff --git a/ide/webpack.config.js b/ide/webpack.config.js index 2d48a13d984fd84a30232aae893f8c27ba098033..7419154b1dbdba6f3a2318b9960e9b058b0af504 100644 --- a/ide/webpack.config.js +++ b/ide/webpack.config.js @@ -25,6 +25,8 @@ const childProcess = require('child_process'); const { exec } = require('child_process'); const fs = require('fs'); +const supportPlatform = ['windows', 'linux', 'darwin']; + function runCommand(command) { return new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { @@ -46,12 +48,14 @@ function cpFile(sourcePath, targetPath) { files.forEach((file) => { const source = `${sourcePath}/${file}`; const target = `${targetPath}/${file}`; - fs.copyFile(source, target, (err) => { - if (err) { - console.error('无法复制文件', err); - return; - } - }); + if (fs.lstatSync(source).isFile()) { + fs.copyFile(source, target, (err) => { + if (err) { + console.error('无法复制文件', err); + return; + } + }); + } }); }); } @@ -67,12 +71,30 @@ function clearDirectory(directoryPath) { if (fs.lstatSync(filePath).isDirectory()) { return; } else { - fs.unlinkSync(filePath); // 删除文件 + try { + fs.unlinkSync(filePath); // 删除文件 + } catch { + console.log(`can't del file ${filePath}`); + } } }); } } +function buildMultiPlatform() { + const outPath = path.normalize(path.join(__dirname, '/', 'dist')); + const serverSrc = path.normalize(path.join(__dirname, '/server/main.go')); + for (const platform of supportPlatform) { + const generateFile = platform === 'windows' ? + path.normalize(path.join(outPath, '/', `main.exe`)) : + path.normalize(path.join(outPath, '/', `main_${platform}`)); + const setEnv = `go env -w CGO_ENABLED=0 && go env -w GOOS=${platform} && go env -w GOARCH=amd64`; + const buildCmd = `${setEnv} && go build -o ${generateFile} ${serverSrc}`; + console.log(`compile ${platform} server ...`); + childProcess.execSync(buildCmd); + } +} + const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : 'style-loader'; //compile server ((flag) => { @@ -81,27 +103,12 @@ const stylesHandler = isProduction ? MiniCssExtractPlugin.loader : 'style-loader } console.log('start compile server'); let outPath = path.normalize(path.join(__dirname, '/', 'dist')); - let serverSrc = path.normalize(path.join(__dirname, '/server/main.go')); let binPath = path.normalize(path.join(__dirname, '/', 'bin')); clearDirectory(outPath); cpFile(binPath, outPath); const protoPath = './src/trace/proto/'; runCommand(`pbjs -t static-module -w commonjs -o ${protoPath}SphBaseData.js ${protoPath}SphBaseData.proto`); - let rs; - if (os.type() === 'Windows_NT') { - rs = childProcess.spawnSync('go', ['build', '-o', outPath, serverSrc], { - encoding: 'utf-8', - }); - } else { - rs = childProcess.spawnSync('go', ['build', '-o', outPath + '/main', serverSrc], { - encoding: 'utf-8', - }); - } - if (rs.status === 0) { - console.log('compile server success'); - } else { - console.error('compile server failed', rs); - } + buildMultiPlatform(); })(true); const config = { entry: './src/index.ts', @@ -160,6 +167,10 @@ const config = { from: './server/wasm.json', to: 'wasm.json', }, + { + from: './server/server-config.txt', + to: 'server-config.txt', + }, ], }), // Add your plugins here diff --git a/trace_streamer/.gn b/trace_streamer/.gn index 74c472e0b66e8d6288324e2e6cbc1e186ed89d8d..d7dadfdf90424cc0aed57c4404c0df88eaaf2129 100644 --- a/trace_streamer/.gn +++ b/trace_streamer/.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/.gn_unix b/trace_streamer/.gn_unix index 74c472e0b66e8d6288324e2e6cbc1e186ed89d8d..d7dadfdf90424cc0aed57c4404c0df88eaaf2129 100644 --- a/trace_streamer/.gn_unix +++ b/trace_streamer/.gn_unix @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/.gn_win b/trace_streamer/.gn_win index 5d10241c5c8409be25d789065605bf85a19f8424..de89f9a2d09331685cadf86299a70a9c13c06ed3 100644 --- a/trace_streamer/.gn_win +++ b/trace_streamer/.gn_win @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/BUILD.gn b/trace_streamer/BUILD.gn index 9cc95acb4ec12fe96139b052784335e69e2f5484..6babb6dbdd4c62701bdba4946d24f0a0e35c01f6 100644 --- a/trace_streamer/BUILD.gn +++ b/trace_streamer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/build.sh b/trace_streamer/build.sh index d7b09fc6b6aaea06f96b17c35f898e9ab168baa1..6180709209903fcbfaf09ef5048226405e9231be 100755 --- a/trace_streamer/build.sh +++ b/trace_streamer/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -13,19 +13,19 @@ # limitations under the License. set -e PARAMS=$* -echo $PARAMS +echo "$PARAMS" echo "begin to check input" SOURCE="${BASH_SOURCE[0]}" -cd $(dirname ${SOURCE}) +cd "$(dirname "${SOURCE}")" ./pare_third_party.sh target_os="linux" -target_dir="linux" gn_path="linux" is_debug="false" is_clean="false" target="trace_streamer" gn="gn" ninja="ninja" +use_local_emsdk="false" case "$OSTYPE" in solaris*) echo "SOLARIS" ;; darwin*) gn_path="macx" target_os="macx" ;; @@ -34,24 +34,23 @@ case "$OSTYPE" in msys*) gn_path="windows" target_os="windows" gn="gn.exe" ninja="ninja.exe" ;; *) echo "unknown: $OSTYPE" ;; esac -usage="Usage: $basename $0 wasm/test/fuzz/protoc debug/release/clean" ./dl_tools.sh $gn_path -if { [ "$1" == "sdkdemo" ] || [ "$1" == "wasm" ] || [ "$1" == "test" ] || [ "$1" == "fuzz" ]; } && [ "$#" -ne 0 ];then +if [ "$#" -ne 0 ] && { [ "$1" == "sdkdemo" ] || [ "$1" == "wasm" ] || [ "$1" == "test" ] || [ "$1" == "fuzz" ]; };then TARGET_DIR=$1 if [[ $PARAMS == *"debug"* ]]; then TARGET_DIR=$1"_debug" fi - if [ ! -f "out/$TARGET_DIR/protoc" ] && [ "$1" != "protoc" ];then + if [ ! -f "out/$TARGET_DIR/protoc" ];then ./build.sh protoc - mkdir -p out/$TARGET_DIR - cp out/$target_os/protoc out/$TARGET_DIR/protoc + mkdir -p out/"$TARGET_DIR" + cp out/$target_os/protoc out/"$TARGET_DIR"/protoc fi - if [ ! -f "out/$TARGET_DIR/protoreader_plugin" ] && [ "$1" != "spb" ] && [ -f "out/$TARGET_DIR/protoc" ];then + if [ ! -f "out/$TARGET_DIR/protoreader_plugin" ] && [ -f "out/$TARGET_DIR/protoc" ];then ./build.sh spb - mkdir -p out/$TARGET_DIR - cp out/$target_os/protoreader_plugin out/$TARGET_DIR/protoreader_plugin + mkdir -p out/"$TARGET_DIR" + cp out/$target_os/protoreader_plugin out/"$TARGET_DIR"/protoreader_plugin fi fi if [ $target_os == "windows" ];then @@ -59,7 +58,7 @@ if [ $target_os == "windows" ];then else cp .gn_unix .gn fi -if [ "$1" == "windows" ];then +if [ "$1" == "windows" ] && [ "$2" == "release" ];then echo "gn only support linux and wasm build currently" if [ ! -d "out/windows" ];then mkdir out/windows @@ -67,11 +66,15 @@ if [ "$1" == "windows" ];then touch out/windows/trace_streamer.exe exit fi - if [ "$#" -ne "0" ];then - if [ "$1" == "wasm" ];then - ./dl_emsdk.sh - target="wasm" + if [ "$1" == "wasm" ] || [ "$1" == "sdkdemo" ];then + if command -v em++ &> /dev/null; then + use_local_emsdk="true" + else + ./dl_emsdk.sh + use_local_emsdk="false" + fi + target="$1" fi if [ "$1" == "test" ];then target="test" @@ -82,9 +85,6 @@ if [ "$#" -ne "0" ];then if [ "$1" == "protoc" ];then target="protoc" fi - if [ "$1" == "sdkdemo" ];then - target="sdkdemo" - fi if [ "$1" == "sdkdemotest" ];then target="sdkdemotest" fi @@ -97,4 +97,4 @@ if [ "$target" == "wasm" ] && [ "$target_os" == "windows" ];then echo "!!!build wasm on winows will occur unknown error, strongly suggest you build wasm on linux(Ubuntu)" exit fi -./build_operator.sh $is_debug $target $target_os $is_clean $gn_path $gn $ninja $target_operator +./build_operator.sh $is_debug "$target" $target_os $is_clean $gn_path $gn $ninja "$target_operator" $use_local_emsdk diff --git a/trace_streamer/build/config.gni b/trace_streamer/build/config.gni index f287cf24421de871281053d5641a00e956dc2340..eeed6f5219558abca42e8bf5d258df8af38a2372 100644 --- a/trace_streamer/build/config.gni +++ b/trace_streamer/build/config.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/build/ohos.gni b/trace_streamer/build/ohos.gni index 8b30ab63320ab5c772054b4a5b6d29ae8588b54a..c1c5af6df0d4cd9dfd1654d326b64203659e5bd3 100644 --- a/trace_streamer/build/ohos.gni +++ b/trace_streamer/build/ohos.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/build/protoc.sh b/trace_streamer/build/protoc.sh index 3018b8e0bd78a3581f3a405f738df1aaa2a6790a..e14750bc5039040c65dd12cc178ab13fa7e8e996 100755 --- a/trace_streamer/build/protoc.sh +++ b/trace_streamer/build/protoc.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/build/test.gni b/trace_streamer/build/test.gni index 5bad2529076992ed00c0457fadec69acc3fb30db..8193efed2d08368ad8365f29b50cf6dfdb45b8cf 100644 --- a/trace_streamer/build/test.gni +++ b/trace_streamer/build/test.gni @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/build/ts.gni b/trace_streamer/build/ts.gni index 4cfb52563e69674108301ae39c999088a6f9922f..5743b036906afda259561a53920f53fd846a50dd 100644 --- a/trace_streamer/build/ts.gni +++ b/trace_streamer/build/ts.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -12,7 +12,6 @@ # limitations under the License. declare_args() { - profiler_SmartPerf = true is_independent_compile = false } @@ -39,7 +38,6 @@ if (is_independent_compile) { COMMON_LIBRARY = "//commonlibrary" } -script_executable = "/usr/bin/env" device_kernel_version = "default" OHOS_TRACE_STREAMER_PROTOS_DIR = get_path_info("../src", "abspath") @@ -55,14 +53,7 @@ if (target_os == "windows") { OHOS_TRACE_STREAMER_DIR_PROTOC = get_path_info("./protoc_w.py", "abspath") } -OHOS_PROFILER_3RDPARTY_GRPC_DIR = "${THIRD_PARTY}/grpc" OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR = "${THIRD_PARTY}/protobuf" OHOS_PROFILER_3RDPARTY_GOOGLETEST_DIR = "${THIRD_PARTY}/googletest" OHOS_PROFILER_SUBSYS_NAME = "developtools" OHOS_PROFILER_PART_NAME = "smartperf_host" -OHOS_PROFILER_TEST_MODULE_OUTPUT_PATH = "smartperf_host" - -build_l2 = false -if (getenv("BUILD_L2") == "true") { - build_l2 = true -} diff --git a/trace_streamer/build_operator.sh b/trace_streamer/build_operator.sh index 1745fa6b01a3f246ee753efc10199ea245b750a8..2967e6ea47c4e8747823cd374491733a17959990 100755 --- a/trace_streamer/build_operator.sh +++ b/trace_streamer/build_operator.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -22,6 +22,7 @@ gn_path="$5" gn="$6" ninja="$7" target_operator="$8" +use_local_emsdk="$9" if [ "$#" -ge "7" ];then if [ "$target" != "trace" ] && [ "$target" != "linux" ] && [ "$target" != "windows" ] && [ "$target" != "macx" ] && [ "$target" != "trace_streamer" ] && [ "$target" != "wasm" ] && @@ -61,7 +62,7 @@ if [ "$is_debug" != "false" ];then ext="_debug" fi -if [ "$target" == "test" ] || [ "$target" == "fuzz" ] || [ "$target"="wasm" ] || [ "$target"="sdkdemo" ] || [ "$target"="sdkdemotest" ];then +if [ "$target" == "test" ] || [ "$target" == "fuzz" ] || [ "$target" == "wasm" ] || [ "$target" == "sdkdemo" ] || [ "$target" == "sdkdemotest" ];then target_dir=$target else target_dir=$target_os @@ -69,15 +70,19 @@ fi if [ "$target" == "trace_streamer" ] || [ "$target" == "trace" ] || [ "$target" == "spb" ] || [ "$target" == "protoc" ];then target_dir=$target_os fi -echo "target_dir:" $target_dir -echo "target:" $target +echo "target_dir:" "$target_dir" +echo "target:" "$target" out_dir=out/$target_dir$ext -if [ "$is_clean" == "true" ];then - prebuilts/$gn_path/$gn gen $out_dir --clean - prebuilts/$gn_path/$ninja -C $out_dir -t clean +if [ "$is_clean" == "true" ];then + prebuilts/"$gn_path"/"$gn" gen "$out_dir" --clean + prebuilts/"$gn_path"/"$ninja" -C "$out_dir" -t clean else - prebuilts/$gn_path/$gn gen $out_dir --args='is_debug='"$is_debug"' target="'"$target"'" target_os="'"$target_os"'" is_independent_compile=true' + prebuilts/"$gn_path"/"$gn" gen "$out_dir" --args='is_debug='"$is_debug"' target="'"$target"'" target_os="'"$target_os"'" is_independent_compile=true'' use_local_emsdk='"$use_local_emsdk" echo "begin to build ..." - prebuilts/$gn_path/$ninja -C $out_dir + prebuilts/"$gn_path"/"$ninja" -C "$out_dir" fi + +if [ "$out_dir" == "macx" ];then + ./mac_depend.sh +fi \ No newline at end of file diff --git a/trace_streamer/dl_emsdk.sh b/trace_streamer/dl_emsdk.sh index 93520b20f6343781daea84b7f9384c3edda36b9f..31fa98383c2410155ca4f4b0e2ebf053c9ce058e 100755 --- a/trace_streamer/dl_emsdk.sh +++ b/trace_streamer/dl_emsdk.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -12,10 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. set -e -if [ -d "prebuilts/emsdk" ] && [ ! -d "prebuilts/emsdk/emsdk/emscripten" ];then - rm -rf prebuilts/emsdk -fi -if [ ! -d "prebuilts/emsdk" ];then +if [ ! -d "tools/emsdk" ];then echo "you need emsdk to compile wasm" if [ ! -d "tools" ];then mkdir tools @@ -29,15 +26,4 @@ if [ ! -d "prebuilts/emsdk" ];then ./emsdk activate 3.1.12 cd ../../ fi - if [ ! -d "prebuilts/emsdk" ];then - mkdir prebuilts/emsdk - fi - if [ ! -d "prebuilts/emsdk/emsdk" ];then - mkdir prebuilts/emsdk/emsdk - fi - if [ ! -d "prebuilts/emsdk/node" ];then - mkdir prebuilts/emsdk/node - fi - mv tools/emsdk/upstream/* prebuilts/emsdk/emsdk - mv tools/emsdk/node/* prebuilts/emsdk/node fi diff --git a/trace_streamer/dl_tools.sh b/trace_streamer/dl_tools.sh index fa97b0624f170ae2ae112a453d04b519a75928e9..bec7052e685072b4bca40780487ba4910b93e447 100755 --- a/trace_streamer/dl_tools.sh +++ b/trace_streamer/dl_tools.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/doc/des_tables.md b/trace_streamer/doc/des_tables.md index 34d80d762520ca6ee965d61ded4f36b996515d5b..3c81dfc44e8c04b8e72db08e6fcababb13ad6564 100755 --- a/trace_streamer/doc/des_tables.md +++ b/trace_streamer/doc/des_tables.md @@ -72,7 +72,6 @@ TraceStreamer可以将trace数据源转化为易于理解和使用的数据库 | perf_sample | 记录Hiperf工具的采样信息| | perf_thread | 记录Hiperf工具采集到的进程和线程数据| | process | 记录所有的进程信息| -| process_filter | 过滤进程| | process_measure | 保存进程的所有计量值| | process_measure_filter | 将进程ID作为key1,进程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id| | raw | 此数据结构主要作为ThreadState的上下文使用,这张表是sched_waking,sched_wakup, cpu_idle事件的原始记录| @@ -86,7 +85,6 @@ TraceStreamer可以将trace数据源转化为易于理解和使用的数据库 | sys_mem_measure | 记录了所有的系统内存相关的测量信息| | task_pool | 记录任务池相关数据,与callstack表相关联| | thread | 记录所有的线程信息| -| thread_filter | 过滤线程| | thread_state | 记录线程状态信息| | trace_config | 记录trace数据源,proto的事件-plugin与其process_name| | trace_range | 记录ftrace数据与其他类型数据的时间交集,供前端展示数据时使用| @@ -150,7 +148,6 @@ TraceStreamer可以将trace数据源转化为易于理解和使用的数据库 |perf_sample | - | - |perf数据(非插件模式) | |perf_thread | - | - |perf数据(非插件模式) | |process | - |ftrace-plugin |进程信息 | -|process_filter | - |ftrace-plugin |进程计量表的辅助表 | |process_measure | - |ftrace-plugin |进程内存 | |process_measure_filter| - |ftrace-plugin |process_measure的辅助表| |raw | - |ftrace-plugin |线程唤醒信息 | @@ -165,7 +162,6 @@ TraceStreamer可以将trace数据源转化为易于理解和使用的数据库 |thread_state | 通用的 |ftrace-plugin |线程调度图(常用) | |trace_config | 通用的 |hisysevent-plugin |记录trace数据源 | |trace_range | 通用的 | - |trace数据的时长 | -|thread_filter | 通用的 |ftrace-plugin |线程计量跟踪表(比较少用)| |clock_snapshot | 通用的 |通用的 |时钟号和时间,时钟名的映射表| |datasource_clockid | 通用的 |通用的 |数据源和时钟号的映射表| |task_pool | - | - |任务池数据 | diff --git a/trace_streamer/format-code.sh b/trace_streamer/format-code.sh index 82e28c637e5f48d86b661eefd4f9624961c6e66b..df80964aa25ffaec20dfaea3947f5b70455eebe3 100755 --- a/trace_streamer/format-code.sh +++ b/trace_streamer/format-code.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/gcov.sh b/trace_streamer/gcov.sh index d2ed2386c209c20078322fbf921e54215e02a555..b243f6c9cf2233e9af7bbe300001783a2cb0318b 100755 --- a/trace_streamer/gcov.sh +++ b/trace_streamer/gcov.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/gn/BUILD.gn b/trace_streamer/gn/BUILD.gn index 28ba290908fa2137f19aaa7ebc18b839727d0a60..994d77011de6b2e69f6a69f71392f08b367306b6 100644 --- a/trace_streamer/gn/BUILD.gn +++ b/trace_streamer/gn/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -61,17 +61,19 @@ config("default") { if (is_debug && is_win) { ldflags += [ "-fstack-protector" ] } - if (is_debug && is_linux && !use_wasm) { - cflags += [ - "-g", - "-fno-omit-frame-pointer", - "-fstandalone-debug", - ] - ldflags += [ "-fsanitize=address" ] + if (is_debug && !use_wasm) { + cflags += [ "-g" ] + if (is_linux) { + cflags += [ + "-fno-omit-frame-pointer", + "-fstandalone-debug", + ] + ldflags += [ "-fsanitize=address" ] + } } + if (target_os == "windows") { cflags += [ "-D target_cpu_x86_64" ] - libs += [ "z" ] } else if (is_linux || is_mac) { cflags += [ "-Wa,--noexecstack", @@ -89,7 +91,6 @@ config("default") { "-DHAVE_CONFIG_H", "-DCC_IS_CLANG", ] - libs += [ "z" ] } if (!use_wasm && !is_win && !is_mac && !is_test && !is_mingw) { cflags += [ "-D HAVE_LIBUNWIND" ] diff --git a/trace_streamer/gn/CONFIG.gn b/trace_streamer/gn/CONFIG.gn index a81681b65aece8381b796e4637ebc526436523b1..6eaffd17dbb5d2929551f5a587088de284f30d9d 100644 --- a/trace_streamer/gn/CONFIG.gn +++ b/trace_streamer/gn/CONFIG.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -109,6 +109,5 @@ set_defaults("executable") { if (use_wasm) { set_default_toolchain("//gn/toolchain:wasm") } else { - print(use_wasm) set_default_toolchain("//gn/toolchain:gcc_like") } diff --git a/trace_streamer/gn/toolchain/BUILD.gn b/trace_streamer/gn/toolchain/BUILD.gn index 657d518c23aa0b8fa1ba1bb9228b5238404dd89a..fc46d23297e14f6af8aeb4443dd9ac1e27f6f652 100644 --- a/trace_streamer/gn/toolchain/BUILD.gn +++ b/trace_streamer/gn/toolchain/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -39,11 +39,17 @@ toolchain("wasm") { # emsdk_dir and em_config are defined in wasm.gni. print("use gcc_like_chain wasm") if (!is_mac) { - ar = "$emsdk_dir/emscripten/emar --em-config $em_config" + ar = "emar" + } + cc = "emcc" + cxx = "em++" + if (!use_local_emsdk) { + if (!is_mac) { + ar = "$emsdk_dir/emscripten/emar --em-config $em_config" + } + cc = "$emsdk_dir/emscripten/emcc --em-config $em_config" + cxx = "$emsdk_dir/emscripten/em++ --em-config $em_config" } - cc = "$emsdk_dir/emscripten/emcc --em-config $em_config" - cxx = "$emsdk_dir/emscripten/em++ --em-config $em_config" - lib_switch = "-l" ld_arg = "" lib_dir_switch = "-L" diff --git a/trace_streamer/gn/wasm.gni b/trace_streamer/gn/wasm.gni index e181f0f569097abd9e23e58c6c813a06af2d3f67..c28e6b85474a2697ca01efe11d94fb220a233af9 100644 --- a/trace_streamer/gn/wasm.gni +++ b/trace_streamer/gn/wasm.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -13,15 +13,19 @@ import("./wasm_vars.gni") -em_config = rebase_path(".emscripten", "") -emsdk_dir = rebase_path("//prebuilts/emsdk/emsdk", "") - +declare_args() { + use_local_emsdk = false +} +if (!use_local_emsdk) { + em_config = rebase_path("//tools/emsdk/.emscripten", "") + emsdk_dir = rebase_path("//tools/emsdk/upstream", "") +} template("wasm_lib") { _exports = "['ccall', 'callMain', 'addFunction', 'FS']" print(invoker.name) assert(defined(invoker.name)) - # If the name is trace_sreamer the target_name must be trace_sreamer_wasm. + # If the name is trace_streamer_builtin the target_name must be trace_streamer_builtin_wasm. assert(invoker.name + "_wasm" == target_name) _target_ldflags = [ "-s", @@ -44,8 +48,6 @@ template("wasm_lib") { "EXPORT_NAME=${target_name}", "-s", "MODULARIZE=1", - "-s", - "USE_ZLIB=1", "-lworkerfs.js", # For FS.filesystems.WORKERFS "-s", "ASSERTIONS=1", diff --git a/trace_streamer/gn/wasm_vars.gni b/trace_streamer/gn/wasm_vars.gni index 8b858fda7329eb8466b6975a0fefa7945532a5e4..0108e3a06d04240c6cb70392247ee337bf7e8cc1 100644 --- a/trace_streamer/gn/wasm_vars.gni +++ b/trace_streamer/gn/wasm_vars.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/huoyantu.sh b/trace_streamer/huoyantu.sh index e10830d261b51cfd73e5ddbe97638449e3dd22da..facf5e92ff1788d8a27afab929b48288f4912787 100755 --- a/trace_streamer/huoyantu.sh +++ b/trace_streamer/huoyantu.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/lcov.sh b/trace_streamer/lcov.sh index 42bdb0f91df634101fe431f9f7f5adf0acbc3968..fffe126f735385e0dbdf7393f7b09a74253dfb9c 100755 --- a/trace_streamer/lcov.sh +++ b/trace_streamer/lcov.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/lcov_operator.sh b/trace_streamer/lcov_operator.sh index 8bdc98d5916bbb78e58def75ce5d29d43194dc84..4dbc012e1a96d96e1d41daa4c6a3cf22a94e9796 100755 --- a/trace_streamer/lcov_operator.sh +++ b/trace_streamer/lcov_operator.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/gn/.emscripten b/trace_streamer/mac_depend.sh similarity index 46% rename from trace_streamer/gn/.emscripten rename to trace_streamer/mac_depend.sh index 97e12ef16abdaf931b2083af45e4563dd1b77f90..e8a37a4f9e266d380d3bf0565f6a7fac0fb477ea 100644 --- a/trace_streamer/gn/.emscripten +++ b/trace_streamer/mac_depend.sh @@ -1,4 +1,6 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. + +#!/bin/bash +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -10,23 +12,11 @@ # 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. - -from platform import system -import os -import sys - -thisFile = os.getenv('EM_CONFIG') -if thisFile is None: - sys.stderr.write('No EM_CONFIG in .emscripten file\n') - sys.exit(-1) - -rootDir = os.path.dirname(os.path.dirname(thisFile)) -emsdkPath = os.path.join(rootDir, 'prebuilts/emsdk/emsdk') -nodePath = os.path.join(rootDir, 'prebuilts/emsdk/node/16.20.0_64bit') - -LLVM_ROOT = os.path.join(emsdkPath, 'bin') -NODE_JS = os.path.join(nodePath, 'bin/node') -EMSCRIPTEN_ROOT = os.path.join(emsdkPath, 'emscripten') -COMPILER_ENGINE = NODE_JS -JS_ENGINES = [NODE_JS] -BINARYEN_ROOT = emsdkPath +set -e +cd out/macx +if [ ! -d "lib" ];then + echo "cp macx depend" + mkdir lib + find /usr -name 'libc+*.dylib' -exec cp {} lib \; +fi +install_name_tool -change /usr/lib/libc++.1.dylib ./lib/libc++.1.dylib trace_streamer diff --git a/trace_streamer/pare_third_party.sh b/trace_streamer/pare_third_party.sh index 4d5aadda4cae2a86021709007df9537cc050c028..56e5380baa4a714acd2d5fb681c2ce70612bf635 100755 --- a/trace_streamer/pare_third_party.sh +++ b/trace_streamer/pare_third_party.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -41,16 +41,21 @@ if [ ! -f "protobuf/BUILD.gn" ];then fi fi +if [ ! -f "zlib/BUILD.gn" ];then + rm -rf zlib + git clone --depth=1 git@gitee.com:openharmony/third_party_zlib.git + if [ -d "third_party_zlib" ];then + mv third_party_zlib zlib + $cp ../prebuilts/patch_zlib/zlibbuild.gn zlib/BUILD.gn + fi +fi if [ ! -f "googletest/BUILD.gn" ];then rm -rf googletest git clone --depth=1 git@gitee.com:openharmony/third_party_googletest.git if [ -d "third_party_googletest" ];then mv third_party_googletest googletest $cp ../prebuilts/patch_googletest/googletestbuild.gn ../third_party/googletest/BUILD.gn - $patch -p0 ../third_party/googletest/googletest/include/gtest/internal/gtest-internal.h ../prebuilts/patch_googletest/gtest_internal.h.patch - $patch -p0 ../third_party/googletest/googletest/include/gtest/internal/gtest-port.h ../prebuilts/patch_googletest/gtest_port.h.patch - $patch -p0 ../third_party/googletest/googletest/include/gtest/gtest-message.h ../prebuilts/patch_googletest/gtest-message.h.patch - $sed -i "/using ::std::string/s/^\(.*\)$/\/\/\1/g" ../third_party/googletest/googletest/include/gtest/hwext/gtest-tag.h + $patch -p1 < ../prebuilts/patch_googletest/gtest.patch fi fi diff --git a/trace_streamer/prebuilts/patch_bounds_checking_function/bounds_checking_functionbuild.gn b/trace_streamer/prebuilts/patch_bounds_checking_function/bounds_checking_functionbuild.gn index f93a2ee18bee82df47d693d27e78b167d40e2d26..2ce84f1ea7c968312773a86d805a77eb44d276b0 100644 --- a/trace_streamer/prebuilts/patch_bounds_checking_function/bounds_checking_functionbuild.gn +++ b/trace_streamer/prebuilts/patch_bounds_checking_function/bounds_checking_functionbuild.gn @@ -1,5 +1,5 @@ # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn b/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn index 95335b888d81c6a890d1a1a7187ecad2201dd87a..2e1320774fca494150ff56accde4d61bf6619177 100644 --- a/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn +++ b/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -41,6 +41,7 @@ static_library("gtest") { "-Wno-missing-noreturn", ] sources = [ + "googletest/include/gtest/gtest-assertion-result.h", "googletest/include/gtest/gtest-death-test.h", "googletest/include/gtest/gtest-message.h", "googletest/include/gtest/gtest-param-test.h", @@ -68,6 +69,7 @@ static_library("gtest") { "googletest/include/gtest/internal/gtest-tuple.h", "googletest/include/gtest/internal/gtest-type-util.h", "googletest/src/gtest-all.cc", + "googletest/src/gtest-assertion-result.cc", "googletest/src/gtest-death-test.cc", "googletest/src/gtest-filepath.cc", "googletest/src/gtest-internal-inl.h", diff --git a/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch b/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch deleted file mode 100644 index 266103762b66274a49f8321cb336c2ccb017ab2d..0000000000000000000000000000000000000000 --- a/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- third_party/googletest/googletest/include/gtest/gtest-message.h 2023-01-17 16:10:56.252360383 +0800 -+++ /home/suze/tp/code/ohos_devtools_trace_resolver/third_party/googletest/googletest/include/gtest/gtest-message.h 2023-01-06 17:58:25.830759482 +0800 -@@ -49,8 +49,11 @@ - - #include - #include -+#undef private -+#define private private - #include -- -+#undef private -+#define private public - #include "gtest/internal/gtest-port.h" - - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ diff --git a/trace_streamer/prebuilts/patch_googletest/gtest.patch b/trace_streamer/prebuilts/patch_googletest/gtest.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6c2b3ae89da11a72f404e632de5474413858dfb --- /dev/null +++ b/trace_streamer/prebuilts/patch_googletest/gtest.patch @@ -0,0 +1,79 @@ +--- third_party/googletest/googletest/include/gtest/gtest-message.h ++++ third_party/googletest/googletest/include/gtest/gtest-message.h +@@ -51,7 +51,11 @@ + #include + #include + #include ++#undef private ++#define private private + #include ++#undef private ++#define private public + #include + + #include "gtest/internal/gtest-port.h" +--- third_party/googletest/googletest/include/gtest/gtest.h ++++ third_party/googletest/googletest/include/gtest/gtest.h +@@ -56,12 +56,20 @@ + + #include + #include ++#undef private ++#define private private + #include ++#undef private ++#define private public + #include + #include + #include + #include ++#undef private ++#define private private + #include ++#undef private ++#define private public + #include + #include + #include +--- third_party/googletest/googletest/include/gtest/internal/gtest-internal.h ++++ third_party/googletest/googletest/include/gtest/internal/gtest-internal.h +@@ -58,7 +58,11 @@ + + #include + #include ++#undef private ++#define private private + #include ++#undef private ++#define private public + #include + #include + #include +--- third_party/googletest/googletest/include/gtest/internal/gtest-port.h ++++ third_party/googletest/googletest/include/gtest/internal/gtest-port.h +@@ -2356,7 +2356,11 @@ using Any = ::absl::any; + // Otherwise for C++17 and higher use std::any for UniversalPrinter<> + // specializations. + #define GTEST_INTERNAL_HAS_ANY 1 ++#undef private ++#define private private + #include ++#undef private ++#define private public + namespace testing { + namespace internal { + using Any = ::std::any; +--- third_party/googletest/googletest/include/gtest/internal/gtest-string.h ++++ third_party/googletest/googletest/include/gtest/internal/gtest-string.h +@@ -51,7 +51,11 @@ + #include + + #include ++#undef private ++#define private private + #include ++#undef private ++#define private public + #include + + #include "gtest/internal/gtest-port.h" diff --git a/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch b/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch deleted file mode 100644 index e47ac4faa2343fc71ba90adae8cccb66b8cf0fa4..0000000000000000000000000000000000000000 --- a/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- third_party/googletest/googletest/include/gtest/internal/gtest-internal.h 2023-01-17 16:10:56.252360383 +0800 -+++ /home/suze/tp/code/ohos_devtools_trace_resolver/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h 2023-01-06 17:58:25.830759482 +0800 -@@ -54,7 +54,11 @@ - #include - #include - #include -+#undef private -+#define private private - #include -+#undef private -+#define private public - #include - #include - #include diff --git a/trace_streamer/prebuilts/patch_googletest/gtest_port.h.patch b/trace_streamer/prebuilts/patch_googletest/gtest_port.h.patch deleted file mode 100644 index bb5d1e2d3d316b0fd53355268072c2a620c54022..0000000000000000000000000000000000000000 --- a/trace_streamer/prebuilts/patch_googletest/gtest_port.h.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- third_party/googletest/googletest/include/gtest/internal/gtest-port.h 2023-01-17 16:10:56.252360383 +0800 -+++ /home/suze/tp/code/ohos_devtools_trace_resolver/third_party/googletest/googletest/include/gtest/internal/gtest-port.h 2023-01-06 17:58:25.834759489 +0800 -@@ -276,7 +276,6 @@ - # include - # include - #endif -- - #include // NOLINT - #include - #include -@@ -2287,7 +2286,11 @@ using Any = ::absl::any; - // Otherwise for C++17 and higher use std::any for UniversalPrinter<> - // specializations. - #define GTEST_INTERNAL_HAS_ANY 1 --#include -+#undef private -+#define private private -+#include // NOLINT -+#undef private -+#define private public - namespace testing { - namespace internal { - using Any = ::std::any; diff --git a/trace_streamer/prebuilts/patch_hiperf/BUILD.gn b/trace_streamer/prebuilts/patch_hiperf/BUILD.gn index 3421545dccd35478019632b987822b161051f156..e319db0a174c2f49b5d2700516e5370d6e9f106e 100644 --- a/trace_streamer/prebuilts/patch_hiperf/BUILD.gn +++ b/trace_streamer/prebuilts/patch_hiperf/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -26,8 +26,8 @@ ohos_source_set("elf") { "include/nonlinux/linux", "include/nonlinux", "${THIRD_PARTY}/bounds_checking_function/include", - "${SRC}/../prebuilts/emsdk/node/16.20.0_64bit/include/node", ] + public_deps = [ "${THIRD_PARTY}/zlib:libz" ] } ohos_source_set("hiperf_src") { configs -= [ trace_cfg_path ] diff --git a/trace_streamer/prebuilts/patch_hiperf/file_ex.h b/trace_streamer/prebuilts/patch_hiperf/file_ex.h index 09481777ef360eac52adc38e3ca5afe144b406f7..d6aec8be113a9cb747471dd714d213d230e2583b 100644 --- a/trace_streamer/prebuilts/patch_hiperf/file_ex.h +++ b/trace_streamer/prebuilts/patch_hiperf/file_ex.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn b/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn index 04ea0f2cf180e6ad5883a5985f8bac686eeb27b8..8e94adbb3720fa975316de8191c4e7e644edd039 100644 --- a/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn +++ b/trace_streamer/prebuilts/patch_hiperf/hiviewdfx_BUILD.gn @@ -47,10 +47,6 @@ ohos_source_set("hiviewdfx_source") { cflags += [ "-includeMingW64Fix.h" ] include_dirs += [ "${THIRD_PARTY}/libunwind/include/mingw" ] } - if (use_wasm) { - include_dirs += - [ "${PREBUILTS}/emsdk/emsdk/emscripten/cache/sysroot/include/" ] - } sources += [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_elf.cpp", "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_elf_parser.cpp", @@ -60,7 +56,7 @@ ohos_source_set("hiviewdfx_source") { "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_mmap.cpp", "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_symbols.cpp", ] - if (is_debug) { + if (is_debug && is_linux) { sources += [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_accessors.cpp" ] } } diff --git a/trace_streamer/prebuilts/patch_hiperf/unique_fd.h b/trace_streamer/prebuilts/patch_hiperf/unique_fd.h index f6210a31c0cc60afe5d71074d004b8da97710b68..61eeb21e9c28dacfe36b028fe8cf269f46617967 100644 --- a/trace_streamer/prebuilts/patch_hiperf/unique_fd.h +++ b/trace_streamer/prebuilts/patch_hiperf/unique_fd.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/prebuilts/patch_libunwind/libunwindbuild.gn b/trace_streamer/prebuilts/patch_libunwind/libunwindbuild.gn index 93f94de8b6147f6de536e1cfcb01130b893765fe..5228ee192b54adfb755d7cfb6e3025c429e15286 100644 --- a/trace_streamer/prebuilts/patch_libunwind/libunwindbuild.gn +++ b/trace_streamer/prebuilts/patch_libunwind/libunwindbuild.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/prebuilts/patch_protobuf/protobufbuild.gn b/trace_streamer/prebuilts/patch_protobuf/protobufbuild.gn index 8c5841a7eee4925309c7f780e6ded4cefbdd937e..4326da6d939f6e77dd77203fb86f74e63ba5fffd 100644 --- a/trace_streamer/prebuilts/patch_protobuf/protobufbuild.gn +++ b/trace_streamer/prebuilts/patch_protobuf/protobufbuild.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/prebuilts/patch_sqlite/sqlite3build.gn b/trace_streamer/prebuilts/patch_sqlite/sqlite3build.gn index 5644a48ba0a540e7fe6a2e649c2a160bfb44dcef..dfd9237e1dff89108ce8ddd410e7922c222dad0c 100644 --- a/trace_streamer/prebuilts/patch_sqlite/sqlite3build.gn +++ b/trace_streamer/prebuilts/patch_sqlite/sqlite3build.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/prebuilts/patch_zlib/zlibbuild.gn b/trace_streamer/prebuilts/patch_zlib/zlibbuild.gn new file mode 100644 index 0000000000000000000000000000000000000000..c05bff0d5fd9a6f9c6313db94e36ad2eaf7e08a4 --- /dev/null +++ b/trace_streamer/prebuilts/patch_zlib/zlibbuild.gn @@ -0,0 +1,66 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# 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("//build/ohos.gni") + +config("zlib_config") { + cflags = [ + "-Wno-incompatible-pointer-types", + "-Werror", + "-Wno-strict-prototypes", + "-Wimplicit-function-declaration", + ] +} + +config("zlib_public_config") { + include_dirs = [ "." ] +} + +ohos_source_set("libz") { + sources = [ + "adler32.c", + "compress.c", + "contrib/minizip/ioapi.c", + "contrib/minizip/unzip.c", + "contrib/minizip/zip.c", + "crc32.c", + "crc32.h", + "deflate.c", + "deflate.h", + "gzclose.c", + "gzguts.h", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inffast.h", + "inffixed.h", + "inflate.c", + "inflate.h", + "inftrees.c", + "inftrees.h", + "trees.c", + "trees.h", + "uncompr.c", + "zconf.h", + "zlib.h", + "zutil.c", + "zutil.h", + ] + configs += [ ":zlib_config" ] + public_configs = [ ":zlib_public_config" ] + + part_name = "zlib" + subsystem_name = "thirdparty" +} \ No newline at end of file diff --git a/trace_streamer/sdk/demo_sdk/BUILD.gn b/trace_streamer/sdk/demo_sdk/BUILD.gn index ed08f311d40cead7e6f23ec26bf50a1b84a2535f..7278cc971df2ea11d78b5fb595ae026a84eff4b5 100644 --- a/trace_streamer/sdk/demo_sdk/BUILD.gn +++ b/trace_streamer/sdk/demo_sdk/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/doc/wasm.md b/trace_streamer/sdk/demo_sdk/doc/wasm.md index 0c2876b9e1816899915b5c07234cf56743c6045e..b8b6ea81fd4a64a98ac62e3c3e7c54531357f512 100644 --- a/trace_streamer/sdk/demo_sdk/doc/wasm.md +++ b/trace_streamer/sdk/demo_sdk/doc/wasm.md @@ -7,36 +7,6 @@ git pull ./emsdk update # this may not work, ignore it ./emsdk install latest ./emsdk activate latest -安装之后,需要将upstream目录复制到prebuilts/emsdk/emsdk,node复制到prebuilts/emsdk/node -``` -安装之后,目录结构当如: -``` -prebuilts/emsdk -├── prebuilts/emsdk/emsdk -│ ├── prebuilts/emsdk/emsdk/bin -│ ├── prebuilts/emsdk/emsdk/emscripten -│ │ ├── prebuilts/emsdk/emsdk/emscripten/cache -│ │ ├── prebuilts/emsdk/emsdk/emscripten/cmake -│ │ ├── prebuilts/emsdk/emsdk/emscripten/docs -│ │ ├── prebuilts/emsdk/emsdk/emscripten/media -│ │ ├── prebuilts/emsdk/emsdk/emscripten/node_modules -│ │ ├── prebuilts/emsdk/emsdk/emscripten/__pycache__ -│ │ ├── prebuilts/emsdk/emsdk/emscripten/src -│ │ ├── prebuilts/emsdk/emsdk/emscripten/system -│ │ ├── prebuilts/emsdk/emsdk/emscripten/tests -│ │ ├── prebuilts/emsdk/emsdk/emscripten/third_party -│ │ └── prebuilts/emsdk/emsdk/emscripten/tools -│ ├── prebuilts/emsdk/emsdk/include -│ │ └── prebuilts/emsdk/emsdk/include/c++ -│ └── prebuilts/emsdk/emsdk/lib -│ └── prebuilts/emsdk/emsdk/lib/clang -└── prebuilts/emsdk/node - └── prebuilts/emsdk/node/14.18.2_64bit - ├── prebuilts/emsdk/node/14.18.2_64bit/bin - ├── prebuilts/emsdk/node/14.18.2_64bit/include - ├── prebuilts/emsdk/node/14.18.2_64bit/lib - └── prebuilts/emsdk/node/14.18.2_64bit/share -``` 之后调用 ``` ./build.sh sdkdemo 进行编译demo diff --git a/trace_streamer/sdk/demo_sdk/main.cpp b/trace_streamer/sdk/demo_sdk/main.cpp index 59b9cf5d546a6c53ad08f31ceeb0568d5b11d972..70c19a1ba62d37099a94859ef051eb88fc938021 100644 --- a/trace_streamer/sdk/demo_sdk/main.cpp +++ b/trace_streamer/sdk/demo_sdk/main.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/plugin/BUILD.gn b/trace_streamer/sdk/demo_sdk/plugin/BUILD.gn index 3523d0cfca355a99d199e43070612e07ee0e09d3..a932cf3835cee3114ff4eab78dc18ffaa37a505c 100644 --- a/trace_streamer/sdk/demo_sdk/plugin/BUILD.gn +++ b/trace_streamer/sdk/demo_sdk/plugin/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.cpp b/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.cpp index 6808b37f18990a38df8e72df72d37869a727e84d..8fc8e095e8f040f797e6b4f13d578e10688f83e7 100644 --- a/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.cpp +++ b/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.h b/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.h index 7acff69fc1eeaa92c3d74893cf75b4f41ad4fb8d..65182d96f398b50ee83267d5d8487520e6f44699 100644 --- a/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.h +++ b/trace_streamer/sdk/demo_sdk/plugin/sdk_plugin_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/protos/BUILD.gn b/trace_streamer/sdk/demo_sdk/protos/BUILD.gn index 5feff386d4eb0409f379a94d9fee5c85b9b42637..1e981e06d8f86a69fdc3fb8bfe3021d126b8ccd5 100644 --- a/trace_streamer/sdk/demo_sdk/protos/BUILD.gn +++ b/trace_streamer/sdk/demo_sdk/protos/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/protos/protogen.sh b/trace_streamer/sdk/demo_sdk/protos/protogen.sh index 1560e67f17fe6e8fe3b79fce6dfbb73170ad48cb..4448c0cd7e2346a0a29bf486241ed6c012595916 100755 --- a/trace_streamer/sdk/demo_sdk/protos/protogen.sh +++ b/trace_streamer/sdk/demo_sdk/protos/protogen.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/protos/protos.gni b/trace_streamer/sdk/demo_sdk/protos/protos.gni index 09c4f2f77e8030ce411934efc93da68ec41e245b..1c7592a3593eb75094b29ac67a4b5480dc07d062 100644 --- a/trace_streamer/sdk/demo_sdk/protos/protos.gni +++ b/trace_streamer/sdk/demo_sdk/protos/protos.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/BUILD.gn b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/BUILD.gn index ea60d11247d9f8666450d7c4b7b157e94a8b88ca..855f3b17e96d2592b5708c90759598c791502aa3 100644 --- a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/BUILD.gn +++ b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -33,26 +33,12 @@ foreach(proto, mock_data_sources) { "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", ] - mock_data_codegen_standard += [ - "$proto_out_dir/${name}_standard.pb.h", - "$proto_out_dir/${name}_standard.pb.cc", - ] mock_data_codegen_reader += [ "$proto_out_dir/$name.pbreader.h" ] } mock_data_codegen_all += mock_data_codegen mock_data_codegen_all += mock_data_codegen_standard mock_data_codegen_all += mock_data_codegen_reader -mock_plugin_config_sources = [ "./mock_plugin_config.proto" ] -mock_plugin_config_codegen_standard = [] -foreach(proto, mock_plugin_config_sources) { - name = get_path_info(proto, "name") - mock_plugin_config_codegen_standard += [ - "$proto_out_dir/${name}_standard.pb.h", - "$proto_out_dir/${name}_standard.pb.cc", - ] -} - config("cpu_include_config") { include_dirs = [ "$proto_out_dir" ] } @@ -102,19 +88,6 @@ ohos_source_set("mock_data_cpp_standard") { sources = mock_data_codegen_standard } -ohos_source_set("mock_plugin_config_cpp_standard") { - deps = [ ":mock_data_cpp_gen" ] - public_deps = [ - "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_lite_static", - "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protobuf_static", - ] - include_dirs = [ "$proto_out_dir" ] - public_configs = [ ":cpu_include_config" ] - sources = mock_plugin_config_codegen_standard - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" -} - ohos_source_set("mock_data_encoder") { deps = [ ":mock_data_cpp_gen" ] include_dirs = [ "$proto_out_dir" ] diff --git a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_config.proto b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_config.proto index 1f267cff59c12b1a2a37386930a546572eaeee22..024156efae697d8d2356ec2d8932a5abcdacaa18 100755 --- a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_config.proto +++ b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_result.proto b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_result.proto index 780c39196cd9a7fb55e57eb04b3241fbd6d56069..e1d9a939e010c91cdf8e25fe8ad78b115e89af88 100755 --- a/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_result.proto +++ b/trace_streamer/sdk/demo_sdk/protos/types/plugins/mock_data/mock_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.cpp b/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.cpp index cea67010deb373874cb3244928bdcaf87917e8f5..600920a9adea5b8fe2c78b8c7cd59204fe162a73 100644 --- a/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.cpp +++ b/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "demo_rpc_server.h" #include diff --git a/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.h b/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.h index d34e9d7c42f20c5a6f570dfef733e89ae1688433..f4f381004ac87147ac0a5417dd29c5841528793b 100644 --- a/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.h +++ b/trace_streamer/sdk/demo_sdk/rpc/demo_rpc_server.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp index 71932a4be9f3608ad5157b8fe85e48c5e0164e3d..c37b62b26c2258504e70f23625f573fcbfa8b5e8 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp +++ b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.h b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.h index 91b53e6d717711524de19dbd02b416333af5e9ed..9f3bef7cb0465924764b4af517e930a27625a979 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.h +++ b/trace_streamer/sdk/demo_sdk/sdk/sdk_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/ts.gni b/trace_streamer/sdk/demo_sdk/sdk/ts.gni index ca2553f28a01c663ae36c527081de2ee11902fd5..4ca0cd25e53fae1e0eac4583c0028aea7cef3b91 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/ts.gni +++ b/trace_streamer/sdk/demo_sdk/sdk/ts.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.cpp b/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.cpp index e5f0f604ce527193270c285af4197aff4e30802b..973c614e273359d384ecdd7e0d8fd6ec6875f6d9 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.cpp +++ b/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.h b/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.h index 4ce67f44b2ac9219b090cf111c5c5a6b278ee4ad..1f2fd9248ffea6cc81589e02392ba8fe712a7de0 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.h +++ b/trace_streamer/sdk/demo_sdk/sdk/ts_sdk_api.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/wasm_func.cpp b/trace_streamer/sdk/demo_sdk/sdk/wasm_func.cpp index ded228bdf5aa04cca17ba1f6bf428a02aafc5c04..1d4d342b2b190b3f9ea1e9ff6081330b78b7b373 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/wasm_func.cpp +++ b/trace_streamer/sdk/demo_sdk/sdk/wasm_func.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/sdk/wasm_func.h b/trace_streamer/sdk/demo_sdk/sdk/wasm_func.h index 94ffc8c2176cf9548e60792f292758d21d9d8f7c..9966cc169bad066677f35e1b6cb58efe9d1247f6 100644 --- a/trace_streamer/sdk/demo_sdk/sdk/wasm_func.h +++ b/trace_streamer/sdk/demo_sdk/sdk/wasm_func.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/demo_meta_table.cpp b/trace_streamer/sdk/demo_sdk/table/demo_meta_table.cpp index 41865534c5213e8bd1c2b72b33467b646976614a..ed457004949ee30dd98fc9cac1e7fa9aba8e96ab 100644 --- a/trace_streamer/sdk/demo_sdk/table/demo_meta_table.cpp +++ b/trace_streamer/sdk/demo_sdk/table/demo_meta_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/demo_meta_table.h b/trace_streamer/sdk/demo_sdk/table/demo_meta_table.h index f45e220a610bb62a213f91b357d6d1d26dd4cbd7..1e20285b9be5741159d981dd05daaa048df58678 100644 --- a/trace_streamer/sdk/demo_sdk/table/demo_meta_table.h +++ b/trace_streamer/sdk/demo_sdk/table/demo_meta_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/demo_table_base.cpp b/trace_streamer/sdk/demo_sdk/table/demo_table_base.cpp index 15c94ebf79a4de4160dc094645be71a47adaaa72..95351b893786e0ec545ec1bd8db99257c9400503 100644 --- a/trace_streamer/sdk/demo_sdk/table/demo_table_base.cpp +++ b/trace_streamer/sdk/demo_sdk/table/demo_table_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/demo_table_base.h b/trace_streamer/sdk/demo_sdk/table/demo_table_base.h index a715a60a987c070b426e80b5b8944620ed5574eb..792eac21590b693c0ac63b5bdc0feceb9b49865a 100644 --- a/trace_streamer/sdk/demo_sdk/table/demo_table_base.h +++ b/trace_streamer/sdk/demo_sdk/table/demo_table_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.cpp b/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.cpp index 7ebab31e054b24ffba23dc3aa8e4b97fba33bdd0..84630b8805c6588dc160d6f2b4a909dee442479d 100644 --- a/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.cpp +++ b/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.h b/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.h index 35eb32f32bd19cddf073e09c1f4abc866078d692..7449327c2214c98534d8e53d570001df4f3f4c22 100644 --- a/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.h +++ b/trace_streamer/sdk/demo_sdk/table/gpu_counter_object_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.cpp b/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.cpp index 4bae5eb5aa5c84f155d76a96683a0d11db043910..5691745b779b36f0f3ea2ea0a5ea6ea4d6380eac 100644 --- a/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.cpp +++ b/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.h b/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.h index 0a8bdda9658d3cfcce559a01730bc9cceb072c6a..530c5d89ccbcdc77253063a83080a0580f514cb5 100644 --- a/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.h +++ b/trace_streamer/sdk/demo_sdk/table/gpu_counter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/slice_object_table.cpp b/trace_streamer/sdk/demo_sdk/table/slice_object_table.cpp index 19dfe29dc1a84bd0042130dd2d45961b1cba136f..9e7c9bdc5b960802df3d259bac110d57bd1db3c4 100644 --- a/trace_streamer/sdk/demo_sdk/table/slice_object_table.cpp +++ b/trace_streamer/sdk/demo_sdk/table/slice_object_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/slice_object_table.h b/trace_streamer/sdk/demo_sdk/table/slice_object_table.h index bb5e95edc3443d3e2d74ec93bfe8cc7a58d1c3fd..db7f64590c0a3a69c9ff7448d6c2eadbace3d158 100644 --- a/trace_streamer/sdk/demo_sdk/table/slice_object_table.h +++ b/trace_streamer/sdk/demo_sdk/table/slice_object_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/slice_table.cpp b/trace_streamer/sdk/demo_sdk/table/slice_table.cpp index c93761fef3af6818d2e82f828c9d49754c79a2b7..a53f52a69140e6ae904505435b1b03cc0eefa5ef 100644 --- a/trace_streamer/sdk/demo_sdk/table/slice_table.cpp +++ b/trace_streamer/sdk/demo_sdk/table/slice_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/table/slice_table.h b/trace_streamer/sdk/demo_sdk/table/slice_table.h index 37a7e72674b797c304df85c232c2ddcd2be5cdf6..1516457dafbbec6087b9566eaa437f0fc5a9ea9d 100644 --- a/trace_streamer/sdk/demo_sdk/table/slice_table.h +++ b/trace_streamer/sdk/demo_sdk/table/slice_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/test/BUILD.gn b/trace_streamer/sdk/demo_sdk/test/BUILD.gn index 7cdd848dbbc96f5c877abe3fa7ce0ae9f0fb8110..06192a8e5a5e82a32f5f848591d7e0d8307f28a9 100644 --- a/trace_streamer/sdk/demo_sdk/test/BUILD.gn +++ b/trace_streamer/sdk/demo_sdk/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -40,7 +40,6 @@ if (target == "sdkdemotest") { "./", "../parser", "../cfg", - "${PREBUILTS}/emsdk/emsdk/emscripten/system/include", "${THIRD_PARTY}/sqlite/include", "${OHOS_PROTO_GEN}", "${OHOS_PROTO_GEN}/types/plugins/mock_data", diff --git a/trace_streamer/sdk/demo_sdk/test/unittest/sdk_api_test.cpp b/trace_streamer/sdk/demo_sdk/test/unittest/sdk_api_test.cpp index 536259ceabeaa06746074dd5889a3361463b1a07..c613bd2db5839e2dc243acf3d729be14165bf23c 100644 --- a/trace_streamer/sdk/demo_sdk/test/unittest/sdk_api_test.cpp +++ b/trace_streamer/sdk/demo_sdk/test/unittest/sdk_api_test.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.cpp b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.cpp index 11531a798fedf3e0f3f97042174606f96179fdc7..162d7ee418dae57319955f68cae4063a274c96eb 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.h b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.h index 458e196207c9453549cce8e2fae21419b110e6d1..329b8cf0aa638bd3e73b33744c16fcae71b6b9bc 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_reader.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.cpp b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.cpp index e9ba3a6063fcd9495432a5bce35b5c7cc621b61c..952268f428266ff0e8a217603705a3c37147e973 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.h b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.h index 0777a042ecd8d1b22674deb9eb1185e2a2511e3f..65a7cdfe75039aac88b7a83da0428d4346250944 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_cache_writer.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.cpp b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.cpp index 2e6c41249306e65e29ad90ad2b15fbabff623d77..8b92721fc95080fbb9a136c08c8b4578c318bc68 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.h b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.h index e1f530d7c54faafb303c0b3313698d15f10c0c69..a3d4ee2247f24354dda91885bc25e2f397fa2e5c 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/demo_trace_data_db.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.cpp b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.cpp index 76ff0c574a9d031ed43264a42c1bb75e83ba8eaf..6da285b4ecad188756601663f1f660f96200255f 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.h b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.h index 435b90f60b097f532ef4a7c30b45f4045580c79d..b7f023efaf719496652346696efc2097336c8151 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.cpp b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.cpp index 4d8dd22c63841c43d986bfbb83cb80ff8bfdcc9b..52ec6875f4f9a6623a13f2f59d09cb85a5478fab 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.h b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.h index db5460e7845496712c01cd85381a52b19d187a17..9efb966ae250f6666fb05d884c234c67b0338bd9 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_data_cache_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.cpp b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.cpp index 982122b824464a73b7e299a2eb729501c0476401..49265b3f7af9993dfb2ae5e2ea940ae6684ec784 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h index ebb1d7641ce6f74b629070f2478bc860a7b84852..af7c994d184b2f9d437e9f3dad7faa85ae999fd2 100644 --- a/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h +++ b/trace_streamer/sdk/demo_sdk/trace_data/trace_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.cpp b/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.cpp index cba3853d0c9f2a01127eb45e196f00431bdc843e..6b4cea746ca5baceb59a6f6a7ba42af040fd8c4d 100644 --- a/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.cpp +++ b/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.h b/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.h index 7306899e31d0bee0e1944444bec2b212cd53e1b6..aa3927b5e9b72579da9ea47b48fb0b3017ed59f4 100644 --- a/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.h +++ b/trace_streamer/sdk/demo_sdk/trace_streamer/trace_streamer_selector.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/ts.gni b/trace_streamer/sdk/demo_sdk/ts.gni index ca2553f28a01c663ae36c527081de2ee11902fd5..4ca0cd25e53fae1e0eac4583c0028aea7cef3b91 100644 --- a/trace_streamer/sdk/demo_sdk/ts.gni +++ b/trace_streamer/sdk/demo_sdk/ts.gni @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/sdk/demo_sdk/version.cpp b/trace_streamer/sdk/demo_sdk/version.cpp index 3edd0a61995128007579f7958377822027311dfb..eff03c9a794cb3b8a44c97b8ac06e975e7e92123 100644 --- a/trace_streamer/sdk/demo_sdk/version.cpp +++ b/trace_streamer/sdk/demo_sdk/version.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdk/demo_sdk/version.h b/trace_streamer/sdk/demo_sdk/version.h index a3d980964471bb8f78e54e6ae09405de8fbb128f..17633bf372612d35fc7f4c90e54e377b395786ae 100644 --- a/trace_streamer/sdk/demo_sdk/version.h +++ b/trace_streamer/sdk/demo_sdk/version.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/sdktest.sh b/trace_streamer/sdktest.sh index c485bd0aa1729fca043c1d44d1f5c6ef4c7b00f7..f662cafc3170656cac2b4bfd2446e5d90fed1fe2 100755 --- a/trace_streamer/sdktest.sh +++ b/trace_streamer/sdktest.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/BUILD.gn b/trace_streamer/src/BUILD.gn index a2338a1ec2a2690bf674341c4d8ed9be06ad7e4a..9b7e6acef9920b4da0e8b48792758d906c8dee19 100644 --- a/trace_streamer/src/BUILD.gn +++ b/trace_streamer/src/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -134,13 +134,6 @@ ohos_source_set("trace_streamer_source") { "${SRC}/trace_data/trace_stdtype/htrace", "${SRC}/trace_data/trace_stdtype/measure", ] - if (use_wasm) { - include_dirs += - [ "../prebuilts/emsdk/emsdk/emscripten/cache/sysroot/include" ] - } - if (is_test) { - include_dirs += [ "../prebuilts/emsdk/emsdk/emscripten/system/include" ] - } if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] diff --git a/trace_streamer/src/base/BUILD.gn b/trace_streamer/src/base/BUILD.gn index d9bc1131a9d197efaffcb09b74ffa6ec03ad72b3..70209b12c1c643a49e488f7253611a65277fe5db 100644 --- a/trace_streamer/src/base/BUILD.gn +++ b/trace_streamer/src/base/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/base/args_set.h b/trace_streamer/src/base/args_set.h index 579c2e41ae91aadb99e1717e28ca7949c0ec2bb2..493f46340bf39fb7aa72baf7ba2211f2dd0c85c5 100644 --- a/trace_streamer/src/base/args_set.h +++ b/trace_streamer/src/base/args_set.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/base_map.h b/trace_streamer/src/base/base_map.h index 1c3f922659d29627866093e8d5f87df65b85e6f8..9cd0b26db1bd6d25d66ce2e1201907d6b5cb8199 100644 --- a/trace_streamer/src/base/base_map.h +++ b/trace_streamer/src/base/base_map.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/clock_filter.cpp b/trace_streamer/src/base/clock_filter.cpp index 80abb9387c95737d4bfb7819ec650c1ad665f38e..ccf97abb32f46eeef64abbbc5a909fa36c557db5 100644 --- a/trace_streamer/src/base/clock_filter.cpp +++ b/trace_streamer/src/base/clock_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/clock_filter.h b/trace_streamer/src/base/clock_filter.h index dad3df4d6113398b453ae9cb6a4fcfb60a5afaba..0e058f6a5e94640b12db53efaef8bb773bea657f 100644 --- a/trace_streamer/src/base/clock_filter.h +++ b/trace_streamer/src/base/clock_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/codec_cov.cpp b/trace_streamer/src/base/codec_cov.cpp index 342c22e4e4668befde1d061cea655510c19af113..383ddfed5a38eb7a73203d35681c8d6edbb60eec 100644 --- a/trace_streamer/src/base/codec_cov.cpp +++ b/trace_streamer/src/base/codec_cov.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/codec_cov.h b/trace_streamer/src/base/codec_cov.h index 93b8404ba1f58cbed15a9f08102a84c5335a5998..cb2c8a4ed6215111b507631d8969d982f3bb5596 100644 --- a/trace_streamer/src/base/codec_cov.h +++ b/trace_streamer/src/base/codec_cov.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/double_map.h b/trace_streamer/src/base/double_map.h index ea5722af8684a3b9fb668b895a6272b51c249c9a..325ce80bc3408fc2c2fb32e13fffa2dff5ae5370 100644 --- a/trace_streamer/src/base/double_map.h +++ b/trace_streamer/src/base/double_map.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/file.cpp b/trace_streamer/src/base/file.cpp index b4d9feca8d26fa4f3b79130bb29d7ab0dcb251d0..e6e124b59364a95588289d63f6c7ac0990f353c9 100644 --- a/trace_streamer/src/base/file.cpp +++ b/trace_streamer/src/base/file.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/file.h b/trace_streamer/src/base/file.h index 6758056888f2a2b5f86a091f9faac9507827f318..db33d5f7f98267d728a21c09230bf07befdc3be1 100644 --- a/trace_streamer/src/base/file.h +++ b/trace_streamer/src/base/file.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/filter_constraints.cpp b/trace_streamer/src/base/filter_constraints.cpp index 41c379522ecc3fb72933624fee347ea3b84e0437..90574cd70156e6bd6fe16c3e6c213df501789821 100644 --- a/trace_streamer/src/base/filter_constraints.cpp +++ b/trace_streamer/src/base/filter_constraints.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/filter_constraints.h b/trace_streamer/src/base/filter_constraints.h index 927c6c6f46b36f5bd9f18c78c08167f86f4d4031..bd4db5bf623f47acfeb1b52b241f06515e8e7f5e 100644 --- a/trace_streamer/src/base/filter_constraints.h +++ b/trace_streamer/src/base/filter_constraints.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/htrace_file_header.h b/trace_streamer/src/base/htrace_file_header.h index 0056043a596b39daf59493a39c27f7e8868a809b..43e827c194c6a4bcb2a25822b3df1fdd3fe697d4 100644 --- a/trace_streamer/src/base/htrace_file_header.h +++ b/trace_streamer/src/base/htrace_file_header.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/htrace_plugin_time_parser.cpp b/trace_streamer/src/base/htrace_plugin_time_parser.cpp index a77b9ab6db24bc688ac139e1dfe926eba6a31367..7f50417a88da8acd074e01e287051fdd7a0b4bbe 100644 --- a/trace_streamer/src/base/htrace_plugin_time_parser.cpp +++ b/trace_streamer/src/base/htrace_plugin_time_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/htrace_plugin_time_parser.h b/trace_streamer/src/base/htrace_plugin_time_parser.h index 3899b2d18230b4a7c34a585f7e94dfb1172b2450..f71c4e232e1f57336564e4f393b99f5bfeb41f5c 100644 --- a/trace_streamer/src/base/htrace_plugin_time_parser.h +++ b/trace_streamer/src/base/htrace_plugin_time_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/index_map.cpp b/trace_streamer/src/base/index_map.cpp index 5f98514633c1d50c58b66fb71a41878f477da091..5edbe222a7be57c8645c58d2d3003824b272c72d 100644 --- a/trace_streamer/src/base/index_map.cpp +++ b/trace_streamer/src/base/index_map.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/index_map.h b/trace_streamer/src/base/index_map.h index df5b9e068fe1c489f2f9db72a11b3ce40642bb8f..3bedee70223d217db94f7345bf7ba0884e4730a9 100644 --- a/trace_streamer/src/base/index_map.h +++ b/trace_streamer/src/base/index_map.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/log.cpp b/trace_streamer/src/base/log.cpp index f1d9948ecd727439d126eb1faf9fff16e300f4b7..6788b21fcf0bc46f423e301a2c997fb3f4327bff 100644 --- a/trace_streamer/src/base/log.cpp +++ b/trace_streamer/src/base/log.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/log.h b/trace_streamer/src/base/log.h index 11bfcb6b7c59fb5ea9afeca5ab9cb4b9ec71202f..201dc8e432065c9969997e6465e3f6e35fa67a72 100644 --- a/trace_streamer/src/base/log.h +++ b/trace_streamer/src/base/log.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/numerical_to_string.h b/trace_streamer/src/base/numerical_to_string.h index d9eaf5bd5ce6a2e943dc7415d4bd1d8ac889b179..3290589a4382b3f24e6b3a161d368b288cf38046 100644 --- a/trace_streamer/src/base/numerical_to_string.h +++ b/trace_streamer/src/base/numerical_to_string.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/optimize.h b/trace_streamer/src/base/optimize.h index e44a6bdf4e3f42443f27cc966ccb7fdcb87db0b6..ef870b3d1ddbb09903697c447b1ff9ffa149817d 100644 --- a/trace_streamer/src/base/optimize.h +++ b/trace_streamer/src/base/optimize.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/parting_string.cpp b/trace_streamer/src/base/parting_string.cpp index a5c9ec69d679250a3d7abac27036e29aeea8a883..4447727834d21e0817a56ede99920970f8091ae1 100644 --- a/trace_streamer/src/base/parting_string.cpp +++ b/trace_streamer/src/base/parting_string.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/parting_string.h b/trace_streamer/src/base/parting_string.h index 9cb1767f1205e3a8ef508af7b122d7689261fc82..d80f1d9784b25c0f5d21651fe37f4aa550125d58 100644 --- a/trace_streamer/src/base/parting_string.h +++ b/trace_streamer/src/base/parting_string.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/quatra_map.h b/trace_streamer/src/base/quatra_map.h index 7492f05d61b4ca1dc0cfa256bd9187d92ead5ec4..a79fed7d7f78a89ace8cf9f346c361f1a93f20cb 100644 --- a/trace_streamer/src/base/quatra_map.h +++ b/trace_streamer/src/base/quatra_map.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/sqlite_ext/BUILD.gn b/trace_streamer/src/base/sqlite_ext/BUILD.gn index 9cdf7cea753b0a8af5249cd59e1ca845da756e3d..206301b1b2d38306cf34aca9d470441d022e95fb 100644 --- a/trace_streamer/src/base/sqlite_ext/BUILD.gn +++ b/trace_streamer/src/base/sqlite_ext/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp index 9aedc509420349cdc04b9dc88db7963e23b9ac88..28c01897d5dad8caf915fc4e31ac36a1dabc3500 100644 --- a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp +++ b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.h b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.h index e1ce74a727d69a10d177682f38f54ac943c0687c..aeadf43d5744bdbd12d3d134db0935e350510cfa 100644 --- a/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.h +++ b/trace_streamer/src/base/sqlite_ext/sqlite_ext_funcs.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/string_help.cpp b/trace_streamer/src/base/string_help.cpp index 45b1a3133a49647c8124f322be2ddfbc47ff9e9e..f22dc236fce838788bcf5ecd3e08ff706885f3e7 100644 --- a/trace_streamer/src/base/string_help.cpp +++ b/trace_streamer/src/base/string_help.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -62,6 +62,18 @@ std::vector SplitStringToVec(const std::string& str, const std::str return result; } +std::string TrimInvisibleCharacters(const std::string& str) +{ + size_t start = 0; + size_t end = str.length() - 1; + while (start <= end && !std::isgraph(str[start])) { + start++; + } + while (end >= start && !std::isgraph(str[end])) { + end--; + } + return str.substr(start, end - start + 1); +} std::string FormatString(const char* p) { diff --git a/trace_streamer/src/base/string_help.h b/trace_streamer/src/base/string_help.h index 3db8f724fd4e2482679b3c22892b7c4680e8be65..4123a0e1ebf1b524dcafb57e1aa43dd8d5999960 100644 --- a/trace_streamer/src/base/string_help.h +++ b/trace_streamer/src/base/string_help.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -28,6 +28,7 @@ bool StartWith(const std::string& str, const std::string& res); bool EndWith(const std::string& str, const std::string& res); std::string FormatString(const char* p); std::string Strip(const std::string& str); +std::string TrimInvisibleCharacters(const std::string& str); } // namespace base } // namespace SysTuning #endif // SRC_TRACE_BASE_STRINGHELP_H diff --git a/trace_streamer/src/base/string_to_numerical.h b/trace_streamer/src/base/string_to_numerical.h index 52ac6547c4d7402c27fe733563f96886b18f2d4c..75f0512503f15a3d27589023d57f2d5e7397d313 100644 --- a/trace_streamer/src/base/string_to_numerical.h +++ b/trace_streamer/src/base/string_to_numerical.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/triple_map.h b/trace_streamer/src/base/triple_map.h index 9326eebb705394d44f43fc9ed8f6ad45543282de..bd5141bf897827270149cda4506555451a42c2c0 100644 --- a/trace_streamer/src/base/triple_map.h +++ b/trace_streamer/src/base/triple_map.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/ts_common.cpp b/trace_streamer/src/base/ts_common.cpp index 5c0c967fecde1707470610140a337f1ebd859821..e78ec0c7ed73a84efd3eac64134ab53eca210f76 100644 --- a/trace_streamer/src/base/ts_common.cpp +++ b/trace_streamer/src/base/ts_common.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/base/ts_common.h b/trace_streamer/src/base/ts_common.h index 8e3b3a8013a627d7ba376326467b7d862a9d6247..6a0070d07f51437de25c5935a852483d121b505d 100644 --- a/trace_streamer/src/base/ts_common.h +++ b/trace_streamer/src/base/ts_common.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/cfg/trace_streamer_config.cpp b/trace_streamer/src/cfg/trace_streamer_config.cpp index 667be5eda13b0510879181a4a7ee3826bcc09630..bcd49944416ec79a023325383b10630d09f1f5c3 100644 --- a/trace_streamer/src/cfg/trace_streamer_config.cpp +++ b/trace_streamer/src/cfg/trace_streamer_config.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/cfg/trace_streamer_config.h b/trace_streamer/src/cfg/trace_streamer_config.h index 14dd2cffd96b63dc5ce2f6eb108457dc84766703..056732c45711acb8740d00f69999e4cf5852f693 100644 --- a/trace_streamer/src/cfg/trace_streamer_config.h +++ b/trace_streamer/src/cfg/trace_streamer_config.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/BUILD.gn b/trace_streamer/src/filter/BUILD.gn index 994896a21f43e0953d62d3c421a6c15c3fffbc61..958d463ebb6043cfd869fdfb5543408e405dfe00 100644 --- a/trace_streamer/src/filter/BUILD.gn +++ b/trace_streamer/src/filter/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/filter/animation_filter.cpp b/trace_streamer/src/filter/animation_filter.cpp index fa4cb4826934162c0b4b92a4c0215d83a691f057..3f13acca02d2bafc81a2200720d8a425567b3239 100644 --- a/trace_streamer/src/filter/animation_filter.cpp +++ b/trace_streamer/src/filter/animation_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/animation_filter.h b/trace_streamer/src/filter/animation_filter.h index f033c94914f2d7afd635e719c3951a92fe708756..a9cb027fabafd932aacbed1f643fa5d0470cffb7 100644 --- a/trace_streamer/src/filter/animation_filter.h +++ b/trace_streamer/src/filter/animation_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/app_start_filter.cpp b/trace_streamer/src/filter/app_start_filter.cpp index 29bc755adbdc2e75377210b38c28e48e3b5e1864..73a8eb1b7786338c5d294ea227c3dad935001871 100644 --- a/trace_streamer/src/filter/app_start_filter.cpp +++ b/trace_streamer/src/filter/app_start_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/app_start_filter.h b/trace_streamer/src/filter/app_start_filter.h index f7385b103bd3f10048820153d0dab47a1ca11e77..8e670d5a93a394393d9dd20d1f8adf66718586b2 100644 --- a/trace_streamer/src/filter/app_start_filter.h +++ b/trace_streamer/src/filter/app_start_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/args_filter.cpp b/trace_streamer/src/filter/args_filter.cpp index 6a45b80612ca26cf3276ce8aa2ba81b0f86a367d..1c1e456d7b99ece81cd46a0ca0992f96a2ecd954 100644 --- a/trace_streamer/src/filter/args_filter.cpp +++ b/trace_streamer/src/filter/args_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/args_filter.h b/trace_streamer/src/filter/args_filter.h index 2f187d193d3f3bd367a3ec5601da3a20e973a38d..4295cffb3fc96d2f97e501577de100551a8967f6 100644 --- a/trace_streamer/src/filter/args_filter.h +++ b/trace_streamer/src/filter/args_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/binder_filter.cpp b/trace_streamer/src/filter/binder_filter.cpp index ee83aa9157fd676d27f00db8aa4a1d0cc192e837..cc1b14ac17d55b3dc54991f2c9933b3fa23dde8e 100644 --- a/trace_streamer/src/filter/binder_filter.cpp +++ b/trace_streamer/src/filter/binder_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/binder_filter.h b/trace_streamer/src/filter/binder_filter.h index 457dee0b9d123de2dc4ea9598614772e18347e68..81323fe0a2b26afff6a772dda18432870c117b25 100644 --- a/trace_streamer/src/filter/binder_filter.h +++ b/trace_streamer/src/filter/binder_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/clock_filter_ex.cpp b/trace_streamer/src/filter/clock_filter_ex.cpp index 98d68f1b3a0dd4e841fd93c1d42aaf5ec5af4cae..cfcb654340aa4f4131f01a0814b78298388c883a 100644 --- a/trace_streamer/src/filter/clock_filter_ex.cpp +++ b/trace_streamer/src/filter/clock_filter_ex.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/clock_filter_ex.h b/trace_streamer/src/filter/clock_filter_ex.h index ce14b5b60cc3e5db7b7ec9a0d5131a875f1a1197..f6a661a42ffbe1243bccbee863b68985260fc0d8 100644 --- a/trace_streamer/src/filter/clock_filter_ex.h +++ b/trace_streamer/src/filter/clock_filter_ex.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/cpu_filter.cpp b/trace_streamer/src/filter/cpu_filter.cpp index e83266367952764859e0d86f2c878748bb49a1f4..3176043b92b9ade32ebfad67aa5912e71485b35c 100644 --- a/trace_streamer/src/filter/cpu_filter.cpp +++ b/trace_streamer/src/filter/cpu_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -67,9 +67,11 @@ void CpuFilter::ProcPrevPidSwitchEvent(uint64_t ts, if (lastRow != INVALID_UINT64) { auto lastCpu = traceDataCache_->GetConstThreadStateData().CpusData()[lastRow]; auto lastState = traceDataCache_->GetConstThreadStateData().StatesData()[lastRow]; - auto lastStartTs = traceDataCache_->GetConstThreadStateData().TimeStamsData()[lastRow]; - if ((cpu != lastCpu) && (lastState == TASK_RUNNING) && (ts == lastStartTs)) { - isChangeCpu = true; + auto lastStartTs = traceDataCache_->GetConstThreadStateData().TimeStampData()[lastRow]; + if ((cpu != lastCpu) && (lastState == TASK_RUNNING)) { + if (traceDataCache_->HMKernelTraceEnabled() || (ts == lastStartTs)) { + isChangeCpu = true; + } } if (!isChangeCpu) { CheckWakeupEvent(prevPid); @@ -99,14 +101,14 @@ void CpuFilter::ProcPrevPidSwitchEvent(uint64_t ts, void CpuFilter::InsertSwitchEvent(uint64_t ts, uint64_t cpu, uint32_t prevPid, - uint64_t prevPior, + int32_t prevPrio, uint64_t prevState, uint32_t nextPid, - uint64_t nextPior, + int32_t nextPrio, DataIndex nextInfo) { BinderTransactionInfo btInfo = {prevPid, nextPid, INVALID_UINT64, INVALID_UINT64}; - auto index = traceDataCache_->GetSchedSliceData()->AppendSchedSlice(ts, INVALID_UINT64, cpu, nextPid, 0, nextPior); + auto index = traceDataCache_->GetSchedSliceData()->AppendSchedSlice(ts, INVALID_UINT64, cpu, nextPid, 0, nextPrio); auto prevTidOnCpu = cpuToRowSched_.find(cpu); if (prevTidOnCpu != cpuToRowSched_.end()) { traceDataCache_->GetSchedSliceData()->Update(prevTidOnCpu->second.row, ts, prevState); @@ -193,26 +195,9 @@ bool CpuFilter::InsertProcessFreeEvent(uint64_t ts, uint32_t pid) void CpuFilter::Finish() const { - auto size = traceDataCache_->ThreadSize(); - for (auto i = 0; i < size; i++) { - auto thread = traceDataCache_->GetThreadData(i); - if (thread->internalPid_ != INVALID_UINT32) { - traceDataCache_->GetProcessData(thread->internalPid_)->threadCount_++; - traceDataCache_->GetProcessData(thread->internalPid_)->cpuStatesCount_ += thread->cpuStatesCount_; - traceDataCache_->GetProcessData(thread->internalPid_)->sliceSize_ += thread->sliceSize_; - traceDataCache_->GetProcessData(thread->internalPid_)->switchCount_ += thread->switchCount_; - continue; - } - auto ipid = traceDataCache_->AppendNewProcessData( - thread->tid_, traceDataCache_->GetDataFromDict(thread->nameIndex_), thread->startT_); - thread->internalPid_ = ipid; - traceDataCache_->GetProcessData(thread->internalPid_)->threadCount_++; - traceDataCache_->GetProcessData(thread->internalPid_)->cpuStatesCount_ += thread->cpuStatesCount_; - traceDataCache_->GetProcessData(thread->internalPid_)->sliceSize_ += thread->sliceSize_; - traceDataCache_->GetProcessData(thread->internalPid_)->switchCount_ += thread->switchCount_; - } + UpdateProcessData(true); auto threadState = traceDataCache_->GetConstThreadStateData(); - size = threadState.Size(); + auto size = threadState.Size(); auto rowData = threadState.ItidsData(); for (auto i = 0; i < size; i++) { auto thread = traceDataCache_->GetThreadData(rowData[i]); @@ -339,5 +324,56 @@ void CpuFilter::TransactionClear(uint32_t iTidFrom, uint32_t transactionId) transactionIdToInfo_.erase(transactionId); } } + +void CpuFilter::UpdateProcessData(bool isFinish) const +{ + for (auto i = 0; i < traceDataCache_->ThreadSize(); i++) { + auto thread = traceDataCache_->GetThreadData(i); + if (thread->internalPid_ != INVALID_UINT32) { + if (!isFinish) { + continue; + } + traceDataCache_->GetProcessData(thread->internalPid_)->threadCount_++; + traceDataCache_->GetProcessData(thread->internalPid_)->cpuStatesCount_ += thread->cpuStatesCount_; + traceDataCache_->GetProcessData(thread->internalPid_)->sliceSize_ += thread->sliceSize_; + traceDataCache_->GetProcessData(thread->internalPid_)->switchCount_ += thread->switchCount_; + continue; + } + auto ipid = traceDataCache_->AppendNewProcessData( + thread->tid_, traceDataCache_->GetDataFromDict(thread->nameIndex_), thread->startT_); + thread->internalPid_ = ipid; + traceDataCache_->GetProcessData(thread->internalPid_)->threadCount_++; + traceDataCache_->GetProcessData(thread->internalPid_)->cpuStatesCount_ += thread->cpuStatesCount_; + traceDataCache_->GetProcessData(thread->internalPid_)->sliceSize_ += thread->sliceSize_; + traceDataCache_->GetProcessData(thread->internalPid_)->switchCount_ += thread->switchCount_; + } +} + +bool CpuFilter::UpdateSchedSliceReadySize(uint64_t minSchedSliceRowToBeUpdated) +{ + auto schedSlice = traceDataCache_->GetSchedSliceData(); + for (auto i = 0; i < schedSlice->Size(); i++) { + traceDataCache_->GetSchedSliceData()->ReviseInternalPid( + i, traceDataCache_->GetThreadData(schedSlice->InternalTidsData()[i])->internalPid_); + } + schedSlice->UpdateReadySize(schedSlice->Size()); + for (const auto& [_, schedSliceInfo] : cpuToRowSched_) { + if (minSchedSliceRowToBeUpdated > schedSliceInfo.row) { + minSchedSliceRowToBeUpdated = schedSliceInfo.row; + } + } + // the ready size isn't all + TS_CHECK_TRUE_RET(minSchedSliceRowToBeUpdated != INVALID_UINT64, true); + schedSlice->UpdateReadySize(minSchedSliceRowToBeUpdated); + TS_LOGI("minSchedSliceRowToBeUpdated=%" PRIu64 ", size=%zu, ready.size=%zu\n", minSchedSliceRowToBeUpdated, + schedSlice->Size(), schedSlice->readySize_); + for (auto& [_, schedSliceInfo] : cpuToRowSched_) { + schedSliceInfo.row -= schedSlice->readySize_; + } + for (auto& [_, binderTransactionInfo] : transactionIdToInfo_) { + binderTransactionInfo.schedSliceRow -= schedSlice->readySize_; + } + return true; +} } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/filter/cpu_filter.h b/trace_streamer/src/filter/cpu_filter.h index ec1535b243b1c49da2ed086dc7f63a8517468511..2c49cd2984fcef489ea18703e4b0c5e42e3cc9b7 100644 --- a/trace_streamer/src/filter/cpu_filter.h +++ b/trace_streamer/src/filter/cpu_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -41,10 +41,10 @@ public: void InsertSwitchEvent(uint64_t ts, uint64_t cpu, uint32_t prevPid, - uint64_t prevPior, + int32_t prevPrio, uint64_t prevState, uint32_t nextPid, - uint64_t nextPior, + int32_t nextPrio, DataIndex nextInfo); bool InsertBlockedReasonEvent(uint64_t ts, uint64_t cpu, @@ -59,6 +59,18 @@ public: void InsertRunnableBinderRecvEvent(uint32_t transactionId, uint32_t iTid); void Finish() const; void Clear(); + void UpdateProcessData(bool isFinish = false) const; + void UpdateReadySize() + { + UpdateProcessData(); + uint64_t minSchedSliceRowToBeUpdated = INVALID_UINT64; + for (const auto& [_, binderTransactionInfo] : transactionIdToInfo_) { + if (minSchedSliceRowToBeUpdated > binderTransactionInfo.schedSliceRow) { + minSchedSliceRowToBeUpdated = binderTransactionInfo.schedSliceRow; + } + } + UpdateSchedSliceReadySize(minSchedSliceRowToBeUpdated); + } private: struct BinderTransactionInfo { @@ -79,6 +91,9 @@ private: uint32_t prevPid, uint64_t prevState, BinderTransactionInfo& btInfo); + bool UpdateSchedSliceReadySize(uint64_t minSchedSliceRowToBeUpdated = INVALID_UINT64); + +private: std::map cpuToRowThreadState_ = {}; typedef struct { uint32_t iTid; diff --git a/trace_streamer/src/filter/filter_base.cpp b/trace_streamer/src/filter/filter_base.cpp index d3bbcd5b42879f975af15193fce3d312721a2724..8d68ad707f0458c3c0bcd95ecb57ad2f91d37f24 100644 --- a/trace_streamer/src/filter/filter_base.cpp +++ b/trace_streamer/src/filter/filter_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/filter_base.h b/trace_streamer/src/filter/filter_base.h index 7f75e55d17483454b85df64d28c2494fad1d31cd..a9e81b7638b0be190dcb5e18bc9d21637c60c824 100644 --- a/trace_streamer/src/filter/filter_base.h +++ b/trace_streamer/src/filter/filter_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/filter_filter.cpp b/trace_streamer/src/filter/filter_filter.cpp index 9ed67817f6586a843e6212e2a06da8cd43dd1c73..3e6d6d9025fa1e627e6dbcaf1d332252b64640e6 100644 --- a/trace_streamer/src/filter/filter_filter.cpp +++ b/trace_streamer/src/filter/filter_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -31,8 +31,9 @@ FilterFilter::~FilterFilter() = default; uint32_t FilterFilter::AddFilter(std::string type, std::string name, uint64_t arg) { auto filter = traceDataCache_->GetFilterData(); - size_t id = filter->AppendNewFilterData(type, name, arg); - return static_cast(id); + filter->AppendNewFilterData(type, name, arg); + // the filter id is the measure_filter table row + return static_cast(filter->id_ - 1); } } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/filter/filter_filter.h b/trace_streamer/src/filter/filter_filter.h index cef929bb0a378faa79f4a97cc828ee68e7d56299..75debbf6bb55d058e28f3e6b4674da727f3f4dc7 100644 --- a/trace_streamer/src/filter/filter_filter.h +++ b/trace_streamer/src/filter/filter_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/frame_filter.cpp b/trace_streamer/src/filter/frame_filter.cpp index 18ea13237c856d1dbb621d3d9c8972968b335c17..2a153875ad2525fc9316aae4347aa9ccd92b1deb 100644 --- a/trace_streamer/src/filter/frame_filter.cpp +++ b/trace_streamer/src/filter/frame_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -94,16 +94,10 @@ bool FrameFilter::BeginProcessCommandUni(uint64_t ts, uint32_t sliceIndex) { auto frame = vsyncRenderSlice_.find(itid); - if (frame == vsyncRenderSlice_.end()) { - return false; - } - if (!frame->second.size()) { - return false; - } + TS_CHECK_TRUE_RET(frame != vsyncRenderSlice_.end(), false); + TS_CHECK_TRUE_RET(!frame->second.empty(), false); auto lastFrameSlice = frame->second.back(); - if (lastFrameSlice->vsyncEnd_) { - return false; - } + TS_CHECK_TRUE_RET(!lastFrameSlice->vsyncEnd_, false); std::vector fromSlices = {}; std::vector fromExpectedSlices = {}; for (auto& it : frames) { @@ -115,26 +109,23 @@ bool FrameFilter::BeginProcessCommandUni(uint64_t ts, if (srcFrame == sourceFrameMap->second.end()) { continue; } - fromSlices.push_back(srcFrame->second.get()->frameSliceRow_); - fromExpectedSlices.push_back(srcFrame->second.get()->frameExpectedSliceRow_); - srcFrame->second.get()->dstFrameSliceId_ = lastFrameSlice->frameSliceRow_; - srcFrame->second.get()->dstExpectedFrameSliceId_ = lastFrameSlice->frameExpectedSliceRow_; + fromSlices.push_back(srcFrame->second->frameSliceRow_); + fromExpectedSlices.push_back(srcFrame->second->frameExpectedSliceRow_); + srcFrame->second->dstFrameSliceId_ = lastFrameSlice->frameSliceRow_; + srcFrame->second->dstExpectedFrameSliceId_ = lastFrameSlice->frameExpectedSliceRow_; TraceStdtype::FrameSlice* frameSlice = traceDataCache_->GetFrameSliceData(); - (void)traceDataCache_->GetFrameMapsData()->AppendNew(frameSlice, srcFrame->second.get()->frameSliceRow_, - srcFrame->second.get()->dstFrameSliceId_); - (void)traceDataCache_->GetFrameMapsData()->AppendNew(frameSlice, srcFrame->second.get()->frameExpectedSliceRow_, - srcFrame->second.get()->dstExpectedFrameSliceId_); - frameSlice->SetDst(srcFrame->second.get()->frameSliceRow_, srcFrame->second.get()->dstFrameSliceId_); - frameSlice->SetDst(srcFrame->second.get()->frameExpectedSliceRow_, - srcFrame->second.get()->dstExpectedFrameSliceId_); - if (srcFrame->second.get()->endTs_ != INVALID_UINT64) { + (void)traceDataCache_->GetFrameMapsData()->AppendNew(frameSlice, srcFrame->second->frameSliceRow_, + srcFrame->second->dstFrameSliceId_); + (void)traceDataCache_->GetFrameMapsData()->AppendNew(frameSlice, srcFrame->second->frameExpectedSliceRow_, + srcFrame->second->dstExpectedFrameSliceId_); + frameSlice->SetDst(srcFrame->second->frameSliceRow_, srcFrame->second->dstFrameSliceId_); + frameSlice->SetDst(srcFrame->second->frameExpectedSliceRow_, srcFrame->second->dstExpectedFrameSliceId_); + if (srcFrame->second->endTs_ != INVALID_UINT64) { // erase Source sourceFrameMap->second.erase(it.frameNum); } } - if (!fromSlices.size()) { - return false; - } + TS_CHECK_TRUE_RET(!fromSlices.empty(), false); lastFrameSlice->sourceSlice_ = fromSlices; lastFrameSlice->sourceExpectedSlice_ = fromExpectedSlices; traceDataCache_->GetFrameSliceData()->SetSrcs(lastFrameSlice->frameSliceRow_, fromSlices); @@ -206,7 +197,9 @@ bool FrameFilter::EndFrameQueue(uint64_t ts, uint32_t itid) return false; } auto firstFrameSlicePos = frame->second.begin(); - (void)traceDataCache_->GetGPUSliceData()->AppendNew(firstFrameSlicePos->get()->frameSliceRow_, + TraceStdtype::FrameSlice* frameSlice = traceDataCache_->GetFrameSliceData(); + (void)traceDataCache_->GetGPUSliceData()->AppendNew(frameSlice->diskTableSize_ + + (*firstFrameSlicePos)->frameSliceRow_, ts - firstFrameSlicePos->get()->frameQueueStartTs_); firstFrameSlicePos->get()->gpuEnd_ = true; if (firstFrameSlicePos->get()->vsyncEnd_) { @@ -219,6 +212,55 @@ bool FrameFilter::EndFrameQueue(uint64_t ts, uint32_t itid) } return true; } +void FrameFilter::SetMinFrameSliceRow(uint64_t& minFrameSliceRowToBeUpdated) +{ + for (const auto& [_, frameSlices] : vsyncRenderSlice_) { + for (size_t idx = 0; idx < frameSlices.size(); idx++) { + if (minFrameSliceRowToBeUpdated > frameSlices[idx]->frameSliceRow_) { + minFrameSliceRowToBeUpdated = frameSlices[idx]->frameSliceRow_; + } + if (minFrameSliceRowToBeUpdated > frameSlices[idx]->frameExpectedSliceRow_) { + minFrameSliceRowToBeUpdated = frameSlices[idx]->frameExpectedSliceRow_; + } + } + } + for (const auto& pair : dstRenderSlice_) { + for (const auto& [_, frameSlice] : pair.second) { + if (minFrameSliceRowToBeUpdated > frameSlice->frameSliceRow_) { + minFrameSliceRowToBeUpdated = frameSlice->frameSliceRow_; + } + if (minFrameSliceRowToBeUpdated > frameSlice->frameExpectedSliceRow_) { + minFrameSliceRowToBeUpdated = frameSlice->frameExpectedSliceRow_; + } + } + } +} +bool FrameFilter::UpdateFrameSliceReadySize() +{ + traceDataCache_->GetFrameSliceData()->UpdateDepth(); + auto frameSlice = traceDataCache_->GetFrameSliceData(); + frameSlice->UpdateReadySize(frameSlice->Size()); + uint64_t minFrameSliceRowToBeUpdated = INVALID_UINT64; + SetMinFrameSliceRow(minFrameSliceRowToBeUpdated); + // the ready size isn't all + TS_CHECK_TRUE_RET(minFrameSliceRowToBeUpdated != INVALID_UINT64, true); + frameSlice->UpdateReadySize(minFrameSliceRowToBeUpdated); + TS_LOGI("minFrameSliceRowToBeUpdated=%" PRIu64 ", size=%zu, ready.size=%zu\n", minFrameSliceRowToBeUpdated, + frameSlice->Size(), frameSlice->readySize_); + for (auto& [_, frameSlices] : vsyncRenderSlice_) { + for (size_t idx = 0; idx < frameSlices.size(); idx++) { + frameSlices[idx]->frameSliceRow_ -= minFrameSliceRowToBeUpdated; + frameSlices[idx]->frameExpectedSliceRow_ -= minFrameSliceRowToBeUpdated; + } + } + for (const auto& pair : dstRenderSlice_) { + for (const auto& [_, frameSlice] : pair.second) { + frameSlice->frameSliceRow_ -= minFrameSliceRowToBeUpdated; + frameSlice->frameExpectedSliceRow_ -= minFrameSliceRowToBeUpdated; + } + } + return true; +} void FrameFilter::Clear() { traceDataCache_->GetFrameSliceData()->UpdateDepth(); diff --git a/trace_streamer/src/filter/frame_filter.h b/trace_streamer/src/filter/frame_filter.h index dcc7b9ba2a2e7c31964f15fa8188ab9c2cf2f236..cbd33596a43c463634bbb4cd1796093a57fb0b44 100644 --- a/trace_streamer/src/filter/frame_filter.h +++ b/trace_streamer/src/filter/frame_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -44,6 +44,14 @@ public: bool StartFrameQueue(uint64_t ts, uint32_t itid); bool EndFrameQueue(uint64_t ts, uint32_t itid); void Clear(); + void UpdateReadySize() + { + UpdateFrameSliceReadySize(); + } + +private: + bool UpdateFrameSliceReadySize(); + void SetMinFrameSliceRow(uint64_t& minFrameSliceRowToBeUpdated); private: class FrameSlice { diff --git a/trace_streamer/src/filter/hi_sysevent_measure_filter.cpp b/trace_streamer/src/filter/hi_sysevent_measure_filter.cpp index 682acd0021c5b2a43b94b2769f9ff1d016d23c17..b581b82858d9208fc0d4be730b129eee918e7e1c 100644 --- a/trace_streamer/src/filter/hi_sysevent_measure_filter.cpp +++ b/trace_streamer/src/filter/hi_sysevent_measure_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/hi_sysevent_measure_filter.h b/trace_streamer/src/filter/hi_sysevent_measure_filter.h index 0b302697600cbbb410930256d37d2281508c59e3..0b60fccb3a3aca693c6585a5c5e51d65088c8780 100644 --- a/trace_streamer/src/filter/hi_sysevent_measure_filter.h +++ b/trace_streamer/src/filter/hi_sysevent_measure_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/irq_filter.cpp b/trace_streamer/src/filter/irq_filter.cpp index 0c2e95043aa76d2d6a1e0784f2df9897e17ed901..e1c6febc9dd2292ab1bb96454b717b2b87862591 100644 --- a/trace_streamer/src/filter/irq_filter.cpp +++ b/trace_streamer/src/filter/irq_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/irq_filter.h b/trace_streamer/src/filter/irq_filter.h index 8d26c7ce4cf6da88428b27df5b2188a52c981721..ec6ec1811019feb91d43fc6ff40960540c77f870 100644 --- a/trace_streamer/src/filter/irq_filter.h +++ b/trace_streamer/src/filter/irq_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/measure_filter.cpp b/trace_streamer/src/filter/measure_filter.cpp index fa8391184d33477bd6d1eade761505955c7c08b0..1136f0f6fabc99fe7480775377176d3afdf2df12 100644 --- a/trace_streamer/src/filter/measure_filter.cpp +++ b/trace_streamer/src/filter/measure_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/measure_filter.h b/trace_streamer/src/filter/measure_filter.h index ea13da6e6687d2b84a280f1f5c27624968e301db..72472ff8b2dd6a6aba1b2a02920aa826aabde96d 100644 --- a/trace_streamer/src/filter/measure_filter.h +++ b/trace_streamer/src/filter/measure_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/native_hook_filter.cpp b/trace_streamer/src/filter/native_hook_filter.cpp index e80fb51c5bca350b63e2e6796ff66ea4cb55492f..a24a8c0d5ec0c52532883e97ba9630da84507d82 100644 --- a/trace_streamer/src/filter/native_hook_filter.cpp +++ b/trace_streamer/src/filter/native_hook_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -25,7 +25,8 @@ NativeHookFilter::NativeHookFilter(TraceDataCache* dataCache, const TraceStreame hookPluginData_(std::make_unique()), ipidToSymIdToSymIndex_(INVALID_UINT64), ipidToFilePathIdToFileIndex_(INVALID_UINT64), - ipidToFrameIdToFrameBytes_(nullptr) + ipidToFrameIdToFrameBytes_(nullptr), + stackIdToFramesMapIdAndIdDown_(nullptr) { invalidLibPathIndexs_.insert(traceDataCache_->dataDict_.GetStringIndex("/system/lib/libc++.so")); invalidLibPathIndexs_.insert(traceDataCache_->dataDict_.GetStringIndex("/system/lib64/libc++.so")); @@ -65,7 +66,11 @@ void NativeHookFilter::ParseConfigInfo(ProtoReader::BytesView& protoData) } return; } -void NativeHookFilter::AppendStackMaps(uint32_t ipid, uint32_t stackid, std::vector& frames) +void NativeHookFilter::AppendStackMaps( + uint32_t ipid, + uint32_t stackid, + std::vector& frames, + std::map>>& frameIdAndIdDownInfo) { uint64_t ipidWithStackIdIndex = 0; // the last element is ipid for this batch of frames/ips @@ -81,6 +86,13 @@ void NativeHookFilter::AppendStackMaps(uint32_t ipid, uint32_t stackid, std::vec // allStackIdToFramesMap_ save all offline symbolic call stack if (isOfflineSymbolizationMode_) { allStackIdToFramesMap_.emplace(std::make_pair(ipidWithStackIdIndex, framesSharedPtr)); + if (frameIdAndIdDownInfo.size()) { + for (auto frameIdAndIdItor = frameIdAndIdDownInfo.begin(); frameIdAndIdItor != frameIdAndIdDownInfo.end(); + frameIdAndIdItor++) { + stackIdToFramesMapIdAndIdDown_.Insert(ipidWithStackIdIndex, frameIdAndIdItor->first, + std::move(frameIdAndIdItor->second)); + } + } } } void NativeHookFilter::AppendFrameMaps(uint32_t ipid, uint32_t frameMapId, const ProtoReader::BytesView& bytesView) @@ -606,6 +618,36 @@ std::tuple NativeHookFilter::GetNeedUpdateProcessMapsAddrRan return std::make_tuple(start, end); } +// Offline Symbolization Analysis of Virtual Stacks +void NativeHookFilter::ParseOfflineSymbolVirtualStacks(uint64_t curStackId, + uint64_t curPid, + uint16_t& depth, + uint32_t frameMapIdLoc) +{ + if (isOfflineSymbolizationMode_ && !stackIdToFramesMapIdAndIdDown_.Empty()) { + // Only for offline symbolization of stackmap, containing frame_map_id and frame_map_id_down + auto frameMapId = stackIdToFramesMapIdAndIdDown_.Find(curStackId, frameMapIdLoc); + if (nullptr == frameMapId) { + TS_LOGE("Can not find frame_map_id or frame_map_id_down!!!"); + } else { + for (auto frameIdsItor = frameMapId->begin(); frameIdsItor != frameMapId->end(); frameIdsItor++) { + auto frameBytesPtr = ipidToFrameIdToFrameBytes_.Find(curPid, *frameIdsItor); + if (frameBytesPtr == nullptr) { + TS_LOGE("Can not find Frame by frame_map_id or frame_map_id_down!!!"); + continue; + } + ProtoReader::Frame_Reader reader(*frameBytesPtr); + if (!reader.has_symbol_name()) { + TS_LOGE("Data exception, frames should has symbol_name_name!!!"); + continue; + } + auto symbolIndex = traceDataCache_->dataDict_.GetStringIndex(reader.symbol_name().ToStdString()); + traceDataCache_->GetNativeHookFrameData()->AppendNewNativeHookFrame( + callChainId_, depth++, reader.ip(), symbolIndex, MAX_UINT64, MAX_UINT64, MAX_UINT64, "", 0); + } + } + } +} void NativeHookFilter::FillOfflineSymbolizationFrames( std::map>>::iterator mapItor) { @@ -616,6 +658,7 @@ void NativeHookFilter::FillOfflineSymbolizationFrames( if (isSingleProcData_) { curCacheIpid = SINGLE_PROC_IPID; } + ParseOfflineSymbolVirtualStacks(mapItor->first, curCacheIpid, depth, 0); uint64_t filePathIndex; for (auto itor = framesInfo->rbegin(); itor != framesInfo->rend(); itor++) { // Note that the filePathId here is provided for the end side. Not a true TS internal index dictionary. @@ -628,6 +671,7 @@ void NativeHookFilter::FillOfflineSymbolizationFrames( frameInfo->symbolOffset_, vaddr); UpdateFilePathIndexToCallStackRowMap(row, filePathIndex); } + ParseOfflineSymbolVirtualStacks(mapItor->first, curCacheIpid, depth, 1); } void NativeHookFilter::ReparseStacksWithDifferentMeans() @@ -820,6 +864,37 @@ void NativeHookFilter::MaybeUpdateCurrentSizeDur(uint64_t row, uint64_t timeStam } lastAnyEventRaw = row; } + +void NativeHookFilter::UpdateSymbolIdsForCallChainIdLastCallStack(size_t index) +{ + auto ip = traceDataCache_->GetNativeHookFrameData()->Ips()[index]; + uint32_t ipBitOperation = ip & IP_BIT_OPERATION; + std::ostringstream newSymbol; + newSymbol << "alloc size(" << base::number(ipBitOperation, base::INTEGER_RADIX_TYPE_DEC) << "bytes)" + << "0x" << base::number(ip, base::INTEGER_RADIX_TYPE_HEX); + traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( + index, traceDataCache_->dataDict_.GetStringIndex(newSymbol.str())); +} + +void NativeHookFilter::UpdateSymbolIdsForFilePathIndexFailedInvalid(size_t index) +{ + auto callChainId = traceDataCache_->GetNativeHookFrameData()->CallChainIds()[index]; + auto size = traceDataCache_->GetNativeHookFrameData()->Size(); + if (index < (size - 1)) { + auto nextcallChainId = traceDataCache_->GetNativeHookFrameData()->CallChainIds()[index + 1]; + if (nextcallChainId != callChainId) { + UpdateSymbolIdsForCallChainIdLastCallStack(index); + } else { + auto ip = traceDataCache_->GetNativeHookFrameData()->Ips()[index]; + traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( + index, traceDataCache_->dataDict_.GetStringIndex("unknown 0x" + + base::number(ip, base::INTEGER_RADIX_TYPE_HEX))); + } + } else { + UpdateSymbolIdsForCallChainIdLastCallStack(index); + } +} + // when symbolization failed, use filePath + vaddr as symbol name void NativeHookFilter::UpdateSymbolIdsForSymbolizationFailed() { @@ -836,10 +911,8 @@ void NativeHookFilter::UpdateSymbolIdsForSymbolizationFailed() traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( i, traceDataCache_->dataDict_.GetStringIndex(filePathStr + "+" + vaddrStr)); } else { - auto ip = traceDataCache_->GetNativeHookFrameData()->Ips()[i]; - traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( - i, traceDataCache_->dataDict_.GetStringIndex("unknown 0x" + - base::number(ip, base::INTEGER_RADIX_TYPE_HEX))); + // when symbolization failed,filePath and symbolNameIndex invalid + UpdateSymbolIdsForFilePathIndexFailedInvalid(i); } } } @@ -925,7 +998,7 @@ void NativeHookFilter::ParseFramesInCallStackCompressedMode() } } } -// Called When isCallStackCompressedMode_ is false. +// Called When isCallStackCompressedMode_ is false void NativeHookFilter::ParseFramesWithOutCallStackCompressedMode() { for (auto itor = callChainIdToStackHashValueMap_.begin(); itor != callChainIdToStackHashValueMap_.end(); itor++) { @@ -1009,6 +1082,7 @@ void NativeHookFilter::UpdateLastCallerPathAndSymbolIndexs() } void NativeHookFilter::GetCallIdToLastLibId() { + callIdToLastCallerPathIndex_.clear(); auto size = static_cast(traceDataCache_->GetNativeHookFrameData()->Size()); uint32_t lastCallChainId = INVALID_UINT32; bool foundLast = false; @@ -1045,22 +1119,6 @@ void NativeHookFilter::GetCallIdToLastLibId() } } } -bool NativeHookFilter::GetIpsWitchNeedResymbolization(uint64_t ipid, DataIndex filePathId, std::set& ips) -{ - bool value = false; - auto ipToFrameInfoPtr = ipidToIpToFrameInfo_.Find(ipid); - for (auto itor = ipToFrameInfoPtr->begin(); itor != ipToFrameInfoPtr->end(); itor++) { - if (!itor->second) { - TS_LOGI("ip :%" PRIu64 " can not symbolization! FrameInfo is nullptr", itor->first); - continue; - } - if (itor->second->filePathId_ == filePathId) { - ips.insert(itor->first); - value = true; - } - } - return value; -} template void NativeHookFilter::UpdateFilePathIdAndStValueToSymAddrMap(T* firstSymbolAddr, const int size, uint32_t filePathId) @@ -1101,6 +1159,7 @@ bool NativeHookFilter::NativeHookReloadElfSymbolTable(const std::vector::max(); using namespace OHOS::Developtools::HiPerf; class NativeHookFrameInfo { public: @@ -72,7 +74,10 @@ public: public: void MaybeParseNativeHookMainEvent(uint64_t timeStamp, std::unique_ptr nativeHookMetaData); void ParseConfigInfo(ProtoReader::BytesView& protoData); - void AppendStackMaps(uint32_t ipid, uint32_t stackid, std::vector& frames); + void AppendStackMaps(uint32_t ipid, + uint32_t stackid, + std::vector& frames, + std::map>>& frameIdAndIdDownInfo); void AppendFrameMaps(uint32_t ipid, uint32_t frameMapId, const ProtoReader::BytesView& bytesView); void AppendFilePathMaps(uint32_t ipid, uint32_t filePathId, uint64_t fileIndex); void AppendSymbolMap(uint32_t ipid, uint32_t symId, uint64_t symbolIndex); @@ -90,6 +95,11 @@ public: return isSingleProcData_; } + bool GetOfflineSymbolizationMode() + { + return isOfflineSymbolizationMode_; + } + private: void ProcSymbolTable(uint32_t ipid, uint32_t filePathId, std::shared_ptr reader); void FilterNativeHookMainEvent(size_t num); @@ -117,12 +127,14 @@ private: void UpdateThreadNameWithNativeHookData() const; void GetCallIdToLastLibId(); void GetNativeHookFrameVaddrs(); + void UpdateSymbolIdsForCallChainIdLastCallStack(size_t index); + void UpdateSymbolIdsForFilePathIndexFailedInvalid(size_t index); void UpdateSymbolIdsForSymbolizationFailed(); + void ParseOfflineSymbolVirtualStacks(uint64_t curStackId, uint64_t curPid, uint16_t& depth, uint32_t frameMapIdLoc); void ParseFramesInOfflineSymbolizationMode(); void ParseFramesInCallStackCompressedMode(); void ParseFramesWithOutCallStackCompressedMode(); void ParseSymbolizedNativeHookFrame(); - bool GetIpsWitchNeedResymbolization(uint64_t ipid, DataIndex filePathId, std::set& ips); template void UpdateSymbolTablePtrAndStValueToSymAddrMap(T* firstSymbolAddr, const int size, @@ -156,6 +168,8 @@ private: {}; std::map>> allStackIdToFramesMap_ = {}; std::map>> stackIdToFramesMap_ = {}; + // first key is stackId, second key is framemap_id_loc, value is set framemap_id/framemap_down + DoubleMap>> stackIdToFramesMapIdAndIdDown_; std::map callChainIdToStackHashValueMap_ = {}; std::unordered_map> stackHashValueToFramesHashMap_ = {}; std::unordered_map> frameHashToFrameInfoMap_ = {}; diff --git a/trace_streamer/src/filter/offline_symbolization_filter.cpp b/trace_streamer/src/filter/offline_symbolization_filter.cpp index 7361485b244adfe8c4be1fd3232e677b5fbfdce8..77d779ed67d4aa862d2b2ed92ec4821dd00be1b8 100644 --- a/trace_streamer/src/filter/offline_symbolization_filter.cpp +++ b/trace_streamer/src/filter/offline_symbolization_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -139,7 +139,7 @@ std::shared_ptr OfflineSymbolizationFilter::OfflineSymbolizationByIp( // start symbolization std::shared_ptr frameInfo = std::make_shared(); if (!FillFrameInfo(frameInfo, ip, ipid)) { - if (ip & usefulIpMask_) { + if (ip) { return frameInfo; } return nullptr; diff --git a/trace_streamer/src/filter/offline_symbolization_filter.h b/trace_streamer/src/filter/offline_symbolization_filter.h index 26aa1e644113f2e9a7330a785f6e25339c9cac23..82503d7c629efcf48e30fe5eab55ed7c434aadbe 100644 --- a/trace_streamer/src/filter/offline_symbolization_filter.h +++ b/trace_streamer/src/filter/offline_symbolization_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -99,7 +99,6 @@ private: uint32_t& symbolStart, std::shared_ptr& frameInfo, std::shared_ptr& symbolTable); - const uint64_t usefulIpMask_ = 0xffffff0000000000; uint64_t vmStart_ = INVALID_UINT64; uint64_t vmOffset_ = INVALID_UINT64; }; diff --git a/trace_streamer/src/filter/perf_data_filter.cpp b/trace_streamer/src/filter/perf_data_filter.cpp index a5467655c9e41041af1800671178eff06f64999f..bdaddf30be523402fb9706f25f960383d24c901f 100644 --- a/trace_streamer/src/filter/perf_data_filter.cpp +++ b/trace_streamer/src/filter/perf_data_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/perf_data_filter.h b/trace_streamer/src/filter/perf_data_filter.h index 8b85efa75e8cfc3de2c70904ceb9c882edc271d4..3d7f62989f5f4675348e45d352186ea22f004160 100644 --- a/trace_streamer/src/filter/perf_data_filter.h +++ b/trace_streamer/src/filter/perf_data_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/process_filter.cpp b/trace_streamer/src/filter/process_filter.cpp index e16b6026d442d8f6d9d2195ee526ba4c33d3dfc6..742dd1a5dbf6cd21826555fc6375e3ac83cc02eb 100644 --- a/trace_streamer/src/filter/process_filter.cpp +++ b/trace_streamer/src/filter/process_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/process_filter.h b/trace_streamer/src/filter/process_filter.h index e3d95135d09300c472520b7d47dd5ba974d76f13..f84fa064075b5d01e94f6372c5b57e3051aafc15 100644 --- a/trace_streamer/src/filter/process_filter.h +++ b/trace_streamer/src/filter/process_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/slice_filter.cpp b/trace_streamer/src/filter/slice_filter.cpp index de567b56edf57fc43a15b56f6d3ca5b2f3a20bfc..c3798e88b896cf1ae3d9ec4e1569f879355edcd5 100644 --- a/trace_streamer/src/filter/slice_filter.cpp +++ b/trace_streamer/src/filter/slice_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -327,7 +327,6 @@ size_t SliceFilter::StartSlice(uint64_t timeStamp, } else { argSetId = streamFilters_->argsFilter_->NewArgs(args); sliceRowToArgsSetId_[index] = argSetId; - argsSetIdToSliceRow_[argSetId] = static_cast(index); args.argSetId_ = argSetId; args.inserted_ = true; } @@ -434,7 +433,7 @@ std::tuple SliceFilter::AddArgs(uint32_t tid, DataIndex key1 uint64_t SliceFilter::StartAsyncSlice(uint64_t timeStamp, uint32_t pid, uint32_t threadGroupId, - uint64_t cookie, + int64_t cookie, DataIndex nameIndex) { Unused(pid); @@ -462,7 +461,7 @@ uint64_t SliceFilter::StartAsyncSlice(uint64_t timeStamp, uint64_t SliceFilter::FinishAsyncSlice(uint64_t timeStamp, uint32_t pid, uint32_t threadGroupId, - uint64_t cookie, + int64_t cookie, DataIndex nameIndex) { Unused(pid); @@ -494,6 +493,43 @@ size_t return CompleteSlice(timeStamp, pid, threadGroupId, category, name); } +bool SliceFilter::UpdateIrqReadySize() +{ + CallStack* irqDatas = traceDataCache_->GetIrqData(); + irqDatas->UpdateReadySize(irqDatas->Size()); + uint64_t minIrqRowToBeUpdated = INVALID_UINT64; + for (const auto& [_, irqRecord] : irqEventMap_) { + if (minIrqRowToBeUpdated > irqRecord.row) { + minIrqRowToBeUpdated = irqRecord.row; + } + } + for (const auto& [_, softIrqRecord] : softIrqEventMap_) { + if (minIrqRowToBeUpdated > softIrqRecord.row) { + minIrqRowToBeUpdated = softIrqRecord.row; + } + } + for (const auto& [_, ipiRecord] : ipiEventMap_) { + if (minIrqRowToBeUpdated > ipiRecord.row) { + minIrqRowToBeUpdated = ipiRecord.row; + } + } + // the ready size isn't all + TS_CHECK_TRUE_RET(minIrqRowToBeUpdated != INVALID_UINT64, true); + irqDatas->UpdateReadySize(minIrqRowToBeUpdated); + TS_LOGI("minIrqRowToBeUpdated=%" PRIu64 ", size=%zu, ready.size=%zu\n", minIrqRowToBeUpdated, irqDatas->Size(), + irqDatas->readySize_); + for (auto& [_, irqRecord] : irqEventMap_) { + irqRecord.row -= irqDatas->readySize_; + } + for (auto& [_, ipiRecord] : ipiEventMap_) { + ipiRecord.row -= irqDatas->readySize_; + } + for (auto& [_, softIrqRecord] : softIrqEventMap_) { + softIrqRecord.row -= irqDatas->readySize_; + } + return true; +} + void SliceFilter::Clear() { asyncEventMap_.Clear(); @@ -504,8 +540,6 @@ void SliceFilter::Clear() sliceStackMap_.clear(); depthHolder_.clear(); sliceRowToArgsSetId_.clear(); - argsSetIdToSliceRow_.clear(); - argsSetIdToSliceRow_.clear(); argsSet_.clear(); } } // namespace TraceStreamer diff --git a/trace_streamer/src/filter/slice_filter.h b/trace_streamer/src/filter/slice_filter.h index ffbdf0c94c537c6ed1b20991b04dad63896b561e..b0b6ee8d03f8287784d015d59625a9ccf07388b2 100644 --- a/trace_streamer/src/filter/slice_filter.h +++ b/trace_streamer/src/filter/slice_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -77,12 +77,9 @@ public: DataIndex category = INVALID_UINT64, DataIndex name = INVALID_UINT64); uint64_t - StartAsyncSlice(uint64_t timeStamp, uint32_t pid, uint32_t threadGroupId, uint64_t cookie, DataIndex nameIndex); - uint64_t FinishAsyncSlice(uint64_t timeStamp, - uint32_t pid, - uint32_t threadGroupId, - uint64_t cookie, - DataIndex nameIndex); + StartAsyncSlice(uint64_t timeStamp, uint32_t pid, uint32_t threadGroupId, int64_t cookie, DataIndex nameIndex); + uint64_t + FinishAsyncSlice(uint64_t timeStamp, uint32_t pid, uint32_t threadGroupId, int64_t cookie, DataIndex nameIndex); void IrqHandlerEntry(uint64_t timeStamp, uint32_t cpu, DataIndex catalog, DataIndex nameIndex); std::tuple AddArgs(uint32_t tid, DataIndex key1, DataIndex key2, ArgsSet& args); void IrqHandlerExit(uint64_t timeStamp, uint32_t cpu, ArgsSet args); @@ -91,6 +88,10 @@ public: void SoftIrqEntry(uint64_t timeStamp, uint32_t cpu, DataIndex catalog, DataIndex nameIndex); void SoftIrqExit(uint64_t timeStamp, uint32_t cpu, ArgsSet args); void Clear(); + void UpdateReadySize() + { + UpdateIrqReadySize(); + } private: struct StackInfo { @@ -112,10 +113,11 @@ private: int32_t MatchingIncompleteSliceIndex(const SlicesStack& stack, DataIndex category, DataIndex name); uint8_t CurrentDepth(InternalTid internalTid); void HandleAsyncEventAndOther(ArgsSet args, CallStack* slices, uint64_t lastRow, StackOfSlices& stackInfo); + bool UpdateIrqReadySize(); private: // The parameter list is tid, cookid, functionName, asyncCallId. - TripleMap asyncEventMap_; + TripleMap asyncEventMap_; // this is only used to calc the layer of the async event in same time range std::map asyncNoEndingEventMap_ = {}; // irq map, key1 is cpu, key2 @@ -123,8 +125,8 @@ private: uint64_t ts; size_t row; }; - std::unordered_map irqEventMap_ = {}; - std::unordered_map ipiEventMap_ = {}; + std::unordered_map irqEventMap_ = {}; + std::unordered_map ipiEventMap_ = {}; // irq map, key1 is cpu, key2 std::unordered_map softIrqEventMap_ = {}; std::map asyncEventFilterMap_ = {}; @@ -136,7 +138,6 @@ private: uint64_t asyncEventDisMatchCount_ = 0; uint64_t callEventDisMatchCount_ = 0; std::unordered_map sliceRowToArgsSetId_ = {}; - std::unordered_map argsSetIdToSliceRow_ = {}; std::unordered_map tidToArgsSetId_ = {}; struct SliceInfo { uint32_t row; @@ -146,7 +147,7 @@ private: DataIndex asyncBeginCountId_ = traceDataCache_->GetDataIndex("legacy_unnestable_begin_count"); DataIndex asyncBeginTsId_ = traceDataCache_->GetDataIndex("legacy_unnestable_last_begin_ts"); DataIndex ipiId_ = traceDataCache_->GetDataIndex("IPI"); - std::map irqDataLinker_ = {}; + std::map irqDataLinker_ = {}; }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/filter/stat_filter.cpp b/trace_streamer/src/filter/stat_filter.cpp index 8afbb22e3818797d5c594cffd6ee6911e8df555b..5e72ed0da42718e926cafe014b690d26bbe7c896 100644 --- a/trace_streamer/src/filter/stat_filter.cpp +++ b/trace_streamer/src/filter/stat_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/stat_filter.h b/trace_streamer/src/filter/stat_filter.h index 2f05116ea1df454df17944c133aae3a25bfa48af..c767cdddb36649fa128a3578b424353b9eda248f 100644 --- a/trace_streamer/src/filter/stat_filter.h +++ b/trace_streamer/src/filter/stat_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/system_event_measure_filter.cpp b/trace_streamer/src/filter/system_event_measure_filter.cpp index ad055e191f560b86ee802cf6bc7e49c4d9c7835e..3721d223e133218d1f66f78f7cc7a5b893b8e2be 100644 --- a/trace_streamer/src/filter/system_event_measure_filter.cpp +++ b/trace_streamer/src/filter/system_event_measure_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/system_event_measure_filter.h b/trace_streamer/src/filter/system_event_measure_filter.h index f6d31fd63dffd1bc81f95d3c3e8c41c3d06e6e84..84a8df4528bf3a4bb79fbf3ad116d5ded92a935a 100644 --- a/trace_streamer/src/filter/system_event_measure_filter.h +++ b/trace_streamer/src/filter/system_event_measure_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/filter/task_pool_filter.cpp b/trace_streamer/src/filter/task_pool_filter.cpp index 7b60d5bf5f962342adfb78237ce4e6684cc54859..58e16f4f18e135adda28d83ec626a1e38ab934e7 100644 --- a/trace_streamer/src/filter/task_pool_filter.cpp +++ b/trace_streamer/src/filter/task_pool_filter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -38,7 +38,7 @@ uint32_t TaskPoolFilter::GetIpId(uint32_t index) return thread->internalPid_; } -uint32_t TaskPoolFilter::CheckTheSameTask(uint32_t executeId, uint32_t index) +uint32_t TaskPoolFilter::CheckTheSameTask(uint64_t executeId, uint32_t index) { return IpidExecuteMap_.Find(GetIpId(index), executeId); } @@ -51,9 +51,9 @@ void TaskPoolFilter::TaskPoolFieldSegmentation(const std::string& taskPoolStr, std::string value; for (base::PartingString inner(ss.GetCur(), ':'); inner.Next();) { if (key.empty()) { - key = inner.GetCur(); + key = TrimInvisibleCharacters(inner.GetCur()); } else { - value = inner.GetCur(); + value = TrimInvisibleCharacters(inner.GetCur()); } } args.emplace(std::move(key), std::move(value)); @@ -85,22 +85,32 @@ bool TaskPoolFilter::TaskPoolEvent(const std::string& taskPoolStr, uint32_t inde } return false; } - +// The old business is run in three phases by associating the application with the executeId,New business runs in three +// phases by associating an application with the taskid +auto TaskPoolFilter::GetExecuteIdOrTaskId(const std::unordered_map& args) +{ + std::optional id; + if (args.find("executeId") != args.end()) { + id = base::StrToInt(args.at("executeId")); + } else { + id = base::StrToInt(args.at("taskId")); + } + return id; +} bool TaskPoolFilter::UpdateAssignData(const std::unordered_map& args, uint32_t index) { if (index >= traceDataCache_->GetConstInternalSlicesData().CallIds().size()) { return false; } auto allocItid = traceDataCache_->GetConstInternalSlicesData().CallIds()[index]; - auto executeId = base::StrToInt(args.at(" executeId ")); - auto priority = base::StrToInt(args.at(" priority ")); - auto executeState = base::StrToInt(args.at(" executeState ")); - - uint32_t returnValue = CheckTheSameTask(executeId.value(), index); + auto priority = base::StrToInt(args.at("priority")); + auto executeState = base::StrToInt(args.at("executeState")); + auto id = GetExecuteIdOrTaskId(args); + uint32_t returnValue = CheckTheSameTask(id.value(), index); if (returnValue == INVALID_INT32) { uint32_t taskIndex = traceDataCache_->GetTaskPoolData()->AppendAllocationTaskData( - index, allocItid, executeId.value(), priority.value(), executeState.value()); - IpidExecuteMap_.Insert(GetIpId(index), executeId.value(), taskIndex); + index, allocItid, id.value(), priority.value(), executeState.value()); + IpidExecuteMap_.Insert(GetIpId(index), id.value(), taskIndex); } else { traceDataCache_->GetTaskPoolData()->UpdateAllocationTaskData(returnValue, index, allocItid, priority.value(), executeState.value()); @@ -114,13 +124,11 @@ bool TaskPoolFilter::UpdateExecuteData(const std::unordered_mapGetConstInternalSlicesData().CallIds()[index]; - auto executeId = base::StrToInt(args.at(" executeId ")); - - uint32_t returnValue = CheckTheSameTask(executeId.value(), index); + auto id = GetExecuteIdOrTaskId(args); + uint32_t returnValue = CheckTheSameTask(id.value(), index); if (returnValue == INVALID_INT32) { - uint32_t taskIndex = - traceDataCache_->GetTaskPoolData()->AppendExecuteTaskData(index, executeItid, executeId.value()); - IpidExecuteMap_.Insert(GetIpId(index), executeId.value(), taskIndex); + uint32_t taskIndex = traceDataCache_->GetTaskPoolData()->AppendExecuteTaskData(index, executeItid, id.value()); + IpidExecuteMap_.Insert(GetIpId(index), id.value(), taskIndex); timeoutMap_.emplace(executeItid, taskIndex); if (timeoutMap_.at(executeItid) < taskIndex) { timeoutMap_.at(executeItid) = taskIndex; @@ -141,15 +149,14 @@ 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; - - uint32_t returnValue = CheckTheSameTask(executeId.value(), index); + auto id = GetExecuteIdOrTaskId(args); + auto returnStr_ = std::string_view(args.at("performResult")); + uint32_t returnState = returnStr_.compare("Successful") ? 0 : 1; + uint32_t returnValue = CheckTheSameTask(id.value(), index); if (returnValue == INVALID_INT32) { uint32_t taskIndex = - traceDataCache_->GetTaskPoolData()->AppendReturnTaskData(index, returnItid, executeId.value(), returnState); - IpidExecuteMap_.Insert(GetIpId(index), executeId.value(), taskIndex); + traceDataCache_->GetTaskPoolData()->AppendReturnTaskData(index, returnItid, id.value(), returnState); + IpidExecuteMap_.Insert(GetIpId(index), id.value(), taskIndex); } else { traceDataCache_->GetTaskPoolData()->UpdateReturnTaskData(returnValue, index, returnItid, returnState); } diff --git a/trace_streamer/src/filter/task_pool_filter.h b/trace_streamer/src/filter/task_pool_filter.h index a15cf9b5400ca2f61f02b7e5fb108d397c2c91bf..d4b78e74a37084c4ba2d1250a621e6692ea74dac 100644 --- a/trace_streamer/src/filter/task_pool_filter.h +++ b/trace_streamer/src/filter/task_pool_filter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -35,7 +35,7 @@ public: TaskPoolFilter& operator=(const TaskPoolFilter&) = delete; ~TaskPoolFilter() override; uint32_t GetIpId(uint32_t index); - uint32_t CheckTheSameTask(uint32_t executeId, uint32_t index); + uint32_t CheckTheSameTask(uint64_t executeId, uint32_t index); bool TaskPoolEvent(const std::string& taskPoolStr, uint32_t index); void TaskPoolFieldSegmentation(const std::string& taskPoolStr, std::unordered_map& args); bool UpdateAssignData(const std::unordered_map& args, uint32_t index); @@ -44,10 +44,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: "; + auto GetExecuteIdOrTaskId(const std::unordered_map& args); + 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/main.cpp b/trace_streamer/src/main.cpp index c7564d985cc30ef5982bc5a30e1767261d28558d..161250c0bf0dcf1a61cf2e2fcc1b4142dcd045f4 100644 --- a/trace_streamer/src/main.cpp +++ b/trace_streamer/src/main.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -27,6 +27,8 @@ #include "codec_cov.h" #include "file.h" +#include "filter/cpu_filter.h" +#include "filter/frame_filter.h" #include "filter/slice_filter.h" #include "log.h" #include "metrics.h" @@ -80,15 +82,14 @@ void ShowHelpInfo(const char* argv) " -c command line mode.\n" " -D Specify the directory path with multiple long trace files" " -d dump perf/hook/ebpf readable text.Default dump file path is src path name + `_ReadableText.txt`\n" - " -h start HTTP server.\n" " -l , --level=\n" " Show specific level/levels logs with format: level1,level2,level3\n" " Long level string coule be: DEBUG/INFO/WARN/ERROR/FATAL/OFF.\n" " Short level string coule be: D/I/W/E/F/O.\n" " Default level is OFF.\n" + " -lnc long trace no clear the db cache.\n" " -o set dump file path.\n" " -s separate arkts-plugin data, and save it in current dir with default filename.\n" - " -p Specify the port of HTTP server, default is 9001.\n" " -q select sql from file.\n" " -m Perform operations that query metrics through linux,supports querying multiple metrics items.For " "example:-m x,y,z.\n" @@ -254,6 +255,7 @@ struct TraceExportOption { bool separateFile = false; bool closeMutiThread = false; uint8_t parserThreadNum = INVALID_UINT8; + bool needClearLongTraceCache = true; }; bool CheckFinal(char** argv, TraceExportOption& traceExportOption) { @@ -342,10 +344,13 @@ bool CheckAndSetLongTraceDir(TraceExportOption& traceExportOption, int argc, cha traceExportOption.longTraceDir = std::string(argv[index]); return true; } -bool ParseOtherArgs(int argc, char** argv, TraceExportOption& traceExportOption, int i) +bool ParseOtherArgs(int argc, char** argv, TraceExportOption& traceExportOption, int& i) { if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--info")) { PrintInformation(); + } else if (!strcmp(argv[i], "-lnc")) { + traceExportOption.needClearLongTraceCache = false; + return true; } else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--level")) { TS_CHECK_TRUE_RET(CheckAndSetLogLevel(argc, argv, i), false); return true; @@ -478,36 +483,41 @@ bool OpenAndParserLongTraceFile(TraceStreamerSelector& ts, const std::string& tr close(fd); return true; } -void ParseLongTrace(TraceStreamerSelector& ts, const TraceExportOption& traceExportOption) +bool ParseLongTrace(TraceStreamerSelector& ts, const TraceExportOption& traceExportOption) { std::map seqToFilePathMap; - if (traceExportOption.sqliteFilePath.empty()) { - return; - } - if (!GetLongTraceFilePaths(traceExportOption, seqToFilePathMap)) { - return; - } + TS_CHECK_TRUE(!traceExportOption.sqliteFilePath.empty(), false, "sqliteFilePath is empty"); + TS_CHECK_TRUE(GetLongTraceFilePaths(traceExportOption, seqToFilePathMap), false, "GetLongTraceFilePaths err!"); ts.CreatEmptyBatchDB(traceExportOption.sqliteFilePath); + ts.GetTraceDataCache()->supportThread_ = false; for (auto itor = seqToFilePathMap.begin(); itor != seqToFilePathMap.end(); itor++) { - ts.GetTraceDataCache()->UpdateAllPrevSize(); if (!OpenAndParserLongTraceFile(ts, itor->second)) { break; } - if (std::distance(itor, seqToFilePathMap.end()) == 1) { + if (itor == std::prev(seqToFilePathMap.end())) { ts.WaitForParserEnd(); + if (!traceExportOption.needClearLongTraceCache) { + TS_CHECK_TRUE(ExportDatabase(ts, traceExportOption.sqliteFilePath) == 0, false, "ExportDatabase Err!"); + } } - ts.GetTraceDataCache()->ClearAllPrevCacheData(); - ts.GetStreamFilter()->FilterClear(); - if (!LongTraceExportDatabase(ts, traceExportOption.sqliteFilePath)) { - return; + if (!traceExportOption.needClearLongTraceCache) { + continue; } - if (std::distance(itor, seqToFilePathMap.end()) == 1) { + ts.GetStreamFilter()->sliceFilter_->UpdateReadySize(); // for irq_ + ts.GetStreamFilter()->frameFilter_->UpdateReadySize(); // for frameSliceRow_ + ts.GetStreamFilter()->cpuFilter_->UpdateReadySize(); // for sched_slice + ts.GetTraceDataCache()->UpdateAllReadySize(); + TS_CHECK_TRUE(LongTraceExportDatabase(ts, traceExportOption.sqliteFilePath), false, + "LongTraceExportDatabase Err!"); + ts.GetTraceDataCache()->ClearAllExportedCacheData(); + if (itor == std::prev(seqToFilePathMap.end())) { ts.RevertTableName(traceExportOption.sqliteFilePath); } } if (!traceExportOption.sqliteFilePath.empty()) { ExportStatusToLog(traceExportOption.sqliteFilePath, GetAnalysisResult()); } + return true; } void ExportReadableText(TraceStreamerSelector& ts, const TraceExportOption& traceExportOption) { diff --git a/trace_streamer/src/metrics/BUILD.gn b/trace_streamer/src/metrics/BUILD.gn index 423a9058212863f67932b9812876389b3496aad6..98bbd78d2137ebdc517437369e3adbb4f1194b8c 100644 --- a/trace_streamer/src/metrics/BUILD.gn +++ b/trace_streamer/src/metrics/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/metrics/memAggStrategy.h b/trace_streamer/src/metrics/memAggStrategy.h index d91fd55c47a7f5cb3062e9307eabb4aa46f92506..2ae8242d6fc224f79536421f8f70b8c2199bdbc0 100644 --- a/trace_streamer/src/metrics/memAggStrategy.h +++ b/trace_streamer/src/metrics/memAggStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/metrics/memStrategy.h b/trace_streamer/src/metrics/memStrategy.h index f8ffe63317767eb5a1fadefd2b970ec202bf48cf..f64feafc6765618873402dade33437fb0b24b1cb 100644 --- a/trace_streamer/src/metrics/memStrategy.h +++ b/trace_streamer/src/metrics/memStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/metrics/metaDataStrategy.h b/trace_streamer/src/metrics/metaDataStrategy.h index fa0fea421dc9c4fa6cdc074f1f2df31fb67b04d5..49ca4d24108d0dcbb34b7130a36cec886c22fb2b 100644 --- a/trace_streamer/src/metrics/metaDataStrategy.h +++ b/trace_streamer/src/metrics/metaDataStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/metrics/metrics.cpp b/trace_streamer/src/metrics/metrics.cpp index 80441fa52e36572c804d6812fcfbe02884ea029f..fbe4458f983ec64e59ae295b969d1bc85c91cd7f 100644 --- a/trace_streamer/src/metrics/metrics.cpp +++ b/trace_streamer/src/metrics/metrics.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -19,8 +19,12 @@ namespace SysTuning { namespace TraceStreamer { -const uint32_t EXTRA_CHAR = 4; -const uint32_t SEND_FINISH = 1; +constexpr uint32_t EXTRA_CHAR = 4; +constexpr uint32_t SEND_FINISH = 1; +constexpr uint32_t FUNCTION_ITEM_DUR_MIN = 1; +constexpr uint32_t FUNCTION_ITEM_DUR_MAX = 2; +constexpr uint32_t FUNCTION_ITEM_DUR_AVG = 3; +constexpr uint32_t FUNCTION_ITEM_FUNCTION_NAME = 4; Metrics ::Metrics() { metricsFunction_ = { @@ -167,16 +171,18 @@ void Metrics::InitTraceMetaDataStrategy(const std::string& result) void Metrics::InitSysCallStrategy(const std::string& result) { json jMessage = json::parse(result); - const uint32_t FUNCTION_ITEM_DUR_MIN = 1; - const uint32_t FUNCTION_ITEM_DUR_MAX = 2; - const uint32_t FUNCTION_ITEM_DUR_AVG = 3; - const uint32_t FUNCTION_ITEM_FUNCTION_NAME = 4; for (int i = 0; i < jMessage.at("values").size(); i++) { FunctionItem functionItem; functionItem.functionName = jMessage.at("values")[i].at(FUNCTION_ITEM_FUNCTION_NAME); - functionItem.durMax = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MAX); - functionItem.durMin = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MIN); - functionItem.durAvg = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_AVG); + if (!jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MAX).is_null()) { + functionItem.durMax = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MAX); + } + if (!jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MIN).is_null()) { + functionItem.durMin = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_MIN); + } + if (!jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_AVG).is_null()) { + functionItem.durAvg = jMessage.at("values")[i].at(FUNCTION_ITEM_DUR_AVG); + } sysCallStrategy_.emplace_back(functionItem); } return; diff --git a/trace_streamer/src/metrics/metrics.h b/trace_streamer/src/metrics/metrics.h index 3b25ba9a330931a6eb31419dbd8f24c3290d6e87..e295b593070683be570ca6aa58cc522bf5ad55db 100644 --- a/trace_streamer/src/metrics/metrics.h +++ b/trace_streamer/src/metrics/metrics.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/metrics/sysCallStrategy.h b/trace_streamer/src/metrics/sysCallStrategy.h index 363d8d63eaabb6f2302599003bc54cc234c2eab1..c8fd82a36d010672957ce2a655d432f18c354981 100644 --- a/trace_streamer/src/metrics/sysCallStrategy.h +++ b/trace_streamer/src/metrics/sysCallStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -23,9 +23,9 @@ namespace SysTuning { namespace TraceStreamer { struct FunctionItem { std::string functionName; - uint32_t durMax; - int32_t durMin; - uint32_t durAvg; + int32_t durMax = -1; + int32_t durMin = -1; + int32_t durAvg = -1; }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/metrics/traceStateStrategy.h b/trace_streamer/src/metrics/traceStateStrategy.h index 72ca766244b18e3708862ff35f4bbe0bba936bc7..5f2c5064d5be017f79c0e04c63494220a47a70a0 100644 --- a/trace_streamer/src/metrics/traceStateStrategy.h +++ b/trace_streamer/src/metrics/traceStateStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/metrics/traceTaskStrategy.h b/trace_streamer/src/metrics/traceTaskStrategy.h index 78a2376c1e5fad15363163eafcce745b1e3b5a6f..d60799ef6ad90c548cf375992161b04e3c97cf29 100644 --- a/trace_streamer/src/metrics/traceTaskStrategy.h +++ b/trace_streamer/src/metrics/traceTaskStrategy.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/BUILD.gn b/trace_streamer/src/parser/BUILD.gn index 82a44251bff5cc11be24672c3c7b7ced933bc7be..a3ee30cc163867ccad544f6e465136d7ae937a49 100644 --- a/trace_streamer/src/parser/BUILD.gn +++ b/trace_streamer/src/parser/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp b/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp index 2e088ed2df919a7c426b709583ba13b09d646215..eb81c8c89e4a5fd442c3acad5bd92bedbb324234 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -216,9 +216,8 @@ bool BytraceEventParser::SchedSwitchEvent(const ArgsMap& args, const BytraceLine } else { uprevtid = streamFilters_->processFilter_->UpdateOrCreateThread(line.ts, prevPidValue.value()); } - streamFilters_->cpuFilter_->InsertSwitchEvent( - line.ts, line.cpu, uprevtid, static_cast(prevPrioValue.value()), prevState, nextInternalTid, - static_cast(nextPrioValue.value()), nextInfo); + streamFilters_->cpuFilter_->InsertSwitchEvent(line.ts, line.cpu, uprevtid, prevPrioValue.value(), prevState, + nextInternalTid, nextPrioValue.value(), nextInfo); streamFilters_->statFilter_->IncreaseStat(TRACE_EVENT_SCHED_SWITCH, STAT_EVENT_RECEIVED); return true; } @@ -708,6 +707,22 @@ bool BytraceEventParser::BinderTransactionAllocBufEvent(const ArgsMap& args, con void BytraceEventParser::ParseDataItem(const BytraceLine& line) { eventList_.push_back(std::make_unique(line.ts, std::move(line))); + size_t maxBuffSize = 1000 * 1000; + size_t maxQueue = 2; + if (eventList_.size() < maxBuffSize * maxQueue) { + return; + } + auto cmp = [](const std::unique_ptr& a, const std::unique_ptr& b) { + return a->eventTimestamp < b->eventTimestamp; + }; + std::stable_sort(eventList_.begin(), eventList_.end(), cmp); + auto endOfList = eventList_.begin() + maxBuffSize; + for (auto itor = eventList_.begin(); itor != endOfList; itor++) { + EventInfo* event = itor->get(); + BeginFilterEvents(event); + itor->reset(); + } + eventList_.erase(eventList_.begin(), endOfList); return; } void BytraceEventParser::GetDataSegArgs(BytraceLine& bufLine, ArgsMap& args, uint32_t& tgid) const @@ -738,25 +753,6 @@ void BytraceEventParser::GetDataSegArgs(BytraceLine& bufLine, ArgsMap& args, uin args.emplace(std::move(key), std::move(value)); } } -void BytraceEventParser::FilterAllEventsTemp() -{ - size_t maxBuffSize = 1000 * 1000; - size_t maxQueue = 2; - if (eventList_.size() < maxBuffSize * maxQueue) { - return; - } - auto cmp = [](const std::unique_ptr& a, const std::unique_ptr& b) { - return a->eventTimestamp < b->eventTimestamp; - }; - std::stable_sort(eventList_.begin(), eventList_.end(), cmp); - auto endOfList = eventList_.begin() + maxBuffSize; - for (auto itor = eventList_.begin(); itor != endOfList; itor++) { - EventInfo* event = itor->get(); - BeginFilterEvents(event); - itor->reset(); - } - eventList_.erase(eventList_.begin(), endOfList); -} void BytraceEventParser::FilterAllEvents() { diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.h b/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.h index 78d2dff39900d63504f1afc3a539ba1582d0d31f..3ead563ef5d85a622e04cc4228d8b051f204bc18 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.h +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -41,7 +41,6 @@ private: public: BytraceEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filter); void ParseDataItem(const BytraceLine& line); - void FilterAllEventsTemp(); void FilterAllEvents(); void BeginFilterEvents(EventInfo* event); void Clear(); @@ -95,7 +94,7 @@ private: const uint32_t MIN_CPU_IDLE_ARGS_COUNT = 2; const uint32_t MIN_CPU_FREQUENCY_ARGS_COUNT = 2; const uint32_t MIN_PROCESS_EXIT_ARGS_COUNT = 2; - const uint32_t MIN_CLOCK_SET_RATE_ARGS_COUNT = 3; + const uint32_t MIN_CLOCK_SET_RATE_ARGS_COUNT = 2; const uint32_t MIN_CLOCK_ENABLE_ARGS_COUNT = 3; const uint32_t MIN_CLOCK_DISABLE_ARGS_COUNT = 3; const uint32_t MIN_IRQ_HANDLER_ENTRY_ARGS_COUNT = 2; diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp b/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp index f491f03eb1936fbada08fcf3f9b87f4e559db77b..1a8ae27e848b997a35600f5659d6a127c7dd19be 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h b/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h index 09bdf93404b1540c1043d44a0b16b2f07fd6d187..25da3a8ed712725e4c5d89aa73d668104d794ae2 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp b/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp index 944807f896fba1892db3334d84cc9dc71552f8e5..532af201bd6400f86408e31614b36767868bc21e 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h b/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h index 1018179364ffca9e86f73d5ddd50cd1bc3136c01..7db157d71dc432bd5074b337019f161f9d166859 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp b/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp index d23bf8f572ec489c5fd47f945843563cb011f1dd..9536b7b086a8e4aa3b491c7c5f67c9bcaaa1cbdb 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h b/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h index 0aabfdf0faeccca2c2cbd77a7b62fc253e5665ba..c7903eab8fc301c8adcd227f432c71b6e337352b 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h +++ b/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/common_types.h b/trace_streamer/src/parser/common_types.h index 390a193972438ef4389c3217bc49f3fd03f942b5..8e1e302401ba8a29aa8a5e8b9bbfc02c34ee1ea1 100644 --- a/trace_streamer/src/parser/common_types.h +++ b/trace_streamer/src/parser/common_types.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -113,7 +113,7 @@ public: char phase_ = '\0'; uint32_t tgid_ = 0; std::string name_ = ""; - uint64_t value_ = 0; + int64_t value_ = 0; std::string categoryGroup_ = ""; // Distributed Data std::string chainId_ = ""; diff --git a/trace_streamer/src/parser/ebpf_parser/BUILD.gn b/trace_streamer/src/parser/ebpf_parser/BUILD.gn index 81b1ea633c67111202be05a37d07973ce0945f8a..e66453e6ba111a9e1db10ba8a32b59deeeb7cab9 100644 --- a/trace_streamer/src/parser/ebpf_parser/BUILD.gn +++ b/trace_streamer/src/parser/ebpf_parser/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.cpp b/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.cpp index 22a9936d0ff544bc82a3d162ef5a513e5761f8a8..95fbf8de687284d8662766d4b43365ec5a047801 100644 --- a/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.cpp +++ b/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.h b/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.h index e8d31c7b4803f241643a65188e7efe3a06dc361d..83db12cbe567cd1a8312325e65cfbde460a46847 100644 --- a/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.h +++ b/trace_streamer/src/parser/ebpf_parser/bio_latency_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_base.cpp b/trace_streamer/src/parser/ebpf_parser/ebpf_base.cpp index 6cebc041a72869ee64f1c97b43b1a4e3824e544f..7caf49cb075be7708c7bda22ad3766f8d4709a76 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_base.cpp +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_base.h b/trace_streamer/src/parser/ebpf_parser/ebpf_base.h index d04de8bd24f9c9d886fad6fc95fd352262806329..7345ab1ef51f22302cd16d48b8646b1f3cba2141 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_base.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.cpp b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.cpp index 6ce7be3024fa3b86f4b79e0641bcc792d22e1f0f..6323d4f522a9b3ffba7de46406cb99f288803d73 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.cpp +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h index f6cebaf7c548a9e41056bd294a605a56c2955960..f1d9572fd9a2c31354db8c74687dcb7ccf61a7bb 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.cpp b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.cpp index 482fef4850a07995af26859f52802e9be5b5cc56..5b4335fd0ef4821d0f2c9c0d9183f819a3fe3ca3 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.cpp +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h index 1322e4fb0c87e3259d55c420356c3a04ef0b6247..2580496291327cfb0ad90f0fa3022ac9c3dbcbc6 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_reader.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_data_structure.h b/trace_streamer/src/parser/ebpf_parser/ebpf_data_structure.h index 14e950df54b38d75118f1d89a363fa76f5d12784..4372e9f0ee1c6905c5ec9a49837e818f71cbb51c 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_data_structure.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_data_structure.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.cpp b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.cpp index 3c9eb8ea0d4487430067c6c1eb1cfcf0c3d228ff..c05fade2b5bc5fd4d575022ec80f629ee9c54c82 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.cpp +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h index bdcb45c3ad7dfaf721f054df2f8e0f0857797704..bca1fbf029041258fc07bb59700d4fc6ea815d7b 100644 --- a/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h +++ b/trace_streamer/src/parser/ebpf_parser/ebpf_splitter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.cpp b/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.cpp index 88f626e1239b5eda737453c593c97bfd0e60f85b..ea2498e069c779961c772666457f0078b6d92756 100644 --- a/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.cpp +++ b/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.h b/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.h index c4f75133f37e71a94b2bc7a5327b6efc0fde58db..c984ebe4104e6858ae4ef06de5a508df288a9eab 100644 --- a/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.h +++ b/trace_streamer/src/parser/ebpf_parser/file_system_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.cpp b/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.cpp index 09d5529deff7a69c12404516380017693a6fe893..89a40936a6f2122439b07bfb780d137a9aa0b33c 100644 --- a/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.cpp +++ b/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.h b/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.h index a1c2a560689aff9f7e831355dede77f254e327d7..4cf68356203a3e9454d1b68ba688c860d4db1fe5 100644 --- a/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.h +++ b/trace_streamer/src/parser/ebpf_parser/paged_memory_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/event_parser_base.cpp b/trace_streamer/src/parser/event_parser_base.cpp index a4bdbf4f5e4e7ac919ecf6af18f1fe7b6e680f3d..8a1655af4cd562d39cfead68140f7d667b7a48cc 100644 --- a/trace_streamer/src/parser/event_parser_base.cpp +++ b/trace_streamer/src/parser/event_parser_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/event_parser_base.h b/trace_streamer/src/parser/event_parser_base.h index 431729a0519f38647ee1fa0284e2f30d26342d67..a13522977ef0c0726e8f2ece738852db7cb1512c 100644 --- a/trace_streamer/src/parser/event_parser_base.h +++ b/trace_streamer/src/parser/event_parser_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/hiperf_parser/BUILD.gn b/trace_streamer/src/parser/hiperf_parser/BUILD.gn index f621b6bf1738ffc9726dd643686ffeb25d5d71f7..705a6737c6d423570af26bb343ae2a1b612772c5 100644 --- a/trace_streamer/src/parser/hiperf_parser/BUILD.gn +++ b/trace_streamer/src/parser/hiperf_parser/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp index faef4855304cc5787e0a2d2058cccd85b26eaa79..1652ded99cb2f20dd281ff9155f396c01b0e0802 100644 --- a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp +++ b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h index 5b2840547449fbab7332641781271f9e96fe006a..d9708e2238791d41ebd795c7c4754b35514a7f7d 100644 --- a/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h +++ b/trace_streamer/src/parser/hiperf_parser/perf_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn b/trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn index 07e2e3fd1930494ecc8de3a127e32f0f0d76e174..23b05e47f2e08193da63482411e393075caa3446 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn +++ b/trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp index 0e5e0b5444216b36c40cf75e190e32c1f2cd386b..30cfa09b19cc4f118179d885fddf4d28b7087db5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h index b91ee78e8e2fcf67f09270441c484a730ae5f3ad..0713efac31de2038eed5f49c50eb27fca4aa27fc 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp index a8359956c6162eca0f5e07e3cac85f39d6c0e8b7..d13c2b5ecf7c329c7429461c304efd316c2bd8aa 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h index e32411b647c820c1088ac30ef0255f05530ae5ef..bc87588581f671684b6e37e7698d0207ff10de08 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp index 19438979d7011be19c5d48f353a02d75f07d86f3..4b0c309ea1b41467e78d04a6964ad263b71f0702 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h index c825259cf5f18af2cb4e2e68575bc1bc530309c3..a33f30d412b70de4ee5c689a4fec563b608895f6 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp index 69b30102944f807350166e0c2d3f8053e075ff59..9af110c901c2a6248f229adcdc358e71d7abcf63 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h index 234260a375bf6e9e1c1b1247d88077694529e277..6d1eff67567ac4535294b43fcbb4d837d578a5ea 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp index 1433faaef66a906fb10c328a1a57984b5c19cdaf..4026d33d32f28b15be79a8f0f639c0f80bdb0808 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -200,10 +200,10 @@ void HtraceEventParser::ParserCpuEvent(HtraceDataSegment& tracePacket, eventInfo->cpu_ = msg.cpu(); auto pos = (const char*)detaiBytesView.Data() - tracePacket.seg->data(); eventInfo->detail_ = std::move(tracePacket.seg->substr(pos, detaiBytesView.Size())); + eventInfo->taskNameIndex_ = traceDataCache_->GetDataIndex(ftraceEvent.comm().ToStdString()); #ifdef SUPPORTTHREAD std::lock_guard muxLockGuard(mutex_); #endif - eventInfo->taskNameIndex_ = traceDataCache_->GetDataIndex(ftraceEvent.comm().ToStdString()); htraceEventList_.emplace_back(std::move(eventInfo)); } } @@ -512,8 +512,8 @@ bool HtraceEventParser::SchedSwitchEvent(const EventInfo& event) { ProtoReader::SchedSwitchFormat_Reader msg(event.detail_); streamFilters_->statFilter_->IncreaseStat(TRACE_EVENT_SCHED_SWITCH, STAT_EVENT_RECEIVED); - uint32_t prevPrioValue = msg.prev_prio(); - uint32_t nextPrioValue = msg.next_prio(); + int32_t prevPrioValue = msg.prev_prio(); + int32_t nextPrioValue = msg.next_prio(); uint32_t prevPidValue = msg.prev_pid(); uint32_t nextPidValue = msg.next_pid(); if (!tids_.count(prevPidValue)) { @@ -530,9 +530,8 @@ bool HtraceEventParser::SchedSwitchEvent(const EventInfo& event) streamFilters_->processFilter_->UpdateOrCreateThreadWithName(event.timeStamp_, nextPidValue, nextCommStr); auto uprevtid = streamFilters_->processFilter_->UpdateOrCreateThreadWithName(event.timeStamp_, prevPidValue, prevCommStr); - streamFilters_->cpuFilter_->InsertSwitchEvent(event.timeStamp_, event.cpu_, uprevtid, - static_cast(prevPrioValue), prevState, nextInternalTid, - static_cast(nextPrioValue), INVALID_DATAINDEX); + streamFilters_->cpuFilter_->InsertSwitchEvent(event.timeStamp_, event.cpu_, uprevtid, prevPrioValue, prevState, + nextInternalTid, nextPrioValue, INVALID_DATAINDEX); return true; } bool HtraceEventParser::SchedBlockReasonEvent(const EventInfo& event) @@ -971,6 +970,7 @@ void HtraceEventParser::Clear() const_cast(streamFilters_)->FilterClear(); streamFilters_->sysEventMemMeasureFilter_->Clear(); streamFilters_->sysEventVMemMeasureFilter_->Clear(); + traceDataCache_->GetMeasureData()->ClearRowMap(); printEventParser_.Finish(); } } // namespace TraceStreamer diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h index 751319f26a1f4a4c49dedd5ccad2896989aa4795..499d91296f973c7683bf43618d1c0b86d1baa07a 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -152,8 +152,6 @@ private: std::atomic ftraceOriginStartTime_{std::numeric_limits::max()}; std::atomic ftraceOriginEndTime_{0}; std::deque> htraceEventList_ = {}; - const DataIndex signalGenerateId_ = traceDataCache_->GetDataIndex("signal_generate"); - const DataIndex signalDeliverId_ = traceDataCache_->GetDataIndex("signal_deliver"); const DataIndex schedWakeupName_ = traceDataCache_->GetDataIndex("sched_wakeup"); const DataIndex schedWakingName_ = traceDataCache_->GetDataIndex("sched_waking"); const DataIndex schedWakeupNewName_ = traceDataCache_->GetDataIndex("sched_wakeup_new"); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp index 22c9ec90774434f560a8bbfcec5f3a8378b90613..431a1587680916adde6a58d116b677ff5fd2a65a 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h index 904ebd8ac8cc7bfeb8fe9e4d729bca00467bf9ca..b724a1291ce10f39338e4987b77c3acdd7037d5f 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp index 5bb146ffa5572229342693a3f46468931ebfcf54..d2455c10cbb70a67bf95940d5b756d9aace4d053 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h index e95d90c6a41602493630d52b88b23e00b99a05cb..9137116c56a01549a4bf37450483154a6b3d9daf 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp index 48fc8d1d6ed33a95c73d48b9339ed150ccaaf4e9..cbbeb2f77715f7345e4f9aed4e0c0407e908dac5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h index 41024e536f48649f675303ecd04af7af556dbace..c6a4ded5124fbb80a2ec03e9870d05d1fb3613a5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp index 53d411d8cf474267aadce179ea51cfc4d55dbd9b..45dee872519e4fd8b92c811990363f50a882e0d4 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h index 8558cad561461f9387cabd38476fb369c77862d0..19deb16545b875382e747c5504961a6f8889fcb6 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp index 447306465ebe2c31dba55f69a7add71462abf9c1..fd76ce8abb69a5a07be3f5455e98431998bbecab 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -51,11 +51,13 @@ struct Snapshot { int32_t edgeCount; int32_t traceFunctionCount; }; +int32_t g_nodesSingleLength = 0; void from_json(const json& j, Meta& v) { for (size_t i = 0; i < j["node_fields"].size(); i++) { v.nodeFields.emplace_back(j["node_fields"][i]); } + g_nodesSingleLength = j["node_fields"].size(); for (size_t i = 0; i < j["node_types"].size(); i++) { std::vector nodeTypes; if (j["node_types"][i].is_array()) { @@ -114,24 +116,23 @@ struct Nodes { std::vector traceNodeIds; std::vector detachedness; }; -const int32_t NODES_SINGLE_LENGTH = 7; std::vector g_fromNodeIds; std::vector g_ids; void from_json(const json& j, Nodes& v) { int32_t edgeIndex = 0; - for (size_t i = 0; i < j.size() / NODES_SINGLE_LENGTH; i++) { - v.types.emplace_back(j[i * NODES_SINGLE_LENGTH]); - v.names.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_FIRST]); - v.ids.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_SECOND]); - v.selfSizes.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_THIRD]); - v.edgeCounts.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_FOURTH]); + for (size_t i = 0; i < j.size() / g_nodesSingleLength; i++) { + v.types.emplace_back(j[i * g_nodesSingleLength]); + v.names.emplace_back(j[i * g_nodesSingleLength + OFFSET_FIRST]); + v.ids.emplace_back(j[i * g_nodesSingleLength + OFFSET_SECOND]); + v.selfSizes.emplace_back(j[i * g_nodesSingleLength + OFFSET_THIRD]); + v.edgeCounts.emplace_back(j[i * g_nodesSingleLength + OFFSET_FOURTH]); for (size_t m = edgeIndex; m < edgeIndex + v.edgeCounts.at(i); m++) { - g_fromNodeIds.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_SECOND]); + g_fromNodeIds.emplace_back(j[i * g_nodesSingleLength + OFFSET_SECOND]); } edgeIndex += v.edgeCounts.at(i); - v.traceNodeIds.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_FIFTH]); - v.detachedness.emplace_back(j[i * NODES_SINGLE_LENGTH + OFFSET_SIXTH]); + v.traceNodeIds.emplace_back(j[i * g_nodesSingleLength + OFFSET_FIFTH]); + v.detachedness.emplace_back(j[i * g_nodesSingleLength + OFFSET_SIXTH]); } for (size_t m = 0; m < j.size(); m++) { g_ids.emplace_back(j[m]); @@ -460,13 +461,9 @@ void HtraceJSMemoryParser::ParseSnapshotOrTimeLineEnd(const std::string& result, uint64_t ts) { std::string fileName = ""; - std::regex strEscapeInvalid("\\\\n"); - std::regex strInvalid("\\\\\""); - auto strEscape = std::regex_replace(jsMemoryString_, strEscapeInvalid, ""); - auto str = std::regex_replace(strEscape, strInvalid, "\""); if (type_ == ProtoReader::ArkTSConfig_HeapType::ArkTSConfig_HeapType_SNAPSHOT) { fileName = "Snapshot" + std::to_string(fileId_); - ParseSnapshot(tracePacket, profilerPluginData, str, ts); + ParseSnapshot(tracePacket, profilerPluginData, jsMemoryString_, ts); } else if (type_ == ProtoReader::ArkTSConfig_HeapType::ArkTSConfig_HeapType_TIMELINE) { if (result == snapshotEnd_) { ts = streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, ts); @@ -475,7 +472,7 @@ void HtraceJSMemoryParser::ParseSnapshotOrTimeLineEnd(const std::string& result, return; } fileName = "Timeline"; - ParseTimeLine(profilerPluginData, str); + ParseTimeLine(profilerPluginData, jsMemoryString_); } ts = streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, ts); UpdatePluginTimeRange(TS_CLOCK_REALTIME, ts, ts); @@ -501,10 +498,7 @@ void HtraceJSMemoryParser::ParseJsCpuProfiler(const std::string& result, curTypeIsCpuProfile_ = true; auto jsCpuProfilerString = result.substr(jsCpuProfilerPos + PROFILE_POS, result.size() - jsCpuProfilerPos - PROFILE_POS - END_PROFILE_POS); - std::regex strEscapeInvalid("\\\\n"); - std::regex strInvalid("\\\\\""); - auto strEscape = std::regex_replace(jsCpuProfilerString, strEscapeInvalid, ""); - auto str = std::regex_replace(strEscape, strInvalid, "\""); + ts = streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, ts); UpdatePluginTimeRange(TS_CLOCK_REALTIME, ts, ts); if (enableFileSave_) { @@ -514,11 +508,11 @@ void HtraceJSMemoryParser::ParseJsCpuProfiler(const std::string& result, exit(-1); } (void)ftruncate(fd, 0); - (void)write(fd, str.data(), str.size()); + (void)write(fd, jsCpuProfilerString.data(), jsCpuProfilerString.size()); close(fd); fd = 0; } - jsCpuProfilerParser_->ParseJsCpuProfiler(str, traceDataCache_->SplitFileMinTime(), + jsCpuProfilerParser_->ParseJsCpuProfiler(jsCpuProfilerString, traceDataCache_->SplitFileMinTime(), traceDataCache_->SplitFileMaxTime()); if (traceDataCache_->isSplitFile_) { cpuProfilerSplitFileData_ = jsCpuProfilerParser_->GetUpdateJson().dump(); @@ -550,8 +544,10 @@ void HtraceJSMemoryParser::Parse(ProtoReader::BytesView tracePacket, startTime_ = ts; isFirst_ = false; } - auto resultJson = result.substr(pos + CHUNK_POS, result.size() - pos - CHUNK_POS - END_POS); - jsMemoryString_ += resultJson; + auto jMessage = json::parse(result); + if (jMessage.contains("params") && jMessage["params"].contains("chunk")) { + jsMemoryString_ += jMessage["params"]["chunk"]; + } curTypeIsCpuProfile_ = false; } else { ParseJsCpuProfiler(result, profilerPluginData, ts); @@ -789,6 +785,7 @@ void HtraceJSMemoryParser::ParseSnapshot(ProtoReader::BytesView& tracePacket, (void)write(jsFileId_, jsonString.data(), jsonString.size()); close(jsFileId_); jsFileId_ = 0; + return; } json jMessage = json::parse(jsonString); ParserJSSnapInfo(fileId_, jMessage); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h index 4a9d37c3d52ceec5d4930c9ac219da455d5767a7..9312a392c9c3340d70e9bfe6172cf89b4de27cd0 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, 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 cc927ba82bd1cd276a474d162f88ec6a42f632a8..508aed75faeb95bcfbbd89636601150348246e90 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 @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -284,7 +284,7 @@ uint32_t HtraceMemParser::ParseSmapsBlockType(ProtoReader::SmapsInfo_Reader& sma } } bool hasAppName = path.find("com.huawei.wx") != std::string::npos; - uint32_t detailRet = (smapsInfo, path, hasAppName); + uint32_t detailRet = ParseSmapsBlockDetail(smapsInfo, path, hasAppName); if (detailRet != static_cast(SmapsMemType::SMAPS_MEM_TYPE_INVALID)) { return detailRet; } diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h index a53141b0e15426541f9df9ec3f175c588c84eb4d..3a463f9a706896339fa64dcb263d52c87a04aeb4 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp index 37a67b6118a9c3fef5234c48bebf789aa5c0d03e..aed5c3b1f6af10601f77afd93e0f5ed3aa067700 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -33,28 +33,24 @@ HtraceNativeHookParser::~HtraceNativeHookParser() static_cast(MaxTs())); } -bool HtraceNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesView) +bool HtraceNativeHookParser::ParseStackMapOfflineOrOnline(const ProtoReader::BytesView& bytesView) { - if (traceDataCache_->isSplitFile_) { - auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); - StackMap* stackMap = hookData->mutable_stack_map(); - stackMap->ParseFromArray(bytesView.Data(), bytesView.Size()); - nativeHookFilter_->GetCommHookData().size += bytesView.Size(); - return false; - } ProtoReader::StackMap_Reader stackMapReader(bytesView); - bool parseError = false; auto ipid = streamFilters_->processFilter_->UpdateOrCreateProcessWithName(stackMapReader.pid(), ""); // stores frames info. if offlineSymbolization is true, storing ips data, else storing FrameMap id. std::vector frames; - if (stackMapReader.has_frame_map_id()) { + // Defining multiset to solve the problem of if frame_map_id is equal to frame_map_id_down + std::map>> frameIdAndIdDownInfo; + std::shared_ptr> frameIdAndIdDown = std::make_shared>(); + bool parseError = false; + if (!nativeHookFilter_->GetOfflineSymbolizationMode()) { auto itor = stackMapReader.frame_map_id(&parseError); TS_CHECK_TRUE(!parseError, false, "Parse packed varInt in ParseStackMap function failed!!!"); while (itor) { frames.emplace_back(*itor); itor++; } - } else if (stackMapReader.has_ip()) { + } else { auto itor = stackMapReader.ip(&parseError); TS_CHECK_TRUE(!parseError, false, "Parse packed varInt in ParseStackMap function failed!!!"); // OfflineSymbolization use ipidToStartAddrToMapsInfoMap_ Multi-process differentiation @@ -62,8 +58,41 @@ bool HtraceNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesVi frames.emplace_back(*itor); itor++; } + if (stackMapReader.has_frame_map_id()) { + bool parseFrameMapid = false; + auto frameMapIdItor = stackMapReader.frame_map_id(&parseFrameMapid); + while (frameMapIdItor) { + frameIdAndIdDown->emplace(*frameMapIdItor); + frameMapIdItor++; + } + frameIdAndIdDownInfo.emplace(std::make_pair(0, frameIdAndIdDown)); + } + if (stackMapReader.has_frame_map_id_down()) { + frameIdAndIdDown->clear(); + bool parseFrameMapIdDown = false; + auto frameMapIdDownItor = stackMapReader.frame_map_id_down(&parseFrameMapIdDown); + while (frameMapIdDownItor) { + frameIdAndIdDown->emplace(*frameMapIdDownItor); + frameMapIdDownItor++; + } + frameIdAndIdDownInfo.emplace(std::make_pair(1, frameIdAndIdDown)); + } + } + nativeHookFilter_->AppendStackMaps(ipid, stackMapReader.id(), frames, frameIdAndIdDownInfo); + return true; +} +bool HtraceNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesView) +{ + if (traceDataCache_->isSplitFile_) { + auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); + StackMap* stackMap = hookData->mutable_stack_map(); + stackMap->ParseFromArray(bytesView.Data(), bytesView.Size()); + nativeHookFilter_->GetCommHookData().size += bytesView.Size(); + return false; + } + if (!ParseStackMapOfflineOrOnline(bytesView)) { + return false; } - nativeHookFilter_->AppendStackMaps(ipid, stackMapReader.id(), frames); return true; } diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h index 5172b5aa7ce31fe78e112dc01012807b2ab2d7e9..d885881b5af3474fa352eb2bbd09c32354a3cce0 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -48,6 +48,7 @@ private: void ParseSymbolEvent(const ProtoReader::BytesView& bytesView); void ParseThreadEvent(const ProtoReader::BytesView& bytesView); void ParseFrameMap(std::unique_ptr& nativeHookMetaData); + bool ParseStackMapOfflineOrOnline(const ProtoReader::BytesView& bytesView); bool ParseStackMap(const ProtoReader::BytesView& bytesView); void SplitHookData(std::unique_ptr& nativeHookMetaData, bool& haveSplitSeg); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp index a5d344940dbd853b97e93b8257845ffa6049ddfe..15ab7ab1a7efe3c705b35317552a9027447cd977 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h index 619b6efaed9982b4093e22f1d4932a616b24a580..ccb017ce5cd941ac0bfb8c8a13c8dd9235042b64 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp index 72b7784af8515da8f952fcd1c83bd07890278933..8ba3745a7875315dbd8f253709627922f1ab5141 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -494,22 +494,24 @@ void HtraceParser::ParseFtrace(HtraceDataSegment& dataSeg) dataSeg.clockId = clock_; if (tracePluginResult.has_ftrace_cpu_detail()) { htraceCpuDetailParser_->Parse(dataSeg, tracePluginResult, haveSplitSeg); - dataSeg.status = TS_PARSE_STATUS_PARSED; } if (tracePluginResult.has_symbols_detail()) { htraceSymbolsDetailParser_->Parse(dataSeg.protoData); // has Event haveSplitSeg = true; - dataSeg.status = TS_PARSE_STATUS_PARSED; } if (tracePluginResult.has_clocks_detail()) { htraceClockDetailParser_->Parse(dataSeg.protoData); // has Event haveSplitSeg = true; - dataSeg.status = TS_PARSE_STATUS_PARSED; } if (traceDataCache_->isSplitFile_ && haveSplitSeg) { mTraceDataHtrace_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); } - dataSeg.status = TS_PARSE_STATUS_INVALID; + if (tracePluginResult.has_ftrace_cpu_detail() || tracePluginResult.has_clocks_detail() || + tracePluginResult.has_symbols_detail()) { + dataSeg.status = TS_PARSE_STATUS_PARSED; + } else { + dataSeg.status = TS_PARSE_STATUS_INVALID; + } } void HtraceParser::ParseFPS(HtraceDataSegment& dataSeg) @@ -754,7 +756,6 @@ bool HtraceParser::ParseHiperfData(std::deque::iterator& packagesBegin, } return false; } - bool isFinish = perfProcessedLen_ + packagesBuffer_.size() >= profilerDataLength_ - packetHeaderLength_; auto size = packagesBuffer_.size(); if (isFinish) { diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h index f79cc84823e83000d6b29f4560f1f1a9de1a7293..8b57080b6005fc61ce5757b93211250185035e6f 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -109,6 +109,10 @@ public: return ebpfDataParser_; } void WaitForParserSplitedHtraceEnd(); + void EnableOnlyParseFtrace() + { + onlyParseFtrace_ = true; + } private: bool ParseDataRecursively(std::deque::iterator& packagesBegin, size_t& currentLength); @@ -229,6 +233,7 @@ private: DataIndex arktsPluginConfigIndex_; DataIndex memoryPluginConfigIndex_; std::set supportPluginNameIndex_ = {}; + bool onlyParseFtrace_ = false; }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp index 0dbd003aae9f5ed4d57ea5874aac064e970fcc74..cc6d67cc7d20a8f18f8ad6df9b0222279a1a4a05 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h index 121d4f7cc21ade7bafeba927003b818ee34375d7..99639e3ca6f5664a171085644b5b08cb0ff8c81b 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp index 8fb6ac953d02df3ceef9ef7b96e186a4d63a3338..7b9fe21c96b49e94e08bfeeaa1e09c3987d011cf 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.h b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.h index c80379e79b40db3b36908e07a5e1a59bf9d0a9b8..39a79e0efefe053e77eecc6f89d1573e738283a7 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.h +++ b/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/parser_base.cpp b/trace_streamer/src/parser/parser_base.cpp index ad069faf44445d560cde48e3520e98aab03e3f17..15c90963108c14083a5d884563fa6bff6d5ab21f 100644 --- a/trace_streamer/src/parser/parser_base.cpp +++ b/trace_streamer/src/parser/parser_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/parser_base.h b/trace_streamer/src/parser/parser_base.h index 4a9ef68b6d99ee652b4b03378273f8a69b0a3b6b..a72e136dfa6c9fa3135fca1a7d0184a4251bbbe1 100644 --- a/trace_streamer/src/parser/parser_base.h +++ b/trace_streamer/src/parser/parser_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/print_event_parser.cpp b/trace_streamer/src/parser/print_event_parser.cpp index 62c092fbbf088203ad1201904e0c0d514aca4006..ddc61be6fdf14ea7e3bbee584c1c7172704de977 100644 --- a/trace_streamer/src/parser/print_event_parser.cpp +++ b/trace_streamer/src/parser/print_event_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -125,7 +125,7 @@ void PrintEventParser::ParseStartEvent(const std::string& comm, const TracePoint& point, const BytraceLine& line) { - auto cookie = static_cast(point.value_); + auto cookie = static_cast(point.value_); auto index = streamFilters_->sliceFilter_->StartAsyncSlice(ts, pid, point.tgid_, cookie, traceDataCache_->GetDataIndex(point.name_)); if (point.name_ == onFrameQueeuStartEvent_ && index != INVALID_UINT64) { @@ -137,7 +137,7 @@ void PrintEventParser::ParseStartEvent(const std::string& comm, } void PrintEventParser::ParseFinishEvent(uint64_t ts, uint32_t pid, const TracePoint& point, const BytraceLine& line) { - auto cookie = static_cast(point.value_); + auto cookie = static_cast(point.value_); auto index = streamFilters_->sliceFilter_->FinishAsyncSlice(ts, pid, point.tgid_, cookie, traceDataCache_->GetDataIndex(point.name_)); HandleFrameQueueEndEvent(ts, point.tgid_, point.tgid_, index); @@ -445,11 +445,11 @@ ParseResult PrintEventParser::HandlerCSF(std::string_view pointStr, TracePoint& } std::string valueStr(pointStr.data() + valueIndex, valueLen); - if (!base::StrToInt(valueStr).has_value()) { + if (!base::StrToInt(valueStr).has_value()) { TS_LOGD("point value is error!"); return PARSE_ERROR; } - outPoint.value_ = base::StrToInt(valueStr).value(); + outPoint.value_ = base::StrToInt(valueStr).value(); size_t valuePipe = pointStr.find('|', valueIndex); if (valuePipe != std::string_view::npos) { diff --git a/trace_streamer/src/parser/print_event_parser.h b/trace_streamer/src/parser/print_event_parser.h index 4b5c62155f76c88640eeefa2f9db0e232c8b0f97..6f7a5a73c8a4703d26b0f5f8cb01ee27d52b8cad 100644 --- a/trace_streamer/src/parser/print_event_parser.h +++ b/trace_streamer/src/parser/print_event_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/BUILD.gn b/trace_streamer/src/parser/rawtrace_parser/BUILD.gn index 89974950dd7618619e77d199792638138ef235aa..c8ec43363e70bdbef9de6a711fabf39f8798efe3 100755 --- a/trace_streamer/src/parser/rawtrace_parser/BUILD.gn +++ b/trace_streamer/src/parser/rawtrace_parser/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.cpp b/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.cpp index 5bec4c765d46467a06a453add8b6d52f00c588e1..73e92bd1ee2af2f2133b57ca41223e80bdad984f 100644 --- a/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -29,14 +29,12 @@ #include "ftrace_event_processor.h" #include "string_to_numerical.h" -namespace { -constexpr uint64_t FILTER_MAX_SIZE = 3000000; -} namespace SysTuning { namespace TraceStreamer { CpuDetailParser::CpuDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : streamFilters_(ctx), traceDataCache_(dataCache), printEventParser_(dataCache, ctx) { + standAloneCpuEventList_.resize(CPU_CORE_MAX); printEventParser_.SetTraceType(TRACE_FILETYPE_RAW_TRACE); printEventParser_.SetTraceClockId(clock_); eventToFunctionMap_ = { @@ -148,12 +146,44 @@ void CpuDetailParser::VoltageEventInitialization() config_.eventNameMap_.at(TRACE_EVENT_REGULATOR_DISABLE_COMPLETE), std::bind(&CpuDetailParser::RegulatorDisableCompleteEvent, this, std::placeholders::_1)); } - -void CpuDetailParser::EventAppend(std::unique_ptr event) -{ - rawTraceEventList_.emplace_back(std::move(event)); +void CpuDetailParser::EventAppend(std::shared_ptr event) +{ + standAloneCpuEventList_[event->cpuId].emplace(std::move(event)); + curRawTraceEventNum_++; +} +void CpuDetailParser::ResizeStandAloneCpuEventList(uint32_t cpuNum) +{ + cpuCoreMax_ = cpuNum; + standAloneCpuEventList_.resize(cpuNum); +} +bool CpuDetailParser::SortStandAloneCpuEventList(bool isFinished) +{ + while (curRawTraceEventNum_ > 0) { + uint32_t minTimeCpuId = 0; + uint64_t curMinTs = INVALID_UINT64; + // select a min time from one of the cpu caches + for (int curCpuId = 0; curCpuId < cpuCoreMax_; curCpuId++) { + if (!isFinished && standAloneCpuEventList_[curCpuId].empty()) { + return true; + } else if (standAloneCpuEventList_[curCpuId].empty()) { + continue; + } + uint64_t ts = standAloneCpuEventList_[curCpuId].front()->msgPtr->timestamp(); + if (ts < curMinTs) { + curMinTs = ts; + minTimeCpuId = curCpuId; + } + } + rawTraceEventList_.emplace_back(std::move(standAloneCpuEventList_[minTimeCpuId].front())); + standAloneCpuEventList_[minTimeCpuId].pop(); + curRawTraceEventNum_--; + if (!isFinished && standAloneCpuEventList_[minTimeCpuId].empty()) { + break; + } + } + return true; } -bool CpuDetailParser::FilterAllEvents(FtraceCpuDetailMsg& cpuDetail, bool isFinished) +void CpuDetailParser::UpdateCpuOverwrite(FtraceCpuDetailMsg& cpuDetail) { if (cpuDetail.overwrite()) { if (!lastOverwrite_) { @@ -165,16 +195,12 @@ bool CpuDetailParser::FilterAllEvents(FtraceCpuDetailMsg& cpuDetail, bool isFini } streamFilters_->statFilter_->IncreaseStat(TRACE_EVENT_OTHER, STAT_EVENT_DATA_LOST); } - if (!isFinished && rawTraceEventList_.size() < FILTER_MAX_SIZE) { - return false; - } - auto cmp = [](const std::unique_ptr& a, const std::unique_ptr& b) { - return a->msgPtr->timestamp() < b->msgPtr->timestamp(); - }; - std::stable_sort(rawTraceEventList_.begin(), rawTraceEventList_.end(), cmp); - if (rawTraceEventList_.empty()) { - return false; - } +} +bool CpuDetailParser::FilterAllEvents(FtraceCpuDetailMsg& cpuDetail, bool isFinished) +{ + UpdateCpuOverwrite(cpuDetail); + SortStandAloneCpuEventList(isFinished); + TS_CHECK_TRUE_RET(!rawTraceEventList_.empty(), true); traceDataCache_->UpdateTraceTime(rawTraceEventList_.front()->msgPtr->timestamp()); traceDataCache_->UpdateTraceTime(rawTraceEventList_.back()->msgPtr->timestamp()); for (size_t i = 0; i < rawTraceEventList_.size(); i++) { @@ -183,27 +209,32 @@ bool CpuDetailParser::FilterAllEvents(FtraceCpuDetailMsg& cpuDetail, bool isFini streamFilters_->processFilter_->GetOrCreateThreadWithPid(eventPid_, eventPid_); } DealEvent(*rawTraceEventList_[i].get()); + rawTraceEventList_[i].reset(); } - TS_LOGI("event_size=%d, rawTraceEventList_.size=%zu", cpuDetail.event().size(), rawTraceEventList_.size()); + TS_LOGI("deal rawTraceEventList_.size=%zu", rawTraceEventList_.size()); rawTraceEventList_.clear(); cpuDetail.Clear(); - TS_CHECK_TRUE_RET(isFinished, true); - streamFilters_->cpuFilter_->Finish(); - traceDataCache_->dataDict_.Finish(); - traceDataCache_->UpdataZeroThreadInfo(); - if (traceDataCache_->AppStartTraceEnabled()) { - streamFilters_->appStartupFilter_->FilterAllAPPStartupData(); - } - Clear(); return true; } void CpuDetailParser::Clear() { + cpuCoreMax_ = CPU_CORE_MAX; const_cast(streamFilters_)->FilterClear(); streamFilters_->sysEventMemMeasureFilter_->Clear(); streamFilters_->sysEventVMemMeasureFilter_->Clear(); printEventParser_.Finish(); } +void CpuDetailParser::FinishCpuDetailParser() +{ + streamFilters_->cpuFilter_->Finish(); + traceDataCache_->dataDict_.Finish(); + traceDataCache_->UpdataZeroThreadInfo(); + if (traceDataCache_->AppStartTraceEnabled()) { + streamFilters_->appStartupFilter_->FilterAllAPPStartupData(); + } + Clear(); + traceDataCache_->GetThreadStateData()->SortAllRowByTs(); +} void CpuDetailParser::DealEvent(const RawTraceEventInfo& event) { eventTid_ = event.msgPtr->common_fields().pid(); @@ -232,9 +263,9 @@ bool CpuDetailParser::SchedSwitchEvent(const RawTraceEventInfo& event) auto uprevtid = streamFilters_->processFilter_->UpdateOrCreateThreadWithName( event.msgPtr->timestamp(), schedSwitchMsg.prev_pid(), schedSwitchMsg.prev_comm()); - streamFilters_->cpuFilter_->InsertSwitchEvent( - event.msgPtr->timestamp(), event.cpuId, uprevtid, static_cast(schedSwitchMsg.prev_prio()), - schedSwitchPrevState, nextInternalTid, static_cast(schedSwitchMsg.next_prio()), INVALID_DATAINDEX); + streamFilters_->cpuFilter_->InsertSwitchEvent(event.msgPtr->timestamp(), event.cpuId, uprevtid, + schedSwitchMsg.prev_prio(), schedSwitchPrevState, nextInternalTid, + schedSwitchMsg.next_prio(), INVALID_DATAINDEX); return true; } bool CpuDetailParser::SchedBlockReasonEvent(const RawTraceEventInfo& event) diff --git a/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.h b/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.h index 35ed986b52b32a7edad959c6e31b9f440b16b4ad..940a66f48c92cf53128feb128ace4b3b47fedf7d 100644 --- a/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.h +++ b/trace_streamer/src/parser/rawtrace_parser/cpu_detail_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -14,6 +14,7 @@ */ #ifndef CPU_DETAIL_PARSER_H #define CPU_DETAIL_PARSER_H +#include #include "print_event_parser.h" #include "trace_data_cache.h" #include "trace_plugin_result.pb.h" @@ -21,6 +22,7 @@ namespace SysTuning { namespace TraceStreamer { +constexpr uint32_t CPU_CORE_MAX = 30; struct RawTraceEventInfo { uint8_t cpuId = INVALID_UINT8; uint32_t eventId = INVALID_UINT32; @@ -30,11 +32,15 @@ class CpuDetailParser { public: CpuDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); ~CpuDetailParser() = default; - void EventAppend(std::unique_ptr event); + void EventAppend(std::shared_ptr event); + void ResizeStandAloneCpuEventList(uint32_t cpuNum); bool FilterAllEvents(FtraceCpuDetailMsg& cpuDetail, bool isFinished = false); + void FinishCpuDetailParser(); void Clear(); private: + bool SortStandAloneCpuEventList(bool isFinished = false); + void UpdateCpuOverwrite(FtraceCpuDetailMsg& cpuDetail); void DealEvent(const RawTraceEventInfo& event); bool SchedSwitchEvent(const RawTraceEventInfo& event); bool SchedBlockReasonEvent(const RawTraceEventInfo& event); @@ -81,6 +87,9 @@ private: void StackEventsInitialization(); void VoltageEventInitialization(); +public: + uint32_t cpuCoreMax_ = CPU_CORE_MAX; + private: using FuncCall = std::function; const TraceStreamerFilters* streamFilters_; @@ -91,7 +100,9 @@ private: uint32_t eventTid_ = INVALID_UINT32; uint64_t lastOverwrite_ = 0; - std::deque> rawTraceEventList_ = {}; + uint64_t curRawTraceEventNum_ = 0; + std::deque> rawTraceEventList_ = {}; + std::vector>> standAloneCpuEventList_ = {}; std::map eventToFunctionMap_ = {}; TraceStreamerConfig config_{}; diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp index aca1e11e04cb32d7f9c3c4c25d6a44ae15dd8e83..7c660f75093ec202e4975b769a2c1d3a7d78e3e1 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.h b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.h index af13ac8df991f6975e17bf3e9e51d5566c4fd105..4549009e90443d8e3fa0bac0541e9de83c15043c 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.h +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_event_processor.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.cpp index 8444075f407e3a10c6b616248f5de897833c660d..25243f994f95506581e5e4a8b35095713c6b7207 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.h b/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.h index 94741a69f51ffb302bbcdbdc5f748a69c8cbdb43..d686d48718df986053f963a0e8e4ab291317223d 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.h +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_field_processor.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.cpp index dbd7764c349a4a970683334efce66b13589048ce..cb9afa03e450d897ff828879425f40e95fa800a5 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -60,9 +60,10 @@ bool ReadInfo(uint8_t* startPtr[], uint8_t* endPtr, void* outData, size_t outSiz namespace SysTuning { namespace TraceStreamer { -FtraceProcessor::FtraceProcessor() +FtraceProcessor::FtraceProcessor(TraceDataCache* traceDataCache) : fixedCharArrayRegex_(std::regex(R"(char \w+\[\d+\])")), - flexDataLocArrayRegex_(std::regex(R"(__data_loc [a-zA-Z_0-9 ]+\[\] \w+)")) + flexDataLocArrayRegex_(std::regex(R"(__data_loc [a-zA-Z_0-9 ]+\[\] \w+)")), + traceDataCache_(traceDataCache) { } @@ -529,7 +530,6 @@ bool FtraceProcessor::HandleTimeExtend(const FtraceEventHeader& eventHeader) { uint32_t deltaExt = 0; TS_CHECK_TRUE(ReadInfo(&curPos_, endPosOfData_, &deltaExt, sizeof(deltaExt)), false, "read time delta failed!"); - curTimestamp_ += TimestampIncrements(deltaExt); TS_LOGD("HandleTimeExtend: update ts with %u to %" PRIu64, deltaExt, curTimestamp_); return true; @@ -577,6 +577,10 @@ bool FtraceProcessor::HandleDataRecord(const FtraceEventHeader& eventHeader, } TS_LOGD("HandleDataRecord: eventId = %u, name = %s", eventId, format.eventName.c_str()); + if (traceDataCache_->isSplitFile_) { + curPos_ = eventEnd; + return true; + } if (FtraceEventProcessor::GetInstance().IsSupported(format.eventId)) { std::unique_ptr ftraceEvent = std::make_unique(); ftraceEvent->set_timestamp(curTimestamp_); @@ -596,25 +600,22 @@ bool FtraceProcessor::HandleDataRecord(const FtraceEventHeader& eventHeader, bool FtraceProcessor::HandlePage(FtraceCpuDetailMsg& cpuMsg, CpuDetailParser& cpuDetailParser, uint8_t page[], + bool& haveSplitSeg, size_t size) { curPos_ = page; curPage_ = page; endPosOfPage_ = page + size; - HandlePageHeader(); TS_LOGD("HandlePage: %" PRIu64 " bytes event data in page!", curPageHeader_.size); cpuMsg.set_overwrite(curPageHeader_.overwrite); - curTimestamp_ = curPageHeader_.timestamp; endPosOfData_ = curPageHeader_.endpos; while (curPos_ < curPageHeader_.endpos) { FtraceEventHeader eventHeader = {}; TS_CHECK_TRUE(ReadInfo(&curPos_, endPosOfData_, &eventHeader, sizeof(FtraceEventHeader)), false, "read EventHeader fail!"); - curTimestamp_ += eventHeader.timeDelta; - bool retval = false; switch (eventHeader.typeLen) { case BUFFER_TYPE_PADDING: @@ -634,6 +635,9 @@ bool FtraceProcessor::HandlePage(FtraceCpuDetailMsg& cpuMsg, TS_CHECK_TRUE(retval, false, "parse record data failed!"); break; } + if (traceDataCache_->isSplitFile_ && IsSplitCpuTimeStampData(curTimestamp_, haveSplitSeg)) { + return true; + } TS_LOGD("parsed %ld bytes of page data.", static_cast(curPos_ - curPage_)); } return true; @@ -644,18 +648,15 @@ static inline int RmqEntryTotalSize(unsigned int size) return sizeof(struct RmqEntry) + ((size + RMQ_ENTRY_ALIGN_MASK) & (~RMQ_ENTRY_ALIGN_MASK)); } -bool FtraceProcessor::HmParsePageData(FtraceCpuDetailMsg& cpuMsg, CpuDetailParser& cpuDetailParser, uint8_t*& data) +void FtraceProcessor::HmProcessPageTraceDataEvents(RmqConsumerData* rmqData, + uint64_t timeStampBase, + FtraceCpuDetailMsg& cpuMsg, + CpuDetailParser& cpuDetailParser, + bool& haveSplitSeg) { - RmqConsumerData* rmqData = reinterpret_cast(data); - uint64_t timeStampBase = rmqData->timeStamp; RmqEntry* event; HmTraceHeader* header; - EventFormat format = {}; - - cpuMsg.set_cpu(rmqData->coreId); - cpuMsg.set_overwrite(0); - auto curPtr = rmqData->data; auto endPtr = rmqData->data + rmqData->length; while (curPtr < endPtr) { @@ -664,19 +665,24 @@ bool FtraceProcessor::HmParsePageData(FtraceCpuDetailMsg& cpuMsg, CpuDetailParse if (evtSize == 0U) { break; } - header = reinterpret_cast(event->data); auto eventId = header->commonType; + curPtr += RmqEntryTotalSize(evtSize); if (!GetEventFormatById(eventId, format)) { - curPtr += RmqEntryTotalSize(evtSize); TS_LOGD("mark.debug. evtId = %u evtSize = %u", eventId, evtSize); continue; } + if (traceDataCache_->isSplitFile_) { + if (IsSplitCpuTimeStampData(event->timeStampOffset + timeStampBase, haveSplitSeg)) { + return; + } + continue; + } if (FtraceEventProcessor::GetInstance().IsSupported(format.eventId)) { std::unique_ptr ftraceEvent = std::make_unique(); ftraceEvent->set_timestamp(event->timeStampOffset + timeStampBase); HandleFtraceEvent(*ftraceEvent, reinterpret_cast(header), evtSize, format); - std::unique_ptr eventInfo = std::make_unique(); + std::shared_ptr eventInfo = std::make_shared(); eventInfo->cpuId = cpuMsg.cpu(); eventInfo->eventId = eventId; eventInfo->msgPtr = std::move(ftraceEvent); @@ -687,10 +693,18 @@ bool FtraceProcessor::HmParsePageData(FtraceCpuDetailMsg& cpuMsg, CpuDetailParse "format.eventName = %s format.eventType = %s", eventId, evtSize, format.eventId, format.eventSize, format.eventName.c_str(), format.eventType.c_str()); } - curPtr += RmqEntryTotalSize(evtSize); } - - data += FTRACE_PAGE_SIZE; +} +bool FtraceProcessor::HmParsePageData(FtraceCpuDetailMsg& cpuMsg, + CpuDetailParser& cpuDetailParser, + uint8_t*& data, + bool& haveSplitSeg) +{ + RmqConsumerData* rmqData = reinterpret_cast(data); + uint64_t timeStampBase = rmqData->timeStamp; + cpuMsg.set_cpu(rmqData->coreId); + cpuMsg.set_overwrite(0); + HmProcessPageTraceDataEvents(rmqData, timeStampBase, cpuMsg, cpuDetailParser, haveSplitSeg); return true; } diff --git a/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.h b/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.h index 8ab2720d2f3eeeb70d2d9e6dc82d15c6a4a9fb31..30d6d16593830a0b1246f4575df4f0b7b6a0120e 100644 --- a/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.h +++ b/trace_streamer/src/parser/rawtrace_parser/ftrace_processor.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -32,7 +32,7 @@ constexpr uint32_t FTRACE_PAGE_SIZE = 4096; constexpr uint32_t RMQ_ENTRY_ALIGN_MASK = (1 << 2) - 1; class FtraceProcessor { public: - FtraceProcessor(); + FtraceProcessor(TraceDataCache* traceDataCache); ~FtraceProcessor(); bool SetupEvent(const std::string& desc); @@ -40,9 +40,26 @@ public: bool HandlePage(FtraceCpuDetailMsg& cpuMsg, CpuDetailParser& cpuDetailParser, uint8_t page[], + bool& haveSplitSeg, size_t size = FTRACE_PAGE_SIZE); - bool HmParsePageData(FtraceCpuDetailMsg& cpuMsg, CpuDetailParser& cpuDetailParser, uint8_t*& data); - + bool IsSplitCpuTimeStampData(uint64_t CurTimeStamp, bool& haveSplitSeg) + { + if (traceDataCache_->SplitFileMinTime() <= CurTimeStamp && + traceDataCache_->SplitFileMaxTime() >= CurTimeStamp) { + haveSplitSeg = true; + return true; + } + return false; + } + void HmProcessPageTraceDataEvents(RmqConsumerData* rmqData, + uint64_t timeStampBase, + FtraceCpuDetailMsg& cpuMsg, + CpuDetailParser& cpuDetailParser, + bool& haveSplitSeg); + bool HmParsePageData(FtraceCpuDetailMsg& cpuMsg, + CpuDetailParser& cpuDetailParser, + uint8_t*& data, + bool& haveSplitSeg); bool HandleTgids(const std::string& tgids); bool HandleCmdlines(const std::string& cmdlines); @@ -90,6 +107,7 @@ private: std::unordered_map tgidDict_ = {}; // first is pid, second is taskName std::unordered_map taskNameDict_ = {}; + TraceDataCache* traceDataCache_ = nullptr; const std::string nameLinePrefix_ = "name:"; const std::string idLinePrefix_ = "ID:"; diff --git a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp index 14b818d21705dd89ec11fdde52b7adbfa5c8f6c1..0964318c313569ff80c1de8e8f2f52ca5a2e4c3d 100644 --- a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.h b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.h index 252bd954628480051a0978ed559d2839170e1a2a..b5558fb2d89d62176037eb7c672cf01bac0a56ac 100644 --- a/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.h +++ b/trace_streamer/src/parser/rawtrace_parser/kernel_symbols_processor.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp index 671b403107616605ac8b5bd838207ec11e884036..c59be8a261d8cae39c496c32480d0b6cc5a670cc 100644 --- a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.h b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.h index c1343b250bbe01f2cc0d2013d1dbeaa767f4a34f..da8f4837de7327ff5b07923e7c2277f08a909df4 100644 --- a/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.h +++ b/trace_streamer/src/parser/rawtrace_parser/printk_formats_processor.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp index 836f2b98ebfaf7840903cf6b62824e74d2184b15..7b143c7cb4ab1ced8362bbe6b2b52c883d63b99b 100644 --- a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp +++ b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -26,19 +26,23 @@ RawTraceParser::RawTraceParser(TraceDataCache* dataCache, const TraceStreamerFil : ParserBase(filters), cpuDetail_(std::make_unique()), cpuDetailParser_(std::make_unique(dataCache, filters)), - ftraceProcessor_(std::make_unique()), + ftraceProcessor_(std::make_unique(dataCache)), ksymsProcessor_(std::make_unique(dataCache, filters)), traceDataCache_(dataCache) { } + RawTraceParser::~RawTraceParser() {} void RawTraceParser::ParseTraceDataItem(const std::string& buffer) {} void RawTraceParser::WaitForParserEnd() { cpuDetailParser_->FilterAllEvents(*cpuDetail_.get(), true); + cpuDetailParser_->FinishCpuDetailParser(); UpdateTraceMinRange(); restCommDataCnt_ = 0; hasGotHeader_ = false; + curCpuCoreNum_ = 0; + ClearRawTraceData(); TS_LOGI("Parser raw trace end!"); } void RawTraceParser::UpdateTraceMinRange() @@ -46,9 +50,9 @@ void RawTraceParser::UpdateTraceMinRange() auto schedSlice = traceDataCache_->GetConstSchedSliceData(); std::set uniqueCpuIdSet; uint64_t cpuRunningStatMinTime = INVALID_TIME; - for (size_t i = 0; i < schedSlice.Size() && uniqueCpuIdSet.size() <= cpuCoreMax_; i++) { - auto itor = uniqueCpuIdSet.find(schedSlice.CpusData()[i]); - if (itor != uniqueCpuIdSet.end()) { + for (size_t i = 0; i < schedSlice.Size() && uniqueCpuIdSet.size() <= curCpuCoreNum_; i++) { + auto iter = uniqueCpuIdSet.find(schedSlice.CpusData()[i]); + if (iter != uniqueCpuIdSet.end()) { continue; } uniqueCpuIdSet.emplace(schedSlice.CpusData()[i]); @@ -67,6 +71,12 @@ bool RawTraceParser::InitRawTraceFileHeader(std::deque::iterator& packa TS_LOGI("magicNumber=%d fileType=%d", header.magicNumber, header.fileType); fileType_ = header.fileType; + if (traceDataCache_->isSplitFile_) { + // To resolve the second incoming file, it is necessary to reset the previously set variables to zero + ClearRawTraceData(); + rawTraceSplitCommData_.emplace_back(SpliteDataInfo(curFileOffset_, sizeof(RawTraceFileHeader))); + curFileOffset_ += sizeof(RawTraceFileHeader); + } packagesCurIter += sizeof(RawTraceFileHeader); packagesCurIter = packagesBuffer_.erase(packagesBuffer_.begin(), packagesCurIter); hasGotHeader_ = true; @@ -74,6 +84,9 @@ bool RawTraceParser::InitRawTraceFileHeader(std::deque::iterator& packa } bool RawTraceParser::InitEventFormats(const std::string& buffer) { +#ifdef IS_WASM + restCommDataCnt_ = INVALID_UINT8; // ensure that the restCommData is parsed only once +#endif std::string line; std::istringstream iss(buffer); std::stringstream eventFormat; @@ -88,39 +101,87 @@ bool RawTraceParser::InitEventFormats(const std::string& buffer) } bool RawTraceParser::UpdateCpuCoreMax(uint32_t cpuId) { - if (cpuId >= cpuCoreMax_) { - cpuCoreMax_++; - TS_LOGD("cpuId=%u, cpuCoreMax_=%u", cpuId, cpuCoreMax_); + if (cpuId >= curCpuCoreNum_) { + curCpuCoreNum_++; + TS_LOGI("cpuId=%u, curCpuCoreNum_=%u", cpuId, curCpuCoreNum_); return false; } + if (cpuDetailParser_->cpuCoreMax_ == CPU_CORE_MAX) { + cpuDetailParser_->ResizeStandAloneCpuEventList(curCpuCoreNum_); + } return true; } -bool RawTraceParser::ParseCpuRawData(uint32_t cpuId, const std::string& buffer) +bool RawTraceParser::ParseCpuRawData(uint32_t cpuId, const std::string& buffer, uint32_t curType) { UpdateCpuCoreMax(cpuId); TS_CHECK_TRUE(buffer.size() > 0, true, "cur cpu(%u) raw data is null!", cpuId); auto startPtr = reinterpret_cast(buffer.c_str()); auto endPtr = startPtr + buffer.size(); cpuDetail_->set_cpu(cpuId); + // splice the data curType adn size of each cup that matches the timestamp + uint32_t curFileOffset = curFileOffset_ + sizeof(curType) + sizeof(uint32_t); + uint32_t splitOffset = 0; + uint32_t splitSize = 0; + bool isSplitPosition = false; for (uint8_t* page = const_cast(startPtr); page < endPtr; page += FTRACE_PAGE_SIZE) { - TS_CHECK_TRUE(ftraceProcessor_->HandlePage(*cpuDetail_.get(), *cpuDetailParser_.get(), page), false, - "handle page failed!"); + bool haveSplitSeg = false; + TS_CHECK_TRUE(ftraceProcessor_->HandlePage(*cpuDetail_.get(), *cpuDetailParser_.get(), page, haveSplitSeg), + false, "handle page failed!"); + if (haveSplitSeg) { + splitSize += FTRACE_PAGE_SIZE; + if (!isSplitPosition) { + // splitOffset = first Save the migration amount of CPURAW that currently matches the timestamp + isSplitPosition = true; + splitOffset = curFileOffset; + } + } + curFileOffset += FTRACE_PAGE_SIZE; + } + if (traceDataCache_->isSplitFile_) { + // Skip parsing data for timestamp or non timestamp compliant data + if (splitSize > 0) { + rawTraceSplitCpuData_.emplace_back(SpliteDataInfo(splitOffset, splitSize, curType)); + } + return true; + } + if (cpuDetailParser_->cpuCoreMax_ != CPU_CORE_MAX) { + cpuDetailParser_->FilterAllEvents(*cpuDetail_.get()); } - cpuDetailParser_->FilterAllEvents(*cpuDetail_.get()); return true; } -bool RawTraceParser::HmParseCpuRawData(const std::string& buffer) +bool RawTraceParser::HmParseCpuRawData(const std::string& buffer, uint32_t curType) { TS_CHECK_TRUE(buffer.size() > 0, true, "hm raw data is null!"); auto startPtr = reinterpret_cast(buffer.c_str()); auto endPtr = startPtr + buffer.size(); - - for (uint8_t* data = const_cast(startPtr); data < endPtr;) { - TS_CHECK_TRUE(ftraceProcessor_->HmParsePageData(*cpuDetail_.get(), *cpuDetailParser_.get(), data), false, - "hm parse page failed!"); - cpuDetailParser_->FilterAllEvents(*cpuDetail_.get()); + // splice the data curType adn size of each cup that matches the timestamp + uint32_t curFileOffset = curFileOffset_ + sizeof(curType) + sizeof(uint32_t); + uint32_t splitOffset = 0; + uint32_t splitSize = 0; + bool isSplitPosition = false; + for (uint8_t* data = const_cast(startPtr); data < endPtr; data += FTRACE_PAGE_SIZE) { + bool haveSplitSeg = false; + TS_CHECK_TRUE(ftraceProcessor_->HmParsePageData(*cpuDetail_.get(), *cpuDetailParser_.get(), data, haveSplitSeg), + false, "hm parse page failed!"); + if (haveSplitSeg) { + splitSize += FTRACE_PAGE_SIZE; + if (!isSplitPosition) { + // splitOffset = first Save the migration amount of CPURAW that currently matches the timestamp + isSplitPosition = true; + splitOffset = curFileOffset; + } + } + if (!traceDataCache_->isSplitFile_) { + // No specific analysis is required for time cutting + cpuDetailParser_->FilterAllEvents(*cpuDetail_.get()); + } + curFileOffset += FTRACE_PAGE_SIZE; + } + if (traceDataCache_->isSplitFile_ && splitSize > 0) { + rawTraceSplitCpuData_.emplace_back(SpliteDataInfo(splitOffset, splitSize, curType)); + return true; } TS_LOGD("mark.debug. HmParseCpuRawData end success"); return true; @@ -147,6 +208,7 @@ bool RawTraceParser::ParseLastCommData(uint8_t type, const std::string& buffer) return true; #endif } + void RawTraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish) { packagesBuffer_.insert(packagesBuffer_.end(), &bufferStr[0], &bufferStr[size]); @@ -161,6 +223,36 @@ void RawTraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, } return; } + +bool RawTraceParser::ProcessRawTraceContent(std::string& bufferLine, uint8_t curType) +{ + if (curType >= static_cast(RawTraceContentType::CONTENT_TYPE_CPU_RAW) && + curType < static_cast(RawTraceContentType::CONTENT_TYPE_HEADER_PAGE)) { + curType = static_cast(curType); + if (fileType_ == static_cast(RawTraceFileType::FILE_RAW_TRACE)) { + auto cpuId = curType - static_cast(RawTraceContentType::CONTENT_TYPE_CPU_RAW); + TS_CHECK_TRUE(ParseCpuRawData(cpuId, bufferLine, curType), false, "cpu raw parse failed"); + } else if (fileType_ == static_cast(RawTraceFileType::HM_FILE_RAW_TRACE)) { + TS_CHECK_TRUE(HmParseCpuRawData(bufferLine, curType), false, "hm raw trace parse failed"); + } + if (traceDataCache_->isSplitFile_) { + // exactly uint32_t curSegSize = sizeof(type) + sizeof(len) + bufferLine.size(); + curFileOffset_ += sizeof(uint32_t) + sizeof(uint32_t) + bufferLine.size(); + } + } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_EVENTS_FORMAT)) { + TS_CHECK_TRUE(InitEventFormats(bufferLine), false, "init event format failed"); + } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_HEADER_PAGE)) { + TS_CHECK_TRUE(ftraceProcessor_->HandleHeaderPageFormat(bufferLine), false, "init header page failed"); + } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_PRINTK_FORMATS)) { + TS_CHECK_TRUE(PrintkFormatsProcessor::GetInstance().HandlePrintkSyms(bufferLine), false, + "init printk_formats failed"); + } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_KALLSYMS)) { + TS_CHECK_TRUE(ksymsProcessor_->HandleKallSyms(bufferLine), false, "init printk_formats failed"); + } else { + TS_LOGW("Raw Trace Type(%d) Unknown or has been parsed.", curType); + } + return true; +} bool RawTraceParser::ParseDataRecursively(std::deque::iterator& packagesCurIter) { uint32_t type = 0; @@ -182,25 +274,20 @@ bool RawTraceParser::ParseDataRecursively(std::deque::iterator& package if (ParseLastCommData(curType, bufferLine)) { continue; } - if (curType >= static_cast(RawTraceContentType::CONTENT_TYPE_CPU_RAW) && - curType < static_cast(RawTraceContentType::CONTENT_TYPE_HEADER_PAGE)) { - if (fileType_ == static_cast(RawTraceFileType::FILE_RAW_TRACE)) { - auto cpuId = curType - static_cast(RawTraceContentType::CONTENT_TYPE_CPU_RAW); - TS_CHECK_TRUE(ParseCpuRawData(cpuId, bufferLine), false, "cpu raw parse failed"); - } else if (fileType_ == static_cast(RawTraceFileType::HM_FILE_RAW_TRACE)) { - TS_CHECK_TRUE(HmParseCpuRawData(bufferLine), false, "hm raw trace parse failed"); + // for jump first comm data + if (traceDataCache_->isSplitFile_ && + (curType < static_cast(RawTraceContentType::CONTENT_TYPE_CPU_RAW) || + curType >= static_cast(RawTraceContentType::CONTENT_TYPE_HEADER_PAGE))) { + uint32_t curSegSize = sizeof(type) + sizeof(len) + bufferLine.size(); + rawTraceSplitCommData_.emplace_back(SpliteDataInfo(curFileOffset_, curSegSize)); + curFileOffset_ += curSegSize; + if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_EVENTS_FORMAT)) { + restCommDataCnt_ = INVALID_UINT8; } - } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_EVENTS_FORMAT)) { - TS_CHECK_TRUE(InitEventFormats(bufferLine), false, "init event format failed"); - } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_HEADER_PAGE)) { - TS_CHECK_TRUE(ftraceProcessor_->HandleHeaderPageFormat(bufferLine), false, "init header page failed"); - } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_PRINTK_FORMATS)) { - TS_CHECK_TRUE(PrintkFormatsProcessor::GetInstance().HandlePrintkSyms(bufferLine), false, - "init printk_formats failed"); - } else if (curType == static_cast(RawTraceContentType::CONTENT_TYPE_KALLSYMS)) { - TS_CHECK_TRUE(ksymsProcessor_->HandleKallSyms(bufferLine), false, "init printk_formats failed"); - } else { - TS_LOGW("Raw Trace Type(%d) Unknown or has been parsed.", curType); + continue; + } + if (!ProcessRawTraceContent(bufferLine, curType)) { + return false; } } return true; diff --git a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.h b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.h index 4eb01a640834dcd0a212961dc0912cf8f1fbfc1d..992a15dbee01e582b556789e9c428d9395e4f474 100644 --- a/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.h +++ b/trace_streamer/src/parser/rawtrace_parser/rawtrace_parser.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -30,12 +30,27 @@ public: ~RawTraceParser(); void ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish = false) override; void WaitForParserEnd(); + void ClearRawTraceData() + { + rawTraceSplitCpuData_.clear(); + rawTraceSplitCommData_.clear(); + curFileOffset_ = 0; + } + const auto& GetRawtraceCpuData() + { + return rawTraceSplitCpuData_; + } + const auto& GetRawtraceCommData() + { + return rawTraceSplitCommData_; + } private: bool ParseDataRecursively(std::deque::iterator& packagesCurIter); + bool ProcessRawTraceContent(std::string& bufferLine, uint8_t curType); void ParseTraceDataItem(const std::string& buffer) override; - bool ParseCpuRawData(uint32_t cpuId, const std::string& buffer); - bool HmParseCpuRawData(const std::string& buffer); + bool ParseCpuRawData(uint32_t cpuId, const std::string& buffer, uint32_t curType); + bool HmParseCpuRawData(const std::string& buffer, uint32_t curType); bool ParseLastCommData(uint8_t type, const std::string& buffer); bool InitRawTraceFileHeader(std::deque::iterator& packagesCurIter); bool InitEventFormats(const std::string& buffer); @@ -47,12 +62,26 @@ private: std::unique_ptr cpuDetailParser_ = nullptr; std::unique_ptr ftraceProcessor_ = nullptr; std::unique_ptr ksymsProcessor_ = nullptr; - TraceDataCache* traceDataCache_; + TraceDataCache* traceDataCache_ = nullptr; bool hasGotHeader_ = false; uint8_t fileType_ = 0; uint8_t restCommDataCnt_ = 0; - uint32_t cpuCoreMax_ = 0; + uint32_t curCpuCoreNum_ = 0; const std::string eventEndCmd_ = "print fmt:"; + + uint32_t curFileOffset_ = 0; + // Store 4k types and data sizes each time + struct SpliteDataInfo { + uint32_t splitDataOffset_ = 0; + uint32_t splitDataSize_ = 0; + uint32_t splitType_ = 0; + SpliteDataInfo(uint32_t splitDataOffset, uint32_t splitDataSize, uint32_t splitType = 0) + : splitDataOffset_(splitDataOffset), splitDataSize_(splitDataSize), splitType_(splitType) + { + } + }; + std::deque rawTraceSplitCpuData_ = {}; + std::deque rawTraceSplitCommData_ = {}; }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/parser/thread_state_flag.cpp b/trace_streamer/src/parser/thread_state_flag.cpp index dd440738ec2794e38a700a9d3abf7f73f8cfa98b..8c8a75197e0d57cb273262445e733b7168891a1d 100644 --- a/trace_streamer/src/parser/thread_state_flag.cpp +++ b/trace_streamer/src/parser/thread_state_flag.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/parser/thread_state_flag.h b/trace_streamer/src/parser/thread_state_flag.h index df9bfb77fc030fcd972c38d9a71592d07315ff21..8360e640517eb7870f1eac31753dc39bf28e6ad0 100644 --- a/trace_streamer/src/parser/thread_state_flag.h +++ b/trace_streamer/src/parser/thread_state_flag.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/BUILD.gn b/trace_streamer/src/proto_reader/BUILD.gn index ab50ca6def155615f20726baecd4ed1171de7fff..64981ac6fa16add7cca264abc765f543ac1ada73 100644 --- a/trace_streamer/src/proto_reader/BUILD.gn +++ b/trace_streamer/src/proto_reader/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/proto_reader/include/data_area.h b/trace_streamer/src/proto_reader/include/data_area.h index f5b8a19131d1300620e790618623e2e386e3ac44..7893e28261eab5765f834fc8698f15d182e0ee07 100644 --- a/trace_streamer/src/proto_reader/include/data_area.h +++ b/trace_streamer/src/proto_reader/include/data_area.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/include/proto_reader.h b/trace_streamer/src/proto_reader/include/proto_reader.h index b46babe261bc14bb4b08a7d8af597e255ef5cf03..cc6da1dfcd6ab907835df3e343f8c35c39cc615a 100644 --- a/trace_streamer/src/proto_reader/include/proto_reader.h +++ b/trace_streamer/src/proto_reader/include/proto_reader.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/include/proto_reader_help.h b/trace_streamer/src/proto_reader/include/proto_reader_help.h index a1852a9e0c249f569183d02aa541043638b1ea60..994edb9747814930bd5c2227f61d89c6395f4773 100644 --- a/trace_streamer/src/proto_reader/include/proto_reader_help.h +++ b/trace_streamer/src/proto_reader/include/proto_reader_help.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/proto_reader.cpp b/trace_streamer/src/proto_reader/proto_reader.cpp index 79d9532851ebe5ea671b01985590c62f10e4be64..935d6f0559a73f3d3327dc953612dacf184d2c9c 100644 --- a/trace_streamer/src/proto_reader/proto_reader.cpp +++ b/trace_streamer/src/proto_reader/proto_reader.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/protoc_plugin/BUILD.gn b/trace_streamer/src/proto_reader/protoc_plugin/BUILD.gn index 763e5b0eb0ff61309972ec567aaa86627dad9dfd..e61ade48a2b348ab97f31974cac17925717027d3 100644 --- a/trace_streamer/src/proto_reader/protoc_plugin/BUILD.gn +++ b/trace_streamer/src/proto_reader/protoc_plugin/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.cpp b/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.cpp index 1912b255a27b13e322fd33c522e2f3599fa91537..ee2a971c2adc0f8e0a406bd693dec9f4552fb673 100644 --- a/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.cpp +++ b/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.h b/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.h index 0347ce9eb9209c60417b5d89bd4d106d4413b68b..27106797d8b24fb367934bb22586ec04805afe6a 100644 --- a/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.h +++ b/trace_streamer/src/proto_reader/protoc_plugin/proto_reader_plugin.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/protos/protogen.sh b/trace_streamer/src/protos/protogen.sh index 62849eb94ce3693b15cd4bcc38262b135c088ba0..f8debaa795f60ae3d312d72ecfb7b956d51552bb 100755 --- a/trace_streamer/src/protos/protogen.sh +++ b/trace_streamer/src/protos/protogen.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/protos.gni b/trace_streamer/src/protos/protos.gni index 142b06ffcab1944107f8a164899118418fe5ddbf..3378962d47ade6a7be9d55734457de6a0014b258 100644 --- a/trace_streamer/src/protos/protos.gni +++ b/trace_streamer/src/protos/protos.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/services/BUILD.gn b/trace_streamer/src/protos/services/BUILD.gn index 51a65fe500510bb40bfd1fd37a5440eb90387ae4..d313de69a70275cbe5fc383f9f194500b5eae94f 100644 --- a/trace_streamer/src/protos/services/BUILD.gn +++ b/trace_streamer/src/protos/services/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/services/common_types.proto b/trace_streamer/src/protos/services/common_types.proto index 11441d467d8e86b048129086d9aa9f3e77ef8574..d92416e11c68422675e8fd894974c86c4fa905de 100755 --- a/trace_streamer/src/protos/services/common_types.proto +++ b/trace_streamer/src/protos/services/common_types.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/services/plugin_service.proto b/trace_streamer/src/protos/services/plugin_service.proto index ab8583d216c151f1dbdf4839c1f94a00f65a6bcf..418b54ad3a9b7240ab2d9ea0aed87d8980498980 100755 --- a/trace_streamer/src/protos/services/plugin_service.proto +++ b/trace_streamer/src/protos/services/plugin_service.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/services/plugin_service_types.proto b/trace_streamer/src/protos/services/plugin_service_types.proto index 51aaa29f2f5728fb5beebd8d8cca63b5ba88dd2a..ec67a131d534454a8d3364ffd5070053dcbda58e 100755 --- a/trace_streamer/src/protos/services/plugin_service_types.proto +++ b/trace_streamer/src/protos/services/plugin_service_types.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/services/profiler_service.proto b/trace_streamer/src/protos/services/profiler_service.proto index 35e1e1866dcc847bb4fe1a9b6882b94355fb0471..ef9cd694a4f3a8c79b58bb1ec5f60d584e2c4295 100755 --- a/trace_streamer/src/protos/services/profiler_service.proto +++ b/trace_streamer/src/protos/services/profiler_service.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/services/profiler_service_types.proto b/trace_streamer/src/protos/services/profiler_service_types.proto index 8c0ae56c1c89d83f2c5fd2064e8f7ef46141b617..6e4e409ade6279e77d99581c754346d31df62cd6 100755 --- a/trace_streamer/src/protos/services/profiler_service_types.proto +++ b/trace_streamer/src/protos/services/profiler_service_types.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/smartperf_host/BUILD.gn b/trace_streamer/src/protos/smartperf_host/BUILD.gn index 66c7d41d6db1c76b50434b10bdef93cf411f230c..1ca1e6ccb7d3b72773d96eeda06f2340f3faddeb 100644 --- a/trace_streamer/src/protos/smartperf_host/BUILD.gn +++ b/trace_streamer/src/protos/smartperf_host/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/smartperf_host/sph_data.proto b/trace_streamer/src/protos/smartperf_host/sph_data.proto index 079241db67737a6e6bfaef8bfa4e1e8a8a067371..771eb904529fdea6e63df658fa97aca7dc1888fa 100644 --- a/trace_streamer/src/protos/smartperf_host/sph_data.proto +++ b/trace_streamer/src/protos/smartperf_host/sph_data.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/agent_data/BUILD.gn index bd392e77f6d1edf4af3b78091a704ac97abc4f6d..bf8b97e00401438a54c8adb24c9ad2d00962a8ba 100644 --- a/trace_streamer/src/protos/types/plugins/agent_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/agent_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_app_data.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_app_data.proto index 5ae99f08e7d6c56e36e6ffb53b898cd8ed41c397..2d850601755545273bd897448dfcc2f6370c9c83 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_app_data.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_app_data.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_config.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_config.proto index 470d9461c87fef829dffe3eb1e828a5b7663901e..de5d04d740a298f25b8e5658b89664832b30d001 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_energy_data.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_energy_data.proto index 575dcfff62d80a94e58a8b6a99a949584ad27149..f4e11e49bb2728a167ce752bad8cac65733b3264 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_energy_data.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_energy_data.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_java_heap.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_java_heap.proto index 7b8930931acfcf27b02a64dcb15dd23670c1eb7e..2816addf4a0cedbe3c80501f28ab32cdb1dfaf8c 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_java_heap.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_java_heap.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_network_data.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_network_data.proto index 918af6320a8c3b796c6343981fd2d5630d357c24..661af4c554c12ac7373bee0a6f9743898d4b8ede 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_network_data.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_network_data.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_result.proto b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_result.proto index ad9a3704af99363009136628db1a735ccdd40af6..b9a6c1de87804fea59cf11353f62cad7207468ad 100755 --- a/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/agent_data/agent_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/bytrace_plugin/BUILD.gn b/trace_streamer/src/protos/types/plugins/bytrace_plugin/BUILD.gn index ce1c79b0f6bc53ef8604bbf55b2aa750a2614b91..c02768e4c013e2b9cfb7565062fc67b6a4889d50 100644 --- a/trace_streamer/src/protos/types/plugins/bytrace_plugin/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/bytrace_plugin/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/bytrace_plugin/bytrace_plugin_config.proto b/trace_streamer/src/protos/types/plugins/bytrace_plugin/bytrace_plugin_config.proto index 8c26822268288ae9adca92f98e862583e0f141f5..8535180d4e551788c9bbb29ec6f13213ab3fcee6 100755 --- a/trace_streamer/src/protos/types/plugins/bytrace_plugin/bytrace_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/bytrace_plugin/bytrace_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/cpu_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/cpu_data/BUILD.gn index 25f6ed2f4fd19a7cc4c990009edbc82a21681140..410fecf6baa4a1e7a96633d8a9ab08214f42856c 100644 --- a/trace_streamer/src/protos/types/plugins/cpu_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/cpu_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_config.proto b/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_config.proto index 9b9c2a30d55ebb6e59a002049d48ae2bc31f48f3..0bd43aef7d04400eac7e834a82b7f5d91aeed155 100755 --- a/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_result.proto b/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_result.proto index 781a8f521fea4878fc1bf53c040e32ec4d31d829..9d66a92c44877e336d55efb01031c8de89d83183 100755 --- a/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/cpu_data/cpu_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/diskio_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/diskio_data/BUILD.gn index 437b7d688919052673e3acfc14ba8784323be8fa..c7d3690a3b606025f20061ce10403da0ab8c6a7d 100644 --- a/trace_streamer/src/protos/types/plugins/diskio_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/diskio_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_config.proto b/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_config.proto index 8caac241978ff6910abff7aead9b0e60f22aa649..a058cc00e849af0b3c23dfd4c223b16b5a39ec0f 100755 --- a/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_result.proto b/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_result.proto index faabd31436d4dbf58c62c68330367b60b7c97cc4..7ecf3c209a51dc2b7ac054efd980c7b5c1e10f40 100755 --- a/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/diskio_data/diskio_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/autogenerated.gni b/trace_streamer/src/protos/types/plugins/ftrace_data/autogenerated.gni index fcae596874f54b553a799e96b3f2022460405093..c67541b44cccc94baa8ccea5ad37ebecea90ebba 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/autogenerated.gni +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/autogenerated.gni @@ -1,5 +1,5 @@ # THIS FILE IS GENERATE BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/binder.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/binder.proto index f1d0acd59d8986e9b5606fa3684bdebc76057726..ce457f7c4f03c4e7a1795adb8363313a63effe72 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/binder.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/binder.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/block.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/block.proto index 5975c0e3ff1d4a4e6bd2cdd26e9ca4bba2409d1a..657964ce103d77d825ba9ba5d623d87c15349a61 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/block.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/block.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/cgroup.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/cgroup.proto index 22544329885160245b94d20d0d8a6e1d51877328..ea6e21551b93ee3c8208485ae3f8c75dc6198c46 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/cgroup.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/cgroup.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/clk.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/clk.proto index 0f74b25fb2eef0935707786bcf3402d169dd55f8..94581c0023fe2a54cd52dcbf2cb190f7578fc33d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/clk.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/clk.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/compaction.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/compaction.proto index 2df331f2893674fb8d8d65163e25a9efba26e3e2..b172a992ad2d28c6a5ecd86ee23373ae22ab7eb2 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/compaction.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/compaction.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/cpuhp.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/cpuhp.proto index db805bc33e41cdc383846b1f81ab9dd358456cc5..d97bd468f98c06f91a0fde71971a23e991d131fb 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/cpuhp.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/cpuhp.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/BUILD.gn b/trace_streamer/src/protos/types/plugins/ftrace_data/default/BUILD.gn index 030c00157b4695677948183316ca3c6b44d1d393..cab63254f8c14891a5ff871efed581c4e35f8942 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/autogenerated.gni b/trace_streamer/src/protos/types/plugins/ftrace_data/default/autogenerated.gni index 0e98ef48f7c3d7977718f04196d250a09a896f83..e11161a9349402c48caf48eb653e55c73a87e581 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/autogenerated.gni +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/autogenerated.gni @@ -1,5 +1,5 @@ # THIS FILE IS GENERATE BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/binder.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/binder.proto index f1d0acd59d8986e9b5606fa3684bdebc76057726..ce457f7c4f03c4e7a1795adb8363313a63effe72 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/binder.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/binder.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/block.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/block.proto index 5975c0e3ff1d4a4e6bd2cdd26e9ca4bba2409d1a..657964ce103d77d825ba9ba5d623d87c15349a61 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/block.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/block.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/cgroup.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/cgroup.proto index e3f9a86b52977a0af8b107e89a3f8b0ab23f3efd..ca5abbecb223fa35268e0800520c152138d4105a 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/cgroup.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/cgroup.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/clk.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/clk.proto index 0f74b25fb2eef0935707786bcf3402d169dd55f8..94581c0023fe2a54cd52dcbf2cb190f7578fc33d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/clk.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/clk.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/compaction.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/compaction.proto index 2df331f2893674fb8d8d65163e25a9efba26e3e2..b172a992ad2d28c6a5ecd86ee23373ae22ab7eb2 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/compaction.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/compaction.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/cpuhp.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/cpuhp.proto index db805bc33e41cdc383846b1f81ab9dd358456cc5..d97bd468f98c06f91a0fde71971a23e991d131fb 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/cpuhp.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/cpuhp.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/dma_fence.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/dma_fence.proto index 74b511b8f5be7f6f77db7b9dfd351393dc38c53e..68079bfd3c9fc32d8e51d82ee128df261dd07c3c 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/dma_fence.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/dma_fence.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ext4.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ext4.proto index d66f4baaebf2e2bba8ee3428377e76ee502a1e02..bcbfdc9c5aa056b680a7ef3b44acb200b3a05173 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ext4.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ext4.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/f2fs.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/f2fs.proto index 370be1cd2b9959a97ef39125f728de908881464a..94f98ed750a305803d5e27c8e022d2fd4f6b937b 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/f2fs.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/f2fs.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/filelock.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/filelock.proto index 1a52d8c9f3c34b90b57db8f8da444eb2d7c62c91..897c281e3cdec8179380338fe203a9f4775d0034 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/filelock.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/filelock.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/filemap.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/filemap.proto index a1621207a719d050a76f23e90b91012ac6526ad8..057a56e6cd89aff055f4d7d445d0ab46d5322008 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/filemap.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/filemap.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace.proto index 80c23a999c8129916bd7608b0e3c99fe107181b4..4d8189c6c387484343f53cede425e303dea89580 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace_event.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace_event.proto index e979685300ccc34867fe91b110b52ec010531fcc..b7772bc9c7320ec3290e7c6e159c406da43abd1c 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace_event.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ftrace_event.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpio.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpio.proto index 1410af52c24e250e5aa6434c7993537c2f918a25..c3cc1fbad3cb8d68f7012494907506e8510afd71 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpio.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpio.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpu_mem.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpu_mem.proto index 72543ad9f7e7bb9e95902bd3deb6e9dfb5218049..b25a7ffd536f97365759b0ae0a5242d992b1550f 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpu_mem.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/gpu_mem.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/i2c.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/i2c.proto index 4f1de54988f7d1c3b06502630e09b60c4258e0b9..fb9733bfefe60de975a025d4551b5719ca9abcca 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/i2c.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/i2c.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ipi.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ipi.proto index 0eda02f6e3b3485f07125e6bfb5baa1ceb34b004..b93c3ab8696d87e5cb8fbc7a58cf6567d1481915 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/ipi.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/ipi.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/irq.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/irq.proto index 1e3ce1afebc69cd764ddb991914090168d3b79e1..a06fa98557784f8cb7af7e8fa8316392c5b90e3d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/irq.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/irq.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/kmem.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/kmem.proto index f42f27c9011ae9fab391043cd1c4e9d6ea4eeeaf..62efae3d8a92c57b171d4b743fda5a06e43eab12 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/kmem.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/kmem.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/mmc.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/mmc.proto index 36e890fdfe5bc535f02cf0608f91c7ad2bc6ad86..21d5c9fbb9d27f9affe66f40516c60d748eb0546 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/mmc.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/mmc.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/net.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/net.proto index c4b3c31fcf7a647765843c4d694dde9ace41f7fb..0e914f2991265872670be5f29dcc3d1cb9447202 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/net.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/net.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/oom.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/oom.proto index d7b6b9c60bb8b17f279c158396f78af802d5bdcc..f2a6e516dcffc3a3b29eeb4ea31f54501616e1bb 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/oom.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/oom.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/pagemap.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/pagemap.proto index c931e12f275aead37148fc5395a94829b4d2153b..05128f0f7543a549723ed9ac8c27cbe0181116e0 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/pagemap.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/pagemap.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/power.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/power.proto index 3a223d1b3d640688eef81982287ec3fb99ba43dd..6f916b3ee2a6a6903feebf828e590473992b5273 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/power.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/power.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/printk.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/printk.proto index 39be37e143ef980b271bb70391613cdd71966345..a8fa65ad65ce24d559d093a111315f4ff1bd724c 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/printk.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/printk.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/raw_syscalls.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/raw_syscalls.proto index 2abbf1112293901eb5da3df3338926c1f11846e8..50355d5614c4e3282a65593d73eceff8adcacac1 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/raw_syscalls.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/raw_syscalls.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/rcu.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/rcu.proto index 5448d1e605bf867d5745d8aff4b391622b909490..2e93c884def4a4088e5ba1fcafe815a3c6d42db2 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/rcu.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/rcu.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/regulator.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/regulator.proto index 5fa5d6534aa3a29a4af9fa51519f2936cbf3fc90..7b2b193b5372000328c0accc6c76905cf5390f2f 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/regulator.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/regulator.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/sched.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/sched.proto index 7af27b8184df94a4cd55b559435573fb5ad26f16..c1db507fcbc02fe88ad47f59e51b2b00b139f346 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/sched.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/sched.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/signal.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/signal.proto index 01246e67df9f2004cd132d2b688a5de74174bae5..0999c1c432dd6309aa2ff9a79ec0621d2201f71d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/signal.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/signal.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/sunrpc.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/sunrpc.proto index 35c4f67cb56077b32598918dd8dbede5dd329c4c..964593fe95166cbb5ee9bf9424c699197be4704a 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/sunrpc.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/sunrpc.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/task.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/task.proto index 82177f60b5bd3e1d62077d63627490c360280624..62644a200d2ee81cd6ce87afa73ccfeadbb58a2d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/task.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/task.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/timer.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/timer.proto index d85b207f4e7532ea457dbc8b054fd594115c513c..1d0c219cf5be4ac138a4d6620e877e4f8de221f9 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/timer.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/timer.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_config.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_config.proto index 825b14a8a98af5a2d299951f1be3ddcca5dc6d2a..2b421e5dd9c0ff00251dcb7f6743cc55a5e788b3 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_result.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_result.proto index 96476feea7211c28e737ede7ec903f924075ac86..2e28ce6cd70513fc308a5991d36ad1c252dc56b2 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/trace_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/v4l2.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/v4l2.proto index 7ca31b507160e8a66bd9ddeb1b485d957dcb6c50..fbbf0ceb6335f64414751007683baf20355821d1 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/v4l2.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/v4l2.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/vmscan.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/vmscan.proto index c9f1867f74c298e46b96323be93926d24cf1c0d7..25e7e1d950e12dd0cd02b6638ecc93a433a63812 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/vmscan.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/vmscan.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/workqueue.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/workqueue.proto index 040e5abf1bfc038ee0be5ea33de0c25e4bcfd68c..647589798d6886983253987af964e147ce6a5936 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/workqueue.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/workqueue.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/default/writeback.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/default/writeback.proto index fdf2bdb1002df4a7593eff0e1725366237357420..ae92c907a77298191548f06a39e72f9ae5277468 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/default/writeback.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/default/writeback.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/dma_fence.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/dma_fence.proto index 74b511b8f5be7f6f77db7b9dfd351393dc38c53e..68079bfd3c9fc32d8e51d82ee128df261dd07c3c 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/dma_fence.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/dma_fence.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/ext4.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/ext4.proto index d66f4baaebf2e2bba8ee3428377e76ee502a1e02..bcbfdc9c5aa056b680a7ef3b44acb200b3a05173 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/ext4.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/ext4.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/filelock.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/filelock.proto index 1a52d8c9f3c34b90b57db8f8da444eb2d7c62c91..897c281e3cdec8179380338fe203a9f4775d0034 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/filelock.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/filelock.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/filemap.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/filemap.proto index 5410c6f4f35946198bab32688f1f0eae025873ee..90bad742aa6ca8851bd21070d6b2fd3b2a7e6180 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/filemap.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/filemap.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace.proto index 80c23a999c8129916bd7608b0e3c99fe107181b4..4d8189c6c387484343f53cede425e303dea89580 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace_event.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace_event.proto index 3ddd7e4aef2ce6a84e9eaae7fa7a6733c3a720f0..b1804bde30f94e29e5cde4673c2c427ad7a03424 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace_event.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/ftrace_event.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/gpio.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/gpio.proto index 1410af52c24e250e5aa6434c7993537c2f918a25..c3cc1fbad3cb8d68f7012494907506e8510afd71 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/gpio.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/gpio.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/i2c.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/i2c.proto index 4f1de54988f7d1c3b06502630e09b60c4258e0b9..fb9733bfefe60de975a025d4551b5719ca9abcca 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/i2c.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/i2c.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/ipi.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/ipi.proto index 0eda02f6e3b3485f07125e6bfb5baa1ceb34b004..b93c3ab8696d87e5cb8fbc7a58cf6567d1481915 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/ipi.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/ipi.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/irq.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/irq.proto index 1e3ce1afebc69cd764ddb991914090168d3b79e1..a06fa98557784f8cb7af7e8fa8316392c5b90e3d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/irq.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/irq.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/kmem.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/kmem.proto index 51b7d49818bf0c51b463d641ccf495dbbb6907a4..4c2e5dbbc7b036551ba99a450b6ee0d8183e4bb4 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/kmem.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/kmem.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/net.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/net.proto index c4b3c31fcf7a647765843c4d694dde9ace41f7fb..0e914f2991265872670be5f29dcc3d1cb9447202 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/net.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/net.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/oom.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/oom.proto index d7b6b9c60bb8b17f279c158396f78af802d5bdcc..f2a6e516dcffc3a3b29eeb4ea31f54501616e1bb 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/oom.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/oom.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/pagemap.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/pagemap.proto index c931e12f275aead37148fc5395a94829b4d2153b..05128f0f7543a549723ed9ac8c27cbe0181116e0 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/pagemap.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/pagemap.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/power.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/power.proto index 3a223d1b3d640688eef81982287ec3fb99ba43dd..6f916b3ee2a6a6903feebf828e590473992b5273 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/power.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/power.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/printk.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/printk.proto index 39be37e143ef980b271bb70391613cdd71966345..a8fa65ad65ce24d559d093a111315f4ff1bd724c 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/printk.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/printk.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/raw_syscalls.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/raw_syscalls.proto index 590b964924c3d87e36e3e542eaf1fb891371f209..cd9b1f29198ccc3504a4fe4cdf32ca5c2bd08955 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/raw_syscalls.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/raw_syscalls.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/rcu.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/rcu.proto index 5448d1e605bf867d5745d8aff4b391622b909490..2e93c884def4a4088e5ba1fcafe815a3c6d42db2 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/rcu.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/rcu.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/sched.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/sched.proto index 13dcccb7aac708b77526d474e791255adeb1cb6f..56d7d74711b83ec9c5580114a7daf4b595e2c3db 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/sched.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/sched.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/signal.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/signal.proto index 01246e67df9f2004cd132d2b688a5de74174bae5..0999c1c432dd6309aa2ff9a79ec0621d2201f71d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/signal.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/signal.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/sunrpc.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/sunrpc.proto index 35c4f67cb56077b32598918dd8dbede5dd329c4c..964593fe95166cbb5ee9bf9424c699197be4704a 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/sunrpc.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/sunrpc.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/task.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/task.proto index 82177f60b5bd3e1d62077d63627490c360280624..62644a200d2ee81cd6ce87afa73ccfeadbb58a2d 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/task.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/task.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/timer.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/timer.proto index d85b207f4e7532ea457dbc8b054fd594115c513c..1d0c219cf5be4ac138a4d6620e877e4f8de221f9 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/timer.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/timer.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_config.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_config.proto index e56265861500c204d39f398e9e674eaaafcb2f25..7e537b84162f923ea808dcd7f6187e6af016c820 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_result.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_result.proto index 96476feea7211c28e737ede7ec903f924075ac86..2e28ce6cd70513fc308a5991d36ad1c252dc56b2 100644 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/trace_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/v4l2.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/v4l2.proto index 7ca31b507160e8a66bd9ddeb1b485d957dcb6c50..fbbf0ceb6335f64414751007683baf20355821d1 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/v4l2.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/v4l2.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/vmscan.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/vmscan.proto index c9f1867f74c298e46b96323be93926d24cf1c0d7..25e7e1d950e12dd0cd02b6638ecc93a433a63812 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/vmscan.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/vmscan.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/workqueue.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/workqueue.proto index 040e5abf1bfc038ee0be5ea33de0c25e4bcfd68c..647589798d6886983253987af964e147ce6a5936 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/workqueue.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/workqueue.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/ftrace_data/writeback.proto b/trace_streamer/src/protos/types/plugins/ftrace_data/writeback.proto index fdf2bdb1002df4a7593eff0e1725366237357420..ae92c907a77298191548f06a39e72f9ae5277468 100755 --- a/trace_streamer/src/protos/types/plugins/ftrace_data/writeback.proto +++ b/trace_streamer/src/protos/types/plugins/ftrace_data/writeback.proto @@ -1,5 +1,5 @@ // THIS FILE IS GENERATED BY ftrace_proto_generator.py, PLEASE DON'T EDIT IT! -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hidump_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/hidump_data/BUILD.gn index 71eac95bab75cc9a003ed30f073d18cf4d161c8d..7db56c832a9f8a33b1a6886be50e839519d00473 100644 --- a/trace_streamer/src/protos/types/plugins/hidump_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hidump_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_config.proto index 46e33f6a89516b63123fb03cea6252c6900a5543..144070089160e432fc50a76f335bf63f47b5deb5 100755 --- a/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_result.proto b/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_result.proto index 5cf6e5534268dd72699a0384e3779615ff0ee77e..1ac1d4a9e343f8cc07ed7e30ba097700e1564f58 100755 --- a/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/hidump_data/hidump_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hiebpf_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/hiebpf_data/BUILD.gn index d60d663e21466dda6beb253a5c0d451b338b824c..6c5e9ce558056ff1d33120be210448b94c0f5362 100644 --- a/trace_streamer/src/protos/types/plugins/hiebpf_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hiebpf_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hiebpf_data/hiebpf_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hiebpf_data/hiebpf_plugin_config.proto index f0b44a3df808ad855266cd9e797e3a71b007489f..b1ca7770ce60f41ffa0e7f526d2c19358febed62 100755 --- a/trace_streamer/src/protos/types/plugins/hiebpf_data/hiebpf_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hiebpf_data/hiebpf_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hilog_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/hilog_data/BUILD.gn index de1e1e828cdb8356f3ddfdf65147cd394a09c026..95f8efd16e100a68d20327ce8764f32eb99a8a06 100644 --- a/trace_streamer/src/protos/types/plugins/hilog_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hilog_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_config.proto index 79dca9d918597b2b446fb0c21260eb7c0db3fcd4..801ad09f0ebda911da9ea949f11bc24386875e0b 100755 --- a/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_result.proto b/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_result.proto index 64e678def7dcc24176e55185be17027c34c0d15c..4d3ceebfdea8d8ab0bc4005d8c23f19ef369cb0a 100755 --- a/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/hilog_data/hilog_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/BUILD.gn b/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/BUILD.gn index ebc0ca88e646a45c46934d64632e439e8401a483..bd193a576d944d55e6fca5cbd6b1b6b392eec0a7 100644 --- a/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/hiperf_call_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/hiperf_call_plugin_config.proto index e11b279f296a3ebf0b5bc52ce51b0fd88311ccc7..c7afbf802d46c10e5e460b245a05c6fa850c3d5f 100755 --- a/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/hiperf_call_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hiperf_call_plugin/hiperf_call_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hiperf_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/hiperf_data/BUILD.gn index b557a70e543f54d68be56c7828e70fc49f81da50..8c6ec6235044b67d0419a5d2c4404f33cc62c5c1 100644 --- a/trace_streamer/src/protos/types/plugins/hiperf_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hiperf_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hiperf_data/hiperf_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hiperf_data/hiperf_plugin_config.proto index b5933b06a96b3bdc21015a8489b86b232afe5b2a..88862cd3ad7a304132e94ae50047e4f58f4f8e0b 100755 --- a/trace_streamer/src/protos/types/plugins/hiperf_data/hiperf_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hiperf_data/hiperf_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hisysevent_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/hisysevent_data/BUILD.gn index 4f3f56f3a63af82b9abfc7a273704ac2ebbd0b5c..74f44618a19ffcf596d0678c5d76a9b1b345e480 100644 --- a/trace_streamer/src/protos/types/plugins/hisysevent_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/hisysevent_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_config.proto b/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_config.proto index bce0cf0c97cccdf1a87360c8f663fa681d8d72a3..986bb38d267683c7114f7d017379098d4cc7b7b8 100644 --- a/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_result.proto b/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_result.proto index 80d0835559a22e81851c4d616eeed34a1f9deb7c..dfc3ad94562dbe91a601e49676f7e4badf34bee1 100644 --- a/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/hisysevent_data/hisysevent_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/js_memory/BUILD.gn b/trace_streamer/src/protos/types/plugins/js_memory/BUILD.gn index 630109b88cd74885ca60e29f72d20585d6338745..526a8eaa3230416118944c029d3de200ee1bfc86 100644 --- a/trace_streamer/src/protos/types/plugins/js_memory/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/js_memory/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/js_memory/js_heap_config.proto b/trace_streamer/src/protos/types/plugins/js_memory/js_heap_config.proto index 71ebdba1a9b050d85e8e49a52a6f2e9daa677d96..21c55e86dd4bf8f5fbbe468fb59b79ce8c5ce647 100755 --- a/trace_streamer/src/protos/types/plugins/js_memory/js_heap_config.proto +++ b/trace_streamer/src/protos/types/plugins/js_memory/js_heap_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/js_memory/js_heap_result.proto b/trace_streamer/src/protos/types/plugins/js_memory/js_heap_result.proto index 36da4d55ada9752172b4dd13013932f31be7b184..14fb2d97155ebc636a0a5e06e3d47d1670075545 100755 --- a/trace_streamer/src/protos/types/plugins/js_memory/js_heap_result.proto +++ b/trace_streamer/src/protos/types/plugins/js_memory/js_heap_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/memory_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/memory_data/BUILD.gn index ba3c874578a49dbcb051f82eb458708d6dd28cde..d1ce0d06a9fd23fa1ecf2ee72102106b42ac6d13 100644 --- a/trace_streamer/src/protos/types/plugins/memory_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/memory_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_common.proto b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_common.proto index 73c441677d1c542c82843d1c8bf2fb911953014a..9da5a51b40db39d6240247ecf42bc52d38c12deb 100755 --- a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_common.proto +++ b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_common.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_config.proto b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_config.proto index af8d87ae499f0f139be8c7115685dc26b51c7573..7879cb56eac6345c633a9681db983ecf837ad758 100755 --- a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_result.proto b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_result.proto index 71fbf3ae322c76301e9b534b290df3df8df7bf73..dbbfb04f0b62e34abd9598dd0352288ae4a4b3a8 100755 --- a/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/memory_data/memory_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/native_hook/BUILD.gn b/trace_streamer/src/protos/types/plugins/native_hook/BUILD.gn index d0e7ff6ef0fe9cc08f699f4bc9d0a44aebc5c065..9acd79f42d7fa8e9db94bef9ed010101cf3ecaa7 100644 --- a/trace_streamer/src/protos/types/plugins/native_hook/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/native_hook/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/native_hook/native_hook_config.proto b/trace_streamer/src/protos/types/plugins/native_hook/native_hook_config.proto index 4307f597e52e11c43a41b4bc4c975e09da282e8a..19a3b7a7cc95ae8921d1ba0f9402d1b03295ce84 100755 --- a/trace_streamer/src/protos/types/plugins/native_hook/native_hook_config.proto +++ b/trace_streamer/src/protos/types/plugins/native_hook/native_hook_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto b/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto index 847a8cad00196a2266b68c1bf273ebf1269b10f7..5e1c32fb59cf7e6a72566cb835303bcb31540253 100755 --- a/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto +++ b/trace_streamer/src/protos/types/plugins/native_hook/native_hook_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 @@ -72,6 +72,7 @@ message StackMap { repeated uint64 frame_map_id = 2; // online symbolization use frame_map_id repeated uint64 ip = 3; // offline symbolization use ip int32 pid = 4; + repeated uint64 frame_map_id_down = 5; } message FrameMap { diff --git a/trace_streamer/src/protos/types/plugins/network_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/network_data/BUILD.gn index 56a24606432821c161b7940a56d11400cad873a0..9b505e8363207d9a13c670543864007284da00e1 100644 --- a/trace_streamer/src/protos/types/plugins/network_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/network_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/network_data/network_plugin_config.proto b/trace_streamer/src/protos/types/plugins/network_data/network_plugin_config.proto index fc17d6525a1a6fbeefb253ad435eb4e04edaa657..5599b155343c953d58d6b00b71e599a70b9f4b11 100755 --- a/trace_streamer/src/protos/types/plugins/network_data/network_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/network_data/network_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/network_data/network_plugin_result.proto b/trace_streamer/src/protos/types/plugins/network_data/network_plugin_result.proto index 2ce759cc660ed0abf3f6c3a42cdbd7e74c5eb68d..3f684136af48e7da5d4fc61a0ecbf4c73268a329 100755 --- a/trace_streamer/src/protos/types/plugins/network_data/network_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/network_data/network_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/process_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/process_data/BUILD.gn index 2673048e5fceb331288b5cc4681db82f16557f82..ebff1491318f1594149b6b7cd536a5adaf7699b3 100644 --- a/trace_streamer/src/protos/types/plugins/process_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/process_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/process_data/process_plugin_config.proto b/trace_streamer/src/protos/types/plugins/process_data/process_plugin_config.proto index 75b20efc405e583b395c0e8c95c3ee1f952fff04..b97dd03caf08c8db6566183ea301e4e54c691eb7 100755 --- a/trace_streamer/src/protos/types/plugins/process_data/process_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/process_data/process_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/process_data/process_plugin_result.proto b/trace_streamer/src/protos/types/plugins/process_data/process_plugin_result.proto index 8f790ed024b487fab19cb058da0bfa27c708904b..f7f2995b1fd9a340c9be7fa30da3a2fce75e6ed6 100755 --- a/trace_streamer/src/protos/types/plugins/process_data/process_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/process_data/process_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/sample_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/sample_data/BUILD.gn index be31733b6cd461437243e0a923aad8b03d184e10..55c1cec7c39ef52046ba7cac15bb45dba2328beb 100644 --- a/trace_streamer/src/protos/types/plugins/sample_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/sample_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_config.proto b/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_config.proto index 262398e4f7ef762650353047c804927db761f6c8..d7486907c92a3f289c14bdaaa6c98febddf9bee5 100755 --- a/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_result.proto b/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_result.proto index 0418c7a57d488433aac656509a41162a03139990..34289485612d28bbce7fbe4babef2f8a83260f98 100755 --- a/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/sample_data/sample_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/stream_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/stream_data/BUILD.gn index 9978b8427b23ba08faf44046de4ec19f13772b2e..51e492ca30a3dd031529688b69ed030775b38bc0 100644 --- a/trace_streamer/src/protos/types/plugins/stream_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/stream_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_config.proto b/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_config.proto index 9d124a74c2b03a0bd03313bdd35bc66c73c1730d..3047cbe962b4eb55ed5af576caac3be890442377 100755 --- a/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_config.proto +++ b/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_config.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_result.proto b/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_result.proto index 66d2a334ef628fda1a55602a2a763c8fb58a0994..6e616db36cc0768c6f0c163d275def9a1dbf9d49 100755 --- a/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_result.proto +++ b/trace_streamer/src/protos/types/plugins/stream_data/stream_plugin_result.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/protos/types/plugins/test_data/BUILD.gn b/trace_streamer/src/protos/types/plugins/test_data/BUILD.gn index 8ec3a4878b9da23b040ad26ed38a98b1d3bf67c6..35deb954d86d376a4e926a3c7a7c1d9865b973af 100644 --- a/trace_streamer/src/protos/types/plugins/test_data/BUILD.gn +++ b/trace_streamer/src/protos/types/plugins/test_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/protos/types/plugins/test_data/test.proto b/trace_streamer/src/protos/types/plugins/test_data/test.proto index 6c258861b6887d589cb477575be70d1fd3dede9e..fc04b11fd765af9eeab9ce524e77a517e4474245 100755 --- a/trace_streamer/src/protos/types/plugins/test_data/test.proto +++ b/trace_streamer/src/protos/types/plugins/test_data/test.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Huawei Device Co., Ltd. +// Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. // 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 diff --git a/trace_streamer/src/rpc/ffrt_converter.cpp b/trace_streamer/src/rpc/ffrt_converter.cpp index 2cbc49211672eb181b8fc755ee927b8692388064..1aaa2b7f05474278c1894f06737ed4d8dbde50e5 100644 --- a/trace_streamer/src/rpc/ffrt_converter.cpp +++ b/trace_streamer/src/rpc/ffrt_converter.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -127,7 +127,7 @@ std::string FfrtConverter::MakeEndFakeLog(const std::string& mark, (void)sprintf_s( result.get(), MAX_LEN, " %s-%s (%7d) [%s] .... %s: sched_switch: prev_comm=%s prev_pid=%s prev_prio=%d prev_state=S ==> " - "next_comm=%s next_pid=%s next_prio=%d\n", + "next_comm=%s next_pid=%d next_prio=%d\n", label.c_str(), taskId.c_str(), pid, cpuId.c_str(), endTimeStamp.c_str(), label.c_str(), taskId.c_str(), prio, threadName.c_str(), tid, prio); std::string fakeLog = result.get(); @@ -322,20 +322,17 @@ void FfrtConverter::FindFfrtProcessAndClassifyLogs(std::string& log, std::string FfrtConverter::GetTaskId(int pid, long long gid) { - std::stringstream ss; - auto max = INVALID_UINT32 / scaleFactor_; - int length = 1; - auto temp = gid; - while (temp > 0) { - temp /= scaleFactor_; - length++; - max /= scaleFactor_; - } - while (pid >= max) { - pid /= scaleFactor_; - } + stringstream ss; ss << pid << "0" << gid; - return ss.str(); + auto str = ss.str(); + while (str.size() > uint32MaxLength_) { + str.erase(0, 1); + } + auto result = stoll(str); + if (result > INVALID_UINT32) { + str.erase(0, 1); + } + return str; } bool FfrtConverter::IsDigit(const std::string& str) @@ -369,22 +366,71 @@ FfrtConverter::TypeFfrtPid FfrtConverter::ClassifyLogsForFfrtWorker(vector& results, TypeFfrtPid& ffrtPidsMap) { - if (mark.find("sched_switch:") == std::string::npos) { - return; + int prio; + std::unordered_map> taskLabels; + for (auto& [pid, tids] : ffrtPidsMap) { + taskLabels[pid] = {}; + for (auto& [tid, info] : ffrtPidsMap[pid]) { + auto& threadName = info.name; + auto switchInFakeLog = false; + auto switchOutFakeLog = false; + auto ffbkMarkRemove = false; + auto gid = WAKE_EVENT_DEFAULT_VALUE; + for (auto& line : info.line) { + auto mark = results[line]; + ProcessMarkWithSchedSwitch(results, line, tid, prio, mark); + if (mark.find("|FFRT") != std::string::npos || mark.find("|H:FFRT") != std::string::npos) { + auto returnValue = + ProcessMarkWithFFRT(results, line, threadName, prio, tid, pid, gid, taskLabels, mark); + if (!returnValue) { + continue; + } + switchInFakeLog = true; + continue; + } + if (gid != WAKE_EVENT_DEFAULT_VALUE) { + auto returnValue = DeleteRedundance(switchInFakeLog, switchOutFakeLog, mark, line, results); + if (!returnValue) { + continue; + } + static const std::regex EndPattern = std::regex(R"( F\|(\d+)\|[BF]\|(\d+))"); + static const std::regex HEndPattern = std::regex(R"( F\|(\d+)\|H:[BF]\s(\d+))"); + if (std::regex_search(mark, EndPattern) || std::regex_search(mark, HEndPattern)) { + results[line] = MakeEndFakeLog(mark, pid, taskLabels[pid][gid], gid, tid, threadName, prio); + gid = WAKE_EVENT_DEFAULT_VALUE; + switchOutFakeLog = false; + continue; + } + auto fakeLog = ConvertWorkerLogToTask(mark, pid, taskLabels[pid][gid], gid, tid); + results[line] = fakeLog; + continue; + } + } + } } - if (mark.find("prev_pid=" + std::to_string(tid) + " ") != std::string::npos) { - static std::string beginPprio = "prev_prio="; - auto beginPos = mark.find(beginPprio); - beginPos = beginPos + beginPprio.length(); - auto endPos = mark.find_first_of(" ", beginPos); - prio = stoi(mark.substr(beginPos, endPos - beginPos)); - } else if (mark.find("next_pid=" + std::to_string(tid)) != std::string::npos) { - static std::string beginNprio = "next_prio="; - auto beginPos = mark.find(beginNprio); - beginPos = beginPos + beginNprio.length(); - prio = stoi(mark.substr(beginPos)); + return; +} +void FfrtConverter::ProcessMarkWithSchedSwitch(vector& results, + const int& line, + const int& tid, + int& prio, + const std::string& mark) +{ + if (mark.find("sched_switch:") != std::string::npos) { + if (mark.find("prev_pid=" + std::to_string(tid) + " ") != std::string::npos) { + static std::string beginPprio = "prev_prio="; + auto beginPos = mark.find(beginPprio); + beginPos = beginPos + beginPprio.length(); + auto endPos = mark.find_first_of(" ", beginPos); + prio = stoi(mark.substr(beginPos, endPos - beginPos)); + } else if (mark.find("next_pid=" + std::to_string(tid)) != std::string::npos) { + static std::string beginNprio = "next_prio="; + auto beginPos = mark.find(beginNprio); + beginPos = beginPos + beginNprio.length(); + prio = stoi(mark.substr(beginPos)); + } } } std::string FfrtConverter::GetLabel(const string& mark) @@ -394,7 +440,7 @@ std::string FfrtConverter::GetLabel(const string& mark) if (mark.find("H:FFRT::") != std::string::npos) { auto beginPos = mark.rfind("["); auto endPos = mark.rfind("]"); - auto label = mark.substr(beginPos + 1, endPos - beginPos - 1); + label = mark.substr(beginPos + 1, endPos - beginPos - 1); } else { static std::string indexHFfrt = "|H:FFRT"; auto beginPos = mark.find(indexHFfrt); @@ -406,7 +452,7 @@ std::string FfrtConverter::GetLabel(const string& mark) if (mark.find("|FFRT::") != std::string::npos) { auto beginPos = mark.rfind("["); auto endPos = mark.rfind("]"); - auto label = mark.substr(beginPos + 1, endPos - beginPos - 1); + label = mark.substr(beginPos + 1, endPos - beginPos - 1); } else { static std::string indexFfrt = "|FFRT"; auto beginPos = mark.find(indexFfrt); @@ -417,123 +463,73 @@ std::string FfrtConverter::GetLabel(const string& mark) } return label; } -std::string FfrtConverter::getNewMissLog(std::string& missLog, - const std::string& mark, - const int pid, - const int tid, - std::string threadName) +bool FfrtConverter::ProcessMarkWithFFRT(vector& results, + const int& line, + const std::string& threadName, + int& prio, + const int& tid, + const int& pid, + int32_t& gid, + std::unordered_map>& taskLabels, + const std::string& mark) { - auto timestamp = ExtractTimeStr(mark); - auto cpuId = ExtractCpuId(mark); - std::unique_ptr result = std::make_unique(MAX_LEN); - (void)sprintf_s(result.get(), MAX_LEN, " %s-%d (%7d) [%s] .... %s: %sE|%d\n", threadName.c_str(), tid, pid, - cpuId.c_str(), timestamp.c_str(), tracingMarkerKey_.c_str(), pid); - missLog = missLog + result.get(); - memset_s(result.get(), MAX_LEN, 0, MAX_LEN); - return missLog; + std::string missLog; + auto label = GetLabel(mark); + if (label.find("executor_task") != std::string::npos || label.find("ex_task") != std::string::npos) { + return false; + } + if (gid != WAKE_EVENT_DEFAULT_VALUE) { + missLog = MakeEndFakeLog(mark, pid, taskLabels[pid][gid], gid, tid, threadName, prio); + auto timestamp = ExtractTimeStr(mark); + auto cpuId = ExtractCpuId(mark); + std::unique_ptr result = std::make_unique(MAX_LEN); + (void)sprintf_s(result.get(), MAX_LEN, " %s-%d (%7d) [%s] .... %s: %sE|%d\n", threadName.c_str(), tid, + pid, cpuId.c_str(), timestamp.c_str(), tracingMarkerKey_.c_str(), pid); + missLog = missLog + result.get(); + memset_s(result.get(), MAX_LEN, 0, MAX_LEN); + } + auto beginPos = mark.rfind("|"); + if (beginPos != std::string::npos && IsDigit(mark.substr(beginPos + 1))) { + gid = stoll(mark.substr(beginPos + 1)); + } else { + return false; + } + if (taskLabels[pid].find(gid) == taskLabels[pid].end()) { + taskLabels[pid][gid] = label; + } + results[line] = MakeBeginFakeLog(mark, pid, taskLabels[pid][gid], gid, tid, threadName, prio); + if (!missLog.empty()) { + results[line] = missLog + results[line]; + } + return true; } - -void FfrtConverter::DeleteRedundance(const std::string& mark, - std::string& log, - bool switchInFakeLog, - bool switchOutFakeLog, - const int pid, - const std::string& label, - long long gid, - const int tid, - const std::string& threadName, - const int prio) +bool FfrtConverter::DeleteRedundance(bool& switchInFakeLog, + bool& switchOutFakeLog, + const std::string& mark, + const int& line, + vector& results) { static const std::regex CoPattern = std::regex(R"( F\|(\d+)\|Co\|(\d+))"); static const std::regex HCoPattern = std::regex(R"( F\|(\d+)\|H:Co\s(\d+))"); if (std::regex_search(mark, CoPattern) || std::regex_search(mark, HCoPattern)) { - log.clear(); + results[line].clear(); if (switchInFakeLog) { switchInFakeLog = false; - return; + return false; } else { switchOutFakeLog = true; - return; + return false; } } if (switchInFakeLog && (mark.find(tracingMarkerKey_ + "B") != std::string::npos)) { - log.clear(); - return; + results[line].clear(); + return false; } if (switchOutFakeLog && (mark.find(tracingMarkerKey_ + "E") != std::string::npos)) { - log.clear(); - return; - } - static const std::regex EndPattern = std::regex(R"( F\|(\d+)\|[BF]\|(\d+))"); - static const std::regex HEndPattern = std::regex(R"( F\|(\d+)\|H:[BF]\s(\d+))"); - if (std::regex_search(mark, EndPattern) || std::regex_search(mark, HEndPattern)) { - log = MakeEndFakeLog(mark, pid, label, gid, tid, threadName, prio); - gid = WAKE_EVENT_DEFAULT_VALUE; - switchOutFakeLog = false; - return; - } - auto fakeLog = ConvertWorkerLogToTask(mark, pid, label, gid, tid); - log = fakeLog; - return; -} -void FfrtConverter::ConvertFfrtThreadToFfrtTaskByLine( - int pid, - int tid, - int& prio, - std::vector& results, - ffrtContent& content, - std::unordered_map>& taskLabels) -{ - auto& threadName = content.name; - auto switchInFakeLog = false; - auto switchOutFakeLog = false; - auto gid = WAKE_EVENT_DEFAULT_VALUE; - for (auto& line : content.line) { - auto mark = results[line]; - UpdatePrio(prio, mark, tid); - if (mark.find("FFRT::[") != std::string::npos) { - std::string missLog; - auto label = GetLabel(mark); - if (label.find("executor_task") != std::string::npos || label.find("ex_task") != std::string::npos) { - continue; - } - if (gid != WAKE_EVENT_DEFAULT_VALUE) { - missLog = MakeEndFakeLog(mark, pid, taskLabels[pid][gid], gid, tid, threadName, prio); - missLog = getNewMissLog(missLog, mark, pid, tid, threadName); - } - auto beginPos = mark.rfind("|"); - if (beginPos != std::string::npos && IsDigit(mark.substr(beginPos + 1))) { - gid = stoll(mark.substr(beginPos + 1)); - } else { - continue; - } - if (taskLabels[pid].find(gid) == taskLabels[pid].end()) { - taskLabels[pid][gid] = label; - } - results[line] = MakeBeginFakeLog(mark, pid, taskLabels[pid][gid], gid, tid, threadName, prio); - if (!missLog.empty()) { - results[line] = missLog + results[line]; - } - switchInFakeLog = true; - continue; - } - if (gid != WAKE_EVENT_DEFAULT_VALUE) { - DeleteRedundance(mark, results[line], switchInFakeLog, switchOutFakeLog, pid, taskLabels[pid][gid], gid, - tid, threadName, prio); - } - } -} -void FfrtConverter::ConvertFfrtThreadToFfrtTask(vector& results, FfrtConverter::TypeFfrtPid& ffrtPidsMap) -{ - int prio; - std::unordered_map> taskLabels; - for (auto& [pid, tids] : ffrtPidsMap) { - taskLabels[pid] = {}; - for (auto& [tid, info] : ffrtPidsMap[pid]) { - ConvertFfrtThreadToFfrtTaskByLine(pid, tid, prio, results, info, taskLabels); - } + results[line].clear(); + return false; } - return; + return true; } } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/rpc/ffrt_converter.h b/trace_streamer/src/rpc/ffrt_converter.h index dc431a30ab21af460a7f2484167b97e8aedfdc9a..7519f40edec696aa433366558ba15400246b5d6d 100644 --- a/trace_streamer/src/rpc/ffrt_converter.h +++ b/trace_streamer/src/rpc/ffrt_converter.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -65,13 +65,27 @@ private: std::unordered_map>& traceMap, FfrtConverter::TypeFfrtPid& ffrtPidsMap); int FindTid(string& log); - void ConvertFfrtThreadToFfrtTaskByLine(int pid, - int tid, - int& prio, - std::vector& results, - ffrtContent& content, - std::unordered_map>& taskLabels); + std::string GetLabel(const std::string& mark); void ConvertFfrtThreadToFfrtTask(vector& results, TypeFfrtPid& ffrtPidsMap); + void ProcessMarkWithSchedSwitch(vector& results, + const int& line, + const int& tid, + int& prio, + const std::string& mark); + bool ProcessMarkWithFFRT(vector& results, + const int& line, + const std::string& threadName, + int& prio, + const int& tid, + const int& pid, + int32_t& gid, + std::unordered_map>& taskLabels, + const std::string& mark); + bool DeleteRedundance(bool& switchInFakeLog, + bool& switchOutFakeLog, + const std::string& mark, + const int& line, + vector& results); std::string MakeBeginFakeLog(const std::string& mark, const int pid, const std::string& label, @@ -106,28 +120,11 @@ private: std::string GetTaskId(int pid, long long gid); bool IsDigit(const std::string& str); void CheckTraceMarker(vector& lines); - void UpdatePrio(int& prio, const std::string& mark, const int tid); - std::string GetLabel(const std::string& mark); - void DeleteRedundance(const std::string& mark, - std::string& log, - bool switchInFakeLog, - bool switchOutFakeLog, - const int pid, - const std::string& label, - long long gid, - const int tid, - const std::string& threadName, - const int prio); - std::string getNewMissLog(std::string& missLog, - const std::string& mark, - const int pid, - const int tid, - std::string threadName); private: const std::regex indexPattern_ = std::regex(R"(\(.+\)\s+\[\d)"); const std::regex matchPattern_ = std::regex(R"( \(.+\)\s+\[\d)"); - const int scaleFactor_ = 10; + const int uint32MaxLength_ = 10; std::string tracingMarkerKey_ = "tracing_mark_write: "; }; } // namespace TraceStreamer diff --git a/trace_streamer/src/rpc/rpc_server.cpp b/trace_streamer/src/rpc/rpc_server.cpp index 6ef9013920463ff55aa92861a28e0d99ce182d31..e0223d1ace0a67800aa8b8be8c308003775392cc 100644 --- a/trace_streamer/src/rpc/rpc_server.cpp +++ b/trace_streamer/src/rpc/rpc_server.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -27,6 +27,7 @@ #include "htrace_parser.h" #include "json.hpp" #include "log.h" +#include "rawtrace_parser.h" #include "string_help.h" #include "trace_streamer_selector.h" #include "ts_common.h" @@ -40,6 +41,7 @@ const size_t PACKET_HEADER_LENGTH = 1024; const std::string VALUE = "{\"value\":["; const std::string OFFSET = "{\"offset\":"; const std::string SIZE = ",\"size\":"; +const std::string TYPE = ",\"type\":"; const std::string EMPTY_VALUE = "{\"value\":[]}"; using json = nlohmann::json; @@ -50,6 +52,7 @@ struct ParserConfig { int32_t aniConfigValue; int32_t binderConfigValue; int32_t ffrtConvertConfigValue; + int32_t HMKernelConfigValue; }; void from_json(const json& j, ParserConfig& v) { @@ -58,6 +61,7 @@ void from_json(const json& j, ParserConfig& v) j.at("AnimationAnalysis").get_to(v.aniConfigValue); j.at("BinderRunnable").get_to(v.binderConfigValue); j.at("FfrtConvert").get_to(v.ffrtConvertConfigValue); + j.at("HMKernel").get_to(v.HMKernelConfigValue); } } // namespace jsonns #if IS_WASM @@ -290,6 +294,34 @@ bool RpcServer::SendBytraceSplitFileData(SplitFileCallBack splitFileCallBack, in return true; } +bool RpcServer::SendRawtraceSplitFileData(SplitFileCallBack splitFileCallBack, int32_t isFinish) +{ + const auto& mTraceRawCpuData = ts_->GetRawtraceData()->GetRawtraceCpuData(); + const auto& mTraceRawCommData = ts_->GetRawtraceData()->GetRawtraceCommData(); + std::string result = VALUE; + + for (size_t commDataIndex = 0; commDataIndex < mTraceRawCommData.size(); commDataIndex++) { + result += OFFSET + std::to_string(mTraceRawCommData.at(commDataIndex).splitDataOffset_); + result += SIZE + std::to_string(mTraceRawCommData.at(commDataIndex).splitDataSize_); + result += TYPE + std::to_string(mTraceRawCommData.at(commDataIndex).splitType_); + result += "},"; + } + + for (size_t cpuDataIndex = 0; cpuDataIndex < mTraceRawCpuData.size(); cpuDataIndex++) { + result += OFFSET + std::to_string(mTraceRawCpuData.at(cpuDataIndex).splitDataOffset_); + result += SIZE + std::to_string(mTraceRawCpuData.at(cpuDataIndex).splitDataSize_); + result += TYPE + std::to_string(mTraceRawCpuData.at(cpuDataIndex).splitType_); + result += "},"; + } + if (result != VALUE && !ts_->GetRawtraceData()->GetRawtraceCommData().empty()) { + result.pop_back(); + result += "]}\r\n"; + splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, isFinish); + } + TS_LOGI("mTraceRawCpuData.size()= %lu, mTraceRawCommData.size()=%lu\n result=%s\n", mTraceRawCpuData.size(), + mTraceRawCommData.size(), result.data()); + return true; +} bool RpcServer::ParseSplitFileData(const uint8_t* data, size_t len, int32_t isFinish, @@ -311,6 +343,13 @@ bool RpcServer::ParseSplitFileData(const uint8_t* data, ts_->GetTraceDataCache()->isSplitFile_ = false; return true; } + if (ts_->GetFileType() == TRACE_FILETYPE_RAW_TRACE) { + SendRawtraceSplitFileData(splitFileCallBack, 0); + splitFileCallBack(EMPTY_VALUE, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 1); + ts_->GetRawtraceData()->ClearRawTraceData(); + ts_->GetTraceDataCache()->isSplitFile_ = false; + return true; + } if (ts_->GetFileType() == TRACE_FILETYPE_H_TRACE) { ProcHtraceSplitResult(splitFileCallBack); } @@ -699,6 +738,7 @@ bool RpcServer::ParserConfig(std::string parserConfigJson) ts_->UpdateAnimationTraceStatus(parserConfig.aniConfigValue); ts_->UpdateTaskPoolTraceStatus(parserConfig.taskConfigValue); ts_->UpdateBinderRunnableTraceStatus(parserConfig.binderConfigValue); + ts_->UpdateHMKernelTraceStatus(parserConfig.HMKernelConfigValue); ffrtConvertEnabled_ = parserConfig.ffrtConvertConfigValue; startParseTime_ = (std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch())) diff --git a/trace_streamer/src/rpc/rpc_server.h b/trace_streamer/src/rpc/rpc_server.h index 533bb3146d6ff1bd669e309b4d242865f5dd06c2..cac28d0d64483d22db24384f7965a29e1f7f4081 100644 --- a/trace_streamer/src/rpc/rpc_server.h +++ b/trace_streamer/src/rpc/rpc_server.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -69,6 +69,8 @@ public: return ffrtConvertEnabled_; }; bool DetermineSystrace(const uint8_t* data, size_t len); + + bool SendRawtraceSplitFileData(SplitFileCallBack splitFileCallBack, int32_t isFinish); #ifdef IS_WASM bool SaveAndParseFfrtData(const uint8_t* data, size_t len, ResultCallBack resultCallBack, bool isFinish); bool ReadAndParseData(const std::string& filePath); diff --git a/trace_streamer/src/rpc/wasm_func.cpp b/trace_streamer/src/rpc/wasm_func.cpp index 584d8316d86743f1cbc3bce018788281c4963ee4..ca744861e977b66f27d809f118b1a2639f56a337 100644 --- a/trace_streamer/src/rpc/wasm_func.cpp +++ b/trace_streamer/src/rpc/wasm_func.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/rpc/wasm_func.h b/trace_streamer/src/rpc/wasm_func.h index e6bfc8ec8a4136577f4b5f1b90959f1149e74a52..c4d15b8561874272d2fec4edfb65c0368ba70a8a 100644 --- a/trace_streamer/src/rpc/wasm_func.h +++ b/trace_streamer/src/rpc/wasm_func.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/BUILD.gn b/trace_streamer/src/table/BUILD.gn index 2a2eb77f0b67db103c6691ec049d3a87b3359fa8..43373a20cdf05dc63c45492cee866dfb66753d44 100644 --- a/trace_streamer/src/table/BUILD.gn +++ b/trace_streamer/src/table/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/base/BUILD.gn b/trace_streamer/src/table/base/BUILD.gn index ac002df11ca80d9c18be1efa430652a07e46f448..61ab9200160b0ab569df056bf4e1424d6e32584a 100644 --- a/trace_streamer/src/table/base/BUILD.gn +++ b/trace_streamer/src/table/base/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/base/args_table.cpp b/trace_streamer/src/table/base/args_table.cpp index bfdf82bd7180cfb542970ac2974bdcf144e9553e..88270ca73c9ce270c103f10762e12d482a2c4d94 100644 --- a/trace_streamer/src/table/base/args_table.cpp +++ b/trace_streamer/src/table/base/args_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -107,7 +107,7 @@ int32_t ArgsTable::Cursor::Column(int32_t col) const { switch (static_cast(col)) { case Index::ID: - sqlite3_result_int64(context_, CurrentRow()); // IdsData() will be optimized + sqlite3_result_int64(context_, static_cast(argSet_.IdsData()[CurrentRow()])); break; case Index::KEY: sqlite3_result_int64(context_, static_cast(argSet_.NamesData()[CurrentRow()])); diff --git a/trace_streamer/src/table/base/data_dict_table.cpp b/trace_streamer/src/table/base/data_dict_table.cpp index aab154b56ff62737e9daf3137a199357354fc3e9..ddf29288ed386903ea6563b55275b9bcede573d0 100644 --- a/trace_streamer/src/table/base/data_dict_table.cpp +++ b/trace_streamer/src/table/base/data_dict_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/data_type_table.cpp b/trace_streamer/src/table/base/data_type_table.cpp index 82ca5027564e2c9ebed9bb9b5b6901a20f419884..1a4678e532e73e6501fc613fdc2910affd42f570 100644 --- a/trace_streamer/src/table/base/data_type_table.cpp +++ b/trace_streamer/src/table/base/data_type_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/datasource_clockid_table.cpp b/trace_streamer/src/table/base/datasource_clockid_table.cpp index 480896052dfdc5b6e0d87e311002e4f9308b773e..f8855ff59c667498609cfa9e1e68c37184263149 100644 --- a/trace_streamer/src/table/base/datasource_clockid_table.cpp +++ b/trace_streamer/src/table/base/datasource_clockid_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/device_info_table.cpp b/trace_streamer/src/table/base/device_info_table.cpp index 59f6ea5b7fc89a775648ca906f18b1f41ff34205..3de60f54037e8349ecb9bbc62aa9b395947aea0d 100644 --- a/trace_streamer/src/table/base/device_info_table.cpp +++ b/trace_streamer/src/table/base/device_info_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/args_table.h b/trace_streamer/src/table/base/include/args_table.h index 8cbfb3c4b12c19bfa7bb1e82c225f4f0a038e759..06da26279630abc7fb1e0a4ebd313d3813b57d5c 100644 --- a/trace_streamer/src/table/base/include/args_table.h +++ b/trace_streamer/src/table/base/include/args_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/data_dict_table.h b/trace_streamer/src/table/base/include/data_dict_table.h index 659cc26c5b9cd42aa2bb9889bb88a02a76468ed1..ce981a9cb998049ea87d094f8c7b6e26e40472ff 100644 --- a/trace_streamer/src/table/base/include/data_dict_table.h +++ b/trace_streamer/src/table/base/include/data_dict_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/data_type_table.h b/trace_streamer/src/table/base/include/data_type_table.h index 124b5626a044a9fa7d8ef2e223994b3ecb2de7c0..b28025f21e08b5b8f395d49965431f77f1b6eb7c 100644 --- a/trace_streamer/src/table/base/include/data_type_table.h +++ b/trace_streamer/src/table/base/include/data_type_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/datasource_clockid_table.h b/trace_streamer/src/table/base/include/datasource_clockid_table.h index b58537fd81a4aa514176ac77a7e2deab12d11c1d..1bfcdc4001f93e6988f3e01fc7a054d2988c4e1a 100644 --- a/trace_streamer/src/table/base/include/datasource_clockid_table.h +++ b/trace_streamer/src/table/base/include/datasource_clockid_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/device_info_table.h b/trace_streamer/src/table/base/include/device_info_table.h index ff6985151107ff87125cf988e286009bc8c503a3..dccdc62b6ce01693bc039d25cd69aab1a457331b 100644 --- a/trace_streamer/src/table/base/include/device_info_table.h +++ b/trace_streamer/src/table/base/include/device_info_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/meta_table.h b/trace_streamer/src/table/base/include/meta_table.h index 91484d952ebca863d1ece01ea321f3b118cc5def..99b7b0a865e991e802367a48e67f609542b075fe 100644 --- a/trace_streamer/src/table/base/include/meta_table.h +++ b/trace_streamer/src/table/base/include/meta_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/range_table.h b/trace_streamer/src/table/base/include/range_table.h index 1644c05d9a7dbc245f0a262cc2b46f0daa62e95b..388e51c1ec068210fa784abb0c75996e94571918 100644 --- a/trace_streamer/src/table/base/include/range_table.h +++ b/trace_streamer/src/table/base/include/range_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/span_join.h b/trace_streamer/src/table/base/include/span_join.h index c15f6256454c478d2ab97d80410f14a5be548681..df8410603efaecc8faf9ce640ec19a1f5fbc0cc8 100644 --- a/trace_streamer/src/table/base/include/span_join.h +++ b/trace_streamer/src/table/base/include/span_join.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/stat_table.h b/trace_streamer/src/table/base/include/stat_table.h index e0c6dfaca98afc316b37331756fd83f717367303..412cf70f430be0a9b35bd4d8c82a54ff816d5c69 100644 --- a/trace_streamer/src/table/base/include/stat_table.h +++ b/trace_streamer/src/table/base/include/stat_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/symbols_table.h b/trace_streamer/src/table/base/include/symbols_table.h index 82c2a6833d1790897cd008f37e0255d1dc02e379..053ca2f3686af469ff21ede03b8a12baaa40e72a 100644 --- a/trace_streamer/src/table/base/include/symbols_table.h +++ b/trace_streamer/src/table/base/include/symbols_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/table_base.h b/trace_streamer/src/table/base/include/table_base.h index 53f754476da17abf1c3cab2608cba1baf07a75b0..21cab807ca87c566a8d043f595f04dd7850825e2 100644 --- a/trace_streamer/src/table/base/include/table_base.h +++ b/trace_streamer/src/table/base/include/table_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/include/trace_config_table.h b/trace_streamer/src/table/base/include/trace_config_table.h index bf49bc0b10d233a649747ad0dd42f971e9760333..820dd9647ef6782600f8a507c756d013db16b19b 100644 --- a/trace_streamer/src/table/base/include/trace_config_table.h +++ b/trace_streamer/src/table/base/include/trace_config_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/meta_table.cpp b/trace_streamer/src/table/base/meta_table.cpp index e13a82680ce44a77e2a739530db88b8ede19eb3f..2505148d15930e3b2fc215e7c11a7f704df6a5eb 100644 --- a/trace_streamer/src/table/base/meta_table.cpp +++ b/trace_streamer/src/table/base/meta_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/range_table.cpp b/trace_streamer/src/table/base/range_table.cpp index 38255acc756c5db811db9798795fa2cad6e4efcd..bc2fd9e66cd0fbeaafa91638df3175e15ff51a44 100644 --- a/trace_streamer/src/table/base/range_table.cpp +++ b/trace_streamer/src/table/base/range_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/span_join.cpp b/trace_streamer/src/table/base/span_join.cpp index 464f94d5b73d1b72f8bedb086ead0011287fab67..5f9e073946f1e027a7b2dc44ce6886199b36b39c 100644 --- a/trace_streamer/src/table/base/span_join.cpp +++ b/trace_streamer/src/table/base/span_join.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/stat_table.cpp b/trace_streamer/src/table/base/stat_table.cpp index e70f969dc788d10394d3e712a345c9752f861a00..d2e42e9ed806062a25b305bf2faea822584cdf54 100644 --- a/trace_streamer/src/table/base/stat_table.cpp +++ b/trace_streamer/src/table/base/stat_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/symbols_table.cpp b/trace_streamer/src/table/base/symbols_table.cpp index 276715818d78809d560706aa6b8f3679c09aeced..d194ebf14df8e8c1dfe432bf4a620c3b0deeac4e 100644 --- a/trace_streamer/src/table/base/symbols_table.cpp +++ b/trace_streamer/src/table/base/symbols_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/table_base.cpp b/trace_streamer/src/table/base/table_base.cpp index 3198283844669425867ca88ec7b0530f7e188c2d..8f34c5395562f555199e6a22c4cac09f1120bd74 100644 --- a/trace_streamer/src/table/base/table_base.cpp +++ b/trace_streamer/src/table/base/table_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/base/trace_config_table.cpp b/trace_streamer/src/table/base/trace_config_table.cpp index e4dd6039d5f893d9c346789791f3ca1a87364e78..38435d61b049c7b546f09aa019708f55963153c1 100644 --- a/trace_streamer/src/table/base/trace_config_table.cpp +++ b/trace_streamer/src/table/base/trace_config_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/BUILD.gn b/trace_streamer/src/table/ebpf/BUILD.gn index 43aa532da980e613e03fa3a55adf8fe30f0000c2..bdc78b11f19999699f1282922a825568968d5b76 100644 --- a/trace_streamer/src/table/ebpf/BUILD.gn +++ b/trace_streamer/src/table/ebpf/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/ebpf/bio_latency_sample_table.cpp b/trace_streamer/src/table/ebpf/bio_latency_sample_table.cpp index c9f6d650c5e2c20f48883dfa2c122c0db7c86c2b..e77247e4bbc97dcfcb986621966e6bcf12e03e5d 100644 --- a/trace_streamer/src/table/ebpf/bio_latency_sample_table.cpp +++ b/trace_streamer/src/table/ebpf/bio_latency_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/ebpf_callstack_table.cpp b/trace_streamer/src/table/ebpf/ebpf_callstack_table.cpp index 8ef39c46d1d80d296696e0012090b4beb411177a..05cb520ab708f8f78e53ee48a94ab3e06950e2b8 100644 --- a/trace_streamer/src/table/ebpf/ebpf_callstack_table.cpp +++ b/trace_streamer/src/table/ebpf/ebpf_callstack_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/file_system_sample_table.cpp b/trace_streamer/src/table/ebpf/file_system_sample_table.cpp index 460473186fb170a2e1eeafc010bbfeb1fdf1e4bd..6f566337b678e0abe5f6e281807110a071385ca3 100644 --- a/trace_streamer/src/table/ebpf/file_system_sample_table.cpp +++ b/trace_streamer/src/table/ebpf/file_system_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/include/bio_latency_sample_table.h b/trace_streamer/src/table/ebpf/include/bio_latency_sample_table.h index 606cf1e93eeb88af816d2ae03dd8e0be08dece6f..2716e85a7eee9cb3ce9a756e14ff39f239d5e41d 100644 --- a/trace_streamer/src/table/ebpf/include/bio_latency_sample_table.h +++ b/trace_streamer/src/table/ebpf/include/bio_latency_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/include/ebpf_callstack_table.h b/trace_streamer/src/table/ebpf/include/ebpf_callstack_table.h index f0d38b78650e96a522f1dc5c0cc2378b8aa06d5d..beb84e867d845c55ba7264c8a5c7ce4b5eaf4009 100644 --- a/trace_streamer/src/table/ebpf/include/ebpf_callstack_table.h +++ b/trace_streamer/src/table/ebpf/include/ebpf_callstack_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ebpf/include/file_system_sample_table.h b/trace_streamer/src/table/ebpf/include/file_system_sample_table.h index 6f3ebbd6462b202a184638a8a42e120338d2141d..8b40f7492c68e39de10bdeb027597df7a78064a8 100644 --- a/trace_streamer/src/table/ebpf/include/file_system_sample_table.h +++ b/trace_streamer/src/table/ebpf/include/file_system_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/BUILD.gn b/trace_streamer/src/table/ftrace/BUILD.gn index 166f9c03f3996451ae59a16cb817635cc06275a9..83a40dff5fc762e3f974d2ca6e64a351861855d4 100644 --- a/trace_streamer/src/table/ftrace/BUILD.gn +++ b/trace_streamer/src/table/ftrace/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/ftrace/animation_table.cpp b/trace_streamer/src/table/ftrace/animation_table.cpp index fcc80784fcfe34fe70b85d0b320c374039d06dd0..afa80a3c580528afae94debf0f20143d8e264fb4 100644 --- a/trace_streamer/src/table/ftrace/animation_table.cpp +++ b/trace_streamer/src/table/ftrace/animation_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/app_startup_table.cpp b/trace_streamer/src/table/ftrace/app_startup_table.cpp index 449c65a1f1257e78564b5bfc96be99fdef8fcb0c..1b499e7ba09c4f9cbce10f196e0125b7fab8c707 100644 --- a/trace_streamer/src/table/ftrace/app_startup_table.cpp +++ b/trace_streamer/src/table/ftrace/app_startup_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/callstack_table.cpp b/trace_streamer/src/table/ftrace/callstack_table.cpp index 4bb35b31cd3ab65d3ebefac5686743e8dd20a62e..eb91acef5089465be3ad3cae0356ec6a44c54da5 100644 --- a/trace_streamer/src/table/ftrace/callstack_table.cpp +++ b/trace_streamer/src/table/ftrace/callstack_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -122,7 +122,7 @@ int32_t CallStackTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_valu indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), slicesObj_.CallIds()); break; case Index::COOKIES_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), slicesObj_.Cookies()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), slicesObj_.Cookies()); break; default: break; @@ -148,7 +148,7 @@ int32_t CallStackTable::Cursor::Column(int32_t col) const { switch (static_cast(col)) { case Index::ID: - sqlite3_result_int64(context_, CurrentRow()); + sqlite3_result_int64(context_, static_cast(slicesObj_.IdsData()[CurrentRow()])); break; case Index::TS: SetTypeColumnInt64(slicesObj_.TimeStampData()[CurrentRow()], INVALID_UINT64); @@ -182,7 +182,7 @@ void CallStackTable::Cursor::HandleTypeColumns(int32_t col) const SetTypeColumnInt64(slicesObj_.Depths()[CurrentRow()], INVALID_UINT64); break; case Index::COOKIES_ID: - SetTypeColumnInt64(slicesObj_.Cookies()[CurrentRow()], INVALID_UINT64); + SetTypeColumnInt64(slicesObj_.Cookies()[CurrentRow()], INVALID_INT64); break; case Index::PARENT_ID: { if (slicesObj_.ParentIdData()[CurrentRow()].has_value()) { diff --git a/trace_streamer/src/table/ftrace/clk_event_filter_table.cpp b/trace_streamer/src/table/ftrace/clk_event_filter_table.cpp index 83b1df941391f62b112ec26292d72f7be9d253f2..a28c1261936a9e1d694a615654e641a092e85101 100644 --- a/trace_streamer/src/table/ftrace/clk_event_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/clk_event_filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/clock_event_filter_table.cpp b/trace_streamer/src/table/ftrace/clock_event_filter_table.cpp index da68792038891e54018f3b5e23199f5eecc04df3..a96721bb50b073c59518cc6c81cd0e2f980646a8 100644 --- a/trace_streamer/src/table/ftrace/clock_event_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/clock_event_filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/clock_snapshot_table.cpp b/trace_streamer/src/table/ftrace/clock_snapshot_table.cpp index f05ee9428501ed9bfd50ee8fb6bfd9cb7957f17c..1131c9d193966780ac1fd9b5455eb2959424b3d3 100644 --- a/trace_streamer/src/table/ftrace/clock_snapshot_table.cpp +++ b/trace_streamer/src/table/ftrace/clock_snapshot_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp b/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp index b6135814a8be0015a8ca098e8fca80e4d8503e57..44951427ff81f0b593b929bf18de19b9416af855 100644 --- a/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/cpu_measure_filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -21,11 +21,10 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { ID = 0, TYPE, NAME, CPU }; +enum class Index : int32_t { ID = 0, NAME, CPU }; CpuMeasureFilterTable::CpuMeasureFilterTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("name", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("cpu", "INTEGER")); tablePriKey_.push_back("id"); @@ -82,8 +81,8 @@ std::unique_ptr CpuMeasureFilterTable::CreateCursor() } CpuMeasureFilterTable::Cursor::Cursor(const TraceDataCache* dataCache, TableBase* table) - : TableBase::Cursor(dataCache, table, static_cast(dataCache->GetConstCpuMeasureData().Size())), - cpuMeasureObj_(dataCache->GetConstCpuMeasureData()) + : TableBase::Cursor(dataCache, table, static_cast(dataCache->GetConstCpuMeasuresData().Size())), + cpuMeasureObj_(dataCache->GetConstCpuMeasuresData()) { } @@ -134,9 +133,6 @@ int32_t CpuMeasureFilterTable::Cursor::Column(int32_t column) const case Index::ID: sqlite3_result_int64(context_, static_cast(cpuMeasureObj_.IdsData()[CurrentRow()])); break; - case Index::TYPE: - sqlite3_result_text(context_, "cpu_measure_filter", STR_DEFAULT_LEN, nullptr); - break; case Index::NAME: { const std::string& str = dataCache_->GetDataFromDict(static_cast(cpuMeasureObj_.NameData()[CurrentRow()])); diff --git a/trace_streamer/src/table/ftrace/dynamic_frame_table.cpp b/trace_streamer/src/table/ftrace/dynamic_frame_table.cpp index 17b7ccc9eac67d7d9fef8a96a72a186dd74aa28e..36e749a7db3657c8ec645143a17fe998384ac172 100644 --- a/trace_streamer/src/table/ftrace/dynamic_frame_table.cpp +++ b/trace_streamer/src/table/ftrace/dynamic_frame_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/filter_table.cpp b/trace_streamer/src/table/ftrace/filter_table.cpp index 11d4b69f75fa27c90972b5e7a582ef0e4e16b933..41577606688f9696b04937e0f8bf8e5e193a811c 100644 --- a/trace_streamer/src/table/ftrace/filter_table.cpp +++ b/trace_streamer/src/table/ftrace/filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -106,7 +106,7 @@ int32_t FilterTable::Cursor::Column(int32_t col) const { switch (static_cast(col)) { case Index::ID: - sqlite3_result_int64(context_, CurrentRow()); // IdsData() will be optimized + sqlite3_result_int64(context_, filterObj_.IdsData()[CurrentRow()]); // IdsData() will be optimized break; case Index::TYPE: sqlite3_result_text(context_, filterObj_.TypeData()[CurrentRow()].c_str(), STR_DEFAULT_LEN, nullptr); diff --git a/trace_streamer/src/table/ftrace/frame_maps_table.cpp b/trace_streamer/src/table/ftrace/frame_maps_table.cpp index 30251a76f6ee32fd042deda1511ed3dcc0216376..e2d0601d3cf59cbc0595b1a280707a294fef4f27 100644 --- a/trace_streamer/src/table/ftrace/frame_maps_table.cpp +++ b/trace_streamer/src/table/ftrace/frame_maps_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -114,7 +114,7 @@ int32_t FrameMapsTable::Cursor::Column(int32_t column) const { switch (static_cast(column)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); + sqlite3_result_int64(context_, static_cast(frameMapsObj_.IdsData()[CurrentRow()])); break; case Index::SRC_ROW: sqlite3_result_int64(context_, static_cast(frameMapsObj_.SrcIndexs()[CurrentRow()])); diff --git a/trace_streamer/src/table/ftrace/frame_slice_table.cpp b/trace_streamer/src/table/ftrace/frame_slice_table.cpp index 45618b6cb60f15458348aa4073ec349ab7503ba5..7e1c174d614d4c0ce8a5c289852806637f0707b7 100644 --- a/trace_streamer/src/table/ftrace/frame_slice_table.cpp +++ b/trace_streamer/src/table/ftrace/frame_slice_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -163,7 +163,7 @@ int32_t FrameSliceTable::Cursor::Column(int32_t column) const { switch (static_cast(column)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); + sqlite3_result_int64(context_, static_cast(frameSliceObj_.IdsData()[CurrentRow()])); break; case Index::TS: SetTypeColumnInt64(frameSliceObj_.TimeStampData()[CurrentRow()], INVALID_UINT64); diff --git a/trace_streamer/src/table/ftrace/gpu_slice_table.cpp b/trace_streamer/src/table/ftrace/gpu_slice_table.cpp index 0fe4f4d2e1f9c36d2467977c4996e10154b405a6..54a045e83f183bbcd2f378bc192cfb2d88ef810d 100644 --- a/trace_streamer/src/table/ftrace/gpu_slice_table.cpp +++ b/trace_streamer/src/table/ftrace/gpu_slice_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -113,7 +113,7 @@ int32_t GPUSliceTable::Cursor::Column(int32_t column) const { switch (static_cast(column)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); + sqlite3_result_int64(context_, static_cast(gpuSliceObj_.IdsData()[CurrentRow()])); break; case Index::FRAME_ROW: sqlite3_result_int64(context_, static_cast(gpuSliceObj_.FrameRows()[CurrentRow()])); diff --git a/trace_streamer/src/table/ftrace/include/animation_table.h b/trace_streamer/src/table/ftrace/include/animation_table.h index 894b2f0b9376028e90a0b84187f28fff4006a957..c4d965598834517461d141d832cce5dd08f3ebae 100644 --- a/trace_streamer/src/table/ftrace/include/animation_table.h +++ b/trace_streamer/src/table/ftrace/include/animation_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/app_startup_table.h b/trace_streamer/src/table/ftrace/include/app_startup_table.h index 5eb14657a92307dccd8c4a71b4e861cca40a9341..af2fa66d53823fa80cef7f21b0e30a354dedb532 100644 --- a/trace_streamer/src/table/ftrace/include/app_startup_table.h +++ b/trace_streamer/src/table/ftrace/include/app_startup_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/callstack_table.h b/trace_streamer/src/table/ftrace/include/callstack_table.h index bbbb9b6306f2ee0f951a035c2c3e890e06080130..0d3fbe8edef6156b05cd8ffaa1d7b1bfa8cb4e4c 100644 --- a/trace_streamer/src/table/ftrace/include/callstack_table.h +++ b/trace_streamer/src/table/ftrace/include/callstack_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/clk_event_filter_table.h b/trace_streamer/src/table/ftrace/include/clk_event_filter_table.h index 6abe4327d32d57f642debaefc8e725cc3000840c..93fb3c58c2d2d8a96ce324f2784e6e9f6d8fe001 100644 --- a/trace_streamer/src/table/ftrace/include/clk_event_filter_table.h +++ b/trace_streamer/src/table/ftrace/include/clk_event_filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/clock_event_filter_table.h b/trace_streamer/src/table/ftrace/include/clock_event_filter_table.h index e4060cbbbab4954534d0214d3a338e483d41b62e..e0cfac6ecfa3a5530f914d4ddf2de2fedc34d1dc 100644 --- a/trace_streamer/src/table/ftrace/include/clock_event_filter_table.h +++ b/trace_streamer/src/table/ftrace/include/clock_event_filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/clock_snapshot_table.h b/trace_streamer/src/table/ftrace/include/clock_snapshot_table.h index ed4f472a680184458c7db9add17c502e31f8a491..d1568f1a3e08bb5680f494a6509566ed9da42cbe 100644 --- a/trace_streamer/src/table/ftrace/include/clock_snapshot_table.h +++ b/trace_streamer/src/table/ftrace/include/clock_snapshot_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/cpu_measure_filter_table.h b/trace_streamer/src/table/ftrace/include/cpu_measure_filter_table.h index b0c4f71d41d9d822131377b90d74090fba0d52a7..adfd20874b51138a102ec3da28f45b3f895c2156 100644 --- a/trace_streamer/src/table/ftrace/include/cpu_measure_filter_table.h +++ b/trace_streamer/src/table/ftrace/include/cpu_measure_filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -30,7 +30,7 @@ public: private: int64_t GetSize() override { - return dataCache_->GetConstCpuMeasureData().Size(); + return dataCache_->GetConstCpuMeasuresData().Size(); } void GetOrbyes(FilterConstraints& cpufc, EstimatedIndexInfo& cpuei) override; void FilterByConstraint(FilterConstraints& cpufc, diff --git a/trace_streamer/src/table/ftrace/include/dynamic_frame_table.h b/trace_streamer/src/table/ftrace/include/dynamic_frame_table.h index 48c2af652803d9e94106a01e4453cca9e92e4ca9..b6b26bd4d47dfe3f163facb28aae7f6b91631f4f 100644 --- a/trace_streamer/src/table/ftrace/include/dynamic_frame_table.h +++ b/trace_streamer/src/table/ftrace/include/dynamic_frame_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/filter_table.h b/trace_streamer/src/table/ftrace/include/filter_table.h index 23056be655270a4039da874ca09a8b36d5f7f375..4ffb4c6f79ba799d20c4514fb25ef63350adcf7a 100644 --- a/trace_streamer/src/table/ftrace/include/filter_table.h +++ b/trace_streamer/src/table/ftrace/include/filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/frame_maps_table.h b/trace_streamer/src/table/ftrace/include/frame_maps_table.h index f7da99d729c0b1fe0c517453fa68891207e603a9..0311155e2b42d0b0ad8529322f4af3245c483a80 100644 --- a/trace_streamer/src/table/ftrace/include/frame_maps_table.h +++ b/trace_streamer/src/table/ftrace/include/frame_maps_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/frame_slice_table.h b/trace_streamer/src/table/ftrace/include/frame_slice_table.h index 7ab529d7a886963093929878438f56726614a2fb..cb83e602492dda606ae9aa7d06bacfc679ff375e 100644 --- a/trace_streamer/src/table/ftrace/include/frame_slice_table.h +++ b/trace_streamer/src/table/ftrace/include/frame_slice_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/gpu_slice_table.h b/trace_streamer/src/table/ftrace/include/gpu_slice_table.h index 0fd64ca235a6c2251f84528a8a3e4eae88b78239..b789d43bff4c3b8e1b5263f29bb4889634d3eee4 100644 --- a/trace_streamer/src/table/ftrace/include/gpu_slice_table.h +++ b/trace_streamer/src/table/ftrace/include/gpu_slice_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/instants_table.h b/trace_streamer/src/table/ftrace/include/instants_table.h index 05ce1494de9c915033b51c928df7ff42841f84ea..cee21be75a69850d52841182165d4fe7a84f76b2 100644 --- a/trace_streamer/src/table/ftrace/include/instants_table.h +++ b/trace_streamer/src/table/ftrace/include/instants_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/irq_table.h b/trace_streamer/src/table/ftrace/include/irq_table.h index 7b719da2a39dbdcdf437b3407e3ff714db8e9480..08e65771906ff7396b13f5b0976091ca72fe4c81 100644 --- a/trace_streamer/src/table/ftrace/include/irq_table.h +++ b/trace_streamer/src/table/ftrace/include/irq_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/measure_table.h b/trace_streamer/src/table/ftrace/include/measure_table.h index c27100fb10ebdc7618d1d1ece8179cc64a0dbe36..f61e01d095ca43c5ee02991337d467ba6fb993a2 100644 --- a/trace_streamer/src/table/ftrace/include/measure_table.h +++ b/trace_streamer/src/table/ftrace/include/measure_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/process_measure_filter_table.h b/trace_streamer/src/table/ftrace/include/process_measure_filter_table.h index b84ef64069f1a49ce12420d992941ef6d3d105cb..c51457f1d11004651672d62152b666f3f03e024a 100644 --- a/trace_streamer/src/table/ftrace/include/process_measure_filter_table.h +++ b/trace_streamer/src/table/ftrace/include/process_measure_filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/process_table.h b/trace_streamer/src/table/ftrace/include/process_table.h index 28e2168ea145686f91f22eb322ea7f69afe7b22b..18109036d57d2b708db4b5b3fbfdf2cd09e2da42 100644 --- a/trace_streamer/src/table/ftrace/include/process_table.h +++ b/trace_streamer/src/table/ftrace/include/process_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/raw_table.h b/trace_streamer/src/table/ftrace/include/raw_table.h index 90de10b4f1c147920626b13b8b70ada1c16c3deb..dbe6ac4f90250afdd44d8f596f8f3df38901b229 100644 --- a/trace_streamer/src/table/ftrace/include/raw_table.h +++ b/trace_streamer/src/table/ftrace/include/raw_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/sched_slice_table.h b/trace_streamer/src/table/ftrace/include/sched_slice_table.h index 4a9886165c19ddc0b14d387d9d500fa0c9d4bc3c..97e7b72b1a6980f2dab0dfcb9e8095c36a5ac8a3 100644 --- a/trace_streamer/src/table/ftrace/include/sched_slice_table.h +++ b/trace_streamer/src/table/ftrace/include/sched_slice_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/so_static_initalization_table.h b/trace_streamer/src/table/ftrace/include/so_static_initalization_table.h index 38ca17b8fff3bb1aa701715e9b9d7fbdc41de929..f9805ddbcfe77d7c070de3e4530713d99664746d 100644 --- a/trace_streamer/src/table/ftrace/include/so_static_initalization_table.h +++ b/trace_streamer/src/table/ftrace/include/so_static_initalization_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/system_call_table.h b/trace_streamer/src/table/ftrace/include/system_call_table.h index 97ee5fda4fe6765f4535ed44cfac2cbf23313e1e..2dfa3819b2c5a3b949ffa5dd9784227727566ad7 100644 --- a/trace_streamer/src/table/ftrace/include/system_call_table.h +++ b/trace_streamer/src/table/ftrace/include/system_call_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/system_event_filter_table.h b/trace_streamer/src/table/ftrace/include/system_event_filter_table.h index 9d38eaa3c5c1203282cf12272a16ee37d794aba7..f27b844f33ac18a6788a9c65f23336cda970a721 100644 --- a/trace_streamer/src/table/ftrace/include/system_event_filter_table.h +++ b/trace_streamer/src/table/ftrace/include/system_event_filter_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/task_pool_table.h b/trace_streamer/src/table/ftrace/include/task_pool_table.h index 36ba076456131330257ab747e60d463e0ad0770a..3964e16b2d3a4a1c0f020690e40d6166d685c1bc 100644 --- a/trace_streamer/src/table/ftrace/include/task_pool_table.h +++ b/trace_streamer/src/table/ftrace/include/task_pool_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/thread_state_table.h b/trace_streamer/src/table/ftrace/include/thread_state_table.h index 6b74ce00cf9c5ee6feba694b4cb13408c0c59ac6..925bdde0e36913c05db9ae13fcdd4f95ec1c194f 100644 --- a/trace_streamer/src/table/ftrace/include/thread_state_table.h +++ b/trace_streamer/src/table/ftrace/include/thread_state_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/include/thread_table.h b/trace_streamer/src/table/ftrace/include/thread_table.h index 93f7bc4bd2576a458344a4edb0c3c886600e1110..00ccc14f3bf1f5e9eeecf9662f81390a8938e684 100644 --- a/trace_streamer/src/table/ftrace/include/thread_table.h +++ b/trace_streamer/src/table/ftrace/include/thread_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/instants_table.cpp b/trace_streamer/src/table/ftrace/instants_table.cpp index d6bc461959c4e96b17a756fa3bf448840a82ce39..04d2c892fc7f37ada154a39cd7b10e95db8fbc00 100644 --- a/trace_streamer/src/table/ftrace/instants_table.cpp +++ b/trace_streamer/src/table/ftrace/instants_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/irq_table.cpp b/trace_streamer/src/table/ftrace/irq_table.cpp index 51ed85aaf2b23d8fe5cec16ac622f2a50317835b..f15e6be2684f1a32aa28da12476a09aa899a2ce0 100644 --- a/trace_streamer/src/table/ftrace/irq_table.cpp +++ b/trace_streamer/src/table/ftrace/irq_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -46,6 +46,7 @@ IrqTable::IrqTable(const TraceDataCache* dataCache) : TableBase(dataCache) tableColumn_.emplace_back(TableBase::ColumnInfo("cookie", "INTEGER")); tableColumn_.emplace_back(TableBase::ColumnInfo("parent_id", "INTEGER")); tableColumn_.emplace_back(TableBase::ColumnInfo("argsetid", "INTEGER")); + tableColumn_.emplace_back(TableBase::ColumnInfo("chainId", "TEXT")); tableColumn_.emplace_back(TableBase::ColumnInfo("spanId", "TEXT")); tableColumn_.emplace_back(TableBase::ColumnInfo("parentSpanId", "TEXT")); tableColumn_.emplace_back(TableBase::ColumnInfo("flag", "TEXT")); @@ -134,7 +135,7 @@ int32_t IrqTable::Cursor::Column(int32_t column) const { switch (static_cast(column)) { case Index::ID: - sqlite3_result_int64(context_, CurrentRow()); + sqlite3_result_int64(context_, static_cast(slicesObj_.IdsData()[CurrentRow()])); break; case Index::TS: SetTypeColumnInt64(slicesObj_.TimeStampData()[CurrentRow()], INVALID_UINT64); @@ -165,7 +166,7 @@ void IrqTable::Cursor::HandleTypeColumns(int32_t column) const { switch (static_cast(column)) { case Index::COOKIE_ID: - SetTypeColumnInt64(slicesObj_.Cookies()[CurrentRow()], INVALID_UINT64); + SetTypeColumnInt64(slicesObj_.Cookies()[CurrentRow()], INVALID_INT64); break; case Index::PARENT_ID: { if (slicesObj_.ParentIdData()[CurrentRow()].has_value()) { diff --git a/trace_streamer/src/table/ftrace/measure_table.cpp b/trace_streamer/src/table/ftrace/measure_table.cpp index 6e2db44eac147a5b0742615a5727d7a44662e06e..304c5aa9329ee15da81d37216c1093ccb0e6d17d 100644 --- a/trace_streamer/src/table/ftrace/measure_table.cpp +++ b/trace_streamer/src/table/ftrace/measure_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -38,19 +38,17 @@ std::unique_ptr MeasureTable::CreateCursor() } MeasureTable::Cursor::Cursor(const TraceDataCache* dataCache, TableBase* table) - : TableBase::Cursor( - dataCache, - table, - static_cast(table->name_ == "measure" || table->name_ == "_measure" - ? dataCache->GetConstMeasureData().Size() - : (table->name_ == "process_measure" || table->name_ == "_process_measure" - ? dataCache->GetConstProcessMeasureData().Size() - : dataCache->GetConstSysMemMeasureData().Size()))), - measureObj(table->name_ == "measure" || table->name_ == "_measure" + : TableBase::Cursor(dataCache, + table, + static_cast(table->name_ == "measure" + ? dataCache->GetConstMeasureData().Size() + : (table->name_ == "process_measure" + ? dataCache->GetConstProcessMeasureData().Size() + : dataCache->GetConstSysMemMeasureData().Size()))), + measureObj(table->name_ == "measure" ? dataCache->GetConstMeasureData() - : (table->name_ == "process_measure" || table->name_ == "_process_measure" - ? dataCache->GetConstProcessMeasureData() - : dataCache->GetConstSysMemMeasureData())) + : (table->name_ == "process_measure" ? dataCache->GetConstProcessMeasureData() + : dataCache->GetConstSysMemMeasureData())) { } diff --git a/trace_streamer/src/table/ftrace/process_measure_filter_table.cpp b/trace_streamer/src/table/ftrace/process_measure_filter_table.cpp index a23c74b9c0bd093bc237cf2516f807a103d347f2..f2f1ecd98a8a57a21b9bc0ceafdd8824c0fedadf 100644 --- a/trace_streamer/src/table/ftrace/process_measure_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/process_measure_filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -19,11 +19,10 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { ID = 0, TYPE, NAME, INTERNAL_PID }; +enum class Index : int32_t { ID = 0, NAME, INTERNAL_PID }; ProcessMeasureFilterTable::ProcessMeasureFilterTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("name", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("ipid", "INTEGER")); tablePriKey_.push_back("id"); @@ -140,9 +139,6 @@ int32_t ProcessMeasureFilterTable::Cursor::Column(int32_t col) const sqlite3_result_int64(context_, static_cast( dataCache_->GetConstProcessMeasureFilterData().IdsData()[CurrentRow()])); break; - case Index::TYPE: - sqlite3_result_text(context_, "process_measure_filter", STR_DEFAULT_LEN, nullptr); - break; case Index::NAME: { size_t strId = static_cast(dataCache_->GetConstProcessMeasureFilterData().NamesData()[CurrentRow()]); diff --git a/trace_streamer/src/table/ftrace/process_table.cpp b/trace_streamer/src/table/ftrace/process_table.cpp index 8853ae67df7f5649fac9ea4f4ec6f8d4fdb4782d..9972d418d7605826eac96bb2aa810a48e9441d45 100644 --- a/trace_streamer/src/table/ftrace/process_table.cpp +++ b/trace_streamer/src/table/ftrace/process_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -20,7 +20,6 @@ namespace TraceStreamer { enum class Index : int32_t { ID = 0, IPID, - TYPE, PID, NAME, START_TS, @@ -34,7 +33,6 @@ ProcessTable::ProcessTable(const TraceDataCache* dataCache) : TableBase(dataCach { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("ipid", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("pid", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("name", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("start_ts", "INTEGER")); @@ -164,9 +162,6 @@ int32_t ProcessTable::Cursor::Column(int32_t col) const case Index::IPID: sqlite3_result_int64(context_, CurrentRow()); break; - case Index::TYPE: - sqlite3_result_text(context_, "process", STR_DEFAULT_LEN, nullptr); - break; case Index::PID: sqlite3_result_int64(context_, process.pid_); break; diff --git a/trace_streamer/src/table/ftrace/raw_table.cpp b/trace_streamer/src/table/ftrace/raw_table.cpp index f568ae055bf8b9db9ebceca166a502a4494712ff..dad61c6111a4dac253d7e010baf8a36cf5e29e0a 100644 --- a/trace_streamer/src/table/ftrace/raw_table.cpp +++ b/trace_streamer/src/table/ftrace/raw_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -16,7 +16,7 @@ #include "raw_table.h" namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { ID = 0, TYPE, TS, NAME, CPU, INTERNAL_TID }; +enum class Index : int32_t { ID = 0, TS, NAME, CPU, INTERNAL_TID }; enum RawType { RAW_CPU_IDLE = 1, RAW_SCHED_WAKEUP = 2, RAW_SCHED_WAKING = 3 }; uint32_t GetNameIndex(const std::string& name) { @@ -33,7 +33,6 @@ uint32_t GetNameIndex(const std::string& name) RawTable::RawTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("ts", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("name", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("cpu", "INTEGER")); @@ -133,10 +132,7 @@ int32_t RawTable::Cursor::Column(int32_t column) const { switch (static_cast(column)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); - break; - case Index::TYPE: - sqlite3_result_text(context_, "raw", STR_DEFAULT_LEN, nullptr); + sqlite3_result_int64(context_, static_cast(rawObj_.IdsData()[CurrentRow()])); break; case Index::TS: sqlite3_result_int64(context_, static_cast(rawObj_.TimeStampData()[CurrentRow()])); diff --git a/trace_streamer/src/table/ftrace/sched_slice_table.cpp b/trace_streamer/src/table/ftrace/sched_slice_table.cpp index c31c555174ebf6a521238bd83aee8f685bb2b3cb..83b988ea3e0ac95286308497a98b9f7eef8e3746 100644 --- a/trace_streamer/src/table/ftrace/sched_slice_table.cpp +++ b/trace_streamer/src/table/ftrace/sched_slice_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -19,23 +19,10 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { - ID = 0, - TYPE, - TS, - DUR, - TS_END, - CPU, - INTERNAL_TID, - INTERNAL_PID, - END_STATE, - PRIORITY, - ARGSETID -}; +enum class Index : int32_t { ID = 0, TS, DUR, TS_END, CPU, INTERNAL_TID, INTERNAL_PID, END_STATE, PRIORITY, ARGSETID }; SchedSliceTable::SchedSliceTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("ts", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("dur", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("ts_end", "INTEGER")); @@ -176,10 +163,7 @@ int32_t SchedSliceTable::Cursor::Column(int32_t col) const { switch (static_cast(col)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); - break; - case Index::TYPE: - sqlite3_result_text(context_, "sched_slice", STR_DEFAULT_LEN, nullptr); + sqlite3_result_int64(context_, static_cast(schedSliceObj_.IdsData()[CurrentRow()])); break; case Index::TS: sqlite3_result_int64(context_, static_cast(schedSliceObj_.TimeStampData()[CurrentRow()])); @@ -205,7 +189,7 @@ int32_t SchedSliceTable::Cursor::Column(int32_t col) const break; } case Index::PRIORITY: - sqlite3_result_int64(context_, static_cast(schedSliceObj_.PriorityData()[CurrentRow()])); + sqlite3_result_int(context_, schedSliceObj_.PriorityData()[CurrentRow()]); break; case Index::ARGSETID: { const uint32_t& argSetId = schedSliceObj_.ArgSetData()[CurrentRow()]; diff --git a/trace_streamer/src/table/ftrace/so_static_initalization_table.cpp b/trace_streamer/src/table/ftrace/so_static_initalization_table.cpp index 9be821f6fd336d058bb21e689e0dd842807f50cd..2205d6dcdc13244e27e4c1b6de39ac12af792fbb 100644 --- a/trace_streamer/src/table/ftrace/so_static_initalization_table.cpp +++ b/trace_streamer/src/table/ftrace/so_static_initalization_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/system_call_table.cpp b/trace_streamer/src/table/ftrace/system_call_table.cpp index 73e5988ce3f1f7869d1ae1895fc3166de874df37..9d0fcdcfb82b6edc4623f8c16f894a0fe9c76d24 100644 --- a/trace_streamer/src/table/ftrace/system_call_table.cpp +++ b/trace_streamer/src/table/ftrace/system_call_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/system_event_filter_table.cpp b/trace_streamer/src/table/ftrace/system_event_filter_table.cpp index 5c4e452aaa96c53f00581155c9945cf1feaabb34..539e9279368ae0784f5bb53a35445e0000d541a7 100644 --- a/trace_streamer/src/table/ftrace/system_event_filter_table.cpp +++ b/trace_streamer/src/table/ftrace/system_event_filter_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/ftrace/task_pool_table.cpp b/trace_streamer/src/table/ftrace/task_pool_table.cpp index 9dbc0c9d0f6018c66ebf1b74c9893b7e28f59f40..1f6a10d3533dfe8e9730c86c78852bc042fc8155 100644 --- a/trace_streamer/src/table/ftrace/task_pool_table.cpp +++ b/trace_streamer/src/table/ftrace/task_pool_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -25,7 +25,7 @@ enum class Index : int32_t { ALLOCATION_ITID, EXECUTE_ITID, RETURN_ITID, - EXECUTE_ID, + TASK_ID, PRIORITY, EXECUTE_STATE, RETURN_STATE, @@ -40,7 +40,7 @@ TaskPoolTable::TaskPoolTable(const TraceDataCache* dataCache) : TableBase(dataCa tableColumn_.push_back(TableBase::ColumnInfo("allocation_itid", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("execute_itid", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("return_itid", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("execute_id", "INTEGER")); + tableColumn_.push_back(TableBase::ColumnInfo("task_id", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("priority", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("execute_state", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("return_state", "INTEGER")); @@ -114,10 +114,10 @@ void TaskPoolTable::Cursor::HandleTypeColumns(int32_t taskPoolTabColumn) const dataCache_->GetConstTaskPoolData().ReturnItids()[CurrentRow()])); } break; - case Index::EXECUTE_ID: - if (taskPoolObj_.ExecuteIds()[CurrentRow()] != INVALID_INT32) { - sqlite3_result_int64(context_, static_cast( - dataCache_->GetConstTaskPoolData().ExecuteIds()[CurrentRow()])); + case Index::TASK_ID: + if (taskPoolObj_.TaskIds()[CurrentRow()] != INVALID_INT64) { + sqlite3_result_int64( + context_, static_cast(dataCache_->GetConstTaskPoolData().TaskIds()[CurrentRow()])); } break; case Index::PRIORITY: diff --git a/trace_streamer/src/table/ftrace/thread_state_table.cpp b/trace_streamer/src/table/ftrace/thread_state_table.cpp index 209eaad04800e055b245346c7d907030c664a1df..1636c05590cf4f3dc1943054298e708df470f2a7 100644 --- a/trace_streamer/src/table/ftrace/thread_state_table.cpp +++ b/trace_streamer/src/table/ftrace/thread_state_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -20,11 +20,10 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { ID = 0, TYPE, TS, DUR, CPU, INTERNAL_TID, TID, PID, STATE, ARGSETID }; +enum class Index : int32_t { ID = 0, TS, DUR, CPU, INTERNAL_TID, TID, PID, STATE, ARGSETID }; ThreadStateTable::ThreadStateTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("ts", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("dur", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("cpu", "INTEGER")); @@ -146,7 +145,7 @@ void ThreadStateTable::Cursor::HandleIndex(const FilterConstraints& fc, sqlite3_ indexMapBack->FilterId(c.op, argv[i]); break; case Index::TS: - indexMapBack->FilterTS(c.op, argv[i], threadStateObj_.TimeStamsData()); + indexMapBack->FilterTS(c.op, argv[i], threadStateObj_.TimeStampData()); break; case Index::INTERNAL_TID: indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), @@ -188,13 +187,10 @@ int32_t ThreadStateTable::Cursor::Column(int32_t col) const { switch (static_cast(col)) { case Index::ID: - sqlite3_result_int64(context_, static_cast(CurrentRow())); - break; - case Index::TYPE: - sqlite3_result_text(context_, "thread_state", STR_DEFAULT_LEN, nullptr); + sqlite3_result_int64(context_, static_cast(threadStateObj_.IdsData()[CurrentRow()])); break; case Index::TS: - sqlite3_result_int64(context_, static_cast(threadStateObj_.TimeStamsData()[CurrentRow()])); + sqlite3_result_int64(context_, static_cast(threadStateObj_.TimeStampData()[CurrentRow()])); break; case Index::DUR: SetTypeColumnInt64(threadStateObj_.DursData()[CurrentRow()], INVALID_UINT64); diff --git a/trace_streamer/src/table/ftrace/thread_table.cpp b/trace_streamer/src/table/ftrace/thread_table.cpp index da00248f54be895cb79946991bc7443f3538b03f..499774e0c13ea4336942b8806c87207e5cdd705a 100644 --- a/trace_streamer/src/table/ftrace/thread_table.cpp +++ b/trace_streamer/src/table/ftrace/thread_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -17,23 +17,11 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { - ID = 0, - ITID, - TYPE, - TID, - NAME, - START_TS, - END_TS, - INTERNAL_PID, - IS_MAIN_THREAD, - SWITCH_COUNT -}; +enum class Index : int32_t { ID = 0, ITID, TID, NAME, START_TS, END_TS, INTERNAL_PID, IS_MAIN_THREAD, SWITCH_COUNT }; ThreadTable::ThreadTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("itid", "INTEGER")); - tableColumn_.push_back(TableBase::ColumnInfo("type", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("tid", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("name", "TEXT")); tableColumn_.push_back(TableBase::ColumnInfo("start_ts", "INTEGER")); @@ -305,10 +293,6 @@ int32_t ThreadTable::Cursor::Column(int32_t col) const sqlite3_result_int64(context_, CurrentRow()); break; } - case Index::TYPE: { - sqlite3_result_text(context_, "thread", strlen("thread"), nullptr); - break; - } case Index::TID: { SetTypeColumnInt64(thread.tid_, INVALID_UINT32); break; diff --git a/trace_streamer/src/table/hi_sysevent/BUILD.gn b/trace_streamer/src/table/hi_sysevent/BUILD.gn index f3bee1e99a8d1f3a9f8e0fa29d5e8a449b50bd3e..b140ec36cae5ab0536239956250f4c1e79e88a02 100644 --- a/trace_streamer/src/table/hi_sysevent/BUILD.gn +++ b/trace_streamer/src/table/hi_sysevent/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/hi_sysevent/device_state_table.cpp b/trace_streamer/src/table/hi_sysevent/device_state_table.cpp index 8801048883689fe9612b147c5b354bceb3239279..bf6b2936be737af6702f82df5b1d1ce0cddef21b 100644 --- a/trace_streamer/src/table/hi_sysevent/device_state_table.cpp +++ b/trace_streamer/src/table/hi_sysevent/device_state_table.cpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/include/device_state_table.h b/trace_streamer/src/table/hi_sysevent/include/device_state_table.h index 1e8f6a41e02d942c694e85c3bb2cad78f029faca..c77e75ae55ca45a93f47037da1879b0d067959d7 100644 --- a/trace_streamer/src/table/hi_sysevent/include/device_state_table.h +++ b/trace_streamer/src/table/hi_sysevent/include/device_state_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/include/sysevent_all_event_table.h b/trace_streamer/src/table/hi_sysevent/include/sysevent_all_event_table.h index eff62e18ad536a8389860dec7bbd1d324ac566f6..afd2e937783717b9fbac0558837f0e2387eea125 100644 --- a/trace_streamer/src/table/hi_sysevent/include/sysevent_all_event_table.h +++ b/trace_streamer/src/table/hi_sysevent/include/sysevent_all_event_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/include/sysevent_measure_table.h b/trace_streamer/src/table/hi_sysevent/include/sysevent_measure_table.h index 9ddcfe5a59f7362a0f496757970eb2788bd9901f..5be482b37a129bb26a20bf059b324b46bc792647 100644 --- a/trace_streamer/src/table/hi_sysevent/include/sysevent_measure_table.h +++ b/trace_streamer/src/table/hi_sysevent/include/sysevent_measure_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/include/sysevent_subkey_table.h b/trace_streamer/src/table/hi_sysevent/include/sysevent_subkey_table.h index c1e1d0167fb17413aa4d16dc34f2fd88d113dd79..2fe68eae89da447385a17bf580d183402d6a3b80 100644 --- a/trace_streamer/src/table/hi_sysevent/include/sysevent_subkey_table.h +++ b/trace_streamer/src/table/hi_sysevent/include/sysevent_subkey_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/sysevent_all_event_table.cpp b/trace_streamer/src/table/hi_sysevent/sysevent_all_event_table.cpp index 9d7fed86af5be196b627ca08c6859027e0176f83..6df4d0a00ef9d1112c89e45a53191a94e9574b05 100644 --- a/trace_streamer/src/table/hi_sysevent/sysevent_all_event_table.cpp +++ b/trace_streamer/src/table/hi_sysevent/sysevent_all_event_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/sysevent_measure_table.cpp b/trace_streamer/src/table/hi_sysevent/sysevent_measure_table.cpp index 837d1874898d1c3d80722ffe6cd690db71566e75..182071de982c43a17d6e39ea2a1fdadca5c3f0f3 100644 --- a/trace_streamer/src/table/hi_sysevent/sysevent_measure_table.cpp +++ b/trace_streamer/src/table/hi_sysevent/sysevent_measure_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hi_sysevent/sysevent_subkey_table.cpp b/trace_streamer/src/table/hi_sysevent/sysevent_subkey_table.cpp index 63e58c88dca3d98804f6f47989a0540a207247dc..208a92de7ce32d439637112b107b3f99b44d4cdb 100644 --- a/trace_streamer/src/table/hi_sysevent/sysevent_subkey_table.cpp +++ b/trace_streamer/src/table/hi_sysevent/sysevent_subkey_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/BUILD.gn b/trace_streamer/src/table/hiperf/BUILD.gn index ca2508bed8e3d6363c118aa89be9e7ad2fd88aca..4ec34ec7b8a410bf2067194f5a1f734b2863bf3c 100644 --- a/trace_streamer/src/table/hiperf/BUILD.gn +++ b/trace_streamer/src/table/hiperf/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/hiperf/include/perf_call_chain_table.h b/trace_streamer/src/table/hiperf/include/perf_call_chain_table.h index 8e792c262d40c85229c548508c1a3094ff8a25ee..de82c4434cf8f106de1d467f9b339af1bc801f51 100644 --- a/trace_streamer/src/table/hiperf/include/perf_call_chain_table.h +++ b/trace_streamer/src/table/hiperf/include/perf_call_chain_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/include/perf_files_table.h b/trace_streamer/src/table/hiperf/include/perf_files_table.h index b0523ef2816d1f0e8c107eb6f228ec846e662fa2..8f931d261939ab1c17a4e4ef4aa931dfd611deb6 100644 --- a/trace_streamer/src/table/hiperf/include/perf_files_table.h +++ b/trace_streamer/src/table/hiperf/include/perf_files_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/include/perf_report_table.h b/trace_streamer/src/table/hiperf/include/perf_report_table.h index a829cc6fedf4f467f42fe79835f03fcc4354b4a4..c32dfaef886cbaad1f3855c4db872d85d7213ae2 100644 --- a/trace_streamer/src/table/hiperf/include/perf_report_table.h +++ b/trace_streamer/src/table/hiperf/include/perf_report_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/include/perf_sample_table.h b/trace_streamer/src/table/hiperf/include/perf_sample_table.h index a57ddec905084569e8055268e1ad8ab14a8bbab7..2e39fcb656cfd88346310e1207cce33bf5bb3d13 100644 --- a/trace_streamer/src/table/hiperf/include/perf_sample_table.h +++ b/trace_streamer/src/table/hiperf/include/perf_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/include/perf_thread_table.h b/trace_streamer/src/table/hiperf/include/perf_thread_table.h index 0e5d38b7ad7f2dcd92eb188aa34728193c200ae5..1502d1d9423d76f9b8c384d252d0b8ee012ae565 100644 --- a/trace_streamer/src/table/hiperf/include/perf_thread_table.h +++ b/trace_streamer/src/table/hiperf/include/perf_thread_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/perf_call_chain_table.cpp b/trace_streamer/src/table/hiperf/perf_call_chain_table.cpp index 8d313232ba8a92c5e94445f20a5648768ce015c1..088ab4f2181025adf4b97e4094c17c6f208a5c92 100644 --- a/trace_streamer/src/table/hiperf/perf_call_chain_table.cpp +++ b/trace_streamer/src/table/hiperf/perf_call_chain_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/perf_files_table.cpp b/trace_streamer/src/table/hiperf/perf_files_table.cpp index 2a9cd52d90c7950748de8343f059d60fa23f46e0..332188332e9f2f06c54b55e73bec78f8b3c79450 100644 --- a/trace_streamer/src/table/hiperf/perf_files_table.cpp +++ b/trace_streamer/src/table/hiperf/perf_files_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/perf_report_table.cpp b/trace_streamer/src/table/hiperf/perf_report_table.cpp index b5e146538db5809378c386c888c05ee95117d2db..cd2a7ae3b18b05c40b353f03ed24a645664a9511 100644 --- a/trace_streamer/src/table/hiperf/perf_report_table.cpp +++ b/trace_streamer/src/table/hiperf/perf_report_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/perf_sample_table.cpp b/trace_streamer/src/table/hiperf/perf_sample_table.cpp index 6a9bbbdcb5cfa436678246264d1bd9a368d75cae..ff0d518d0e722815f4282560d429941cd2e1ca85 100644 --- a/trace_streamer/src/table/hiperf/perf_sample_table.cpp +++ b/trace_streamer/src/table/hiperf/perf_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/hiperf/perf_thread_table.cpp b/trace_streamer/src/table/hiperf/perf_thread_table.cpp index bbcc207c856cf9cba2686fcb5c52ecd6b5054bb2..832a1d0362371eeb046c8f422d6c3a73e50c75ed 100644 --- a/trace_streamer/src/table/hiperf/perf_thread_table.cpp +++ b/trace_streamer/src/table/hiperf/perf_thread_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/BUILD.gn b/trace_streamer/src/table/js_memory/BUILD.gn index 549bed832882fd5eb5b61d05e6e40bf941191770..639440500205c7df1a762c9d71a8b8efda62c0d1 100644 --- a/trace_streamer/src/table/js_memory/BUILD.gn +++ b/trace_streamer/src/table/js_memory/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/js_memory/include/js_config_table.h b/trace_streamer/src/table/js_memory/include/js_config_table.h index d8620473fbdb7900c37a0095a0a94b2957c388ca..6a194bfbff1add4ff62676d48a4de50ae99ccf77 100644 --- a/trace_streamer/src/table/js_memory/include/js_config_table.h +++ b/trace_streamer/src/table/js_memory/include/js_config_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_cpu_profiler_node_table.h b/trace_streamer/src/table/js_memory/include/js_cpu_profiler_node_table.h index cf546152966f438eb06c05ae4aeb816290bf75db..a265c1fa000c98cdbc559dec9a11122f63944e03 100644 --- a/trace_streamer/src/table/js_memory/include/js_cpu_profiler_node_table.h +++ b/trace_streamer/src/table/js_memory/include/js_cpu_profiler_node_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_cpu_profiler_sample_table.h b/trace_streamer/src/table/js_memory/include/js_cpu_profiler_sample_table.h index 39182352dbbf88e7f9e2d94e3163a925b15d7553..196f7d5b21b17da0ecad758a4e6492b241759b86 100644 --- a/trace_streamer/src/table/js_memory/include/js_cpu_profiler_sample_table.h +++ b/trace_streamer/src/table/js_memory/include/js_cpu_profiler_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_edges_table.h b/trace_streamer/src/table/js_memory/include/js_heap_edges_table.h index dcb967110facb7d2b45bade786b1d01b62f72f95..5bc6a2831c2b450b2b3e74d7686b370359ab1d07 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_edges_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_edges_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_files_table.h b/trace_streamer/src/table/js_memory/include/js_heap_files_table.h index 113b22bd503f534ab7f7d13e698934d820500fff..994c8c8019612ce67a310e8b659936dce165b145 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_files_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_files_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_info_table.h b/trace_streamer/src/table/js_memory/include/js_heap_info_table.h index d97f396e36394b176b731779a82f4cd7172e6972..3f51844bf51008bafe06b33a88deb6d668e0562d 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_info_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_info_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_location_table.h b/trace_streamer/src/table/js_memory/include/js_heap_location_table.h index 4fa41d0de809d1a3b39d020c9872cac97c38a8e7..b63aa364f21188a6df0577a205e43ad192115430 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_location_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_location_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_nodes_table.h b/trace_streamer/src/table/js_memory/include/js_heap_nodes_table.h index 4eaad1b8d1a11207869e6a0bc493a1a65ec3bf88..698412b4968147d7bd339d99444123b34cd919c3 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_nodes_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_nodes_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_sample_table.h b/trace_streamer/src/table/js_memory/include/js_heap_sample_table.h index 68034ddd9d4785af8a32ed33ac726c3f6a16cf73..45c7d91305edda113704f3b19a3e3f9aa82bde7c 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_sample_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_string_table.h b/trace_streamer/src/table/js_memory/include/js_heap_string_table.h index 094afb47e97aab6634c8192894c2ba462449513e..2efdf1ba4308c3a1eaf4b3a4f7d0bb117787ed4a 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_string_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_string_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_trace_function_info_table.h b/trace_streamer/src/table/js_memory/include/js_heap_trace_function_info_table.h index 576dd2facb7b6252657bdc333a4a6cdc6726651f..b37b7672d7590feca8800e5b5205a00a0054a25e 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_trace_function_info_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_trace_function_info_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/include/js_heap_trace_node_table.h b/trace_streamer/src/table/js_memory/include/js_heap_trace_node_table.h index 64ff1787495b409ef4ba0a73a12805661709d4b4..283dee1e05f23aab12727f035d63e6c843674bab 100644 --- a/trace_streamer/src/table/js_memory/include/js_heap_trace_node_table.h +++ b/trace_streamer/src/table/js_memory/include/js_heap_trace_node_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_config_table.cpp b/trace_streamer/src/table/js_memory/js_config_table.cpp index 8592cdc48da1c535d91522f5737e633fd4470eb1..7c18b0e9b96637a2e97084f98bb98b47316d7c42 100644 --- a/trace_streamer/src/table/js_memory/js_config_table.cpp +++ b/trace_streamer/src/table/js_memory/js_config_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_cpu_profiler_node_table.cpp b/trace_streamer/src/table/js_memory/js_cpu_profiler_node_table.cpp index fe4bbeccabd47b7738381d4929bfe0fbc5dd1fa3..d87706a3aaea533e7f488aa211d604ef08f0e1b3 100644 --- a/trace_streamer/src/table/js_memory/js_cpu_profiler_node_table.cpp +++ b/trace_streamer/src/table/js_memory/js_cpu_profiler_node_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_cpu_profiler_sample_table.cpp b/trace_streamer/src/table/js_memory/js_cpu_profiler_sample_table.cpp index ca962c730b3b4157ca9f994c5ff378db9f22a640..37a941a8560b32fad9389a90f5d30164187a09f0 100644 --- a/trace_streamer/src/table/js_memory/js_cpu_profiler_sample_table.cpp +++ b/trace_streamer/src/table/js_memory/js_cpu_profiler_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_edges_table.cpp b/trace_streamer/src/table/js_memory/js_heap_edges_table.cpp index 3fcffb1e1e7ef43d2b544412423091e321aba4aa..1e3e4b4411382997d6c8ee011fb3851e4f18fb93 100644 --- a/trace_streamer/src/table/js_memory/js_heap_edges_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_edges_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_files_table.cpp b/trace_streamer/src/table/js_memory/js_heap_files_table.cpp index 29d135a25a8a005a7e3b9b650587919a53b5323b..f32896104e1ce246a5064355af5c8566b9d6bf92 100644 --- a/trace_streamer/src/table/js_memory/js_heap_files_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_files_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_info_table.cpp b/trace_streamer/src/table/js_memory/js_heap_info_table.cpp index eaac27b0e5573c5f5569306957981887215ca132..c532e275d6249d7c7f9a955e50d5df72084c63f1 100644 --- a/trace_streamer/src/table/js_memory/js_heap_info_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_info_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_location_table.cpp b/trace_streamer/src/table/js_memory/js_heap_location_table.cpp index 3186d8195f67986315f377ce3401cef560d04337..75a8fae929d866e82b170205d90487154b476064 100644 --- a/trace_streamer/src/table/js_memory/js_heap_location_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_location_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_nodes_table.cpp b/trace_streamer/src/table/js_memory/js_heap_nodes_table.cpp index 8824afc7738581195a4c8bf771c9c01313e81d83..51b52a1a5c676b6a482433fe0fed60348fdb7913 100644 --- a/trace_streamer/src/table/js_memory/js_heap_nodes_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_nodes_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_sample_table.cpp b/trace_streamer/src/table/js_memory/js_heap_sample_table.cpp index dd58fca2a42786b6e69b08d6e61ab82a8413a578..df2a58323dea80b14ba693a15040f0193d6a0978 100644 --- a/trace_streamer/src/table/js_memory/js_heap_sample_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_string_table.cpp b/trace_streamer/src/table/js_memory/js_heap_string_table.cpp index fd98360622407e2e48728e217de74de05cc513f5..58e11078bc1b733a55caacf44e639ab3895302a0 100644 --- a/trace_streamer/src/table/js_memory/js_heap_string_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_string_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_trace_function_info_table.cpp b/trace_streamer/src/table/js_memory/js_heap_trace_function_info_table.cpp index d67a7b076edc8303a7619a0dfedd0cf3b96c4c9d..bd8fd6b9c5afa0f9f8628a991a6e1b2c5830f73d 100644 --- a/trace_streamer/src/table/js_memory/js_heap_trace_function_info_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_trace_function_info_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/js_memory/js_heap_trace_node_table.cpp b/trace_streamer/src/table/js_memory/js_heap_trace_node_table.cpp index 0e95e1224571d3dc16a540ac633ff132ba8743ba..f59b6b80d6eb9a61e6bcdfacbe3cf54a00f866bc 100644 --- a/trace_streamer/src/table/js_memory/js_heap_trace_node_table.cpp +++ b/trace_streamer/src/table/js_memory/js_heap_trace_node_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/BUILD.gn b/trace_streamer/src/table/monitor/BUILD.gn index 4e2c619969d85ccb94ef96866b0ef72c8fe2077b..1c5f0bbba1260217b0867535f055143de24aa2ee 100644 --- a/trace_streamer/src/table/monitor/BUILD.gn +++ b/trace_streamer/src/table/monitor/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/monitor/cpu_usage_info_table.cpp b/trace_streamer/src/table/monitor/cpu_usage_info_table.cpp index 719291cc09613757cbf51c4487b90af91c46aeca..466ed15769d5ced193ece5117fee42424b3728fe 100644 --- a/trace_streamer/src/table/monitor/cpu_usage_info_table.cpp +++ b/trace_streamer/src/table/monitor/cpu_usage_info_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/disk_io_table.cpp b/trace_streamer/src/table/monitor/disk_io_table.cpp index 8831c9df438eb844ef62b3778ac1e276a79b3b2a..fcea3e4627c030bc64d9fadbbab98eb7869e8dcb 100644 --- a/trace_streamer/src/table/monitor/disk_io_table.cpp +++ b/trace_streamer/src/table/monitor/disk_io_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/hidump_table.cpp b/trace_streamer/src/table/monitor/hidump_table.cpp index bf9e22080e1fee371864a62a689c39e952271d03..3f8133f6ec9ea4624d134efbd3109d744adaf1e6 100644 --- a/trace_streamer/src/table/monitor/hidump_table.cpp +++ b/trace_streamer/src/table/monitor/hidump_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/cpu_usage_info_table.h b/trace_streamer/src/table/monitor/include/cpu_usage_info_table.h index bc6afb5f23f510123f0ee141d6a126176089e16d..32ab2013a74ef926c031c332270307fabd84c8b5 100644 --- a/trace_streamer/src/table/monitor/include/cpu_usage_info_table.h +++ b/trace_streamer/src/table/monitor/include/cpu_usage_info_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/disk_io_table.h b/trace_streamer/src/table/monitor/include/disk_io_table.h index 9e8e949a1bd0e475bf377cd0abf40ffb6eb5aba8..4afeab0a06cb53ba7ba2cd8f141e5946040af44b 100644 --- a/trace_streamer/src/table/monitor/include/disk_io_table.h +++ b/trace_streamer/src/table/monitor/include/disk_io_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/hidump_table.h b/trace_streamer/src/table/monitor/include/hidump_table.h index 682830d84a618067f98d05aac56a3a758d3e0a09..4a84883cd67e70aa6f97e9587112d086ba0a66f6 100644 --- a/trace_streamer/src/table/monitor/include/hidump_table.h +++ b/trace_streamer/src/table/monitor/include/hidump_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/live_process_table.h b/trace_streamer/src/table/monitor/include/live_process_table.h index ba03bf30402735bef8eba1af7a2fedae4d70b80a..6ae01b937814faf8c5a85cf7dee359864558e078 100644 --- a/trace_streamer/src/table/monitor/include/live_process_table.h +++ b/trace_streamer/src/table/monitor/include/live_process_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/log_table.h b/trace_streamer/src/table/monitor/include/log_table.h index f35ee366340dab60732c80995759cbcdf999f290..5155e9608154f67a683876a742a536e9c5b2fe59 100644 --- a/trace_streamer/src/table/monitor/include/log_table.h +++ b/trace_streamer/src/table/monitor/include/log_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_ashmem_table.h b/trace_streamer/src/table/monitor/include/memory_ashmem_table.h index c615b9e240419f3ec0f236accdf619dbfb5c34af..1e7376e65e8a9d2194e91d72d0c80edcd793ddcc 100644 --- a/trace_streamer/src/table/monitor/include/memory_ashmem_table.h +++ b/trace_streamer/src/table/monitor/include/memory_ashmem_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_cpu_table.h b/trace_streamer/src/table/monitor/include/memory_cpu_table.h index 24ad10339088ed90ab237da3a72bd523e1558224..404be70acf09d73db2c2aab7d295745449ac922e 100644 --- a/trace_streamer/src/table/monitor/include/memory_cpu_table.h +++ b/trace_streamer/src/table/monitor/include/memory_cpu_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_dma_table.h b/trace_streamer/src/table/monitor/include/memory_dma_table.h index 9955741d73366e1b5cc615afc6bcf47213db5f43..424e0638a096fdeead8ebe1951a64be9cf0c4f30 100644 --- a/trace_streamer/src/table/monitor/include/memory_dma_table.h +++ b/trace_streamer/src/table/monitor/include/memory_dma_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_process_gpu_table.h b/trace_streamer/src/table/monitor/include/memory_process_gpu_table.h index 2eca087121accd4f104a9e8e5fa3f73f5398e556..f21ab23b4408589a249be4070651237c49441046 100644 --- a/trace_streamer/src/table/monitor/include/memory_process_gpu_table.h +++ b/trace_streamer/src/table/monitor/include/memory_process_gpu_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_profile_table.h b/trace_streamer/src/table/monitor/include/memory_profile_table.h index c37e507bc9111b059d2f62db6ac6253fcc84907f..c9c4c5278695b29f6665472e659f9d70a102b8f1 100644 --- a/trace_streamer/src/table/monitor/include/memory_profile_table.h +++ b/trace_streamer/src/table/monitor/include/memory_profile_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_rs_image_table.h b/trace_streamer/src/table/monitor/include/memory_rs_image_table.h index 54878ea83f11ba8fb480bc0326c2f59a52976ded..ed4fd3553230056631da1e67b4958847faf98ce4 100644 --- a/trace_streamer/src/table/monitor/include/memory_rs_image_table.h +++ b/trace_streamer/src/table/monitor/include/memory_rs_image_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/memory_window_gpu_table.h b/trace_streamer/src/table/monitor/include/memory_window_gpu_table.h index cf67907d4bfd710fbedaf8ae70a3eac7cad462ef..bfb6429a10e3dbc9467a4c531b8dde8f309cbf8b 100644 --- a/trace_streamer/src/table/monitor/include/memory_window_gpu_table.h +++ b/trace_streamer/src/table/monitor/include/memory_window_gpu_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/network_table.h b/trace_streamer/src/table/monitor/include/network_table.h index 91dd50bd89960788b74967fcb1f0bc9382954816..91861001d18863a6c78dca0c675e4116406e8d56 100644 --- a/trace_streamer/src/table/monitor/include/network_table.h +++ b/trace_streamer/src/table/monitor/include/network_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/paged_memory_sample_table.h b/trace_streamer/src/table/monitor/include/paged_memory_sample_table.h index 0ca82a980ae6913a86147518231308eeba76fbdb..cf3fb7fc61f9a13972283f71e882ddaf173ac89d 100644 --- a/trace_streamer/src/table/monitor/include/paged_memory_sample_table.h +++ b/trace_streamer/src/table/monitor/include/paged_memory_sample_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/include/smaps_table.h b/trace_streamer/src/table/monitor/include/smaps_table.h index 973e0303614d14a919a0ae5e993421b55dda7f27..709882fa817f00a23a6d691301904e903d2b7630 100644 --- a/trace_streamer/src/table/monitor/include/smaps_table.h +++ b/trace_streamer/src/table/monitor/include/smaps_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/live_process_table.cpp b/trace_streamer/src/table/monitor/live_process_table.cpp index ad3765674a8257f0d5362b26153d52f33a69c68c..a2fa7549ba278d4b5984d0ad313280752af83ad7 100644 --- a/trace_streamer/src/table/monitor/live_process_table.cpp +++ b/trace_streamer/src/table/monitor/live_process_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/log_table.cpp b/trace_streamer/src/table/monitor/log_table.cpp index 2d28927b142e56bb795a79e51a7979c7fdd73711..cc05d8dbebd9e24843b1c769057ab2b9fb93a832 100644 --- a/trace_streamer/src/table/monitor/log_table.cpp +++ b/trace_streamer/src/table/monitor/log_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_ashmem_table.cpp b/trace_streamer/src/table/monitor/memory_ashmem_table.cpp index 2687c89b2ed7766af7cb1eaf65eff1d3ca6ebe49..f0548e9de05a99f722d4ef506699505170ad4e51 100644 --- a/trace_streamer/src/table/monitor/memory_ashmem_table.cpp +++ b/trace_streamer/src/table/monitor/memory_ashmem_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_cpu_table.cpp b/trace_streamer/src/table/monitor/memory_cpu_table.cpp index 98c4441b7b889edc7a8d41e181d0041257d61d99..81e88bdc273928ace96d4f7d10b0fd9737111341 100644 --- a/trace_streamer/src/table/monitor/memory_cpu_table.cpp +++ b/trace_streamer/src/table/monitor/memory_cpu_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_dma_table.cpp b/trace_streamer/src/table/monitor/memory_dma_table.cpp index 3b282532eb510ec92bf1481c4c80ee3e992fe70c..d520a35a45abeb54e8682a2b40918eeabba4fc43 100644 --- a/trace_streamer/src/table/monitor/memory_dma_table.cpp +++ b/trace_streamer/src/table/monitor/memory_dma_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_process_gpu_table.cpp b/trace_streamer/src/table/monitor/memory_process_gpu_table.cpp index ecf2b4b4d141c887cd627e41a445f249dc39c7a3..1c86cf8d28c844ab8e7adcd45b07b273a9106adc 100644 --- a/trace_streamer/src/table/monitor/memory_process_gpu_table.cpp +++ b/trace_streamer/src/table/monitor/memory_process_gpu_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_profile_table.cpp b/trace_streamer/src/table/monitor/memory_profile_table.cpp index e60ac9f770995226b0f897798416287f4fb5696c..f44c29f11c6cf17db5b74d823729022689a31c8d 100644 --- a/trace_streamer/src/table/monitor/memory_profile_table.cpp +++ b/trace_streamer/src/table/monitor/memory_profile_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_rs_image_table.cpp b/trace_streamer/src/table/monitor/memory_rs_image_table.cpp index 45c09cadae5d651590bae9adbf62b31d9414acf5..649507fd409ef2370a08611eb987db09705d0bed 100644 --- a/trace_streamer/src/table/monitor/memory_rs_image_table.cpp +++ b/trace_streamer/src/table/monitor/memory_rs_image_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/memory_window_gpu_table.cpp b/trace_streamer/src/table/monitor/memory_window_gpu_table.cpp index bd74784c9392aff3ee1379711d267d1893356996..f56586ed306a01e5e69c53cf8ec2e6a46806d373 100644 --- a/trace_streamer/src/table/monitor/memory_window_gpu_table.cpp +++ b/trace_streamer/src/table/monitor/memory_window_gpu_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/network_table.cpp b/trace_streamer/src/table/monitor/network_table.cpp index 34683dda2ae341e8c51bcd5638779821331bd216..1aed700533a1d5b4f97aa3bb2dc643d9611d9ae8 100644 --- a/trace_streamer/src/table/monitor/network_table.cpp +++ b/trace_streamer/src/table/monitor/network_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/paged_memory_sample_table.cpp b/trace_streamer/src/table/monitor/paged_memory_sample_table.cpp index 084268fb46e25d009b79e72885aa35d179986e9c..a7171c4bce9a9e2f038b4eb1e5c3af7c3703f30c 100644 --- a/trace_streamer/src/table/monitor/paged_memory_sample_table.cpp +++ b/trace_streamer/src/table/monitor/paged_memory_sample_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/monitor/smaps_table.cpp b/trace_streamer/src/table/monitor/smaps_table.cpp index 6cc630f8c2f9655f38e95b90b7e9a205d94859ea..43ddf14970a7b7b426924ae3237a2bce318a9891 100644 --- a/trace_streamer/src/table/monitor/smaps_table.cpp +++ b/trace_streamer/src/table/monitor/smaps_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/native_hook/BUILD.gn b/trace_streamer/src/table/native_hook/BUILD.gn index 9785cc4578c92fc3f59115e24aaecb5ce52e36c8..7818dc2295a79965c1b588330b60cffdc63ab68c 100644 --- a/trace_streamer/src/table/native_hook/BUILD.gn +++ b/trace_streamer/src/table/native_hook/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/table/native_hook/include/native_hook_frame_table.h b/trace_streamer/src/table/native_hook/include/native_hook_frame_table.h index 5c41501cbfd59b78d02f74d07929ebfd9123a71b..9095ca9800b88bdd365b3a506f3e165eaf30ef14 100644 --- a/trace_streamer/src/table/native_hook/include/native_hook_frame_table.h +++ b/trace_streamer/src/table/native_hook/include/native_hook_frame_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/native_hook/include/native_hook_statistic_table.h b/trace_streamer/src/table/native_hook/include/native_hook_statistic_table.h index 16ba6f40fde430fe138772757d0e249ed160c7be..00eaba207272a98ba2ff03f4784f8aae63cce1b3 100644 --- a/trace_streamer/src/table/native_hook/include/native_hook_statistic_table.h +++ b/trace_streamer/src/table/native_hook/include/native_hook_statistic_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/native_hook/include/native_hook_table.h b/trace_streamer/src/table/native_hook/include/native_hook_table.h index d7538ab97f8c273727745d475ffe57100f5af38d..c175b42ff9a5dc07fffb921d98518343595ad0b3 100644 --- a/trace_streamer/src/table/native_hook/include/native_hook_table.h +++ b/trace_streamer/src/table/native_hook/include/native_hook_table.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/native_hook/native_hook_frame_table.cpp b/trace_streamer/src/table/native_hook/native_hook_frame_table.cpp index 8310ce1d33e92db5bd7d775614d4ccfd345b4c00..c415040309cffc55caf5fcfac1b9bad420d98054 100644 --- a/trace_streamer/src/table/native_hook/native_hook_frame_table.cpp +++ b/trace_streamer/src/table/native_hook/native_hook_frame_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -17,7 +17,18 @@ namespace SysTuning { namespace TraceStreamer { -enum class Index : int32_t { ID = 0, CALLCHAIN_ID, DEPTH, IP, SYMBOL_ID, FILE_ID, OFFSET, SYMBOL_OFFSET, VADDR }; +enum class Index : int32_t { + ID = 0, + CALLCHAIN_ID, + DEPTH, + IP, + SYMBOL_ID, + FILE_ID, + OFFSET, + SYMBOL_OFFSET, + VADDR, + REAL_STACK +}; NativeHookFrameTable::NativeHookFrameTable(const TraceDataCache* dataCache) : TableBase(dataCache) { tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER")); @@ -29,6 +40,7 @@ NativeHookFrameTable::NativeHookFrameTable(const TraceDataCache* dataCache) : Ta tableColumn_.push_back(TableBase::ColumnInfo("offset", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("symbol_offset", "INTEGER")); tableColumn_.push_back(TableBase::ColumnInfo("vaddr", "TEXT")); + tableColumn_.push_back(TableBase::ColumnInfo("real_stack", "INTEGER")); tablePriKey_.push_back("id"); } @@ -154,6 +166,10 @@ int32_t NativeHookFrameTable::Cursor::Column(int32_t nativeHookFrameCol) const nativeHookFrameInfoObj_.Vaddrs()[CurrentRow()].c_str()); break; } + case Index::REAL_STACK: { + SetTypeColumnInt32(nativeHookFrameInfoObj_.realStack()[CurrentRow()], INVALID_UINT32); + break; + } default: TS_LOGF("Unregistered nativeHookFrameCol : %d", nativeHookFrameCol); break; diff --git a/trace_streamer/src/table/native_hook/native_hook_statistic_table.cpp b/trace_streamer/src/table/native_hook/native_hook_statistic_table.cpp index 684c5745031cb3dced92f8e2a084b8e0f18f66af..dd9680adcac7d7ad0bf9bd1349bd2a5799b74d02 100644 --- a/trace_streamer/src/table/native_hook/native_hook_statistic_table.cpp +++ b/trace_streamer/src/table/native_hook/native_hook_statistic_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/table/native_hook/native_hook_table.cpp b/trace_streamer/src/table/native_hook/native_hook_table.cpp index 75a6b53159fdbb6e88bbc88980926444712c116c..b7a27f39f0e2cf759b1d885b6bb1e78bf6ec8f83 100644 --- a/trace_streamer/src/table/native_hook/native_hook_table.cpp +++ b/trace_streamer/src/table/native_hook/native_hook_table.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/BUILD.gn b/trace_streamer/src/trace_data/BUILD.gn index 121ff2ecaa5061f623ef6a3af0eb095b1b9a48da..a5b029f9335ffdae4eeb79deb1b0f0ab584b6f89 100644 --- a/trace_streamer/src/trace_data/BUILD.gn +++ b/trace_streamer/src/trace_data/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/src/trace_data/sqllite_prepar_cache_data.cpp b/trace_streamer/src/trace_data/sqllite_prepar_cache_data.cpp index 7acc3560f458d7ccdca73f1ac7ca608b0c6fb010..3bf6cf407828c7200c62c1fe7da0e4cb29e06068 100644 --- a/trace_streamer/src/trace_data/sqllite_prepar_cache_data.cpp +++ b/trace_streamer/src/trace_data/sqllite_prepar_cache_data.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/sqllite_prepar_cache_data.h b/trace_streamer/src/trace_data/sqllite_prepar_cache_data.h index e290c454b7e8cefead81e56f78291861b1b2343f..ceed1ddeab00c94e6048dde45dd8a397dae854c6 100644 --- a/trace_streamer/src/trace_data/sqllite_prepar_cache_data.h +++ b/trace_streamer/src/trace_data/sqllite_prepar_cache_data.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -15,7 +15,7 @@ #ifndef SQLLITE_PREPAR_CACHE_DATA_H #define SQLLITE_PREPAR_CACHE_DATA_H - +#include #include #include #include "sqlite3.h" diff --git a/trace_streamer/src/trace_data/trace_data_cache.cpp b/trace_streamer/src/trace_data/trace_data_cache.cpp index 4ab6edbfd55708f9164d81aa878fd350bf77ac87..df387b4368aab864c7c78599275dd33a409892a0 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -279,6 +279,15 @@ void TraceDataCache::UpdateBinderRunnableTraceStatus(bool status) { binderRunnableTraceEnabled_ = status; } +bool TraceDataCache::HMKernelTraceEnabled() const +{ + return HMKernelTraceEnabled_; +} + +void TraceDataCache::UpdateHMKernelTraceStatus(bool status) +{ + HMKernelTraceEnabled_ = status; +} uint64_t TraceDataCache::SplitFileMaxTime() { return splitFileMaxTs_; @@ -629,41 +638,50 @@ void TraceDataCache::ExportEbpfCallChaninText(uint32_t callChainId, std::string& } bufferLine.append("\r\n"); } -void TraceDataCache::ClearAllPrevCacheData() +void TraceDataCache::ClearAllExportedCacheData() { // ftrace plugin - rawData_.ClearExportedData(); - threadStateData_.ClearExportedData(); - instantsData_.ClearExportedData(); + argSet_.ClearExportedData(); filterData_.ClearExportedData(); - processMeasureFilterData_.ClearExportedData(); - clockEventFilterData_.ClearExportedData(); clkEventFilterData_.ClearExportedData(); - schedSliceData_.ClearExportedData(); - irqData_.ClearExportedData(); measureData_.ClearExportedData(); - sysMemMeasureData_.ClearExportedData(); + clockEventFilterData_.ClearExportedData(); processMeasureData_.ClearExportedData(); + processMeasureFilterData_.ClearExportedData(); cpuMeasureData_.ClearExportedData(); + rawData_.ClearExportedData(); + instantsData_.ClearExportedData(); + schedSliceData_.ClearExportedData(); + irqData_.ClearExportedData(); + sysMemMeasureData_.ClearExportedData(); sysCallData_.ClearExportedData(); + frameSliceData_.ClearExportedData(); + frameMapsData_.ClearExportedData(); + gpuSliceData_.ClearExportedData(); } -void TraceDataCache::UpdateAllPrevSize() +void TraceDataCache::UpdateAllReadySize() { - // ftrace plugin - rawData_.UpdateReadySize(rawData_.Size()); - threadStateData_.UpdateReadySize(threadStateData_.Size()); - instantsData_.UpdateReadySize(instantsData_.Size()); - filterData_.UpdateReadySize(filterData_.Size()); - processMeasureFilterData_.UpdateReadySize(processMeasureFilterData_.Size()); - clockEventFilterData_.UpdateReadySize(clockEventFilterData_.Size()); - clkEventFilterData_.UpdateReadySize(clkEventFilterData_.Size()); - schedSliceData_.UpdateReadySize(schedSliceData_.Size()); - irqData_.UpdateReadySize(irqData_.Size()); + // ftrace plugin datacache measureData_.UpdateReadySize(measureData_.Size()); - sysMemMeasureData_.UpdateReadySize(sysMemMeasureData_.Size()); processMeasureData_.UpdateReadySize(processMeasureData_.Size()); + tableToCompletedSize_["measure"] = measureData_.readySize_; + tableToCompletedSize_["process_measure"] = processMeasureData_.readySize_; + tableToCompletedSize_["frame_slice"] = frameSliceData_.readySize_; + tableToCompletedSize_["sched_slice"] = schedSliceData_.readySize_; + tableToCompletedSize_["irq"] = irqData_.readySize_; + + argSet_.UpdateReadySize(argSet_.Size()); + filterData_.UpdateReadySize(filterData_.Size()); + clkEventFilterData_.UpdateReadySize(clkEventFilterData_.Size()); + clockEventFilterData_.UpdateReadySize(clockEventFilterData_.Size()); + processMeasureFilterData_.UpdateReadySize(processMeasureFilterData_.Size()); cpuMeasureData_.UpdateReadySize(cpuMeasureData_.Size()); + rawData_.UpdateReadySize(rawData_.Size()); + + instantsData_.UpdateReadySize(instantsData_.Size()); sysCallData_.UpdateReadySize(sysCallData_.Size()); + frameMapsData_.UpdateReadySize(frameMapsData_.Size()); + gpuSliceData_.UpdateReadySize(gpuSliceData_.Size()); } } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/trace_data/trace_data_cache.h b/trace_streamer/src/trace_data/trace_data_cache.h index bd862249cc4ff4666a862b0e8d460d71d95a70d7..d7b785361879f603408c98bb63b96beb11654f42 100644 --- a/trace_streamer/src/trace_data/trace_data_cache.h +++ b/trace_streamer/src/trace_data/trace_data_cache.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -39,6 +39,8 @@ public: void UpdateAppStartTraceStatus(bool status); bool BinderRunnableTraceEnabled() const; void UpdateBinderRunnableTraceStatus(bool status); + bool HMKernelTraceEnabled() const; + void UpdateHMKernelTraceStatus(bool status); uint64_t SplitFileMaxTime(); uint64_t SplitFileMinTime(); void SetSplitFileMaxTime(uint64_t maxTs); @@ -48,8 +50,8 @@ public: int32_t ExportPerfReadableText(const std::string& outputName, TraceDataDB::ResultCallBack resultCallBack = nullptr); int32_t ExportHookReadableText(const std::string& outputName, TraceDataDB::ResultCallBack resultCallBack = nullptr); int32_t ExportEbpfReadableText(const std::string& outputName, TraceDataDB::ResultCallBack resultCallBack = nullptr); - void ClearAllPrevCacheData(); - void UpdateAllPrevSize(); + void ClearAllExportedCacheData(); + void UpdateAllReadySize(); private: void InitDB(); @@ -85,6 +87,7 @@ private: bool taskPoolTraceEnabled_ = false; bool appStartTraceEnabled_ = false; bool binderRunnableTraceEnabled_ = false; + bool HMKernelTraceEnabled_ = false; uint64_t splitFileMinTs_ = INVALID_UINT64; uint64_t splitFileMaxTs_ = INVALID_UINT64; std::deque> hookCommProtos_; diff --git a/trace_streamer/src/trace_data/trace_data_cache_base.cpp b/trace_streamer/src/trace_data/trace_data_cache_base.cpp index 497eea8d28f1d0ed0ef193ce1df171c1073aad0a..c88931581f66d81c841373fee801525acd3e1631 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_base.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache_base.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_data_cache_base.h b/trace_streamer/src/trace_data/trace_data_cache_base.h index 2affc2a5d12f47bdfbf4992aeab2ff85598e755b..c90fdfef90cf2a1063e010553d804b2114888d9f 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_base.h +++ b/trace_streamer/src/trace_data/trace_data_cache_base.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_data_cache_reader.cpp b/trace_streamer/src/trace_data/trace_data_cache_reader.cpp index c77e134b196ef01702ec76d16b986e69d5025806..d81a43e3e4bfd97e05b8f21ce617c68d48bb2b91 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_reader.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache_reader.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -80,7 +80,7 @@ const SchedSlice& TraceDataCacheReader::GetConstSchedSliceData() const { return schedSliceData_; } -const CpuMeasureFilter& TraceDataCacheReader::GetConstCpuMeasureData() const +const CpuMeasureFilter& TraceDataCacheReader::GetConstCpuMeasuresData() const { return cpuMeasureData_; } diff --git a/trace_streamer/src/trace_data/trace_data_cache_reader.h b/trace_streamer/src/trace_data/trace_data_cache_reader.h index 4c9c1946b825cdef8961809c2ab12f916dcb922d..f233fe362f9b15c896dbe5d2f58f287766d0172b 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_reader.h +++ b/trace_streamer/src/trace_data/trace_data_cache_reader.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -60,7 +60,7 @@ public: const Measure& GetConstProcessMeasureData() const; const ThreadStateData& GetConstThreadStateData() const; const SchedSlice& GetConstSchedSliceData() const; - const CpuMeasureFilter& GetConstCpuMeasureData() const; + const CpuMeasureFilter& GetConstCpuMeasuresData() const; const Instants& GetConstInstantsData() const; const ProcessMeasureFilter& GetConstProcessMeasureFilterData() const; const ClockEventData& GetConstClockEventFilterData() const; diff --git a/trace_streamer/src/trace_data/trace_data_cache_writer.cpp b/trace_streamer/src/trace_data/trace_data_cache_writer.cpp index 0c15fabadaefd57217ff8045878815eca287d0ae..f93d8eaae961f991fc27c81ee72d47d01f1f96df 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_writer.cpp +++ b/trace_streamer/src/trace_data/trace_data_cache_writer.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -519,6 +519,9 @@ void TraceDataCacheWriter::Clear() dmaMemData_.Clear(); gpuProcessMemData_.Clear(); gpuWindowMemData_.Clear(); + gpuSliceData_.Clear(); + frameMapsData_.Clear(); + frameSliceData_.Clear(); } } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/trace_data/trace_data_cache_writer.h b/trace_streamer/src/trace_data/trace_data_cache_writer.h index 8b1b3a4465effcd0fdf5b55a72384f5f9110f8d0..6dee3bc11b89781356d8fce2498580db26782e76 100644 --- a/trace_streamer/src/trace_data/trace_data_cache_writer.h +++ b/trace_streamer/src/trace_data/trace_data_cache_writer.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_data_db.cpp b/trace_streamer/src/trace_data/trace_data_db.cpp index caa2f3b13b34fbd8e533bdc17844f72cba754967..085158bd0cec31768748bf54d8e8c071e51034eb 100644 --- a/trace_streamer/src/trace_data/trace_data_db.cpp +++ b/trace_streamer/src/trace_data/trace_data_db.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -33,6 +33,27 @@ #include "string_help.h" #include "ts_common.h" +namespace { +const std::string UPDATE_MEM_PROC_NAME = + "update process set name = (select name from thread t where t.ipid = process.id and t.name is not null and " + "is_main_thread = 1)"; +const std::string CREATE_MEM_ARGS_VIEW = + "create view args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " + "A.datatype==1 then V.data else A.value end) as strValue from args as A left join data_type as D on " + "(D.typeId " + "= A.datatype) left join data_dict as V on V.id = A.value left join data_dict as V2 on V2.id = A.key"; +// notice 'systuning_export' is 'ATTACH DATABASE name' +const std::string CREATE_EXPORT_DB_ARGS_VIEW = + "create view systuning_export.args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " + "A.datatype==1 then V.data else A.value end) as strValue from args as A left join data_type as D on (D.typeId " + "= A.datatype) left join data_dict as V on V.id = A.value left join data_dict as V2 on V2.id = A.key"; +const std::string CREATE_BATCH_EXPORT_DB_ARGS_VIEW = + "create view systuning_export.args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " + "A.datatype==1 then V.data else A.value end) as strValue from args_ as A left join data_type_ as D on " + "(D.typeId " + "= A.datatype) left join data_dict_ as V on V.id = A.value left join data_dict_ as V2 on V2.id = A.key"; +} // namespace + namespace SysTuning { namespace TraceStreamer { const int32_t ONCE_MAX_MB = 1024 * 1024 * 4; @@ -57,8 +78,12 @@ TraceDataDB::TraceDataDB() : db_(nullptr) TS_LOGF("open :memory db failed"); } ts_create_extend_function(db_); + InitTableToCompletedSize(); +} +void TraceDataDB::InitTableToCompletedSize() +{ + tableToCompletedSize_.insert({"measure", 0}); } - TraceDataDB::~TraceDataDB() { sqlite3_close(db_); @@ -135,6 +160,9 @@ void TraceDataDB::CloseBatchDB() } int32_t TraceDataDB::BatchExportDatabase(const std::string& outputName) { + // for update mem db + ExecuteSql(UPDATE_MEM_PROC_NAME); + // for drop mem db to disk db std::string attachSql("ATTACH DATABASE '" + outputName + "' AS systuning_export"); #ifdef _WIN32 if (!base::GetCoding(reinterpret_cast(attachSql.c_str()), attachSql.length())) { @@ -150,20 +178,17 @@ int32_t TraceDataDB::BatchExportDatabase(const std::string& outputName) std::string clearSql("DELETE FROM systuning_export." + (*itor) + "_"); ExecuteSql(clearSql); } - std::string exportSql("INSERT INTO systuning_export." + (*itor) + "_ SELECT * FROM " + *itor); - ExecuteSql(exportSql); + if (tableToCompletedSize_.count(*itor)) { + std::string exportSql("INSERT INTO systuning_export." + (*itor) + "_ SELECT * FROM " + *itor + + " LIMIT " + std::to_string(tableToCompletedSize_.at(*itor))); + ExecuteSql(exportSql); + } else { + std::string exportSql("INSERT INTO systuning_export." + (*itor) + "_ SELECT * FROM " + *itor); + ExecuteSql(exportSql); + } } } - std::string createArgsView = - "create view systuning_export.args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " - "A.datatype==1 then V.data else A.value end) as strValue from args_ as A left join data_type_ as D on " - "(D.typeId " - "= A.datatype) left join data_dict_ as V on V.id = A.value left join data_dict_ as V2 on V2.id = A.key"; - ExecuteSql(createArgsView); - std::string updateProcessName = - "update process set name = (select name from thread t where t.ipid = process.id and t.name is not null and " - "is_main_thread = 1)"; - ExecuteSql(updateProcessName); + ExecuteSql(CREATE_BATCH_EXPORT_DB_ARGS_VIEW); std::string detachSql("DETACH DATABASE systuning_export"); ExecuteSql(detachSql); return 0; @@ -201,6 +226,7 @@ int32_t TraceDataDB::ExportDatabase(const std::string& outputName, ResultCallBac close(fd); } + ExecuteSql(UPDATE_MEM_PROC_NAME); std::string attachSql("ATTACH DATABASE '" + outputName + "' AS systuning_export"); #ifdef _WIN32 if (!base::GetCoding(reinterpret_cast(attachSql.c_str()), attachSql.length())) { @@ -208,7 +234,6 @@ int32_t TraceDataDB::ExportDatabase(const std::string& outputName, ResultCallBac } #endif ExecuteSql(attachSql); - for (auto itor = internalTables_.begin(); itor != internalTables_.end(); itor++) { if (*itor == "meta" && !exportMetaTable_) { continue; @@ -217,15 +242,7 @@ int32_t TraceDataDB::ExportDatabase(const std::string& outputName, ResultCallBac ExecuteSql(exportSql); } } - std::string createArgsView = - "create view systuning_export.args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " - "A.datatype==1 then V.data else A.value end) as strValue from args as A left join data_type as D on (D.typeId " - "= A.datatype) left join data_dict as V on V.id = A.value left join data_dict as V2 on V2.id = A.key"; - ExecuteSql(createArgsView); - std::string updateProcessName = - "update process set name = (select name from thread t where t.ipid = process.id and t.name is not null and " - "is_main_thread = 1)"; - ExecuteSql(updateProcessName); + ExecuteSql(CREATE_EXPORT_DB_ARGS_VIEW); std::string detachSql("DETACH DATABASE systuning_export"); ExecuteSql(detachSql); @@ -246,18 +263,8 @@ void TraceDataDB::Prepare() "update thread set ipid = \ (select id from process where \ thread.tid = process.pid) where thread.ipid is null;"); - std::string createArgsView = - "create view args_view AS select A.argset, V2.data as keyName, A.id, D.desc, (case when " - "A.datatype==1 then V.data else A.value end) as strValue from args as A left join data_type as D on " - "(D.typeId " - "= A.datatype) left join data_dict as V on V.id = A.value left join data_dict as V2 on V2.id = A.key"; - ExecuteSql(createArgsView); - - std::string updateProcessNewName = - "update process set name = (select name from thread t where t.ipid = process.id and t.name is not " - "null and " - "is_main_thread = 1)"; - ExecuteSql(updateProcessNewName); + ExecuteSql(CREATE_MEM_ARGS_VIEW); + ExecuteSql(UPDATE_MEM_PROC_NAME); } void TraceDataDB::ExecuteSql(const std::string_view& sql) { @@ -354,10 +361,7 @@ int32_t TraceDataDB::SearchDatabase(std::string& sql, bool print) int32_t rowCount = 0; sqlite3_stmt* stmt = nullptr; int32_t ret = sqlite3_prepare_v2(db_, sql.c_str(), static_cast(sql.size()), &stmt, nullptr); - if (sql.back() != '\n') { - sql += "\r\n"; - } - printf("Executing sql: %s", sql.c_str()); + printf("Executing sql: %s\n", sql.c_str()); if (ret != SQLITE_OK) { TS_LOGE("sqlite3_prepare_v2(%s) failed: %d:%s", sql.c_str(), ret, sqlite3_errmsg(db_)); return 0; diff --git a/trace_streamer/src/trace_data/trace_data_db.h b/trace_streamer/src/trace_data/trace_data_db.h index 20745fcf56ab9a6905452d87c1c0c2d77e345b04..65e28da31585ba634f82822c207608a39fb8f15e 100644 --- a/trace_streamer/src/trace_data/trace_data_db.h +++ b/trace_streamer/src/trace_data/trace_data_db.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "sqlite3.h" #include "sqllite_prepar_cache_data.h" @@ -71,6 +72,9 @@ public: public: sqlite3* db_; +protected: + std::unordered_map tableToCompletedSize_; + private: void ExecuteSql(const std::string_view& sql); void SendDatabase(ResultCallBack resultCallBack); @@ -80,6 +84,7 @@ private: int32_t HandleRowData(sqlite3_stmt* stmt, char* res, int32_t outLen, int32_t pos, int32_t colCount); static void GetRowString(sqlite3_stmt* stmt, int32_t colCount, std::string& rowStr); static void SqliteFinalize(sqlite3_stmt* ptr); + void InitTableToCompletedSize(); private: std::list internalTables_ = {}; @@ -88,8 +93,9 @@ private: bool cancelQuery_ = false; std::string wasmDBName_; SqllitePreparCacheData sqlPreparCacheData_; - std::set needClearTable_ = {"data_type", "device_info", "data_dict", "meta", "stat", - "symbols", "thread", "process", "trace_range", "args_view"}; + std::set needClearTable_ = {"data_type", "device_info", "data_dict", "meta", "clock_snapshot", + "callstack", "thread_state", "stat", "symbols", "thread", + "process", "trace_range", "args_view"}; }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.cpp index 57ddc052bf21152c5d3292833756bc629f44c9b4..7cc1fae6ff38d64554c38a1839d2dde4c95c2021 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h index 0c6964a3eba05dad04b6ae71566206944df42002..2fa126ea7109488338f2b4f78a2d37ca3caa0b09 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/base_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -74,6 +74,7 @@ public: { deq.erase(deq.begin(), deq.begin() + readySize_); EraseElements(args...); + diskTableSize_ += readySize_; readySize_ = 0; } template @@ -84,6 +85,7 @@ public: public: size_t readySize_ = 0; + size_t diskTableSize_ = 0; }; } // namespace TraceStdtype } // namespace SysTuning diff --git a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.cpp index 7a5d8120e3e2ee276455a5626ba540e15d4d6139..39a5d0a3942591d1556a7081b6f3a7cc5bb26bed 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -81,15 +81,16 @@ const std::string& MetaData::Name(uint64_t row) const } DataIndex DataDict::GetStringIndex(std::string_view str) { +#ifdef SUPPORTTHREAD + std::lock_guard dictLockGuard(mutex_); +#endif auto itor = dataDictInnerMap_.find(str); if (itor != dataDictInnerMap_.end()) { return itor->second; } - mutex_.lock(); dataDict_.emplace_back(std::string(str)); DataIndex stringIdentity = dataDict_.size() - 1; dataDictInnerMap_.emplace(std::string_view(dataDict_.back()), stringIdentity); - mutex_.unlock(); return stringIdentity; } DataIndex DataDict::GetStringIndexNoWrite(std::string_view str) const diff --git a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h index bc598120305f008c14e417fb042d334f99eaa0fe..9c0a8d482a1ddeedff88cd2ed125fa21d46a743b 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/common_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.cpp index 2d474786d17de1b3af32ab860112253a16766fe4..f1e5e8a0694dbfbb43a4802e510e5a15d85ebde4 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -23,7 +23,7 @@ size_t CallStack::AppendInternalAsyncSlice(uint64_t startT, uint16_t nameIdentify, DataIndex name, uint8_t depth, - uint64_t cookid, + int64_t cookid, const std::optional& parentId) { AppendCommonInfo(startT, durationNs, internalTid); @@ -47,7 +47,7 @@ size_t CallStack::AppendInternalSlice(uint64_t startT, AppendCallStack(cat, name, depth, parentId); identifys_.emplace_back(nameIdentify + depth); ids_.emplace_back(id_++); - cookies_.emplace_back(INVALID_UINT64); + cookies_.emplace_back(INVALID_INT64); AppendDistributeInfo(); return Size() - 1; } @@ -158,7 +158,7 @@ const std::deque& CallStack::Depths() const { return depths_; } -const std::deque& CallStack::Cookies() const +const std::deque& CallStack::Cookies() const { return cookies_; } diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.h index 4c79cddac9f000d0d14d9243386546c5bd08d106..15ee4b5e02bdd8327c5c2d8fb49f1ca61ae87157 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/callstack_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -15,6 +15,7 @@ #ifndef CALLSTACK_STDTYPE_H #define CALLSTACK_STDTYPE_H +#include #include "base_stdtype.h" namespace SysTuning { @@ -28,7 +29,7 @@ public: uint16_t nameIdentify, DataIndex name, uint8_t depth, - uint64_t cookid, + int64_t cookid, const std::optional& parentId); size_t AppendInternalSlice(uint64_t startT, uint64_t durationNs, @@ -83,7 +84,7 @@ public: const std::deque& CatsData() const; const std::deque& NamesData() const; const std::deque& Depths() const; - const std::deque& Cookies() const; + const std::deque& Cookies() const; const std::deque& CallIds() const; const std::deque& IdentifysData() const; const std::deque& ChainIds() const; @@ -100,7 +101,7 @@ private: private: std::deque> parentIds_; std::deque cats_ = {}; - std::deque cookies_ = {}; + std::deque cookies_ = {}; std::deque callIds_ = {}; std::deque identifys_ = {}; std::deque names_ = {}; diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.cpp index fa5b708f25fe18276fcfdb1ae39023b8f593d961..9773eb08bc2c96a7fcd2d34b5a2ee0cf1b56a366 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -25,7 +25,7 @@ size_t FrameSlice::AppendFrame(uint64_t ts, uint32_t ipid, uint32_t itid, uint32 callStackIds_.emplace_back(callStackSliceId); endTss_.emplace_back(INVALID_UINT64); dsts_.emplace_back(INVALID_UINT64); - ids_.emplace_back(ids_.size()); + ids_.emplace_back(id_++); durs_.emplace_back(INVALID_UINT64); types_.emplace_back(0); flags_.emplace_back(INVALID_UINT8); @@ -92,14 +92,14 @@ void FrameSlice::SetType(uint64_t row, uint8_t type) } void FrameSlice::SetDst(uint64_t row, uint64_t dst) { - dsts_[row] = dst; + dsts_[row] = diskTableSize_ + dst; } void FrameSlice::SetSrcs(uint64_t row, const std::vector& fromSlices) { std::string s = ""; for (auto&& i : fromSlices) { - s += std::to_string(i) + ","; + s += std::to_string(diskTableSize_ + i) + ","; } s.pop_back(); srcs_[row] = s; @@ -172,6 +172,7 @@ void FrameSlice::Erase(uint64_t row) size_t GPUSlice::AppendNew(uint32_t frameRow, uint64_t dur) { + ids_.emplace_back(id_++); frameRows_.emplace_back(frameRow); durs_.emplace_back(dur); return Size() - 1; @@ -184,17 +185,13 @@ const std::deque& GPUSlice::Durs() const { return durs_; } -size_t GPUSlice::Size() const -{ - return durs_.size(); -} size_t FrameMaps::AppendNew(FrameSlice* frameSlice, uint64_t src, uint64_t dst) { timeStamps_.emplace_back(0); - ids_.emplace_back(ids_.size()); - srcs_.emplace_back(src); - dsts_.emplace_back(dst); + ids_.emplace_back(id_++); + srcs_.emplace_back(frameSlice->diskTableSize_ + src); + dsts_.emplace_back(frameSlice->diskTableSize_ + dst); if (frameSlice->Types().at(dst) == FrameSlice::EXPECT_SLICE) { uint64_t expRsStartTime = frameSlice->TimeStampData().at(dst); uint64_t expUiEndTime = frameSlice->TimeStampData().at(src) + frameSlice->Durs().at(src); diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.h index 1302ec9b61491845387b03e0ceb8304779fcd5d3..7f1731a513c8ed3f422ec91a25b1d48f970c1e88 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/render_service_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -83,15 +83,20 @@ private: const uint8_t flagValue_ = 2; }; -class GPUSlice : public BatchCacheBase { +class GPUSlice : public CacheBase, public BatchCacheBase { public: size_t AppendNew(uint32_t frameRow, uint64_t dur); const std::deque& FrameRows() const; const std::deque& Durs() const; - size_t Size() const; + void Clear() override + { + CacheBase::Clear(); + frameRows_.clear(); + durs_.clear(); + } void ClearExportedData() override { - EraseElements(frameRows_, durs_); + EraseElements(ids_, frameRows_, durs_); } private: @@ -99,11 +104,15 @@ private: std::deque durs_ = {}; }; -class FrameMaps : public CacheBase { +class FrameMaps : public CacheBase, public BatchCacheBase { public: size_t AppendNew(FrameSlice* frameSlice, uint64_t src, uint64_t dst); const std::deque& SrcIndexs() const; const std::deque& DstIndexs() const; + void ClearExportedData() override + { + EraseElements(timeStamps_, ids_, srcs_, dsts_); + } private: std::deque srcs_ = {}; diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.cpp index 4a8d2b26ce32fd404971a5f3e07f8b80a52cda1b..7b00e16cff656faee09b1b90d12eb521e21006df 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -22,6 +22,7 @@ TableRowId ThreadStateData::AppendThreadState(InternalTime ts, InternalTid itid, TableRowId idState) { + ids_.emplace_back(id_++); timeStamps_.emplace_back(ts); durations_.emplace_back(dur); itids_.emplace_back(itid); @@ -30,7 +31,7 @@ TableRowId ThreadStateData::AppendThreadState(InternalTime ts, states_.emplace_back(idState); cpus_.emplace_back(cpu); argSetIds_.emplace_back(INVALID_UINT32); - return itids_.size() - 1; + return Size() - 1; } void ThreadStateData::SetDuration(TableRowId index, InternalTime dur) @@ -122,8 +123,9 @@ size_t SchedSlice::AppendSchedSlice(uint64_t ts, uint64_t cpu, uint32_t internalTid, uint64_t endState, - uint64_t priority) + int32_t priority) { + ids_.emplace_back(id_++); timeStamps_.emplace_back(ts); durs_.emplace_back(dur); cpus_.emplace_back(cpu); diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.h index eaef50ed41aca7522a23659825ab8c4c6b75714c..c206b7c6189e6afc8a3fa838796354dda480962a 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/sched_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -19,7 +19,7 @@ namespace SysTuning { namespace TraceStdtype { -class ThreadStateData : public BatchCacheBase { +class ThreadStateData : public CacheBase, public BatchCacheBase { public: TableRowId AppendThreadState(InternalTime ts, InternalTime dur, InternalCpu cpu, InternalTid itid, TableRowId idState); @@ -32,9 +32,9 @@ public: void UpdateTidAndPid(TableRowId index, InternalTid tid, InternalTid pid); TableRowId UpdateDuration(TableRowId index, InternalTime ts, InternalCpu cpu, TableRowId idState); void SortAllRowByTs(); - void Clear() + void Clear() override { - timeStamps_.clear(); + CacheBase::Clear(); durations_.clear(); itids_.clear(); tids_.clear(); @@ -44,16 +44,7 @@ public: } void ClearExportedData() override { - EraseElements(timeStamps_, durations_, itids_, tids_, pids_, states_, cpus_); - } - uint32_t Size() const - { - return itids_.size(); - } - - const std::deque& TimeStamsData() const - { - return timeStamps_; + EraseElements(ids_, timeStamps_, durations_, itids_, tids_, pids_, states_, cpus_, argSetIds_); } const std::deque& DursData() const { @@ -85,7 +76,6 @@ public: } private: - std::deque timeStamps_; std::deque durations_; std::deque itids_; std::deque tids_; @@ -102,7 +92,7 @@ public: uint64_t cpu, uint32_t internalTid, uint64_t endState, - uint64_t priority); + int32_t priority); void SetDuration(size_t index, uint64_t duration); void Update(uint64_t index, uint64_t ts, uint64_t state); void UpdateEndState(uint64_t index, uint64_t state); @@ -113,7 +103,7 @@ public: return endStates_; } - const std::deque& PriorityData() const + const std::deque& PriorityData() const { return priority_; } @@ -147,14 +137,15 @@ public: } void ClearExportedData() override { - EraseElements(internalTids_, timeStamps_, durs_, cpus_, endStates_, priority_, internalPids_, tsEnds_); + EraseElements(ids_, internalTids_, timeStamps_, durs_, cpus_, endStates_, priority_, internalPids_, tsEnds_, + argSets_); } private: std::deque internalPids_ = {}; std::deque tsEnds_ = {}; std::deque endStates_ = {}; - std::deque priority_ = {}; + std::deque priority_ = {}; std::deque argSets_ = {}; }; class Raw : public CacheBase, public BatchCacheBase { diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.cpp index f99f9d9ce326738ff6359abfb1b5efc192c069a3..4b66c99534f084c686d47777147c2fb6b0aa08c1 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.h index be9a7ab016c68f475c0a788665e0692beddae308..11b187b9440f0416fef138c6f6213a3138f9cb1e 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/syscall_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.cpp index 417a94a203d14f39f70e117aa302719b7ea739f2..7a450aebf8ad80a4ef9b3e1ee99b1825cdcfcab9 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.h index d75eede809dc000afe3ef5fb8f90787a46771007..e2cc79533f8e2a69ff488018ded58b5c33488c66 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/animation_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.cpp index 5e8b29ea2cde7ddf4992f4c8419bc3c21495819f..d9f293f3a01000b4702cc233b89bb40fb2490943 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.h index 6a6af8a21764a8ceecce836cceeeb2751a011b89..560a3417c6fc78dc48ff0cad9cae487bbf39ef20 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/app_startup_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.cpp index b77f04b4319314c3fe88bf4cbca2eed34955a9db..fe465403e22dcd5120c030e2999e2df777eef60a 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -18,7 +18,7 @@ namespace SysTuning { namespace TraceStdtype { size_t TaskPoolInfo::AppendAllocationTaskData(uint32_t allocationTaskRow, uint32_t allocationItid, - uint32_t executeId, + uint64_t taskId, uint32_t priority, uint32_t executeState) { @@ -28,7 +28,7 @@ size_t TaskPoolInfo::AppendAllocationTaskData(uint32_t allocationTaskRow, allocationItids_.emplace_back(allocationItid); executeItids_.emplace_back(INVALID_INT32); returnItids_.emplace_back(INVALID_INT32); - executeIds_.emplace_back(executeId); + taskIds_.emplace_back(taskId); prioritys_.emplace_back(priority); executeStates_.emplace_back(executeState); returnStates_.emplace_back(INVALID_INT32); @@ -36,7 +36,7 @@ size_t TaskPoolInfo::AppendAllocationTaskData(uint32_t allocationTaskRow, ids_.emplace_back(Size()); return Size() - 1; } -size_t TaskPoolInfo::AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t executeItid, uint32_t executeId) +size_t TaskPoolInfo::AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t executeItid, uint64_t taskId) { allocationTaskRows_.emplace_back(INVALID_INT32); executeTaskRows_.emplace_back(executeTaskRow); @@ -44,7 +44,7 @@ size_t TaskPoolInfo::AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t exe allocationItids_.emplace_back(INVALID_INT32); executeItids_.emplace_back(executeItid); returnItids_.emplace_back(INVALID_INT32); - executeIds_.emplace_back(executeId); + taskIds_.emplace_back(taskId); prioritys_.emplace_back(INVALID_INT32); executeStates_.emplace_back(INVALID_INT32); returnStates_.emplace_back(INVALID_INT32); @@ -54,7 +54,7 @@ size_t TaskPoolInfo::AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t exe } size_t TaskPoolInfo::AppendReturnTaskData(uint32_t returnTaskRow, uint32_t returnItid, - uint32_t executeId, + uint64_t taskId, uint32_t returnState) { allocationTaskRows_.emplace_back(INVALID_INT32); @@ -63,7 +63,7 @@ size_t TaskPoolInfo::AppendReturnTaskData(uint32_t returnTaskRow, allocationItids_.emplace_back(INVALID_INT32); executeItids_.emplace_back(INVALID_INT32); returnItids_.emplace_back(returnItid); - executeIds_.emplace_back(executeId); + taskIds_.emplace_back(taskId); prioritys_.emplace_back(INVALID_INT32); executeStates_.emplace_back(INVALID_INT32); returnStates_.emplace_back(returnState); @@ -95,9 +95,9 @@ const std::deque& TaskPoolInfo::ReturnItids() const { return returnItids_; } -const std::deque& TaskPoolInfo::ExecuteIds() const +const std::deque& TaskPoolInfo::TaskIds() const { - return executeIds_; + return taskIds_; } const std::deque& TaskPoolInfo::Prioritys() const { @@ -128,7 +128,7 @@ void TaskPoolInfo::UpdateAllocationTaskData(uint32_t index, executeStates_[index] = executeState; } } -void TaskPoolInfo::UpdateExecuteTaskData(uint32_t index, uint32_t executeTaskRow, uint32_t executeItid) +void TaskPoolInfo::UpdateExecuteTaskData(uint32_t index, uint32_t executeTaskRow, uint64_t executeItid) { if (index <= Size()) { executeTaskRows_[index] = executeTaskRow; diff --git a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.h index 2c139209056c9ed2aef7218b56a442b6a43cdeb8..9304c16956846b62bd19b8b0090fd53f2cbd1a75 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/ftrace/template/task_pool_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -23,17 +23,17 @@ class TaskPoolInfo : public CacheBase { public: size_t AppendAllocationTaskData(uint32_t allocationTaskRow, uint32_t allocationItid, - uint32_t executeId, + uint64_t taskIds, uint32_t priority, uint32_t executeState); - size_t AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t executeItid, uint32_t executeId); - size_t AppendReturnTaskData(uint32_t returnTaskRow, uint32_t returnItid, uint32_t executeId, uint32_t returnState); + size_t AppendExecuteTaskData(uint32_t executeTaskRow, uint32_t executeItid, uint64_t taskIds); + size_t AppendReturnTaskData(uint32_t returnTaskRow, uint32_t returnItid, uint64_t taskIds, uint32_t returnState); void UpdateAllocationTaskData(uint32_t index, uint32_t allocationTaskRow, uint32_t allocationItid, uint32_t priority, uint32_t executeState); - void UpdateExecuteTaskData(uint32_t index, uint32_t executeTaskRow, uint32_t executeItid); + void UpdateExecuteTaskData(uint32_t index, uint32_t executeTaskRow, uint64_t executeItid); void UpdateReturnTaskData(uint32_t index, uint32_t returnTaskRow, uint32_t returnItid, uint32_t returnState); void AppendTimeoutRow(uint32_t index, uint32_t timeoutRow); @@ -43,7 +43,7 @@ public: const std::deque& AllocationItids() const; const std::deque& ExecuteItids() const; const std::deque& ReturnItids() const; - const std::deque& ExecuteIds() const; + const std::deque& TaskIds() const; const std::deque& Prioritys() const; const std::deque& ExecuteStates() const; const std::deque& ReturnStates() const; @@ -57,7 +57,7 @@ public: allocationItids_.clear(); executeItids_.clear(); returnItids_.clear(); - executeIds_.clear(); + taskIds_.clear(); prioritys_.clear(); executeStates_.clear(); returnStates_.clear(); @@ -71,7 +71,7 @@ private: std::deque allocationItids_ = {}; std::deque executeItids_ = {}; std::deque returnItids_ = {}; - std::deque executeIds_ = {}; + std::deque taskIds_ = {}; std::deque prioritys_ = {}; std::deque executeStates_ = {}; std::deque returnStates_ = {}; diff --git a/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.cpp index 7a81bc8fb95ec740285a8177ca1630e47560e4ea..57c21e9c3e9a171c89085aaf301e36896524dd41 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.h index fddcd9ab67e4b29ce8683771c5379d9b8cd2f8fa..2e32830f886fa5488da30b5a10f72cb1d8a044a8 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/hilog/hilog_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.cpp index f1ce914216ab840641fd0a4fa741605d7f39128a..40e6d2cf0520641fb17de7b69cc1407394ca693c 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.h index cd6c9ab13b0cbdff5b0f76c4cc523d275b764fa1..c35aa3268e29c44fd798f779443a4afba7e0a98a 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/hiperf/hiperf_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.cpp index 262b1d2c6273b07d4c65c7acfaa2efa19a989407..9f53f5131f0b23e3fa8a3266be4c36ea408f2493 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.h index ba5a7dcc728ddaaa113e54faae937cbdc2875108..59db7a80c98c6aff206197d94cc9b6b016837e78 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/hisysevent/hisysevent_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.cpp index 01dc146c693ace92003d7990a7b6877f9e93c1e8..48f7454cf2cdfc34967bd12b1e62aab216c3614b 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.h index 571b2c21e6a5d0273abc15022e4f2b9a075dee2f..74bbf01c6f3d09165c215b1f2c9ea58ebdc3dbfb 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/activity_monitor_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.cpp index f58d25552633ae13b3fb7735377417fa8c740313..4b99b52c4134f5018811decb55fd38ca1b13b1f8 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.h index ad0ac3fd8efd0423e638b0fa75613a419471c725..0678d3954f54d2b5e26356961e620c2b98a1ac83 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/arkts_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.cpp index 387c2315db81f9ee8a9b72da281a2bb1dd1054d9..35c05be183c44affce3df786d4b641129a6fea1b 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.h index a02dcbc2448c96e6a8424b9918043c37a1074683..567d5ddd279aa3576dbf17bb85fe6587d27e4976 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/ebpf_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.cpp index 854585a44b74ef7c71c7d5e2c2ef51c747abdcde..32238bfc2dee9a92381c2c170be0567e41e47a36 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -168,7 +168,8 @@ size_t NativeHookFrame::AppendNewNativeHookFrame(uint32_t callChainId, DataIndex filePath, uint64_t offset, uint64_t symbolOffset, - const std::string& vaddr) + const std::string& vaddr, + uint32_t realStack) { callChainIds_.emplace_back(callChainId); ips_.emplace_back(ip); @@ -178,6 +179,7 @@ size_t NativeHookFrame::AppendNewNativeHookFrame(uint32_t callChainId, offsets_.emplace_back(offset); symbolOffsets_.emplace_back(symbolOffset); vaddrs_.emplace_back(vaddr); + realStack_.emplace_back(realStack); return Size() - 1; } size_t NativeHookFrame::AppendNewNativeHookFrame(uint32_t callChainId, @@ -186,7 +188,8 @@ size_t NativeHookFrame::AppendNewNativeHookFrame(uint32_t callChainId, DataIndex symbolName, DataIndex filePath, uint64_t offset, - uint64_t symbolOffset) + uint64_t symbolOffset, + uint32_t realStack) { callChainIds_.emplace_back(callChainId); ips_.emplace_back(ip); @@ -195,6 +198,7 @@ size_t NativeHookFrame::AppendNewNativeHookFrame(uint32_t callChainId, filePaths_.emplace_back(filePath); offsets_.emplace_back(offset); symbolOffsets_.emplace_back(symbolOffset); + realStack_.emplace_back(realStack); return Size() - 1; } void NativeHookFrame::UpdateSymbolIdToNameMap(uint64_t originSymbolId, uint64_t symbolId) @@ -283,6 +287,10 @@ const std::deque& NativeHookFrame::Vaddrs() const { return vaddrs_; } +const std::deque& NativeHookFrame::realStack() const +{ + return realStack_; +} size_t NativeHookStatistic::AppendNewNativeHookStatistic(uint32_t ipid, uint64_t timeStamp, diff --git a/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.h index 5eb20de262a4fa790bb86cdce225677dd4625845..d802ed89d6af97fd4476942f1d2b9690ee621db0 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/htrace/native_memory_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -127,7 +127,8 @@ public: DataIndex symbolName, DataIndex filePath, uint64_t offset, - uint64_t symbolOffset); + uint64_t symbolOffset, + uint32_t realStack = 1); size_t AppendNewNativeHookFrame(uint32_t callChainId, uint16_t depth, uint64_t ip, @@ -135,7 +136,8 @@ public: DataIndex filePath, uint64_t offset, uint64_t symbolOffset, - const std::string& vaddr); + const std::string& vaddr, + uint32_t realStack = 1); void UpdateFrameInfo(size_t row, DataIndex symbolIndex, DataIndex filePathIndex, @@ -154,6 +156,7 @@ public: const std::deque& Offsets() const; const std::deque& SymbolOffsets() const; const std::deque& Vaddrs() const; + const std::deque& realStack() const; size_t Size() const { return callChainIds_.size(); @@ -168,6 +171,7 @@ public: offsets_.clear(); symbolOffsets_.clear(); vaddrs_.clear(); + realStack_.clear(); } private: @@ -179,6 +183,7 @@ private: std::deque offsets_ = {}; std::deque symbolOffsets_ = {}; std::deque vaddrs_ = {}; + std::deque realStack_ = {}; std::map symbolIdToSymbolName_ = {}; }; diff --git a/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.cpp b/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.cpp index 332b6641ca1f0316332a4c207c9d70c3c1b8b7a8..0d54cba9150c9c0a3b6fc01ad8a9a8a6e290604d 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.cpp +++ b/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.h b/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.h index 73a2ee542ad7a30a93cfa1029c3dc184d71a6eb4..507228ea48e1fdeb21226cebfeea3f3fb651743f 100644 --- a/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.h +++ b/trace_streamer/src/trace_data/trace_stdtype/measure/measure_stdtype.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -179,7 +179,7 @@ public: } void ClearExportedData() override { - EraseElements(internalTids_, ids_, internalPids_, names_); + EraseElements(ids_, internalPids_, names_); } private: diff --git a/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp b/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp index faaddbcaa0f84265d659751ab43c58170f3f5282..5a0c54353e27231c507fc522e9cccb03d8bbf23e 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp +++ b/trace_streamer/src/trace_streamer/trace_streamer_filters.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -42,7 +42,6 @@ void TraceStreamerFilters::FilterClear() sliceFilter_->Clear(); cpuFilter_->Clear(); irqFilter_->Clear(); - binderFilter_->Clear(); frameFilter_->Clear(); } } // namespace TraceStreamer diff --git a/trace_streamer/src/trace_streamer/trace_streamer_filters.h b/trace_streamer/src/trace_streamer/trace_streamer_filters.h index 50e275cb7b2e685116620eb9ae5f14b04246dcca..828b4fdbc758731e0efda6fb324d5bef24b277bd 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_filters.h +++ b/trace_streamer/src/trace_streamer/trace_streamer_filters.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp index 39620f0c8d7cec626aba50edc2fd0460519d5204..ea83a646d7e1589f2d5a145447c22fa78e063ce9 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -138,7 +138,6 @@ void TraceStreamerSelector::InitFilter() streamFilters_->processFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); streamFilters_->clockFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); streamFilters_->filterFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); - streamFilters_->cpuMeasureFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get(), E_CPU_MEASURE_FILTER); streamFilters_->processMeasureFilter_ = @@ -225,6 +224,7 @@ bool TraceStreamerSelector::BatchParseTraceDataSegment(std::unique_ptr(traceDataCache_.get(), streamFilters_.get()); + htraceParser_->EnableOnlyParseFtrace(); } htraceParser_->ParseTraceDataSegment(std::move(data), size); return true; @@ -423,35 +423,31 @@ void TraceStreamerSelector::UpdateAppStartTraceStatus(bool status) { traceDataCache_->UpdateAppStartTraceStatus(status); } +void TraceStreamerSelector::UpdateHMKernelTraceStatus(bool status) +{ + traceDataCache_->UpdateHMKernelTraceStatus(status); +} bool TraceStreamerSelector::LoadQueryFile(const std::string& sqlOperator, std::vector& sqlStrings) { - auto fd = fopen(sqlOperator.c_str(), "r"); - if (!fd) { + std::ifstream file(sqlOperator); + if (!file.is_open()) { TS_LOGE("open file failed!"); - return false; } - char buffer[CHUNK_SIZE]; - while (!feof(fd)) { - std::string sqlString; - while (fgets(buffer, sizeof(buffer), fd)) { - std::string line = buffer; - if (line == "\n" || line == "\r\n") { - break; + std::string sqlString; + std::string line; + while (std::getline(file, line)) { + sqlString += line; + } + if (!sqlString.empty()) { + auto strVec = SplitStringToVec(sqlString, ";"); + for (auto str : strVec) { + auto result = TrimInvisibleCharacters(str); + if (!result.empty()) { + sqlStrings.push_back(result); } - sqlString.append(buffer); - - if (EndWith(line, ";") || EndWith(line, ";\r\n")) { - break; - } - } - - if (sqlString.empty()) { - continue; } - sqlStrings.push_back(sqlString); } - (void)fclose(fd); - fd = nullptr; + file.close(); return true; } bool TraceStreamerSelector::ReadSqlFileAndPrintResult(const std::string& sqlOperator) diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.h b/trace_streamer/src/trace_streamer/trace_streamer_selector.h index 80ec91d0f50b55354c79fd4804ac5244a1c0e197..48d2a5847845da1bec49ac27b837cd77a375e767 100644 --- a/trace_streamer/src/trace_streamer/trace_streamer_selector.h +++ b/trace_streamer/src/trace_streamer/trace_streamer_selector.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -62,12 +62,17 @@ public: void UpdateTaskPoolTraceStatus(bool status); void UpdateAppStartTraceStatus(bool status); void UpdateBinderRunnableTraceStatus(bool status); + void UpdateHMKernelTraceStatus(bool status); void InitMetricsMap(std::map& metricsMap); const std::string MetricsSqlQuery(const std::string& metrics); auto GetBytraceData() { return bytraceParser_.get(); } + auto GetRawtraceData() + { + return rawTraceParser_.get(); + } auto GetHtraceData() { return htraceParser_.get(); diff --git a/trace_streamer/src/version.cpp b/trace_streamer/src/version.cpp index 851dacdf154972b439e0b4853014043b6f688297..b093b5ca30f047aa18b52ead0dc48af1164ce7ba 100644 --- a/trace_streamer/src/version.cpp +++ b/trace_streamer/src/version.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -17,7 +17,7 @@ namespace SysTuning { namespace TraceStreamer { size_t g_loadSize = 0; size_t g_fileSize = 0; -const std::string g_traceStreamerVersion = "3.5.19"; // version -const std::string g_traceStreamerPublishVersion = "2024/01/13"; // publish datetime +const std::string g_traceStreamerVersion = "4.0.2"; // version +const std::string g_traceStreamerPublishVersion = "2024/02/29"; // publish datetime } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/version.h b/trace_streamer/src/version.h index cfb0bcf64432ff608cad256281000b2a9b5d2764..a895195130bbb72bcb0312752ab43764241ee3c2 100644 --- a/trace_streamer/src/version.h +++ b/trace_streamer/src/version.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/test.sh b/trace_streamer/test.sh index 3ecc3a132dc9e7084dd0db3289cb6baf1aa0838f..75129822525d94d7a915c24c54b173edd5e89245 100755 --- a/trace_streamer/test.sh +++ b/trace_streamer/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/test/BUILD.gn b/trace_streamer/test/BUILD.gn index 27d3b37553f6bbdef74eac1fc86651d467186161..aa991ea240eee8b016198f4c39b24a5858b222e8 100644 --- a/trace_streamer/test/BUILD.gn +++ b/trace_streamer/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -117,7 +117,6 @@ if (is_test) { "../src/proto_reader", "../src/proto_reader/include", "../src/table/base/include", - "../prebuilts/emsdk/emsdk/emscripten/system/include", "..", "unittest/base", "${THIRD_PARTY}/googletest/googletest/include/gtest", diff --git a/trace_streamer/test/press_test.sh b/trace_streamer/test/press_test.sh index b9551a4688a43a6c2afb6e0e27393d6093775171..087a3a6073e1dd27db71f33245951d66a226aafa 100755 --- a/trace_streamer/test/press_test.sh +++ b/trace_streamer/test/press_test.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 diff --git a/trace_streamer/test/test_fuzzer/README.md b/trace_streamer/test/test_fuzzer/README.md index bbb57beec4db2bdf6f6b52c9271cd32f5f9d381e..33af7bc13d726e4de50036106fa6e819b3cf0110 100644 --- a/trace_streamer/test/test_fuzzer/README.md +++ b/trace_streamer/test/test_fuzzer/README.md @@ -1,37 +1,3 @@ -# Hi3516烧录OH2代码 - 1. 连接串口线, USB和网线。 - 2. 使用HiTool工具加载并烧写OH2代码编译镜像。 - 镜像路径: OH2_TOOL\out\ohos-arm-release\packages\phone\images\Hi3516DV300-emmc.xml - 3. 在新烧录好的开发板配置网络信息。 - 配置IP: ifconfig eth0 xxx.xxx.xxx.xxx - 配置子网掩码: ifconfig eth0 xxx.xxx.xxx.xxx netmask 255.255.255.0 - 分配hdcd端口: hdcd -t & - 查看端口: netstat -nat - -# 编译FUZZ测试二进制文件 - 1. 修改OH2_TOOL/developtools/profiler/ohos.build - 在testlist中添加:"//developtools/profiler/trace_analyzer/test:fuzztest" - 2. 启动测试shell。 - cd OH2_TOOL - ./test/developertest/start.sh 根据输出提示选择 hi3516DV300对应的数字。 - 3. 编译可执行程序。 - run -t FUZZ -ss developtools -ts hiprofiler_ts_bytrace_fuzz_test - run -t FUZZ -ss developtools -ts hiprofiler_ts_htrace_fuzz_test - run -t FUZZ -ss developtools -ts hiprofiler_ts_selector_fuzz_test - 生成可执行文件路径: OH2_TOOL/out/ohos-arm-release/packages/phone/tests/fuzztest/hiprofiler/ts_fuzz/ - -# 准备FUZZ测试环境 - 1. 使用hdc工具将上一步生成的可执行程序上传到开发板指定目录。 - 例如: hdc_std file send hiprofiler_ts_htrace_fuzz_test /data/local/tmp/FuzzTest - 添加执行权限 chmod +x hiprofiler_ts_htrace_fuzz_test - 2. 上传动态库。 - 代码目录下查询以下动态库, 并上传到开发板/system/lib目录。 - libsqlite.z.so - libcrypto.so - libssl.z.so - libcrypto.z.so - libgrpc.z.so - # 执行FUZZ测试用例 cd /data/local/tmp/FuzzTest ./hiprofiler_ts_bytrace_fuzz_test -max_total_time=20 @@ -39,11 +5,6 @@ ./hiprofiler_ts_selector_fuzz_test -max_total_time=20 # 可能遇到的问题 - 1. 开发板启动失败,重启开发板,进入uboot中配置启动参数。 - setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused androidboot.selinux=permissive skip_initramfs rootdelay=10 init=/init root=/dev/mmcblk0p5 rootfstype=ext4 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),1M(misc),3307M(system),256M(vendor),-(userdata)' - setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800; bootm 0x80000000"; - save - reset - 2. 执行测试用例过程中报“cannot merge previous GCDA ”。 - 在开发板上进入OH2_TOOL目录,执行以下命令: + 1. 执行测试用例过程中报“cannot merge previous GCDA ”。 + 在开发板上进入代码根目录,执行以下命令: find . -name "*.gcda" -print0 | xargs -0 rm diff --git a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/BUILD.gn b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/BUILD.gn index 453a3984d39bf05e9bf824360f18a95255958833..c5bbf59846514906f4aeb63d42c19f9ce8b70a39 100644 --- a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/BUILD.gn +++ b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # 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 @@ -30,9 +30,21 @@ ohos_fuzztest("ts_bytrace_fuzz_test") { "../../../src/proto_reader/include", "../../../src/parser/bytrace_parser", "../../../src/cfg", + "../../../src/metrics", "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/protobuf/src", "${THIRD_PARTY}/bounds_checking_function/include", + "${THIRD_PARTY}/json/single_include/nlohmann", + ] + include_dirs += [ + "${TRACE_STDTYPE}", + "${TRACE_STDTYPE}/ftrace", + "${TRACE_STDTYPE}/ftrace/template", + "${TRACE_STDTYPE}/hilog", + "${TRACE_STDTYPE}/hiperf", + "${TRACE_STDTYPE}/hisysevent", + "${TRACE_STDTYPE}/htrace", + "${TRACE_STDTYPE}/measure", ] cflags = [ "-g", diff --git a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.cpp b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.cpp index eaf6ad5fac31c7f25ca9baf0f0f2ba4a4e9afb71..bdea98b66a43966951166407acc0ba544d800b06 100644 --- a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.cpp +++ b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.cpp @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, @@ -32,11 +32,11 @@ bool BytraceParserFuzzTest(const uint8_t* data, size_t size) TraceStreamerSelector stream_ = {}; stream_.SetDataType(TRACE_FILETYPE_BY_TRACE); std::unique_ptr buf = std::make_unique(size); - if ((void)memcpy_s(buf.get(), size, data, size)) { + if (memcpy_s(buf.get(), size, data, size) != EOK) { return false; } stream_.SetCleanMode(true); - stream_.ParseTraceDataSegment(std::move(buf), size); + stream_.ParseTraceDataSegment(std::move(buf), size, false, false); stream_.WaitForParserEnd(); return true; } diff --git a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.h b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.h index 39b435f1c56eaf1de1c0c58c3b3cd866876eecee..b682e15bb927516b3b15ab76dc8a6f6cfdb4eb4e 100644 --- a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.h +++ b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/bytrace_fuzzer.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. * 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 + * 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, diff --git a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/project.xml b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/project.xml index 85e7ef2c1cc6471e288306f6e3dcea5287a78b0e..21d96a22a4b0f69077b620a05c18e2033e056654 100644 --- a/trace_streamer/test/test_fuzzer/bytrace_fuzzer/project.xml +++ b/trace_streamer/test/test_fuzzer/bytrace_fuzzer/project.xml @@ -1,5 +1,5 @@ -