diff --git a/ide/README_zh.md b/ide/README_zh.md index 73bb46757b4df10b7140eceb9a44911f114f62dc..c0c03824a0834f5507d0c2f217f44ed37094fd25 100644 --- a/ide/README_zh.md +++ b/ide/README_zh.md @@ -65,7 +65,7 @@ ``` ![](./src/figures/deploy/yum_install_go.png) -- windows 系统下 从 https://golang.google.cn/dl/ 下载安装包, 一路next 完成 安装即可 +- windows 系统下 从官网下载安装包, 一路next 完成 安装即可 - 安装完成后 命令行运行验证是否安装成功 diff --git a/ide/package.json b/ide/package.json index 668e537afe246a354deda13f3d599c0444c1bc15..c7d383b78a8d0f9a941ee5c74d87ce914d096192 100644 --- a/ide/package.json +++ b/ide/package.json @@ -53,7 +53,6 @@ "@babel/plugin-proposal-decorators": "^7.17.2", "@babel/preset-env": "^7.23.2", "@babel/preset-typescript": "*", - "@types/google-protobuf": "^3.15.9", "@types/jest": "*", "@types/node": "^17.0.10", "typescript": "^5.2.2", 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/LitSelect.ts b/ide/src/base-ui/select/LitSelect.ts index e72abac21b246ba665337ec73fad7a3661171ab0..1f46499e1f710b62bba128e2074c0af65b8e10c2 100644 --- a/ide/src/base-ui/select/LitSelect.ts +++ b/ide/src/base-ui/select/LitSelect.ts @@ -15,11 +15,15 @@ import { BaseElement, element } from '../BaseElement'; import { selectHtmlStr } from './LitSelectHtml'; +import { LitSelectOption } from './LitSelectOption'; @element('lit-select') export class LitSelect extends BaseElement { private focused: any; private selectInputEl: any; + private selectSearchInputEl: HTMLInputElement | null | undefined; + private selectOptions: HTMLDivElement | null | undefined; + private selectItem: string = ''; private selectClearEl: any; private selectIconEl: any; private bodyEl: any; @@ -38,6 +42,7 @@ export class LitSelect extends BaseElement { 'list-height', 'border', 'mode', + 'showSearchInput', ]; } @@ -140,19 +145,72 @@ export class LitSelect extends BaseElement { } } + get showSearchInput() { + return this.hasAttribute('showSearchInput'); + } + + set showSearchInput(isHide: boolean) { + if (isHide) { + this.setAttribute('showSearchInput', ''); + } else { + this.removeAttribute('showSearchInput'); + } + } + + set showItem(item: string) { + this.selectItem = item; + } + set dataSource(selectDataSource: any) { - selectDataSource.forEach((dateSourceBean: any) => { - let selectOption = document.createElement('lit-select-option'); - if (dateSourceBean.name) { - selectOption.textContent = dateSourceBean.name; - selectOption.setAttribute('value', dateSourceBean.name); - } - this.append(selectOption); - }); - this.initOptions(); + + this.innerHTML = ``; + if (selectDataSource.length > 0) { + this.bodyEl!.style.display = 'flex'; + this.querySelectorAll('lit-select-option').forEach((a) => this.removeChild(a)); + selectDataSource.forEach((dateSourceBean: any) => { + let selectOption = document.createElement('lit-select-option'); + if (dateSourceBean.name) { + selectOption.textContent = dateSourceBean.name; + selectOption.setAttribute('value', dateSourceBean.name); + } else if (dateSourceBean) { + selectOption.textContent = dateSourceBean; + selectOption.setAttribute('value', dateSourceBean); + if ( + this.selectItem !== '' && + this.selectItem === this.value && + this.selectItem === selectOption.textContent + ) { + selectOption.setAttribute('selected', ''); + } + this.selectInputEl!.value = ''; + } + this.append(selectOption); + }); + this.initOptions(); + } else { + this.bodyEl!.style.display = 'none'; + } } - initElements(): void {} + initElements(): void { + if (this.showSearchInput) { + this.shadowRoot!.querySelector('.body-select')!.style.display = 'block'; + this.selectSearchInputEl = this.shadowRoot!.querySelector('#search-input') as HTMLInputElement; + this.selectSearchInputEl?.addEventListener('keyup', (evt) => { + let options = []; + options = [...this.querySelectorAll('lit-select-option')]; + options.filter((a: LitSelectOption) => { + if (a.textContent!.indexOf(this.selectSearchInputEl!.value) <= -1) { + a.style.display = 'none'; + } else { + a.style.display = 'flex'; + } + }); + evt.preventDefault(); + evt.stopPropagation(); + }); + } + } initHtml() { return ` @@ -168,8 +226,13 @@ export class LitSelect extends BaseElement {
- - + +
+ + +
`; } @@ -214,6 +277,7 @@ export class LitSelect extends BaseElement { this.selectIconEl = this.shadowRoot!.querySelector('.icon'); this.selectSearchEl = this.shadowRoot!.querySelector('.search'); this.selectMultipleRootEl = this.shadowRoot!.querySelector('.multipleRoot'); + this.selectOptions = this.shadowRoot!.querySelector('.body-opt') as HTMLDivElement; this.setEventClick(); this.setEvent(); this.selectInputEl.onblur = (ev: any) => { @@ -238,14 +302,14 @@ export class LitSelect extends BaseElement { this.setOnkeydown(); } - setOninput():void{ + setOninput(): void { this.selectInputEl.oninput = (ev: any) => { let els: Element[] = [...this.querySelectorAll('lit-select-option')]; if (this.hasAttribute('show-search')) { if (!ev.target.value) { els.forEach((a: any) => (a.style.display = 'flex')); } else { - this.setSelectItem(els,ev) + this.setSelectItem(els, ev); } } else { this.value = ev.target.value; @@ -253,7 +317,7 @@ export class LitSelect extends BaseElement { }; } - setSelectItem(els:Element[],ev:any):void{ + setSelectItem(els: Element[], ev: any): void { els.forEach((a: any) => { let value = a.getAttribute('value'); if ( @@ -267,7 +331,7 @@ export class LitSelect extends BaseElement { }); } - setEventClick():void{ + setEventClick(): void { this.selectClearEl.onclick = (ev: any) => { if (this.isMultiple()) { let delNodes: Array = []; @@ -298,17 +362,15 @@ export class LitSelect extends BaseElement { if (this.focused === false) { this.selectInputEl.focus(); this.focused = true; - this.bodyEl!.style.display = 'block'; + this.bodyEl!.style.display = 'flex'; } else { - this.blur(); - this.bodyEl!.style.display = 'none'; this.focused = false; } } }; } - setEvent():void{ + setEvent(): void { this.onmouseover = this.onfocus = (ev) => { if (this.focused === false && this.hasAttribute('adaptive-expansion')) { if (this.parentElement!.offsetTop < this.bodyEl!.clientHeight) { @@ -351,7 +413,7 @@ export class LitSelect extends BaseElement { }; } - setOnkeydown():void{ + setOnkeydown(): void { this.selectInputEl.onkeydown = (ev: any) => { if (ev.key === 'Backspace') { if (this.isMultiple()) { @@ -422,7 +484,7 @@ export class LitSelect extends BaseElement { }); } - onSelectedEvent(a:Element):void{ + onSelectedEvent(a: Element): void { a.addEventListener('onSelected', (e: any) => { if (this.isMultiple()) { if (a.hasAttribute('selected')) { @@ -454,6 +516,7 @@ export class LitSelect extends BaseElement { a.removeAttribute('selected'); } else { a.setAttribute('selected', ''); + this.selectItem = a.textContent!; } // @ts-ignore this.value = e.detail.value; diff --git a/ide/src/base-ui/select/LitSelectHtml.ts b/ide/src/base-ui/select/LitSelectHtml.ts index dad54d68e4f5801f8e2150c9c81fe5a8d60880ba..785ebaa12f57fa1d560dee38b7529ca21feabc04 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 = ` `; export const selectHtmlStr = (height: string): string => { - listHeight = height; - return css; + return replacePlaceholders(css, height); }; export const selectVHtmlStr = ` diff --git a/ide/src/base-ui/select/LitSelectOption.ts b/ide/src/base-ui/select/LitSelectOption.ts index de6345c0978a329c62e314007d8ccde251e57ca6..a9f58c3c1894923540e30e5ce1ade902d9f41326 100644 --- a/ide/src/base-ui/select/LitSelectOption.ts +++ b/ide/src/base-ui/select/LitSelectOption.ts @@ -16,7 +16,7 @@ import { BaseElement } from '../BaseElement'; import '../icon/LitIcon'; -const initHtmlStyle:string = ` +const initHtmlStyle: string = ` `; 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..f5c3b9157c35cfade89094144976d9f1e76e40aa 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); } } } @@ -335,7 +344,6 @@ export class LitTable extends HTMLElement { } this.theadElement!.innerHTML = ''; this.theadElement!.append(rowElement); - this.treeElement!.style.top = this.theadElement?.clientHeight + 'px'; }); }); this.shadowRoot!.addEventListener('load', function (event) {}); @@ -384,7 +392,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 +464,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 +520,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 +564,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 +639,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 +689,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 +699,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 +727,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 +743,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 +769,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 +787,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 +807,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 +816,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 +919,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 +933,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 +978,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 +1006,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 +1047,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 +1088,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 +1178,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 +1230,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 +1242,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 +1348,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 +1387,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 +1404,7 @@ export class LitTable extends HTMLElement { composed: true, }) ); + e.stopPropagation(); }; } @@ -1395,7 +1433,11 @@ export class LitTable extends HTMLElement { ); (child as HTMLElement).title = text; } else { - (child as HTMLElement).innerHTML = text; + if (rowObject.data.rowName === 'cpu-profiler' && dataIndex === 'symbolName') { + (child as HTMLElement).innerHTML = ''; + } else { + (child as HTMLElement).innerHTML = text; + } if (dataIndex === 'selfTimeStr' && rowObject.data.chartFrameChildren) { (child as HTMLElement).title = rowObject.data.selfTime + 'ns'; } else if (dataIndex === 'totalTimeStr' && rowObject.data.chartFrameChildren) { @@ -1425,10 +1467,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 +1535,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 +1549,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 +1758,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/CSVFormater.ts b/ide/src/base-ui/utils/CSVFormater.ts index d91d718ab31e2db4c3664ff6ffffd62dde8766dd..3b23a86ad6dc4ab29089816df1e3684863a222f5 100644 --- a/ide/src/base-ui/utils/CSVFormater.ts +++ b/ide/src/base-ui/utils/CSVFormater.ts @@ -143,14 +143,6 @@ export class JSONToCSV { ? (type.ie = has[1]) : (has = agent.match(/msie ([\d.]+)/)) ? (type.ie = has[1]) - : (has = agent.match(/firefox\/([\d.]+)/)) - ? (type.firefox = has[1]) - : (has = agent.match(/chrome\/([\d.]+)/)) - ? (type.chrome = has[1]) - : (has = agent.match(/opera.([\d.]+)/)) - ? (type.opera = has[1]) - : (has = agent.match(/version\/([\d.]+).*safari/)) - ? (type.safari = has[1]) : 0; return type; } 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/command/Cmd.ts b/ide/src/command/Cmd.ts index f1ab49b978671e794e0443d2669a189639689dff..94a9417f3f77f14a7f9111fc5f724759f21b9b21 100644 --- a/ide/src/command/Cmd.ts +++ b/ide/src/command/Cmd.ts @@ -196,6 +196,13 @@ export class Cmd { } return processData; } + static convertOutPackageList(res: string): string[] { + let packageData: string[] = []; + res ? (packageData = res.replace(/\r\n/g, '\r').replace(/\n\t/g, '\r').split(/\r/)) : []; + packageData.shift(); + return packageData; + } + static getDebugProcess(): Promise { return new Promise((resolve, reject) => { if (SpRecordTrace.isVscode) { @@ -237,4 +244,17 @@ export class Cmd { } }); } + static getPackage(): Promise { + return new Promise((resolve, reject) => { + HdcDeviceManager.connect(SpRecordTrace.serialNumber).then((conn) => { + if (conn) { + HdcDeviceManager.shellResultAsString(CmdConstant.CMD_GET_PACKAGE, false).then((res) => { + resolve(Cmd.convertOutPackageList(res)); + }); + } else { + reject(-1); + } + }); + }); + } } diff --git a/ide/src/command/CmdConstant.ts b/ide/src/command/CmdConstant.ts index 9cd1d05e0c3c0d2f9314dd4516c70eba516638cb..b4d63aef1541478e27225b3ed5b57b2b57f1dfa0 100644 --- a/ide/src/command/CmdConstant.ts +++ b/ide/src/command/CmdConstant.ts @@ -17,6 +17,7 @@ export class CmdConstant { static CMD_TRACE_FILE_SIZE = 'hdc_std shell stat --format=%s '; static CMD_SHELL = 'hdc_std shell '; static CMD_MOUNT = 'hdc_std shell mount -o remount,rw /'; + static CMD_GET_PACKAGE = 'hdc_std shell bm dump -a'; static CMD_GET_PROCESS = 'hdc_std shell ps -A -opid,cmd'; static CMD_GET_APP_NMAE = 'hdc_std shell ps -A -ocmd'; static CMD_GET_CPU_COUNT = "hdc_std shell grep -c 'processor' /proc/cpuinfo"; 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..9a9b440c04a64c60f53c7c2708c29b23e1838630 100644 --- a/ide/src/doc/md/quickstart_parsing_ability.md +++ b/ide/src/doc/md/quickstart_parsing_ability.md @@ -28,8 +28,7 @@ Trace 解析能力增强主要是提高 Trace 的解析能力。 ##### 配置完成后, 查看【用户配置路径】是否是配置的路径 - edge浏览器: edge://version/ - chrome浏览器: chrome://version/ + edge浏览器: edge://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/doc/quickstart_parsing_ability.html b/ide/src/doc/quickstart_parsing_ability.html index cfc00fe07cdb28bd1e79c7ee7bbe37773324c22e..9bf2e25aca33a9c0c6f3dfd9de7d70c9f47014c3 100644 --- a/ide/src/doc/quickstart_parsing_ability.html +++ b/ide/src/doc/quickstart_parsing_ability.html @@ -829,7 +829,6 @@ D:\deskTop\msedge.exe.lnk --user-data-dir=D:\Edgedata
         edge浏览器:     edge://version/
        -chrome浏览器: chrome://version/
         

        超大trace抓取配置说明

        diff --git a/ide/src/doc/quickstart_smartperflinux_compile_guide.html b/ide/src/doc/quickstart_smartperflinux_compile_guide.html index 33ef905f5a53a27b1b3039c141758345b51ad3ed..e905a41bf64f5f134bf405a358bc5e5f3e55d65b 100644 --- a/ide/src/doc/quickstart_smartperflinux_compile_guide.html +++ b/ide/src/doc/quickstart_smartperflinux_compile_guide.html @@ -878,7 +878,7 @@
        • - windows 系统下 从 https://golang.google.cn/dl/ 下载安装包, + windows 系统下 从官网下载安装包, 一路next 完成 安装即可

        • 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/icon.svg b/ide/src/icon.svg deleted file mode 100644 index cb1ae9143e933e3653658a4d7f0efcff77985982..0000000000000000000000000000000000000000 --- a/ide/src/icon.svg +++ /dev/null @@ -1,3031 +0,0 @@ - \ No newline at end of file diff --git a/ide/src/index.ts b/ide/src/index.ts index 1b1fba76d9d0289410310e7f9f3c49c7d0177aba..94d26f1ab46c2c7fe17467db957434e975109b0c 100644 --- a/ide/src/index.ts +++ b/ide/src/index.ts @@ -13,4 +13,4 @@ * limitations under the License. */ import './trace/SpApplication'; -document.body.innerHTML = ''; +document.body.innerHTML = ''; 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..5f2e17018c592787b924abfd2dd2676531fee840 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 { @@ -87,14 +90,14 @@ export class SpApplication extends BaseElement { longTraceTypeMessageMap: | Map< - number, - Array<{ - fileType: string; - startIndex: number; - endIndex: number; - size: number; - }> - > + number, + Array<{ + fileType: string; + startIndex: number; + endIndex: number; + size: number; + }> + > | undefined | null; static skinChange: Function | null | undefined = null; @@ -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; @@ -184,8 +188,12 @@ export class SpApplication extends BaseElement { return this.hasAttribute('wasm'); } - set wasm(d: any) { - this.setAttribute('wasm', ''); + set wasm(isWasm: boolean) { + if (isWasm) { + this.setAttribute('wasm', ''); + } else { + this.hasAttribute('wasm') && this.removeAttribute('wasm'); + } } get server(): boolean { @@ -243,6 +251,7 @@ export class SpApplication extends BaseElement { } initElements(): void { + this.wasm = true; this.initPlugin(); this.querySql = true; this.rootEL = this.shadowRoot!.querySelector('.root'); @@ -268,6 +277,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,10 +320,12 @@ export class SpApplication extends BaseElement { this.spRecordTemplate, this.spFlags, this.spKeyboard, + this.spThirdParty, ]; } private openLongTraceFile(ev: any, isRecordTrace: boolean = false) { + this.wasm = true; this.openFileInit(); let detail = (ev as any).detail; let initRes = this.longTraceFileInit(isRecordTrace, detail); @@ -524,13 +536,20 @@ export class SpApplication extends BaseElement { this.traceFileName = fileName; let showFileName = fileName.lastIndexOf('.') === -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.')); TraceRow.rangeSelectObject = undefined; - if (this.sqlite) { - info('Parse trace using sql mode'); - this.handleSqliteMode(ev, showFileName, (ev as any).size, fileName); - } - if (this.wasm) { - info('Parse trace using wasm mode '); - this.handleWasmMode(ev, showFileName, (ev as any).size, fileName); + let typeHeader = (ev as any).slice(0, 6); + let reader: FileReader | null = new FileReader(); + reader.readAsText(typeHeader); + reader.onloadend = (event): void => { + let headerStr: string = `${reader?.result}`; + if (headerStr.indexOf('SQLite') === 0) { + info('Parse trace headerStr sql mode'); + this.wasm = false; + this.handleSqliteMode(ev, showFileName, (ev as any).size, fileName); + } else { + info('Parse trace using wasm mode '); + this.wasm = true; + this.handleWasmMode(ev, showFileName, (ev as any).size, fileName); + } } } @@ -648,6 +667,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(); @@ -763,6 +788,7 @@ export class SpApplication extends BaseElement { { title: 'Flags', icon: 'menu', + // fileModel: this.wasm ? 'wasm' : 'db', clickHandler: (item: MenuItem): void => { this.search = false; this.showContent(this.spFlags!); @@ -773,17 +799,26 @@ 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'; + SpSystemTrace.keyboardFlar = false; SpStatisticsHttpUtil.addOrdinaryVisitAction({ - event: 'Keyboard shortcuts', - action: 'Keyboard shortcuts', + event: 'Keyboard Shortcuts', + action: 'Keyboard Shortcuts', }); }, }, + { + title: '第三方文件', + icon: 'file-fill', + fileModel: this.wasm ? 'wasm' : 'db', + clickHandler: (item: MenuItem): void => { + this.search = false; + this.showContent(this.spThirdParty!); + }, + }, ], }, ]; @@ -814,12 +849,22 @@ export class SpApplication extends BaseElement { second: false, icon: '', describe: 'Actions on the current trace', - children: that.getTraceOptionMenus(showFileName, fileSizeStr, fileName, false), + children: that.getTraceOptionMenus(showFileName, fileSizeStr, fileName, true), + }); + that.mainMenu!.menus!.splice(2, 1, { + collapsed: false, + title: 'Support', + second: false, + icon: '', + describe: 'Support', + children: that.getTraceSupportMenus(), }); that.litSearch!.setPercent('', 101); that.chartFilter!.setAttribute('mode', ''); that.progressEL!.loading = false; that.freshMenuDisable(false); + that.spInfoAndStats!.initInfoAndStatsData(); + that.cutTraceFile!.style.display = 'none'; } ); }; @@ -828,33 +873,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 +1016,15 @@ 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'; + SpSystemTrace.keyboardFlar = false; SpStatisticsHttpUtil.addOrdinaryVisitAction({ - event: 'Keyboard shortcuts', - action: 'Keyboard shortcuts', + event: 'Keyboard Shortcuts', + action: 'Keyboard Shortcuts', }); - that.search = false; - that.showContent(that.spKeyboard!); }, }, ], @@ -1361,6 +1417,7 @@ export class SpApplication extends BaseElement { { title: 'Download File', icon: 'download', + fileModel: this.wasm ? 'wasm' : 'db', clickHandler: (): void => { this.download(this.mainMenu!, fileName, isServer, dbName); SpStatisticsHttpUtil.addOrdinaryVisitAction({ @@ -1368,10 +1425,10 @@ export class SpApplication extends BaseElement { action: 'download', }); }, - }, - { + }, { title: 'Download Database', icon: 'download', + fileModel: this.wasm ? 'wasm' : 'db', clickHandler: (): void => { this.downloadDB(this.mainMenu!, fileName); SpStatisticsHttpUtil.addOrdinaryVisitAction({ @@ -1379,7 +1436,7 @@ export class SpApplication extends BaseElement { action: 'download', }); }, - }, + } ]; this.getTraceQuerySqlMenus(menus); if ((window as any).cpuCount === 0 || !FlagsConfig.getFlagsConfigEnableStatus('SchedulingAnalysis')) { @@ -1388,6 +1445,56 @@ export class SpApplication extends BaseElement { return menus; } + private getTraceSupportMenus(): Array { + return [ + { + title: 'Help Documents', + icon: 'smart-help', + clickHandler: (item: MenuItem): void => { + this.spHelp!.dark = this.dark; + this.search = false; + this.showContent(this.spHelp!); + SpStatisticsHttpUtil.addOrdinaryVisitAction({ + event: 'help_page', + action: 'help_doc', + }); + }, + }, + { + title: 'Flags', + icon: 'menu', + fileModel: this.wasm ? 'wasm' : 'db', + clickHandler: (item: MenuItem): void => { + this.search = false; + this.showContent(this.spFlags!); + SpStatisticsHttpUtil.addOrdinaryVisitAction({ + event: 'flags', + action: 'flags', + }); + }, + }, + { + title: 'Keyboard Shortcuts', + icon: 'smart-help', + clickHandler: (item: MenuItem): void => { + document.querySelector('body > sp-application')!.shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'visible'; + SpStatisticsHttpUtil.addOrdinaryVisitAction({ + event: 'Keyboard Shortcuts', + action: 'Keyboard Shortcuts', + }); + }, + }, + { + title: '第三方文件', + icon: 'file-fill', + fileModel: this.wasm ? 'wasm' : 'db', + clickHandler: (item: MenuItem): void => { + this.search = false; + this.showContent(this.spThirdParty!); + }, + }] + } + private getTraceQuerySqlMenus(menus: Array): void { if (this.querySql) { if (this.spQuerySQL) { @@ -1405,6 +1512,7 @@ export class SpApplication extends BaseElement { menus.push({ title: 'Metrics', icon: 'metric', + fileModel: this.wasm ? 'wasm' : 'db', clickHandler: () => { this.showContent(this.spMetrics!); }, @@ -1429,16 +1537,16 @@ export class SpApplication extends BaseElement { private initSlideMenuEvents(): void { //打开侧边栏 this.sidebarButton!.onclick = (e): void => { - if (this.mainMenu) { - this.mainMenu.style.width = '248px'; - this.mainMenu.style.zIndex = '2000'; - this.mainMenu.style.display = 'flex'; - } if (this.sidebarButton) { this.sidebarButton.style.width = '0px'; this.importConfigDiv!.style.left = '5px'; this.closeKeyPath!.style.left = '25px'; } + if (this.mainMenu) { + this.mainMenu.style.width = '248px'; + this.mainMenu.style.zIndex = '2000'; + this.mainMenu.style.display = 'flex'; + } }; let icon: HTMLDivElement | undefined | null = this.mainMenu?.shadowRoot?.querySelector('div.header > div'); icon!.style.pointerEvents = 'none'; @@ -1929,9 +2037,15 @@ 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( + `index.html?link=true&local=true&traceName=${encodeURIComponent(traceName)}_cut_${cutLeftTs}${fileType}&trace=${encodeURIComponent( blobUrl )}` ); diff --git a/ide/src/trace/SpApplicationPublicFunc.ts b/ide/src/trace/SpApplicationPublicFunc.ts index fd6dd3571a1819069b83066aeaf6bf6a4696e89d..89ec084c3efe2d708d322a8cd1e35c16a804648f 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..4ab04f4f7ee124ce6b84cb62b1f27693de6e892a 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/ProcedureWorkerBpftrace'; 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/FrameChartStruct.ts b/ide/src/trace/bean/FrameChartStruct.ts index 2e8b2c883e1ded8089eb2f1df8f04c95b85eb208..7ecd6d01ddbb430387012cf4c6aa0e6c2cd1ec7c 100644 --- a/ide/src/trace/bean/FrameChartStruct.ts +++ b/ide/src/trace/bean/FrameChartStruct.ts @@ -63,6 +63,7 @@ export class ChartStruct extends BaseStruct { durArray: Array = []; isThread: boolean = false; isProcess: boolean = false; + isJsStack: boolean = false; } export enum ChartMode { @@ -143,13 +144,18 @@ export function draw(canvasCtx: CanvasRenderingContext2D, node: ChartStruct): vo canvasCtx.strokeStyle = '#000'; } } else { - if (spApplication.dark) { - canvasCtx.strokeStyle = '#000'; + if (node.isJsStack) { + canvasCtx.lineWidth = 0.6; + canvasCtx.strokeStyle = `rgb(${lightBlue.r}, ${lightBlue.g}, ${lightBlue.b})`; } else { - canvasCtx.strokeStyle = '#fff'; + if (spApplication.dark) { + canvasCtx.strokeStyle = '#000'; + } else { + canvasCtx.strokeStyle = '#fff'; + } } } - canvasCtx.strokeRect(node.frame.x, node.frame.y, node.frame.width, drawHeight); + canvasCtx.strokeRect(node.frame.x, node.frame.y, node.frame.width - canvasCtx.lineWidth, drawHeight); //文字 if (node.frame.width > 10) { if (node.percent > 0.6 || node.isSearch) { 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/JsStruct.ts b/ide/src/trace/bean/JsStruct.ts index 22ae8175dbfe82d5de7686f3628dd15cf986064c..bbf451e37243ea24d92b3a63f50c8702668780e7 100644 --- a/ide/src/trace/bean/JsStruct.ts +++ b/ide/src/trace/bean/JsStruct.ts @@ -46,7 +46,7 @@ export class JsCpuProfilerUIStruct { this.urlId = urlId; this.line = line; this.column = column; - this.scriptName = ''; + this.scriptName = 'unknown'; } } @@ -113,7 +113,7 @@ export class JsCpuProfilerTabStruct extends JsCpuProfilerUIStruct { super(id, nameId, depth, selfTime, totalTime, urlId, line, column); this.chartFrameChildren = new Array(); this.children = new Array(); - this.scriptName = scriptName; + this.scriptName = scriptName || 'unknown'; } } 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..a415964ce635ee0e7dfe01300216f58dacc750ef --- /dev/null +++ b/ide/src/trace/bean/StateModle.ts @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 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 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..347e88b6f3460a03e7fc529ce0b7ca90623990b7 100644 --- a/ide/src/trace/component/SpFlags.ts +++ b/ide/src/trace/component/SpFlags.ts @@ -162,7 +162,25 @@ export class SpFlags extends BaseElement { }); configSelect.addEventListener('change', () => { let title = configSelect.getAttribute('title'); - FlagsConfig.updateFlagsConfig(title!, configSelect.selectedOptions[0].value); + FlagsConfig.updateFlagsConfig(title!, configSelect.selectedOptions[0].value); + if (title === 'VSync' && configSelect.selectedOptions[0].value === 'Enabled') { + let vsyncSelect = this.shadowRoot?.querySelector('#vsyncSelect'); + vsyncSelect?.removeAttribute('disabled'); + } + if (title === 'VSync' && configSelect.selectedOptions[0].value === 'Disabled') { + let vsyncSelect = this.shadowRoot?.querySelector('#vsyncSelect'); + vsyncSelect?.childNodes.forEach((child: ChildNode) => { + let selectEl = child as HTMLOptionElement; + if (child.textContent === 'VsyncGenerator') { + selectEl.selected = true; + FlagsConfig.updateFlagsConfig('vsyncValue', selectEl.value); + } else { + selectEl.selected = false; + } + }); + + vsyncSelect?.setAttribute('disabled', 'disabled'); + } }); let description = document.createElement('div'); description.className = 'flag-des-div'; @@ -215,9 +233,62 @@ export class SpFlags extends BaseElement { configFooterDiv.appendChild(deviceHeightEl); configDiv.appendChild(configFooterDiv); } + + if(config.title === 'VSync'){ + let configFooterDiv = this.createVsyncOption(); + configDiv.appendChild(configFooterDiv); + } + this.bodyEl!.appendChild(configDiv); }); } + + private createVsyncOption(): HTMLDivElement { + let configFooterDiv = document.createElement('div'); + configFooterDiv.className = 'config_footer'; + let vsyncLableEl = document.createElement("lable"); + vsyncLableEl.className = 'vsync_lable'; + let vsyncTypeEl = document.createElement("select"); + vsyncTypeEl.setAttribute("id", "vsyncSelect"); + vsyncTypeEl.className = 'flag-select'; + let vsyncGenOption = document.createElement('option'); // VsyncGeneratior = H:VsyncGenerator + vsyncGenOption.value = 'H:VsyncGenerator'; + vsyncGenOption.textContent = 'VsyncGenerator'; + vsyncGenOption.selected = true; + vsyncTypeEl.appendChild(vsyncGenOption); + + let vsyncRsOption = document.createElement('option'); // Vsync-rs = H:rs_SendVsync + vsyncRsOption.value = 'H:rs_SendVsync'; + vsyncRsOption.textContent = 'Vsync-rs'; + vsyncTypeEl.appendChild(vsyncRsOption); + + let vsyncAppOption = document.createElement('option'); // Vsync-app = H:app_SendVsync + vsyncAppOption.value = 'H:app_SendVsync'; + vsyncAppOption.textContent = 'Vsync-app'; + vsyncTypeEl.appendChild(vsyncAppOption); + + FlagsConfig.updateFlagsConfig('vsyncValue', vsyncGenOption.value); + vsyncTypeEl.addEventListener('change', function () { + let selectValue = this.selectedOptions[0].value; + console.log(this); + console.log(this.selectedOptions[0]); + console.log(this.selectedOptions[0].value); + FlagsConfig.updateFlagsConfig('vsyncValue', selectValue); + }); + + let flagsItem = window.localStorage.getItem(FlagsConfig.FLAGS_CONFIG_KEY); + let flagsItemJson = JSON.parse(flagsItem!); + let vsync = flagsItemJson.VSync; + if (vsync === 'Enabled') { + vsyncTypeEl.removeAttribute('disabled'); + } else { + vsyncTypeEl.setAttribute('disabled', 'disabled'); + FlagsConfig.updateFlagsConfig('vsyncValue', vsyncGenOption.value); + } + configFooterDiv.appendChild(vsyncLableEl); + configFooterDiv.appendChild(vsyncTypeEl); + return configFooterDiv; + } } export type Params = { @@ -258,6 +329,21 @@ export class FlagsConfig { switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], describeContent: 'Ffrt Convert templates', }, + { + title: 'Bpftrace', + switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], + describeContent: '', + }, + { + title: 'HMKernel', + switchOptions: [{ option: 'Enabled' }, { option: 'Disabled', selected: true }], + describeContent: '', + }, + { + title: 'VSync', + 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..ede6fa139aff3dc00a764012091a9260efbf8417 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

          @@ -165,6 +166,13 @@ table{ 永久框选标记 + + +
          ctr
          + +
          b
          + + 隐藏/显示菜单和搜索框 +
          Ctrl
          + @@ -183,7 +191,7 @@ table{ -
          ?
          +
          /
          展示快捷方式 diff --git a/ide/src/trace/component/SpKeyboard.ts b/ide/src/trace/component/SpKeyboard.ts index 154678278b8492af44b8959fef13823c3c23fd66..5cacda5b568292b5bfa904652e84a22abb097300 100644 --- a/ide/src/trace/component/SpKeyboard.ts +++ b/ide/src/trace/component/SpKeyboard.ts @@ -15,6 +15,7 @@ import { BaseElement, element } from '../../base-ui/BaseElement'; import { SpKeyboardHtml } from './SpKeyboard.html'; +import { SpSystemTrace } from './SpSystemTrace'; @element('sp-keyboard') export class SpKeyboard extends BaseElement { @@ -25,17 +26,14 @@ 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'; + SpSystemTrace.keyboardFlar = true; }); shadow_box!.addEventListener('click', () => { keyboardDiv.style.visibility = 'hidden'; - welcomeDiv.style.visibility = 'visible'; + SpSystemTrace.keyboardFlar = true; }); } diff --git a/ide/src/trace/component/SpRecordConfigModel.ts b/ide/src/trace/component/SpRecordConfigModel.ts index 7101db4151e667c25c03241d7201c426d100a2a8..acd23429f55f25da54f7ee0149b18f099898418a 100644 --- a/ide/src/trace/component/SpRecordConfigModel.ts +++ b/ide/src/trace/component/SpRecordConfigModel.ts @@ -535,6 +535,11 @@ export function createNativePluginConfig( if (spAllocations!.sample_interval) { nativeConfig.sampleInterval = spAllocations!.sample_interval; } + nativeConfig.jsStackReport = spAllocations!.recordJsStack; + if (spAllocations!.recordJsStack) { + nativeConfig.maxJsStackDepth = spAllocations!.max_js_stack_depth; + nativeConfig.filterNapiName = spAllocations!.filter_napi_name; + } } if (spAllocations!.expandPids.length > 1) { nativeConfig.expandPids = spAllocations!.expandPids.splice(0, maxProcessSize); @@ -634,6 +639,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..ff0d1d2f5304a5c37d07040d6d1f6c671b65a557 100644 --- a/ide/src/trace/component/SpRecordTrace.ts +++ b/ide/src/trace/component/SpRecordTrace.ts @@ -66,13 +66,15 @@ 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 = ''; public static selectVersion: string | null; public static isVscode = false; public static cancelRecord = false; - static supportVersions = ['3.2', '4.0+']; + static supportVersions = ['3.2', '4.0+','5.0+']; public deviceSelect: HTMLSelectElement | undefined; public deviceVersion: HTMLSelectElement | undefined; private _menuItems: Array | undefined; @@ -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/); @@ -259,6 +283,8 @@ export class SpRecordTrace extends BaseElement { return '3.2'; } else if (version.indexOf('4.') !== -1) { return '4.0+'; + }else if (version.indexOf('5.') !== -1) { + return '5.0+' } return '3.2'; } @@ -333,6 +359,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 +372,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 +386,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'; } } @@ -506,6 +532,7 @@ export class SpRecordTrace extends BaseElement { let versionItem = this.deviceVersion!.options[this.deviceVersion!.selectedIndex]; SpRecordTrace.selectVersion = versionItem.getAttribute('device-version'); this.spAllocations!.startup_mode = false; + this.spAllocations!.recordJsStack = false; this.nativeMemoryHideBySelectVersion(); this.traceCommand!.hdcCommon = PluginConvertUtils.createHdcCmd( PluginConvertUtils.BeanToCmdTxt(this.makeRequest(), false), diff --git a/ide/src/trace/component/SpSystemTrace.event.ts b/ide/src/trace/component/SpSystemTrace.event.ts index b86eaa4ec08d693d80b6fdf6502490a26fdf768f..9d7dbaa83cff3d5e463262641aa04f6f0f414f3c 100644 --- a/ide/src/trace/component/SpSystemTrace.event.ts +++ b/ide/src/trace/component/SpSystemTrace.event.ts @@ -13,32 +13,36 @@ * 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 { AllAppStartupStructOnClick } from "../database/ui-worker/ProcedureWorkerAllAppStartup"; +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/ProcedureWorkerBpftrace"; +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 { FlagsConfig } from "./SpFlags"; +import { LitMainMenu } from "../../base-ui/menu/LitMainMenu"; function timeoutJudge(sp: SpSystemTrace) { let timeoutJudge = setTimeout(() => { @@ -172,15 +176,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 +233,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 +242,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 +297,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 +305,19 @@ 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(() => AllAppStartupStructOnClick(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 +326,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 +343,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 +428,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 +444,6 @@ function SpSystemTraceDocumentOnMouseMoveMouseUp(sp: SpSystemTrace, rows: Array< } }) .forEach((tr) => { - sp.hoverStructNull(); if (sp.currentRowType != tr.rowType) { sp.currentRowType = tr.rowType || ''; } @@ -451,7 +468,7 @@ export function spSystemTraceDocumentOnMouseOut(sp: SpSystemTrace, ev: MouseEven } } -export function SpSystemTraceDocumentOnKeyPress(sp: SpSystemTrace, ev: KeyboardEvent) { +export function SpSystemTraceDocumentOnKeyPress(this: any, sp: SpSystemTrace, ev: KeyboardEvent) { if (!sp.loadTraceCompleted) { return; } @@ -482,6 +499,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 +541,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; } @@ -605,12 +619,23 @@ export function spSystemTraceDocumentOnKeyUp(sp: SpSystemTrace, ev: KeyboardEven clearTimeout(timerId); } } - if (ev.key.toLocaleLowerCase() === '?') { - document.querySelector('body > sp-application')! - .shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'visible'; + if (ev.key.toLocaleLowerCase() === String.fromCharCode(47)) { + if (SpSystemTrace.keyboardFlar) { + document.querySelector('body > sp-application')! + .shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'visible'; + SpSystemTrace.keyboardFlar = false; + } else { + document.querySelector('body > sp-application')! + .shadowRoot!.querySelector('#sp-keyboard')!.style.visibility = 'hidden'; + SpSystemTrace.keyboardFlar = true; + } } if (!sp.loadTraceCompleted) return; - sp.keyboardEnable && enableVSync(false, ev, () => sp.refreshCanvas(true)); + let flagsItem = window.localStorage.getItem(FlagsConfig.FLAGS_CONFIG_KEY); + let flagsItemJson = JSON.parse(flagsItem!); + if (flagsItemJson.VSync === 'Enabled') { + sp.keyboardEnable && enableVSync(false, ev, () => sp.refreshCanvas(true)); + } let keyPress = ev.key.toLocaleLowerCase(); if (keyPress === 'w' || keyPress === 'a' || keyPress === 's' || keyPress === 'd') { sp.keyPressMap.set(keyPress, false); @@ -643,6 +668,46 @@ export function spSystemTraceDocumentOnKeyUp(sp: SpSystemTrace, ev: KeyboardEven } function spSystemTraceDocumentOnKeyUpCtrlKey(keyPress: string, sp: SpSystemTrace) { + if (keyPress === 'b') { + let menuBox = document.querySelector('body > sp-application')!.shadowRoot?.querySelector('#main-menu') as LitMainMenu; + let searchBox = document.querySelector('body > sp-application') + ?.shadowRoot?.querySelector('div > div.search-vessel') as HTMLDivElement; + let appContent = document.querySelector('body > sp-application') + ?.shadowRoot?.querySelector('div > #app-content') as HTMLDivElement; + let rowPane = appContent?.querySelector('#sp-system-trace')?.shadowRoot?.querySelector('div > div.rows-pane') as HTMLDivElement; + let timerShaft = appContent?.querySelector('#sp-system-trace')?.shadowRoot?.querySelector('div > timer-shaft-element') as HTMLDivElement; + let spChartList = appContent?.querySelector('#sp-system-trace')?.shadowRoot?.querySelector('div > sp-chart-list') as HTMLDivElement; + let canvasEle = spChartList.shadowRoot?.querySelector('canvas') as unknown as HTMLDivElement; + let sidebarButton = searchBox!.querySelector('div > div.sidebar-button') as HTMLDivElement; + let importConfigDiv = searchBox!.querySelector('div > #import-key-path') as HTMLDivElement; + if (menuBox.style.zIndex! === '2000' || searchBox!.style.display !== 'none') { + SpSystemTrace.isHiddenMenu = true; + menuBox.style.width = '0px'; + menuBox.style.display = 'flex'; + menuBox.style.zIndex = '0'; + sidebarButton.style.width = '48px'; + importConfigDiv!.style.left = '45px'; + searchBox!.style.display = 'none'; + if (timerShaft.style.height === '91.75px') { + rowPane.style.maxHeight = '900px' + } else { + rowPane.style.maxHeight = '797px' + } + } else { + SpSystemTrace.isHiddenMenu = false; + menuBox.style.width = '248px'; + menuBox.style.zIndex = '2000'; + menuBox.style.display = 'flex'; + sidebarButton.style.width = '0px'; + importConfigDiv!.style.left = '5px'; + searchBox!.style.display = ''; + if (timerShaft.style.height === '91.75px') { + rowPane.style.maxHeight = '905.25px'; + } else { + rowPane.style.maxHeight = '849px'; + }; + } + } if (keyPress === '[' && sp._slicesList.length > 1) { sp.MarkJump(sp._slicesList, 'slice', 'previous'); } else if (keyPress === ',' && sp._flagList.length > 1) { @@ -667,7 +732,13 @@ 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!)?.()) { + let strict = true; + let offset = false; + if (rows[0].rowType === TraceRow.ROW_TYPE_FRAME_DYNAMIC || rows[0].rowType === TraceRow.ROW_TYPE_FRAME_SPACING) { + strict = false; + offset = true; + } + if (rows && rows[0] && rows[0].getHoverStruct(strict, offset)) { 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..7543b7c13ff07ddb72e32db90d6ea7aa1763b87a 100644 --- a/ide/src/trace/component/SpSystemTrace.init.ts +++ b/ide/src/trace/component/SpSystemTrace.init.ts @@ -13,29 +13,28 @@ * limitations under the License. */ -import {SpSystemTrace} from './SpSystemTrace'; +import { SpSystemTrace } from './SpSystemTrace'; import { TabPaneFrequencySample } from "./trace/sheet/cpu/TabPaneFrequencySample"; import { TabPaneCounterSample } from "./trace/sheet/cpu/TabPaneCounterSample"; import { RangeSelect } from "./trace/base/RangeSelect"; import { TraceRow } from "./trace/base/TraceRow"; import { SportRuler } from "./trace/timer-shaft/SportRuler"; import { SelectionParam } from "../bean/BoxSelection"; -import {error, info} from "../../log/Log"; +import { error, info } from "../../log/Log"; import { SpStatisticsHttpUtil } from "../../statistics/util/SpStatisticsHttpUtil"; import { queryEbpfSamplesCount } from "../database/sql/Memory.sql"; import { SpChartManager } from "./chart/SpChartManager"; -import {ThreadStruct} from "../database/ui-worker/ProcedureWorkerThread"; -import {FlagsConfig} from "./SpFlags"; -import {threadPool} from "../database/SqlLite"; -import {JankStruct} from "../database/ui-worker/ProcedureWorkerJank"; -import {CpuStruct} from "../database/ui-worker/cpu/ProcedureWorkerCPU"; -import {PairPoint} from "../database/ui-worker/ProcedureWorkerCommon"; +import { ThreadStruct } from "../database/ui-worker/ProcedureWorkerThread"; +import { FlagsConfig } from "./SpFlags"; +import { threadPool } from "../database/SqlLite"; +import { JankStruct } from "../database/ui-worker/ProcedureWorkerJank"; +import { CpuStruct } from "../database/ui-worker/cpu/ProcedureWorkerCPU"; +import { PairPoint } from "../database/ui-worker/ProcedureWorkerCommon"; 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) { +function rightButtonOnClick(sp: SpSystemTrace, rightStar: HTMLElementAlias) { Object.assign(sp, { ext(): string { return "Handle the right button click event"; @@ -78,45 +77,45 @@ function rightButtonOnClick(sp: SpSystemTrace,rightStar: HTMLElementAlias) { }, 2000); } } -function rightStarOnClick(sp:SpSystemTrace) { - return function (ev:any){ - let wakeupLists = []; - wakeupLists.push(CpuStruct.selectCpuStruct?.cpu); - for (let wakeupBean of SpSystemTrace.wakeupList) { - wakeupLists.push(wakeupBean.cpu); - } - let wakeupCpuLists = Array.from(new Set(wakeupLists)).sort(); - for (let wakeupCpu of wakeupCpuLists) { - let cpuFavoriteRow: any = sp.shadowRoot?.querySelector>( - `trace-row[row-type='cpu-data'][row-id='${wakeupCpu}']` - ); - if (cpuFavoriteRow === null || cpuFavoriteRow === undefined) { - continue; - } - cpuFavoriteRow!.setAttribute('collect-type', ''); - let replaceRow = document.createElement('div'); - replaceRow.setAttribute('row-id', cpuFavoriteRow.rowId + '-' + cpuFavoriteRow.rowType); - replaceRow.setAttribute('type', 'replaceRow'); - replaceRow.setAttribute('row-parent-id', cpuFavoriteRow.rowParentId); - replaceRow.style.display = 'none'; - cpuFavoriteRow.rowHidden = !cpuFavoriteRow.hasAttribute('scene'); - if (sp.rowsEL!.contains(cpuFavoriteRow)) { - sp.rowsEL!.replaceChild(replaceRow, cpuFavoriteRow); - } - cpuFavoriteRow.tampName = cpuFavoriteRow.name; - sp.favoriteChartListEL!.insertRow(cpuFavoriteRow, sp.currentCollectGroup, true); - sp.collectRows.push(cpuFavoriteRow); - sp.timerShaftEL?.displayCollect(sp.collectRows.length !== 0); - sp.currentClickRow = null; - cpuFavoriteRow.setAttribute('draggable', 'true'); - cpuFavoriteRow.addEventListener('dragstart', cpuFavoriteRowDragStart(sp,cpuFavoriteRow)); - cpuFavoriteRow.addEventListener('dragover', cpuFavoriteRowDragOver(sp)); - cpuFavoriteRow.addEventListener('drop', cpuFavoriteRowDropHandler(sp,cpuFavoriteRow)); - cpuFavoriteRow.addEventListener('dragend', cpuFavoriteRowDragendHandler(sp)); - } - sp.refreshFavoriteCanvas(); - sp.refreshCanvas(true); - } +function rightStarOnClick(sp: SpSystemTrace) { + return function (ev: any) { + let wakeupLists = []; + wakeupLists.push(CpuStruct.selectCpuStruct?.cpu); + for (let wakeupBean of SpSystemTrace.wakeupList) { + wakeupLists.push(wakeupBean.cpu); + } + let wakeupCpuLists = Array.from(new Set(wakeupLists)).sort(); + for (let wakeupCpu of wakeupCpuLists) { + let cpuFavoriteRow: any = sp.shadowRoot?.querySelector>( + `trace-row[row-type='cpu-data'][row-id='${wakeupCpu}']` + ); + if (cpuFavoriteRow === null || cpuFavoriteRow === undefined) { + continue; + } + cpuFavoriteRow!.setAttribute('collect-type', ''); + let replaceRow = document.createElement('div'); + replaceRow.setAttribute('row-id', cpuFavoriteRow.rowId + '-' + cpuFavoriteRow.rowType); + replaceRow.setAttribute('type', 'replaceRow'); + replaceRow.setAttribute('row-parent-id', cpuFavoriteRow.rowParentId); + replaceRow.style.display = 'none'; + cpuFavoriteRow.rowHidden = !cpuFavoriteRow.hasAttribute('scene'); + if (sp.rowsEL!.contains(cpuFavoriteRow)) { + sp.rowsEL!.replaceChild(replaceRow, cpuFavoriteRow); + } + cpuFavoriteRow.tampName = cpuFavoriteRow.name; + sp.favoriteChartListEL!.insertRow(cpuFavoriteRow, sp.currentCollectGroup, true); + sp.collectRows.push(cpuFavoriteRow); + sp.timerShaftEL?.displayCollect(sp.collectRows.length !== 0); + sp.currentClickRow = null; + cpuFavoriteRow.setAttribute('draggable', 'true'); + cpuFavoriteRow.addEventListener('dragstart', cpuFavoriteRowDragStart(sp, cpuFavoriteRow)); + cpuFavoriteRow.addEventListener('dragover', cpuFavoriteRowDragOver(sp)); + cpuFavoriteRow.addEventListener('drop', cpuFavoriteRowDropHandler(sp, cpuFavoriteRow)); + cpuFavoriteRow.addEventListener('dragend', cpuFavoriteRowDragendHandler(sp)); + } + sp.refreshFavoriteCanvas(); + sp.refreshCanvas(true); + } } function cpuFavoriteRowDragStart(sp: SpSystemTrace, cpuFavoriteRow: any) { return function () { @@ -124,17 +123,17 @@ function cpuFavoriteRowDragStart(sp: SpSystemTrace, cpuFavoriteRow: any) { } } function cpuFavoriteRowDragOver(sp: SpSystemTrace) { - return function (ev:any){ + return function (ev: any) { ev.preventDefault(); ev.dataTransfer.dropEffect = 'move'; } } function cpuFavoriteRowDropHandler(sp: SpSystemTrace, cpuFavoriteRow: any) { - return function (ev:any){ + return function (ev: any) { if ( - sp.favoriteChartListEL != null && - sp.currentClickRow != null && - sp.currentClickRow !== cpuFavoriteRow + sp.favoriteChartListEL != null && + sp.currentClickRow != null && + sp.currentClickRow !== cpuFavoriteRow ) { let rect = cpuFavoriteRow.getBoundingClientRect(); if (ev.clientY >= rect.top && ev.clientY < rect.top + rect.height / 2) { @@ -149,7 +148,7 @@ function cpuFavoriteRowDropHandler(sp: SpSystemTrace, cpuFavoriteRow: any) { } } function cpuFavoriteRowDragendHandler(sp: SpSystemTrace) { - return function(){ + return function () { sp.linkNodes.forEach((itln) => { if (itln[0].rowEL.collect) { itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195; @@ -167,8 +166,8 @@ function cpuFavoriteRowDragendHandler(sp: SpSystemTrace) { sp.currentClickRow = null; } } -function triangleFlagHandler(sp:SpSystemTrace) { - return function (event:any) { +function triangleFlagHandler(sp: SpSystemTrace) { + return function (event: any) { let temporaryTime = sp.timerShaftEL?.drawTriangle(event.detail.time, event.detail.type); if (event.detail.timeCallback && temporaryTime) event.detail.timeCallback(temporaryTime); }; @@ -192,38 +191,38 @@ 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); } } } -function slicesChangeHandler(sp:SpSystemTrace) { - return function (event: any) { - sp.timerShaftEL?.modifySlicesList(event.detail); - if (event.detail.hidden) { - sp.slicestime = null; - if (sp._slicesList.length <= 0) { - if (TraceRow.rangeSelectObject) { - let showTab = sp.getShowTab(); - showTab = showTab.filter((it) => it !== 'tabpane-current'); - sp.traceSheetEL?.displayTab(...showTab); - } else { - sp.traceSheetEL?.setAttribute('mode', 'hidden'); - } - } - sp.refreshCanvas(true); - } - } +function slicesChangeHandler(sp: SpSystemTrace) { + return function (event: any) { + sp.timerShaftEL?.modifySlicesList(event.detail); + if (event.detail.hidden) { + sp.slicestime = null; + if (sp._slicesList.length <= 0) { + if (TraceRow.rangeSelectObject) { + let showTab = sp.getShowTab(); + showTab = showTab.filter((it) => it !== 'tabpane-current'); + sp.traceSheetEL?.displayTab(...showTab); + } else { + sp.traceSheetEL?.setMode('hidden'); + } + } + sp.refreshCanvas(true); + } + } } function collectHandler(sp: SpSystemTrace) { return function (event: any) { let currentRow = event.detail.row; if (currentRow.collect) { - collectHandlerYes(sp,currentRow,event); + collectHandlerYes(sp, currentRow, event); } else { - collectHandlerNo(sp,currentRow,event); + collectHandlerNo(sp, currentRow, event); } sp.timerShaftEL?.displayCollect(sp.collectRows.length !== 0); sp.refreshFavoriteCanvas(); @@ -255,7 +254,7 @@ function collectHandler(sp: SpSystemTrace) { ev.preventDefault(); ev.dataTransfer.dropEffect = 'move'; }); - currentRow.addEventListener('drop', collectHandlerDrop(sp,currentRow)); + currentRow.addEventListener('drop', collectHandlerDrop(sp, currentRow)); currentRow.addEventListener('dragend', collectHandlerDragEnd(sp)); }; } @@ -285,7 +284,7 @@ function collectHandlerNo(sp: SpSystemTrace, currentRow: any, event: any) { } allowExpansionRow.length = 0; let replaceRow = sp.rowsEL!.querySelector( - `div[row-id='${currentRow.rowId}-${currentRow.rowType}']` + `div[row-id='${currentRow.rowId}-${currentRow.rowType}']` ); // 取消收藏时,删除父亲ID currentRow.name = currentRow.tampName; @@ -294,11 +293,11 @@ function collectHandlerNo(sp: SpSystemTrace, currentRow: any, event: any) { currentRow.style.boxShadow = `0 10px 10px #00000000`; } } -function collectHandlerYes(sp: SpSystemTrace, currentRow: any, event: any){ +function collectHandlerYes(sp: SpSystemTrace, currentRow: any, event: any) { if ( - !sp.collectRows.find((find) => { - return find === currentRow; - }) + !sp.collectRows.find((find) => { + return find === currentRow; + }) ) { sp.collectRows.push(currentRow); } @@ -319,12 +318,12 @@ function collectHandlerYes(sp: SpSystemTrace, currentRow: any, event: any){ let parentRows = sp.shadowRoot?.querySelectorAll>(`trace-row[row-id='${rowParentId}']`); parentRows?.forEach((parentRow) => { if ( - parentRow?.name && - parentRow?.name != currentRow.name && - !parentRow.rowType!.startsWith('cpu') && - !parentRow.rowType!.startsWith('thread') && - !parentRow.rowType!.startsWith('func') && - !currentRow.name.includes(parentRow.name) + parentRow?.name && + parentRow?.name != currentRow.name && + !parentRow.rowType!.startsWith('cpu') && + !parentRow.rowType!.startsWith('thread') && + !parentRow.rowType!.startsWith('func') && + !currentRow.name.includes(parentRow.name) ) { currentRow.name += '(' + parentRow.name + ')'; } @@ -335,8 +334,8 @@ function collectHandlerYes(sp: SpSystemTrace, currentRow: any, event: any){ } sp.favoriteChartListEL?.insertRow(currentRow, sp.currentCollectGroup, event.detail.type !== 'auto-collect'); } -function collectHandlerDrop(sp: SpSystemTrace, currentRow: HTMLDivElement|undefined|null) { - return function (ev:any) { +function collectHandlerDrop(sp: SpSystemTrace, currentRow: HTMLDivElement | undefined | null) { + return function (ev: any) { if (sp.favoriteChartListEL !== null && sp.currentClickRow !== null && sp.currentClickRow !== currentRow) { let rect = currentRow!.getBoundingClientRect(); if (ev.clientY >= rect.top && ev.clientY < rect.top + rect.height / 2) { @@ -351,15 +350,23 @@ function collectHandlerDrop(sp: SpSystemTrace, currentRow: HTMLDivElement|undefi }; } function collectHandlerDragEnd(sp: SpSystemTrace) { - return function (ev:any) { + return function (ev: any) { sp.linkNodes.forEach((itln) => { if (itln[0].rowEL.collect) { - itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195; + if (sp.timerShaftEL?._checkExpand) { + itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195 + sp.timerShaftEL._usageFoldHeight!; + } else { + itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195; + } } else { itln[0].rowEL.translateY = itln[0].rowEL.offsetTop - sp.rowsPaneEL!.scrollTop; } if (itln[1].rowEL.collect) { - itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195; + if (sp.timerShaftEL?._checkExpand) { + itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195 + sp.timerShaftEL._usageFoldHeight!; + } else { + itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195; + } } else { itln[1].rowEL.translateY = itln[1].rowEL.offsetTop - sp.rowsPaneEL!.scrollTop; } @@ -391,15 +398,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) { @@ -441,17 +454,17 @@ function selectHandlerRows(sp: SpSystemTrace, rows: Array>) { }); if (selection.diskIOipids.length > 0 && !selection.diskIOLatency) { selection.promiseList.push( - queryEbpfSamplesCount( - TraceRow.rangeSelectObject?.startNS || 0, - TraceRow.rangeSelectObject?.endNS || 0, - selection.diskIOipids - ).then((res) => { - if (res.length > 0) { - selection.fsCount = res[0].fsCount; - selection.vmCount = res[0].vmCount; - } - return new Promise((resolve) => resolve(1)); - }) + queryEbpfSamplesCount( + TraceRow.rangeSelectObject?.startNS || 0, + TraceRow.rangeSelectObject?.endNS || 0, + selection.diskIOipids + ).then((res) => { + if (res.length > 0) { + selection.fsCount = res[0].fsCount; + selection.vmCount = res[0].vmCount; + } + return new Promise((resolve) => resolve(1)); + }) ); } sp.rangeTraceRow = rows; @@ -469,7 +482,7 @@ function selectHandlerRows(sp: SpSystemTrace, rows: Array>) { sp.timerShaftEL!.selectionList.push(selection); // 保持选中对象,为后面的再次选中该框选区域做准备。 sp.selectionParam = selection; } -function resizeObserverHandler(sp:SpSystemTrace) { +function resizeObserverHandler(sp: SpSystemTrace) { // @ts-ignore new ResizeObserver((entries) => { TraceRow.FRAME_WIDTH = sp.clientWidth - 249 - sp.getScrollWidth(); @@ -486,7 +499,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!); } @@ -497,9 +512,9 @@ function mutationObserverHandler(sp: SpSystemTrace) { if (sp.style.visibility === 'visible') { if (TraceRow.rangeSelectObject && SpSystemTrace.sliceRangeMark) { sp.timerShaftEL?.setSlicesMark( - TraceRow.rangeSelectObject.startNS || 0, - TraceRow.rangeSelectObject.endNS || 0, - false + TraceRow.rangeSelectObject.startNS || 0, + TraceRow.rangeSelectObject.endNS || 0, + false ); SpSystemTrace.sliceRangeMark = undefined; window.publish(window.SmartEvent.UI.RefreshCanvas, {}); @@ -515,34 +530,36 @@ function mutationObserverHandler(sp: SpSystemTrace) { } function intersectionObserverHandler(sp: SpSystemTrace) { sp.intersectionObserver = new IntersectionObserver( - (entries) => { - entries.forEach((it) => { - let tr = it.target as TraceRow; - tr.intersectionRatio = it.intersectionRatio; - if (!it.isIntersecting) { - tr.sleeping = true; - sp.invisibleRows.indexOf(tr) == -1 && sp.invisibleRows.push(tr); - sp.visibleRows = sp.visibleRows.filter((it) => !it.sleeping); - } else { - tr.sleeping = false; - sp.visibleRows.indexOf(tr) == -1 && sp.visibleRows.push(tr); - sp.invisibleRows = sp.invisibleRows.filter((it) => it.sleeping); - } - sp.visibleRows - .filter((vr) => vr.expansion) - .forEach((vr) => { - 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) - .forEach((vr) => (vr.parentRowEl!.sticky = true)); - if (sp.handler) { - clearTimeout(sp.handler); - } - sp.handler = setTimeout(() => sp.refreshCanvas(false), 100); - }); - }, - { threshold: [0, 0.01, 0.99, 1] } + (entries) => { + entries.forEach((it) => { + let tr = it.target as TraceRow; + tr.intersectionRatio = it.intersectionRatio; + if (!it.isIntersecting) { + tr.sleeping = true; + sp.invisibleRows.indexOf(tr) == -1 && sp.invisibleRows.push(tr); + sp.visibleRows = sp.visibleRows.filter((it) => !it.sleeping); + } else { + tr.sleeping = false; + sp.visibleRows.indexOf(tr) == -1 && sp.visibleRows.push(tr); + sp.invisibleRows = sp.invisibleRows.filter((it) => it.sleeping); + } + sp.visibleRows + .filter((vr) => vr.expansion) + .forEach((vr) => { + 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 && !vr.collect) + .forEach((vr) => (vr.parentRowEl!.sticky = true)); + if (sp.handler) { + clearTimeout(sp.handler); + } + sp.handler = setTimeout(() => sp.refreshCanvas(false), 100); + }); + }, + { threshold: [0, 0.01, 0.99, 1] } ); } function observerHandler(sp: SpSystemTrace) { @@ -560,14 +577,14 @@ 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'); } } } function smartEventSubscribe(sp: SpSystemTrace) { window.subscribe(window.SmartEvent.UI.SliceMark, (data) => sp.sliceMarkEventHandler(data)); - window.subscribe(window.SmartEvent.UI.TraceRowComplete, (tr) => {}); + window.subscribe(window.SmartEvent.UI.TraceRowComplete, (tr) => { }); window.subscribe(window.SmartEvent.UI.RefreshCanvas, () => sp.refreshCanvas(false)); window.subscribe(window.SmartEvent.UI.KeyboardEnable, (tr) => { sp.keyboardEnable = tr.enable; @@ -579,7 +596,7 @@ function smartEventSubscribe(sp: SpSystemTrace) { if (!collapse) { // 一键折叠之前,记录当前打开的泳道图 sp.expandRowList = - Array.from(sp.rowsEL!.querySelectorAll>(`trace-row[folder][expansion]`)) || []; + Array.from(sp.rowsEL!.querySelectorAll>(`trace-row[folder][expansion]`)) || []; } sp.collapseAll = true; sp.setAttribute('disable', ''); @@ -599,7 +616,7 @@ function smartEventSubscribe(sp: SpSystemTrace) { window.subscribe(window.SmartEvent.UI.CollectGroupChange, (group: string) => sp.currentCollectGroup = group); } -export function documentInitEvent(sp:SpSystemTrace) : void{ +export function documentInitEvent(sp: SpSystemTrace): void { if (!document) { return } @@ -621,31 +638,31 @@ export function documentInitEvent(sp:SpSystemTrace) : void{ document.addEventListener('collect', collectHandler(sp)); } -export function spSystemTraceInitElement(sp:SpSystemTrace){ +export function spSystemTraceInitElement(sp: SpSystemTrace) { window.subscribe(window.SmartEvent.UI.LoadFinishFrame, () => sp.drawAllLines()); sp.traceSheetEL = sp.shadowRoot?.querySelector('.trace-sheet'); - if (!sp || !sp.shadowRoot || !sp.traceSheetEL){ + if (!sp || !sp.shadowRoot || !sp.traceSheetEL) { return; } let rightButton: HTMLElement | null | undefined = sp.traceSheetEL.shadowRoot - ?.querySelector('#current-selection > tabpane-current-selection') - ?.shadowRoot?.querySelector('#rightButton'); - let rightStar: HTMLElement | null | undefined =sp.traceSheetEL.shadowRoot - ?.querySelector('#current-selection > tabpane-current-selection') - ?.shadowRoot?.querySelector('#right-star'); + ?.querySelector('#current-selection > tabpane-current-selection') + ?.shadowRoot?.querySelector('#rightButton'); + let rightStar: HTMLElement | null | undefined = sp.traceSheetEL.shadowRoot + ?.querySelector('#current-selection > tabpane-current-selection') + ?.shadowRoot?.querySelector('#right-star'); sp.tipEL = sp.shadowRoot.querySelector('.tip'); sp.rowsPaneEL = sp.shadowRoot.querySelector('.rows-pane'); sp.rowsEL = sp.rowsPaneEL; sp.spacerEL = sp.shadowRoot.querySelector('.spacer'); sp.timerShaftEL = sp.shadowRoot.querySelector('.timer-shaft'); sp.favoriteChartListEL = sp.shadowRoot.querySelector('#favorite-chart-list'); - if (!sp.traceSheetEL.shadowRoot){ + if (!sp.traceSheetEL.shadowRoot) { return; } sp.tabCpuFreq = sp.traceSheetEL.shadowRoot.querySelector('tabpane-frequency-sample'); sp.tabCpuState = sp.traceSheetEL.shadowRoot.querySelector('tabpane-counter-sample'); sp.rangeSelect = new RangeSelect(sp); - rightButton?.addEventListener('click', rightButtonOnClick(sp,rightStar)); + rightButton?.addEventListener('click', rightButtonOnClick(sp, rightStar)); rightStar?.addEventListener('click', rightStarOnClick(sp)); documentInitEvent(sp); SpSystemTrace.scrollViewWidth = sp.getScrollWidth(); @@ -661,7 +678,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; }); @@ -677,38 +696,20 @@ function moveRangeToCenterAndHighlight(sp: SpSystemTrace, findEntry: any) { sp.timerShaftEL?.drawTriangle(findEntry.startTime || 0, 'inverted'); } -export function spSystemTraceShowStruct(sp:SpSystemTrace,previous: boolean, currentIndex: number, structs: Array, retargetIndex?: number){ +export function spSystemTraceShowStruct(sp: SpSystemTrace, previous: boolean, currentIndex: number, structs: Array, retargetIndex?: number) { if (structs.length == 0) { return 0; } - let findIndex = spSystemTraceShowStructFindIndex(sp,previous,currentIndex,structs,retargetIndex); + let findIndex = spSystemTraceShowStructFindIndex(sp, previous, currentIndex, structs, retargetIndex); let findEntry: any; - if (findIndex >= 0) { - findEntry = structs[findIndex]; - } else { - if (previous) { - for (let i = structs.length - 1; i >= 0; i--) { - let it = structs[i]; - if (it.startTime! + it.dur! < TraceRow.range!.startNS) { - findIndex = i; - break; - } - } - if (findIndex == -1) { - findIndex = structs.length - 1; - } - } else { - findIndex = structs.findIndex((it) => it.startTime! > TraceRow.range!.endNS); - if (findIndex == -1) { - findIndex = 0; - } - } - findEntry = structs[findIndex]; - } + findEntry = structs[findIndex]; moveRangeToCenterAndHighlight(sp, findEntry); return findIndex; } -function spSystemTraceShowStructFindIndex(sp: SpSystemTrace, previous: boolean, currentIndex: number, structs: Array, retargetIndex: number | undefined) { +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) { @@ -717,23 +718,45 @@ function spSystemTraceShowStructFindIndex(sp: SpSystemTrace, previous: boolean, 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; } + if (it.startTime! + it.dur! <= TraceRow.range!.startNS) { + findIndex = i; + break; + } + } + if (findIndex == -1) { + findIndex = structs.length - 1; } } } else { - if (currentIndex == -1) { + //左滑 + 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; + } + } + findIndex = structs.findIndex((it, idx) => { + if (idx > currentIndex && + it.startTime! >= TraceRow.range!.startNS && + it.startTime! + it.dur! <= TraceRow.range!.endNS + ) { + return true; + } + if (it.startTime! >= TraceRow.range!.endNS) { + return true + } + }); + if (findIndex == -1) { findIndex = 0; - } else { - findIndex = structs.findIndex((it, idx) => { - return ( - idx > currentIndex - ); - }); } + } return findIndex; } @@ -743,8 +766,8 @@ function findEntryTypeCpu(sp: SpSystemTrace, findEntry: any) { sp.queryAllTraceRow(`trace-row[row-type='cpu-data']`, (row) => row.rowType === 'cpu-data').forEach((item) => { if (item.rowId === `${findEntry.cpu}`) { sp.rechargeCpuData( - findEntry, - item.dataListCache.find((it) => it.startTime > findEntry.startTime) + findEntry, + item.dataListCache.find((it) => it.startTime > findEntry.startTime) ); item.fixedList = [findEntry]; } @@ -756,26 +779,25 @@ 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, - dur: findEntry.dur, - tid: findEntry.tid, - pid: findEntry.pid, - depth: findEntry.depth, - argsetid: findEntry.argsetid, - funName: findEntry.funName, - cookie: findEntry.cookie, - }, - true + { + startTs: findEntry.startTime, + dur: findEntry.dur, + tid: findEntry.tid, + pid: findEntry.pid, + depth: findEntry.depth, + argsetid: findEntry.argsetid, + funName: findEntry.funName, + cookie: findEntry.cookie, + }, + true ); } function findEntryTypeThreadProcess(sp: SpSystemTrace, findEntry: any) { let threadProcessRow = sp.rowsEL?.querySelectorAll>('trace-row')[0]; if (threadProcessRow) { let filterRow = threadProcessRow.childrenList.filter( - (row) => row.rowId === findEntry.rowId && row.rowId === findEntry.rowType + (row) => row.rowId === findEntry.rowId && row.rowId === findEntry.rowType )[0]; filterRow!.highlight = true; sp.closeAllExpandRows(findEntry.rowParentId); @@ -797,7 +819,7 @@ function findEntryTypeSdk(sp: SpSystemTrace, findEntry: any) { let parentRow = sp.shadowRoot!.querySelector>(`trace-row[row-type='sdk'][folder]`); if (parentRow) { let sdkRow = parentRow.childrenList.filter( - (child) => child.rowId === findEntry.rowId && child.rowType === findEntry.rowType + (child) => child.rowId === findEntry.rowId && child.rowType === findEntry.rowType )[0]; sdkRow!.highlight = true; } @@ -808,7 +830,7 @@ function findEntryTypeSdk(sp: SpSystemTrace, findEntry: any) { sp.closeAllExpandRows(findEntry.rowParentId); sp.scrollToProcess(`${findEntry.rowId}`, `${findEntry.rowParentId}`, findEntry.rowType, true); } -async function spSystemTraceInitBuffer(sp:SpSystemTrace,param:{buf?:ArrayBuffer;Url?:string},wasmConfigUri:string,progress:Function) { +async function spSystemTraceInitBuffer(sp: SpSystemTrace, param: { buf?: ArrayBuffer; Url?: string }, wasmConfigUri: string, progress: Function) { if (param.buf) { let configJson = ''; try { @@ -823,30 +845,30 @@ async function spSystemTraceInitBuffer(sp:SpSystemTrace,param:{buf?:ArrayBuffer; } SpSystemTrace.SDK_CONFIG_MAP = sdkConfigMap == undefined ? undefined : sdkConfigMap; return null - }else{ + } else { return null; } } -async function spSystemTraceInitUrl(sp:SpSystemTrace,param: { buf?: ArrayBuffer; url?: string }, wasmConfigUri: string, progress: Function) { +async function spSystemTraceInitUrl(sp: SpSystemTrace, param: { buf?: ArrayBuffer; url?: string }, wasmConfigUri: string, progress: Function) { if (param.url) { let { status, msg } = await threadPool.initServer(param.url, progress); if (!status) { return { status: false, msg: msg }; - }else{ + } else { return null; } - }else{ + } else { return null; } } -export async function spSystemTraceInit(sp:SpSystemTrace,param: { buf?: ArrayBuffer; url?: string }, wasmConfigUri: string, progress: Function) { +export async function spSystemTraceInit(sp: SpSystemTrace, param: { buf?: ArrayBuffer; url?: string }, wasmConfigUri: string, progress: Function) { progress('Load database', 6); - sp.rowsPaneEL!.scroll({top: 0, left: 0}); - let rsBuf = await spSystemTraceInitBuffer(sp,param,wasmConfigUri,progress); + sp.rowsPaneEL!.scroll({ top: 0, left: 0 }); + let rsBuf = await spSystemTraceInitBuffer(sp, param, wasmConfigUri, progress); if (rsBuf) { return rsBuf; } - let rsUrl = await spSystemTraceInitUrl(sp,param,wasmConfigUri,progress); + let rsUrl = await spSystemTraceInitUrl(sp, param, wasmConfigUri, progress); if (rsUrl) { return rsUrl; } @@ -870,10 +892,11 @@ export async function spSystemTraceInit(sp:SpSystemTrace,param: { buf?: ArrayBuf } if (it.folder) { let offsetYTimeOut: any = undefined; - it.addEventListener('expansion-change', expansionChangeHandler(sp,offsetYTimeOut)); + it.addEventListener('expansion-change', expansionChangeHandler(sp, offsetYTimeOut)); } if (sp.loadTraceCompleted) { sp.traceSheetEL?.displaySystemLogsData(); + sp.traceSheetEL?.displaySystemStatesData(); } sp.intersectionObserver?.observe(it); }); @@ -882,7 +905,7 @@ export async function spSystemTraceInit(sp:SpSystemTrace,param: { buf?: ArrayBuf function expansionChangeHandler(sp: SpSystemTrace, offsetYTimeOut: any) { return function (event: any) { let max = [...sp.rowsPaneEL!.querySelectorAll('trace-row')].reduce( - (pre, cur) => pre + cur.clientHeight!, 0); + (pre, cur) => pre + cur.clientHeight!, 0); let offset = sp.rowsPaneEL!.scrollHeight - max; sp.rowsPaneEL!.scrollTop = sp.rowsPaneEL!.scrollTop - offset; JankStruct.delJankLineFlag = false; @@ -915,7 +938,7 @@ function expansionChangeHandler(sp: SpSystemTrace, offsetYTimeOut: any) { }, 360); } } -function linkNodeHandler(linkNode: PairPoint[], sp: SpSystemTrace){ +function linkNodeHandler(linkNode: PairPoint[], sp: SpSystemTrace) { if (linkNode[0].rowEL.collect) { linkNode[0].rowEL.translateY = linkNode[0].rowEL.getBoundingClientRect().top - 195; } else { 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..1d960af3a0784a51f020d0e1e22ec34540753b24 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/ProcedureWorkerBpftrace'; function dpr(): number { return window.devicePixelRatio || 1; @@ -150,6 +151,7 @@ export class SpSystemTrace extends BaseElement { static sliceRangeMark: any; static wakeupList: Array = []; static keyPathList: Array = []; + static keyboardFlar: Boolean = true; static jsProfilerMap: Map = new Map(); times: Set = new Set(); currentSlicesTime: CurrentSlicesTime = new CurrentSlicesTime(); @@ -201,9 +203,11 @@ export class SpSystemTrace extends BaseElement { collapseAll: boolean = false; currentCollectGroup: string = '1'; private _list: Array = []; + static isHiddenMenu: boolean = false; expandRowList: Array> = []; _slicesList: Array = []; _flagList: Array = []; + static currentStartTime: number = 0; set snapshotFile(data: FileInfo) { this.snapshotFiles = data; @@ -257,7 +261,11 @@ export class SpSystemTrace extends BaseElement { addPointPair(startPoint: PairPoint, endPoint: PairPoint): void { if (startPoint.rowEL.collect) { - startPoint.rowEL.translateY = startPoint.rowEL.getBoundingClientRect().top - 195; + if (this.timerShaftEL?._checkExpand) { + startPoint.rowEL.translateY = startPoint.rowEL.getBoundingClientRect().top - 195 + this.timerShaftEL._usageFoldHeight!; + } else { + startPoint.rowEL.translateY = startPoint.rowEL.getBoundingClientRect().top - 195; + } } else { startPoint.rowEL.translateY = startPoint.rowEL.offsetTop - this.rowsPaneEL!.scrollTop; } @@ -498,12 +506,20 @@ export class SpSystemTrace extends BaseElement { rowsElOnScroll = (e: any): void => { this.linkNodes.forEach((itln) => { if (itln[0].rowEL.collect) { - itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195; + if (this.timerShaftEL?._checkExpand) { + itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195 + this.timerShaftEL._usageFoldHeight!; + } else { + itln[0].rowEL.translateY = itln[0].rowEL.getBoundingClientRect().top - 195; + } } else { itln[0].rowEL.translateY = itln[0].rowEL.offsetTop - this.rowsPaneEL!.scrollTop; } if (itln[1].rowEL.collect) { - itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195; + if (this.timerShaftEL?._checkExpand) { + itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195 + this.timerShaftEL._usageFoldHeight!; + } else { + itln[1].rowEL.translateY = itln[1].rowEL.getBoundingClientRect().top - 195; + } } else { itln[1].rowEL.translateY = itln[1].rowEL.offsetTop - this.rowsPaneEL!.scrollTop; } @@ -556,7 +572,20 @@ export class SpSystemTrace extends BaseElement { //draw trace row this.visibleRows.forEach((v, i) => { if (v.collect) { - v.translateY = v.getBoundingClientRect().top - 195; + if (this.timerShaftEL?._checkExpand) { + if (SpSystemTrace.isHiddenMenu) { + v.translateY = v.getBoundingClientRect().top - 195 + this.timerShaftEL.usageFoldHeight! + 48; + } else { + v.translateY = v.getBoundingClientRect().top - 195 + this.timerShaftEL.usageFoldHeight!; + } + } + else { + if (SpSystemTrace.isHiddenMenu) { + v.translateY = v.getBoundingClientRect().top - 195 + 48; + } else { + v.translateY = v.getBoundingClientRect().top - 195; + } + } } else { v.translateY = v.offsetTop - this.rowsPaneEL!.scrollTop; } @@ -752,6 +781,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; @@ -768,6 +802,7 @@ export class SpSystemTrace extends BaseElement { JankStruct.selectJankStruct || AppStartupStruct.selectStartupStruct || SoStruct.selectSoStruct || + SampleStruct.selectSampleStruct || AllAppStartupStruct.selectStartupStruct || FrameAnimationStruct.selectFrameAnimationStruct || JsCpuProfilerStruct.selectJsCpuProfilerStruct; @@ -778,9 +813,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 +1049,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 +1079,7 @@ export class SpSystemTrace extends BaseElement { AllAppStartupStruct.selectStartupStruct = undefined; LtpoStruct.selectLtpoStruct = undefined; HitchTimeStruct.selectHitchTimeStruct = undefined; + SampleStruct.selectSampleStruct = undefined; return this; } @@ -1061,7 +1105,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 +1123,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 +1138,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, @@ -1412,6 +1460,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 +1522,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 +1536,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 +1625,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 +1665,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 +1804,11 @@ export class SpSystemTrace extends BaseElement { this.hoverStructNull(); this.selectStructNull(); this.wakeupListNull(); + setTimeout(() => { + this.onClickHandler(TraceRow.ROW_TYPE_FUNC); + }, 0) FuncStruct.hoverFuncStruct = entry; FuncStruct.selectFuncStruct = entry; - this.onClickHandler(TraceRow.ROW_TYPE_FUNC); this.scrollToDepth(`${funcRowID}`, `${funcStract.pid}`, 'func', true, entry.depth || 0); } }; @@ -1772,6 +1873,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 +1957,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); @@ -1849,9 +1965,9 @@ export class SpSystemTrace extends BaseElement { procedurePool.clearCache(); Utils.clearData(); InitAnalysis.getInstance().isInitAnalysis = true; - procedurePool.submitWithName('logic0', 'clear', {}, undefined, (res: any) => {}); + procedurePool.submitWithName('logic0', 'clear', {}, undefined, (res: any) => { }); if (threadPool) { - threadPool.submitProto(QueryEnum.ClearMemoryCache, {}, (res: any, len: number): void => {}); + threadPool.submitProto(QueryEnum.ClearMemoryCache, {}, (res: any, len: number): void => { }); } this.times.clear(); resetVSync(); @@ -1907,12 +2023,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..12dfd1880405ac08f60ef0e83245c9f20e80e34a 100644 --- a/ide/src/trace/component/chart/FrameChart.ts +++ b/ide/src/trace/component/chart/FrameChart.ts @@ -25,6 +25,7 @@ const filterPixel = 2; // 过滤像素 const textMaxWidth = 50; const scaleRatio = 0.2; // 缩放比例 const ms10 = 10_000_000; +const jsStackPath = ['.ts', '.ets', '.js']; class NodeValue { size: number; @@ -185,6 +186,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); } } @@ -215,6 +231,20 @@ export class FrameChart extends BaseElement { : `Root : ${currentValue}`; } + /** + * 判断lib中是否包含.ts .ets .js .hap + * @param str node.lib + * @returns 是否包含 + */ + private isJsStack(str: string): boolean { + for (const format of jsStackPath) { + if (str.indexOf(format) > 0) { + return true; + } + } + return false; + } + /** * 计算调用栈最大深度,计算每个node显示大小 * @param node 函数块 @@ -224,6 +254,12 @@ export class FrameChart extends BaseElement { private initData(node: ChartStruct, depth: number, calDisplay: boolean): void { node.depth = depth; depth++; + if (this.isJsStack(node.lib)) { + node.isJsStack = true; + } else { + node.isJsStack = false; + } + //设置搜索以及点选的显示值,将点击/搜索的值设置为父节点的显示值 this.clearDisplayInfo(node); if (node.isSearch && calDisplay) { diff --git a/ide/src/trace/component/chart/SpAllAppStartups.ts b/ide/src/trace/component/chart/SpAllAppStartups.ts index faf9f5ea812ce5de20d898237c3fa97d1d9a982e..c82e2f09fa18a0cd0cc79f134427d25e46da0544 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> => { @@ -97,6 +98,12 @@ export class SpAllAppStartupsChart { translateY: undefined, frame: undefined, isHover: false, + value: undefined, + pid: undefined, + process: undefined, + tid: undefined, + itid: undefined, + endItid: undefined }); } return sendRes; diff --git a/ide/src/trace/component/chart/SpBpftraceChart.ts b/ide/src/trace/component/chart/SpBpftraceChart.ts new file mode 100644 index 0000000000000000000000000000000000000000..19fdd265b9141989d0845e152f01f6231c420937 --- /dev/null +++ b/ide/src/trace/component/chart/SpBpftraceChart.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/ProcedureWorkerBpftrace'; +import { queryStartTime } from '../../database/sql/SqlLite.sql'; + +export class SpBpftraceChart { + 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 = 'bpftrace'; + traceRow.index = 0; + traceRow.rowType = TraceRow.ROW_TYPE_SAMPLE; + traceRow.rowParentId = ''; + traceRow.folder = false; + traceRow.style.height = '40px'; + traceRow.name = 'bpftrace'; + 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: 'bpftrace', + 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.getJsonData(e).then((res: any) => { + this.resetChartData(row); + 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: 'bpftrace', + 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/SpChartManager.ts b/ide/src/trace/component/chart/SpChartManager.ts index ea86c2eff93663635a059c4610753c16fbf38503..a89d811c713db2b4654f3c2e9d07b2dad30fc025 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 { SpBpftraceChart } from './SpBpftraceChart'; 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 spBpftraceChart: SpBpftraceChart; 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.spBpftraceChart = new SpBpftraceChart(trace); } async init(progress: Function) { @@ -122,6 +131,9 @@ export class SpChartManager { progress('cpu', 70); await this.cpu.init(); info('initData cpu Data initialized'); + if (FlagsConfig.getFlagsConfigEnableStatus('Bpftrace')) { + await this.spBpftraceChart.init(null); + } progress('process/thread state', 73); await this.cpu.initProcessThreadStateData(progress); if (FlagsConfig.getFlagsConfigEnableStatus('SchedulingAnalysis')) { @@ -146,6 +158,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 +191,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 +203,11 @@ export class SpChartManager { progress('display', 95); } + async initSample(ev: File) { + await this.initSampleTime(); + await this.spBpftraceChart.init(ev); + } + async importSoFileUpdate() { SpSystemTrace.DATA_DICT.clear(); let dict = await queryDataDICT(); @@ -230,6 +251,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 +282,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/SpCpuChart.ts b/ide/src/trace/component/chart/SpCpuChart.ts index a0b0e25a5edc32fadaa1b7e860eb919d4428c348..c00df099dc17c7ae98f8b828ec78b41c79979021 100644 --- a/ide/src/trace/component/chart/SpCpuChart.ts +++ b/ide/src/trace/component/chart/SpCpuChart.ts @@ -55,7 +55,7 @@ export class SpCpuChart { traceRow.rowId = `${cpuId}`; traceRow.rowType = TraceRow.ROW_TYPE_CPU; traceRow.rowParentId = ''; - traceRow.style.height = '40px'; + traceRow.style.height = '30px'; traceRow.name = `Cpu ${cpuId}`; traceRow.favoriteChangeHandler = this.trace.favoriteChangeHandler; traceRow.selectChangeHandler = this.trace.selectChangeHandler; diff --git a/ide/src/trace/component/chart/SpEBPFChart.ts b/ide/src/trace/component/chart/SpEBPFChart.ts index 851b3663111f8b6233517a35a06e8f0e611ed2f9..7527a52a0e696bcda1fd89706b8b7f4280e456b0 100644 --- a/ide/src/trace/component/chart/SpEBPFChart.ts +++ b/ide/src/trace/component/chart/SpEBPFChart.ts @@ -343,7 +343,7 @@ export class SpEBPFChart { vmTraceRow.selectChangeHandler = this.trace.selectChangeHandler; vmTraceRow.focusHandler = () => this.focusHandler(vmTraceRow); vmTraceRow.findHoverStruct = () => { - EBPFChartStruct.hoverEBPFStruct = vmTraceRow.getHoverStruct(false); + EBPFChartStruct.hoverEBPFStruct = vmTraceRow.getHoverStruct(false, false, 'size'); }; vmTraceRow.onThreadHandler = (useCache) => { let context: CanvasRenderingContext2D; 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..d73efcc88dba6e9f76aea74a40abd95f75ee42f8 --- /dev/null +++ b/ide/src/trace/component/chart/SpLTPO.ts @@ -0,0 +1,502 @@ +/* + * 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, + queryRSNowTimeList, + querySignaledList, + querySkipDataList +} 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 rsNowTimeList: Array = []; + static skipDataList: Array = []; + static ltpoDataArr: Array = []; + static sendLTPODataArr: Array = []; + static sendHitchDataArr: Array = []; + static signaledFence: Array = []; + static tempRsNowTimeList: Array = []; + static threadName: String = 'Present%'; + static funName: String = 'H:Waiting for Present Fence%'; + static signaledList: Array = []; + constructor(trace: SpSystemTrace) { + SpLtpoChart.trace = trace; + } + + async init() { + SpLtpoChart.ltpoDataArr = []; + SpLtpoChart.fanceNameList = await queryFanceNameList(); + SpLtpoChart.fpsnameList = await queryFpsNameList(); + SpLtpoChart.realFpsList = await queryRealFpsList(); + SpLtpoChart.rsNowTimeList = await queryRSNowTimeList(); + SpLtpoChart.skipDataList = await querySkipDataList(); + SpLtpoChart.signaledList = await querySignaledList(); + this.initFenceName(); + this.initFpsName(); + if (SpLtpoChart.realFpsList.length > 0) { + this.initRealFps(); + }; + this.initRsNowTime(); + //特殊情况:当前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) { + let fpsIndex = 0; + let fanceIndex = 0; + while (fpsIndex < SpLtpoChart.fpsnameList!.length) { + if (SpLtpoChart.fanceNameList[fanceIndex] && SpLtpoChart.fpsnameList[fpsIndex]) { + if (SpLtpoChart.fanceNameList[fanceIndex].ts! > SpLtpoChart.fpsnameList[fpsIndex].ts! && + SpLtpoChart.fanceNameList[fanceIndex].ts! < SpLtpoChart.fpsnameList[fpsIndex].ts! + SpLtpoChart.fpsnameList[fpsIndex].dur!) { + fpsIndex++; + fanceIndex++; + } else if (SpLtpoChart.fanceNameList[fanceIndex].ts! < SpLtpoChart.fpsnameList[fpsIndex].ts!) { + SpLtpoChart.fanceNameList.splice(fanceIndex, 1); + } else if (SpLtpoChart.fanceNameList[fanceIndex].ts! > SpLtpoChart.fpsnameList[fpsIndex].ts! + SpLtpoChart.fpsnameList[fpsIndex].dur!) { + SpLtpoChart.fpsnameList.splice(fpsIndex, 1); + } + } else if (SpLtpoChart.fanceNameList[fanceIndex] && !SpLtpoChart.fpsnameList[fpsIndex]) { + SpLtpoChart.fanceNameList.splice(fanceIndex); + } else if (!SpLtpoChart.fanceNameList[fanceIndex] && SpLtpoChart.fpsnameList[fpsIndex]) { + SpLtpoChart.fpsnameList.splice(fpsIndex) + } else { + return + } + } + } + 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; + }; + this.fenceToFps(); + this.fpsToRenderService(); + this.filterNowTime(); + if (SpLtpoChart.fanceNameList && SpLtpoChart.fanceNameList.length) { + await this.initFolder(); + await this.initHitchTime(); + } + } + //提取FenceId + initFenceName(): void { + 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]); + } + }) + }; + //从数据库中查询的name中提取fps + initFpsName(): void { + SpLtpoChart.fpsnameList.map((item) => { + if (item.name!.indexOf('=') === -1) { + let cutFpsNameArr = item.name!.split(',')[0].split(':'); + let cutFpsNameTimeArr = item.name!.split(',')[1].split(':'); + item.fps = Number(cutFpsNameArr[cutFpsNameArr.length - 1]); + item.nowTime = Number(cutFpsNameTimeArr[cutFpsNameTimeArr.length - 1]); + } else { + let cutFpsNameArr = item.name!.split('='); + item.fps = Number(cutFpsNameArr[cutFpsNameArr.length - 1]); + } + }) + }; + //如果存在切帧,提取fps + initRealFps(): void { + SpLtpoChart.realFpsList.map((item) => { + let cutRealFpsArr = item.name!.split(' '); + item.fps = Number(cutRealFpsArr[cutRealFpsArr.length - 1]); + }); + this.setRealFps(); + }; + //从render_service中获取nowTime + initRsNowTime(): void { + SpLtpoChart.rsNowTimeList.map((item) => { + let cutRsNameArr = item.name!.split(' ')[2].split(':'); + item.nowTime = Number(cutRsNameArr[cutRsNameArr.length - 1]); + }) + }; + //处理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++; + } + } + }; + //RSHardwareThread泳道的fps数组集成FenceId数组中的FenceId和signaled + fenceToFps() { + if (SpLtpoChart.fanceNameList.length === SpLtpoChart.fpsnameList.length) { + let fenceIndex = 0; + let fpsIndex = 0; + while (fpsIndex < SpLtpoChart.fpsnameList.length) { + if (SpLtpoChart.fpsnameList[fpsIndex] && SpLtpoChart.fanceNameList[fenceIndex]) { + if (SpLtpoChart.fanceNameList[fenceIndex].ts! > SpLtpoChart.fpsnameList[fpsIndex].ts! && + SpLtpoChart.fanceNameList[fenceIndex].ts! < (SpLtpoChart.fpsnameList[fpsIndex].ts! + SpLtpoChart.fpsnameList[fpsIndex].dur!)) { + SpLtpoChart.fpsnameList[fpsIndex].fanceId = SpLtpoChart.fanceNameList[fenceIndex].fanceId; + if (SpLtpoChart.fanceNameList[fenceIndex].signaled) { + SpLtpoChart.fpsnameList[fpsIndex].signaled = SpLtpoChart.fanceNameList[fenceIndex].signaled; + }; + fenceIndex++; + fpsIndex++; + } else if (SpLtpoChart.fanceNameList[fenceIndex].ts! < SpLtpoChart.fpsnameList[fpsIndex].ts!) { + fenceIndex++; + } else if (SpLtpoChart.fanceNameList[fenceIndex].ts! > (SpLtpoChart.fpsnameList[fpsIndex].ts! + SpLtpoChart.fpsnameList[fpsIndex].dur!)) { + fpsIndex++; + } + } else { + return; + } + } + } + }; + //render_service的nowTime 集成RSHardThread泳道Fps数组的FenceId和Signaled + fpsToRenderService(): void { + if (SpLtpoChart.signaledList.length || SpLtpoChart.skipDataList.length) { + let rsIndex = 0; + let hardIndex = 0; + while (rsIndex < SpLtpoChart.rsNowTimeList.length) { + if (SpLtpoChart.fpsnameList[hardIndex] && SpLtpoChart.rsNowTimeList[rsIndex]) { + if (SpLtpoChart.rsNowTimeList[rsIndex].nowTime! > SpLtpoChart.fpsnameList[hardIndex].nowTime!) { //处理nowTime不一致的情况 + hardIndex++; + } else if (SpLtpoChart.rsNowTimeList[rsIndex].nowTime! < SpLtpoChart.fpsnameList[hardIndex].nowTime!) { + rsIndex++; + } else { + SpLtpoChart.rsNowTimeList[rsIndex].fanceId = SpLtpoChart.fpsnameList[hardIndex].fanceId; + SpLtpoChart.rsNowTimeList[rsIndex].fps = SpLtpoChart.fpsnameList[hardIndex].fps; + if (SpLtpoChart.fpsnameList[hardIndex].signaled) { + SpLtpoChart.rsNowTimeList[rsIndex].signaled = SpLtpoChart.fpsnameList[hardIndex].signaled; + }; + hardIndex++; + rsIndex++; + } + } else { + return; + } + } + } + }; + //render_service中找出skip和signaled,将需要从上平时间减去的时间计算出来存在对应的nowTime的item中 + filterNowTime(): void { + let skipIndex = 0; + let nowTimeIndex = 0; + let cutTimeSum = 0; + let tempFps = 0;//如果中间出现signaled,记录一下fps; + //将render_service中的nowTime数组中的skip去除掉 + SpLtpoChart.tempRsNowTimeList = SpLtpoChart.rsNowTimeList.filter((item) => item.fps); + while (skipIndex < SpLtpoChart.skipDataList.length) { + if (SpLtpoChart.skipDataList[skipIndex] && SpLtpoChart.tempRsNowTimeList[nowTimeIndex]) { + if (SpLtpoChart.skipDataList[skipIndex].ts! > SpLtpoChart.tempRsNowTimeList[nowTimeIndex].ts!) { + if (cutTimeSum > 0 && nowTimeIndex > 0) { + SpLtpoChart.tempRsNowTimeList[nowTimeIndex - 1].cutTime = cutTimeSum; + if (!SpLtpoChart.tempRsNowTimeList[nowTimeIndex].signaled) { + cutTimeSum = 0; + } + }; + if (SpLtpoChart.tempRsNowTimeList[nowTimeIndex].signaled && nowTimeIndex > 0) {//两帧之间初心signaled + tempFps = SpLtpoChart.tempRsNowTimeList[nowTimeIndex].fps!; + cutTimeSum += 1000 / tempFps; + SpLtpoChart.tempRsNowTimeList[nowTimeIndex - 1].cutTime = cutTimeSum; + SpLtpoChart.tempRsNowTimeList.splice(nowTimeIndex, 1); + } else if (!SpLtpoChart.tempRsNowTimeList[nowTimeIndex].signaled) { + nowTimeIndex++; + cutTimeSum = 0; + tempFps = 0; + } + } else if (SpLtpoChart.skipDataList[skipIndex].ts! < SpLtpoChart.tempRsNowTimeList[nowTimeIndex].ts!) { + if (nowTimeIndex > 0) { + cutTimeSum += tempFps ? (1000 / tempFps) : (1000 / SpLtpoChart.tempRsNowTimeList[nowTimeIndex - 1].fps!); + } + skipIndex++; + } + } else { + return; + } + } + }; + 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[] = []; + let ltpoDataIndex = 0; + let tempRsNowTimeIndex = 0; + //当有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; + } + while (ltpoDataIndex < ltpoDataArr.length) { + let sendStartTs: number | undefined = 0; + let sendDur: number | undefined = 0; + let cutSendDur: number | undefined = 0; + if (ltpoDataArr[ltpoDataIndex].fanceId !== -1 && ltpoDataArr[ltpoDataIndex].nextDur) { + sendStartTs = Number(ltpoDataArr[ltpoDataIndex].startTs) + Number(ltpoDataArr[ltpoDataIndex].dur); + sendDur = Number(ltpoDataArr[ltpoDataIndex].nextStartTs) + Number(ltpoDataArr[ltpoDataIndex].nextDur) - sendStartTs; + }; + if (ltpoDataArr[ltpoDataIndex] && SpLtpoChart.tempRsNowTimeList[tempRsNowTimeIndex]) { + if (ltpoDataArr[ltpoDataIndex].fanceId! < SpLtpoChart.tempRsNowTimeList[tempRsNowTimeIndex].fanceId!) { + ltpoDataIndex++; + } else if (ltpoDataArr[ltpoDataIndex].fanceId! > SpLtpoChart.tempRsNowTimeList[tempRsNowTimeIndex].fanceId!) { + tempRsNowTimeIndex++; + } else { + if (SpLtpoChart.tempRsNowTimeList[tempRsNowTimeIndex].cutTime) { + cutSendDur = sendDur - (SpLtpoChart.tempRsNowTimeList[tempRsNowTimeIndex].cutTime! * 1000000); + cutSendDur = cutSendDur < 0 ? 0 : cutSendDur; + } + } + }; + let tmpDur = cutSendDur ? ((Math.ceil(cutSendDur / 100000)) / 10) : (Math.ceil(sendDur / 100000)) / 10; + if (tmpDur < 170) { + sendDataArr.push( + { + dur: sendDur, + cutSendDur: cutSendDur, + value: 0, + startTs: sendStartTs, + pid: ltpoDataArr[ltpoDataIndex].fanceId, + itid: ltpoDataArr[ltpoDataIndex].fanceId, + name: undefined, + presentId: ltpoDataArr[ltpoDataIndex].fanceId, + ts: undefined, + fanceId: ltpoDataArr[ltpoDataIndex].fanceId, + fps: ltpoDataArr[ltpoDataIndex].fps, + nextStartTs: ltpoDataArr[ltpoDataIndex].nextStartTs, + nextDur: ltpoDataArr[ltpoDataIndex].nextDur, + translateY: undefined, + frame: undefined, + isHover: false, + startTime: undefined, + signaled: undefined, + nowTime: undefined, + cutTime: undefined + } + ); + }; + ltpoDataIndex++; + tempRsNowTimeIndex++; + } + 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); + } + } + + } + + + 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; + SpLtpoChart.sendLTPODataArr = this.sendDataHandle(SpLtpoChart.presentArr, SpLtpoChart.ltpoDataArr); + for (let i = 0; i < SpLtpoChart.sendLTPODataArr.length; i++) { + let tmpDur = SpLtpoChart.sendLTPODataArr[i].cutSendDur ? (SpLtpoChart.sendLTPODataArr[i].cutSendDur! / 1000000) : (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( + { + ltpoContext: 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; + SpLtpoChart.sendHitchDataArr = this.sendDataHandle(SpLtpoChart.presentArr, SpLtpoChart.ltpoDataArr); + for (let i = 0; i < SpLtpoChart.sendHitchDataArr.length; i++) { + let tmpVale = 0; + let tmpDur = 0; + if (SpLtpoChart.sendHitchDataArr[i].cutSendDur) { + tmpVale = (Math.ceil(((SpLtpoChart.sendHitchDataArr[i].cutSendDur! / 1000000) - (1000 / SpLtpoChart.sendHitchDataArr[i].fps!)) * 10)) / 10; + tmpDur = SpLtpoChart.sendHitchDataArr[i].cutSendDur! / 1000000; + } else { + tmpVale = (Math.ceil(((SpLtpoChart.sendHitchDataArr[i].dur! / 1000000) - (1000 / SpLtpoChart.sendHitchDataArr[i].fps!)) * 10)) / 10; + tmpDur = SpLtpoChart.sendHitchDataArr[i].dur! / 1000000; + } + + let mathValue = tmpDur * Number(SpLtpoChart.sendHitchDataArr[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( + { + hitchTimeContext: 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..9bf06a9f34527c2645f7a9b7ffac58a053459a4b 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'; } @@ -146,13 +148,16 @@ export class SpProcessChart { }); if (funcRow && !funcRow.isComplete) { let max = Math.max(...asyncFuncGroups.map((it) => it.depth || 0)) + 1; - let maxHeight = max * 20; + let maxHeight = max * 18 + 6; funcRow.style.height = `${maxHeight}px`; funcRow.setAttribute('height', `${maxHeight}`); } 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,333 @@ 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 = '18px'; + 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 * 18 + 6; + 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); + } + }); + } + private calMaxHeight(asyncFunctions: any[]) : number{ + let max = 0; + asyncFunctions.forEach((it) => { + const depth = it.depth || 0; + if (depth > max) { + max = depth; + } + }); + max += 1; + return max * 18 + 6;; + } + + //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]; + }); + const maxHeight = this.calMaxHeight(asyncFunctions); + 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/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/chart/VSync.ts b/ide/src/trace/component/chart/VSync.ts index 299ba5b4f7f90eeb4f2a4e4757fcd3f225cfad02..3687ffbf2b25fa99ac5935ffe3335c525c9b6c9c 100644 --- a/ide/src/trace/component/chart/VSync.ts +++ b/ide/src/trace/component/chart/VSync.ts @@ -14,6 +14,7 @@ */ import { query } from '../../database/SqlLite'; import { TraceRow } from '../trace/base/TraceRow'; +import { FlagsConfig } from '../../component/SpFlags'; interface VSyncData { startTime: number; dur: number; @@ -49,18 +50,28 @@ export const querySfVSyncData = (): Promise> => })` ); -export const querySingleVSyncData = (): Promise> => - query( - 'querySingleVSyncData', - `SELECT c.ts - tb.start_ts startTime + export const querySingleVSyncData = (): Promise> => { + let flagsItem = window.localStorage.getItem(FlagsConfig.FLAGS_CONFIG_KEY); + let flagsItemJson = JSON.parse(flagsItem!); + let vsyncValue = flagsItemJson.vsyncValue; + let vsyncCondition = ''; + if (vsyncValue === 'H:VsyncGenerator' || vsyncValue === '') { + vsyncCondition = ` AND (callstack.name like 'H:GenerateVsyncCount%' or callstack.name like 'H:VSyncGenerator::ThreadLoop::Continue%'))`; + } else { + vsyncCondition = ` AND callstack.name like '${vsyncValue}%' )`; + } + + let sql = + `SELECT c.ts - tb.start_ts startTime FROM callstack c, trace_range tb WHERE c.id IN (SELECT callstack.id AS trackId FROM callstack JOIN process - WHERE process.name = 'render_service' - AND (callstack.name like 'H:GenerateVsyncCount%' or callstack.name like 'H:VSyncGenerator::ThreadLoop::Continue%'))` - ); + WHERE process.name = 'render_service'` + + vsyncCondition; + return query('querySingleVSyncData', sql); + } /** * load single vsync data 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/SpAllocation.html.ts b/ide/src/trace/component/setting/SpAllocation.html.ts index 2aeb248a1190149bbdc5e4a327ad46ce0cd4110d..8487003f00faedf9c564c8c957a9c5aa8d6b4f8c 100644 --- a/ide/src/trace/component/setting/SpAllocation.html.ts +++ b/ide/src/trace/component/setting/SpAllocation.html.ts @@ -127,9 +127,10 @@ input::-webkit-input-placeholder{ #two_kb{ background-color:var(--dark-background5, #FFFFFF) } -.processSelect { - border-radius: 15px; - width: 84%; +.processSelect, .packageSelect { + border-radius: 15px; + width: 84%; + height: 27px; } .value-range { opacity: 0.6; @@ -220,6 +221,9 @@ lit-switch { + +
          Max unwind level @@ -254,10 +258,6 @@ lit-switch { Byte
          -
          - Use Fp Unwind - -
          Sample Interval (Available on recent OpenHarmony 4.0) Max Sample Interval Rang is 0 - 65535, default 0 @@ -267,6 +267,29 @@ lit-switch { this.value.toString().startsWith('0')){ this.value = '1'}" onkeyup="this.value=this.value.replace(/\\D/g,'')" value="0">
          + + +
          + Use Fp Unwind + +
          Use Record Accurately (Available on recent OpenHarmony 4.0) @@ -286,9 +309,13 @@ lit-switch { Use Response Lib Mode (Available on recent OpenHarmony 4.0) +
          +
          + Record Js Stack +
          Use Record Statistics (Available on recent OpenHarmony 4.0) diff --git a/ide/src/trace/component/setting/SpAllocations.ts b/ide/src/trace/component/setting/SpAllocations.ts index 3c1e45d8568f173e61ee898d314a9a01150742c6..72fe9aae7ad80d3270c1776a94bc55f053485846 100644 --- a/ide/src/trace/component/setting/SpAllocations.ts +++ b/ide/src/trace/component/setting/SpAllocations.ts @@ -21,20 +21,13 @@ import LitSwitch from '../../../base-ui/switch/lit-switch'; import { LitSlider } from '../../../base-ui/slider/LitSlider'; import { LitSelectV } from '../../../base-ui/select/LitSelectV'; import { SpAllocationHtml } from './SpAllocation.html'; -import { - NUM_16384, - NUM_1800, - NUM_30, - NUM_300, - NUM_3600, - NUM_450, - NUM_60, - NUM_600 -} from '../../bean/NumBean'; +import { NUM_16384, NUM_1800, NUM_30, NUM_300, NUM_3600, NUM_450, NUM_60, NUM_600 } from '../../bean/NumBean'; +import { LitSelect } from '../../../base-ui/select/LitSelect'; @element('sp-allocations') export class SpAllocations extends BaseElement { private processId: LitSelectV | null | undefined; + private packageName: LitSelect | null | undefined; private unwindEL: HTMLInputElement | null | undefined; private shareMemory: HTMLInputElement | null | undefined; private shareMemoryUnit: HTMLSelectElement | null | undefined; @@ -45,11 +38,14 @@ export class SpAllocations extends BaseElement { private recordAccurately: LitSwitch | null | undefined; private offlineSymbol: LitSwitch | null | undefined; private startupMode: LitSwitch | null | undefined; + private jsStackModel: LitSwitch | null | undefined; private responseLibMode: LitSwitch | null | undefined; private recordStatisticsResult: HTMLDivElement | null | undefined; private sampleInterval: HTMLInputElement | null | undefined; private filterSize: HTMLInputElement | null | undefined; + private napiName: HTMLInputElement | null | undefined; + private jsStackDepth: HTMLInputElement | null | undefined; set startSamp(allocationStart: boolean) { if (allocationStart) { @@ -64,17 +60,17 @@ export class SpAllocations extends BaseElement { } get appProcess(): string { - return this.processId!.value || ''; + return this.processId!.value || this.packageName!.value || ''; } get unwind(): number { - log(`unwind value is :${ this.unwindEL!.value}`); + log(`unwind value is :${this.unwindEL!.value}`); return Number(this.unwindEL!.value); } get shared(): number { let value = this.shareMemory?.value || ''; - log(`shareMemory value is :${ value}`); + log(`shareMemory value is :${value}`); if (value !== '') { return Number(this.shareMemory?.value) || NUM_16384; } @@ -83,7 +79,7 @@ export class SpAllocations extends BaseElement { get filter(): number { let value = this.filterMemory?.value || ''; - log(`filter value is :${ value}`); + log(`filter value is :${value}`); if (value !== '') { return Number(value); } @@ -151,9 +147,23 @@ export class SpAllocations extends BaseElement { } } + get recordJsStack(): boolean { + let value = this.jsStackModel?.checked; + if (value !== undefined) { + return value; + } + return false; + } + + set recordJsStack(value: boolean) { + if (this.jsStackModel) { + this.jsStackModel.checked = value; + } + } + get expandPids(): number[] { let allPidList: number[] = []; - if (this.processId?.value.length > 0) { + if (this.processId!.value.length > 0) { let result = this.processId?.value.match(/\((.+?)\)/g); if (result) { for (let index = 0; index < result.length; index++) { @@ -170,6 +180,20 @@ export class SpAllocations extends BaseElement { return Number(this.sampleInterval!.value); } + get filter_napi_name(): string { + if (this.jsStackModel?.checked) { + return this.napiName!.value || ''; + } + return ''; + } + + get max_js_stack_depth(): number { + if (this.jsStackModel?.checked) { + return Number(this.jsStackDepth!.value); + } + return 0; + } + connectedCallback(): void { this.unwindEL?.addEventListener('keydown', this.handleInputChange); this.shareMemory?.addEventListener('keydown', this.handleInputChange); @@ -180,9 +204,11 @@ export class SpAllocations extends BaseElement { this.statisticsSlider?.addEventListener('input', this.statisticsSliderInputHandler); this.intervalResultInput?.addEventListener('input', this.intervalResultInputHandler); this.intervalResultInput?.addEventListener('focusout', this.intervalResultFocusOutHandler); - this.statisticsSlider?.shadowRoot?.querySelector('#slider')!. - addEventListener('mouseup', this.statisticsSliderMouseupHandler); - this.startupMode?.addEventListener('change',this.startupModeChangeHandler); + this.statisticsSlider?.shadowRoot + ?.querySelector('#slider')! + .addEventListener('mouseup', this.statisticsSliderMouseupHandler); + this.startupMode?.addEventListener('change', this.startupModeChangeHandler); + this.jsStackModel?.addEventListener('change', this.jsStackModelChangeHandler); } disconnectedCallback(): void { @@ -194,10 +220,12 @@ export class SpAllocations extends BaseElement { this.filterSize?.removeEventListener('keydown', this.handleInputChange); this.statisticsSlider?.removeEventListener('input', this.statisticsSliderInputHandler); this.intervalResultInput?.removeEventListener('input', this.intervalResultInputHandler); - this.intervalResultInput?.removeEventListener('focusout', this.intervalResultFocusOutHandler); - this.statisticsSlider?.shadowRoot?.querySelector('#slider')!. - removeEventListener('mouseup', this.statisticsSliderMouseupHandler); - this.startupMode?.removeEventListener('change',this.startupModeChangeHandler); + this.intervalResultInput?.removeEventListener('focusout', this.jsStackModelChangeHandler); + this.statisticsSlider?.shadowRoot + ?.querySelector('#slider')! + .removeEventListener('mouseup', this.statisticsSliderMouseupHandler); + this.startupMode?.removeEventListener('change', this.startupModeChangeHandler); + this.jsStackModel?.removeEventListener('change', this.startupModeChangeHandler); } handleInputChange = (ev: KeyboardEvent): void => { @@ -210,10 +238,16 @@ export class SpAllocations extends BaseElement { initElements(): void { this.filterSize = this.shadowRoot?.querySelector('#filterSized'); this.processId = this.shadowRoot?.getElementById('pid') as LitSelectV; + this.packageName = this.shadowRoot?.getElementById('packageName') as LitSelect; + this.packageName.style.display = 'none'; let process = this.processId.shadowRoot?.querySelector('input') as HTMLInputElement; process!.addEventListener('mousedown', () => { this.processMouseDownHandler(process); }); + let packageInput = this.packageName.shadowRoot?.querySelector('input') as HTMLInputElement; + packageInput!.addEventListener('mousedown', () => { + this.packageMouseDownHandler(packageInput); + }); this.unwindEL = this.shadowRoot?.getElementById('unwind') as HTMLInputElement; this.shareMemory = this.shadowRoot?.getElementById('shareMemory') as HTMLInputElement; this.shareMemoryUnit = this.shadowRoot?.getElementById('shareMemoryUnit') as HTMLSelectElement; @@ -222,8 +256,11 @@ export class SpAllocations extends BaseElement { this.recordAccurately = this.shadowRoot?.getElementById('use_record_accurately') as LitSwitch; this.offlineSymbol = this.shadowRoot?.getElementById('use_offline_symbolization') as LitSwitch; this.startupMode = this.shadowRoot?.getElementById('use_startup_mode') as LitSwitch; + this.jsStackModel = this.shadowRoot?.getElementById('use_js-stack') as LitSwitch; this.responseLibMode = this.shadowRoot?.getElementById('response_lib_mode') as LitSwitch; this.sampleInterval = this.shadowRoot?.getElementById('sample-interval-input') as HTMLInputElement; + this.napiName = this.shadowRoot?.getElementById('napiName') as HTMLInputElement; + this.jsStackDepth = this.shadowRoot?.getElementById('jsStackDepth') as HTMLInputElement; this.statisticsSlider = this.shadowRoot?.querySelector('#interval-slider') as LitSlider; this.recordStatisticsResult = this.shadowRoot?.querySelector( '.record-statistics-result' @@ -252,16 +289,52 @@ export class SpAllocations extends BaseElement { this.disable(); } }); + this.initProcessInputStatus(); this.disable(); } + private initProcessInputStatus(): void { + this.packageName!.style.display = 'none'; + this.processId!.style.display = 'block'; + let process = this.processId?.shadowRoot?.querySelector('.root') as HTMLDivElement; + if (process) { + process.style.width = 'auto'; + } + } + startupModeChangeHandler = (): void => { let process = this.processId?.shadowRoot?.querySelector('input') as HTMLInputElement; + let processDiv = this.processId?.shadowRoot?.querySelector('.root') as HTMLDivElement; process.value = ''; + let packageInput = this.packageName?.shadowRoot?.querySelector('input') as HTMLInputElement; + let packageDiv = this.packageName?.shadowRoot?.querySelector('.root') as HTMLDivElement; + packageInput.value = ''; if (this.startup_mode) { - process!.placeholder = 'please input process'; + this.packageName!.showItem = ''; + this.packageName!.style.display = 'block'; + this.processId!.style.display = 'none'; + packageDiv.style.width = 'auto'; + packageInput!.placeholder = 'please select package'; + this.processId!.dataSource([], ''); } else { + this.processId!.showItems = []; + this.packageName!.style.display = 'none'; + this.processId!.style.display = 'block'; + processDiv.style.width = 'auto'; process!.placeholder = 'please select process'; + this.packageName!.dataSource = []; + } + }; + + jsStackModelChangeHandler = (): void => { + let napiRecordName = this.shadowRoot?.querySelector('#napi-div') as HTMLDivElement; + let jsStackRecordDepth = this.shadowRoot?.querySelector('#js-stack-depth-div') as HTMLDivElement; + if (this.recordJsStack) { + napiRecordName.style.display = 'flex'; + jsStackRecordDepth.style.display = 'flex'; + } else { + napiRecordName.style.display = 'none'; + jsStackRecordDepth.style.display = 'none'; } }; @@ -270,8 +343,8 @@ export class SpAllocations extends BaseElement { let percentValue = this.recordStatisticsResult!.getAttribute('percent'); let index = Math.round(Number(percentValue) / NUM_450); index = index < 1 ? 0 : index; - this.intervalResultInput!.value = `${stepValue[index] }`; - this.recordStatisticsResult!.setAttribute('percentValue', `${stepValue[index] }`); + this.intervalResultInput!.value = `${stepValue[index]}`; + this.recordStatisticsResult!.setAttribute('percentValue', `${stepValue[index]}`); }); }; @@ -308,16 +381,16 @@ export class SpAllocations extends BaseElement { }; private processMouseDownHandler(process: HTMLInputElement): void { - if (this.startSamp) { - process.readOnly = false; + if (this.startSamp && !this.startup_mode) { Cmd.getProcess().then((processList) => { this.processId?.dataSource(processList, ''); - if (processList.length > 0 && !this.startup_mode) { + if (processList.length > 0) { this.processId?.dataSource(processList, 'ALL-Process'); } else { this.processId?.dataSource([], ''); } }); + process.readOnly = false; } else { process.readOnly = true; return; @@ -327,6 +400,21 @@ export class SpAllocations extends BaseElement { } else { } } + private packageMouseDownHandler(packageInput: HTMLInputElement): void { + if (this.startSamp && this.startup_mode) { + Cmd.getPackage().then((packageList) => { + if (packageList.length > 0) { + this.packageName!.dataSource = packageList; + } else { + this.packageName!.dataSource = []; + } + }); + packageInput.readOnly = false; + } else { + packageInput.readOnly = true; + return; + } + } intervalResultInputHandler = (): void => { let parentElement = this.statisticsSlider!.parentNode as Element; @@ -341,8 +429,10 @@ export class SpAllocations extends BaseElement { parentElement.setAttribute('percent', '3600'); return; } - if (Number(this.intervalResultInput!.value) < this.statisticsSlider!.sliderStyle.minRange || - Number(this.intervalResultInput!.value) > this.statisticsSlider!.sliderStyle.maxRange) { + if ( + Number(this.intervalResultInput!.value) < this.statisticsSlider!.sliderStyle.minRange || + Number(this.intervalResultInput!.value) > this.statisticsSlider!.sliderStyle.maxRange + ) { this.intervalResultInput!.style.color = 'red'; parentElement.setAttribute('percent', '3600'); } else { @@ -392,6 +482,9 @@ export class SpAllocations extends BaseElement { if (this.startupMode) { this.startupMode.disabled = false; } + if (this.jsStackModel) { + this.jsStackModel.disabled = false; + } if (this.responseLibMode) { this.responseLibMode.disabled = false; } @@ -403,6 +496,11 @@ export class SpAllocations extends BaseElement { inputBoxes!.forEach((item) => { item.disabled = false; }); + if (this.startup_mode) { + this.packageName!.removeAttribute('disabled'); + } else { + this.processId!.removeAttribute('disabled'); + } this.statisticsSlider!.disabled = false; } @@ -417,6 +515,9 @@ export class SpAllocations extends BaseElement { if (this.startupMode) { this.startupMode.disabled = true; } + if (this.jsStackModel) { + this.jsStackModel.disabled = true; + } if (this.offlineSymbol) { this.offlineSymbol.disabled = true; } @@ -431,6 +532,11 @@ export class SpAllocations extends BaseElement { inputBoxes!.forEach((item) => { item.disabled = true; }); + if (this.startup_mode) { + this.packageName!.setAttribute('disabled', ''); + } else { + this.processId!.setAttribute('disabled', ''); + } this.statisticsSlider!.disabled = true; } 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 = `
          -
          +
          10 0 diff --git a/ide/src/trace/component/trace/TimerShaftElement.ts b/ide/src/trace/component/trace/TimerShaftElement.ts index 6113c15be23987e3de1d6cfb815d35c345a1d127..c4bc52e2d7473db4cb532a6aef6b424e3db67b79 100644 --- a/ide/src/trace/component/trace/TimerShaftElement.ts +++ b/ide/src/trace/component/trace/TimerShaftElement.ts @@ -138,6 +138,13 @@ export class TimerShaftElement extends BaseElement { private sliceTime: SlicesTime | undefined | null; public selectionList: Array = []; public selectionMap: Map = new Map(); + public usageEL: HTMLDivElement | null | undefined; + public timerShaftEL: TimerShaftElement | null | undefined; + public rowsPaneEL: HTMLDivElement | null | undefined; + _checkExpand: boolean = false; //是否展开 + _usageFoldHeight: number = 56.25;//初始化时折叠的负载区高度 + usageExpandHeight: number = 75; //给定的展开的负载区高度 + _cpuUsageCount: Array<{ cpu: number; ro: number; rate: number }> = []; get sportRuler(): SportRuler | undefined { return this._sportRuler; @@ -150,11 +157,32 @@ export class TimerShaftElement extends BaseElement { set cpuUsage(value: Array<{ cpu: number; ro: number; rate: number }>) { info('set cpuUsage values :', value); this._cpuUsage = value; + + this._cpuUsageCount = value; + if (this._cpuUsageCount.length) { + this.usageEL!.innerHTML = 'CPU Usage'; + } + if (this._rangeRuler) { this._rangeRuler.cpuUsage = this._cpuUsage; } } + get checkExpand(): boolean { + return this._checkExpand; + } + + set checkExpand(value: boolean) { + this._checkExpand = value; + } + + get usageFoldHeight(): number { + return this._usageFoldHeight; + } + set usageFoldHeight(value: number) { + this._usageFoldHeight = value; + } + get totalNS(): number { return this._totalNS; } @@ -209,6 +237,29 @@ export class TimerShaftElement extends BaseElement { } this.removeTriangle('inverted'); this.setRangeNS(0, this.endNS); + //---------------每次导入trace时触发渲染----------------- + if (this._rangeRuler && this._sportRuler) { + sessionStorage.setItem('foldHeight', String(56.25)) + if (this._checkExpand && this._checkExpand === true) { + this._checkExpand = false; + sessionStorage.setItem('expand', String(this._checkExpand)) + } + sessionStorage.setItem('expand', String(this._checkExpand)) + this.usageEL!.innerHTML = ''; + this.usageEL!.style.textAlign = 'center'; + this.usageEL!.style.height = `${100 - 56.25}px`; + this.usageEL!.style.lineHeight = `${100 - 56.25}px`; + this.timerShaftEL!.style.height = `${146 - 56.25 + 2}px`; + this.canvas!.style.height = `${146 - 56.25}px`; + this.canvas!.height = 146 - 56.25; + this.rowsPaneEL!.style.maxHeight = `${this.rowsPaneEL!.clientHeight + 200}px`; + this._rangeRuler.frame.height = 18.75; + this._sportRuler.frame.y = 43.75; + + this.render(); + this._checkExpand = true; + this._cpuUsageCount = []//清空判断数据 + } } initElements(): void { @@ -229,6 +280,45 @@ export class TimerShaftElement extends BaseElement { }); procedurePool.timelineChange = (a: any) => this.rangeChangeHandler?.(a); window.subscribe(window.SmartEvent.UI.TimeRange, (b) => this.setRangeNS(b.startNS, b.endNS)); + // -----------------------------点击负载区展开折叠--------------------------------- + this.usageEL = this.shadowRoot?.querySelector('.cpu-usage'); + this.timerShaftEL = this.shadowRoot!.host.parentNode?.querySelector('.timer-shaft'); + this.rowsPaneEL = this.shadowRoot!.host.parentNode?.querySelector('.rows-pane'); + const height = this.canvas?.clientHeight || 0; + // 点击cpu usage部分,切换折叠展开 + this.usageEL?.addEventListener('click', (e) => { + if (this._rangeRuler && this.sportRuler && this._cpuUsageCount.length) { + // 计算需要被收起来的高度:总高度75-(总高度/cpu数量)* 2 + this._usageFoldHeight = this.usageExpandHeight - (this.usageExpandHeight / this._rangeRuler.cpuCountData!) * 2; + if (this._checkExpand) { + sessionStorage.setItem('expand', String(this._checkExpand)) + sessionStorage.setItem('foldHeight', String(this._usageFoldHeight)) + this.usageEL!.style.height = '100px'; + this.usageEL!.style.lineHeight = '100px'; + this.usageEL!.style.textAlign = 'center'; + this.timerShaftEL!.style.height = `${height + 2}px`; + this.canvas!.style.height = `${height}px`; + this.canvas!.height = height; + this._rangeRuler.frame.height = 75; + this.sportRuler.frame.y = 100; + this.render(); + this._checkExpand = false; + } else { + sessionStorage.setItem('expand', String(this._checkExpand)) + sessionStorage.setItem('foldHeight', String(this._usageFoldHeight)) + this.usageEL!.style.textAlign = 'center'; + this.usageEL!.style.height = `${100 - this._usageFoldHeight}px`; + this.usageEL!.style.lineHeight = `${100 - this._usageFoldHeight}px`; + this.timerShaftEL!.style.height = `${height - this._usageFoldHeight + 2}px`; + this.canvas!.style.height = `${height - this._usageFoldHeight}px`; + this.canvas!.height = height - this._usageFoldHeight; + this._rangeRuler.frame.height = 75 - this._usageFoldHeight; + this.sportRuler.frame.y = 100 - this._usageFoldHeight; + this.render(); + this._checkExpand = true; + } + } + }); } getRangeRuler() { @@ -303,14 +393,16 @@ export class TimerShaftElement extends BaseElement { xsTxt: [], }, (a) => { - if (this._sportRuler) { - this._sportRuler.range = a; - } - if (this.timeOffsetEL && this._rangeRuler) { - this.timeOffsetEL.textContent = ns2UnitS(a.startNS, this._rangeRuler.getScale()); - } - if (this.loadComplete) { - this.rangeChangeHandler?.(a); + if (a.startNS >= 0 && a.endNS >= 0) { + if (this._sportRuler) { + this._sportRuler.range = a; + } + if (this.timeOffsetEL && this._rangeRuler) { + this.timeOffsetEL.textContent = ns2UnitS(a.startNS, this._rangeRuler.getScale()); + } + if (this.loadComplete) { + this.rangeChangeHandler?.(a); + } } } ); @@ -395,7 +487,7 @@ export class TimerShaftElement extends BaseElement { this._rangeRuler?.keyUp(ev); }; - disconnectedCallback(): void {} + disconnectedCallback(): void { } firstRender = true; diff --git a/ide/src/trace/component/trace/base/Extension.ts b/ide/src/trace/component/trace/base/Extension.ts index 92027f5c5fb8d32f62946b2b1e5105af2b23637d..52524d2839e36a6098b48ec5c2dc21a8d9698eca 100644 --- a/ide/src/trace/component/trace/base/Extension.ts +++ b/ide/src/trace/component/trace/base/Extension.ts @@ -68,6 +68,7 @@ declare global { KeyPath: string; LoadFinish: string; LoadFinishFrame: string; + ShowBottomTab: string; }; }; @@ -127,6 +128,7 @@ window.SmartEvent = { KeyPath: 'SmartEvent-UI-UploadKeyPath', LoadFinish: 'SmartEvent-UI-LoadFinish',//所有泳道刷新完成触发 LoadFinishFrame: 'SmartEvent-UI-LoadFinishFrame',//单个泳道刷新完成触发 + ShowBottomTab: 'SmartEvent-UI-ShowBottomTab',// 显示底部 tab }, }; Window.prototype.subscribe = (ev, fn) => EventCenter.subscribe(ev, fn); diff --git a/ide/src/trace/component/trace/base/RangeSelect.ts b/ide/src/trace/component/trace/base/RangeSelect.ts index 1606e4d46445b10505ddc6fefd79cf48c74645a6..6b75443ea9aa9cb3b1640eb5854e36152e884100 100644 --- a/ide/src/trace/component/trace/base/RangeSelect.ts +++ b/ide/src/trace/component/trace/base/RangeSelect.ts @@ -19,7 +19,8 @@ import { TimerShaftElement } from '../TimerShaftElement'; import { info } from '../../../../log/Log'; import './Extension'; import { SpSystemTrace } from '../../SpSystemTrace'; -import {querySearchRowFuncData} from "../../../database/sql/Func.sql"; +import { fuzzyQueryFuncRowData, queryFuncRowData } from '../../../database/sql/Func.sql'; +import { SpLtpoChart } from '../../chart/SpLTPO'; export class RangeSelect { private rowsEL: HTMLDivElement | undefined | null; @@ -68,42 +69,96 @@ export class RangeSelect { TraceRow.rangeSelectObject = undefined; } - mouseUp(mouseEventUp: MouseEvent): void { - this.endPageX = mouseEventUp.pageX; - this.endPageY = mouseEventUp.pageY; + mouseUp(mouseEventUp?: MouseEvent): void { + if (mouseEventUp) { + this.endPageX = mouseEventUp.pageX; + this.endPageY = mouseEventUp.pageY; + } if (this.drag) { if (this.selectHandler) { this.selectHandler(this.rangeTraceRow || [], !this.isHover); } - //如果只框选了一条泳道,查询H:RSMainThread::DoComposition数据 - let docompositionData: Array = []; - if (this.rangeTraceRow) { - this.rangeTraceRow.forEach((row) => { - row.docompositionList = []; - }); - docompositionData = []; - if ( - this.rangeTraceRow.length === 1 && - this.rangeTraceRow[0]?.getAttribute('row-type') === 'func' && - this.rangeTraceRow[0]?.getAttribute('name')?.startsWith('render_service') - ) { - querySearchRowFuncData( - 'H:RSMainThread::DoComposition', - Number(this.rangeTraceRow[0]?.getAttribute('row-id')), - TraceRow.rangeSelectObject!.startNS!, - TraceRow.rangeSelectObject!.endNS! - ).then((res) => { - res.forEach((item) => { - docompositionData.push(item.startTime!); - }); - this.rangeTraceRow![0].docompositionList = docompositionData; - }); - } + //查询render_service数据 + if (this.rangeTraceRow?.length) { + this.checkRowsName(this.rangeTraceRow) } } this.isMouseDown = false; } + // 判断框选的线程行类型和名称 + checkRowsName(rowList: Array>) { + rowList.forEach((row) => { + if (row.getAttribute('row-type') === 'func' && row.parentRowEl?.getAttribute('name')?.startsWith('render_service')) { + if (row.getAttribute('name')?.startsWith('render_service')) { + this.handleFrameRateData(row, 'H:RSMainThread::DoComposition'); + } else if (row.getAttribute('name')?.startsWith('RSHardwareThrea')) { + this.handleFrameRateData(row, 'H:Repaint'); + } else if (row.getAttribute('name')?.startsWith('Present')) { + this.handlePresentData(row, 'H:Waiting for Present Fence'); + } + } + }) + } + + // 查询DoComposition方法和Repaint方法的数据 + handleFrameRateData(row: TraceRow, funcName: string): void { + let dataList: Array = [] + queryFuncRowData( + funcName, + Number(row?.getAttribute('row-id')), + TraceRow.rangeSelectObject!.startNS!, + TraceRow.rangeSelectObject!.endNS!, + ).then((res) => { + if (res.length >= 2) { + res.forEach((item) => { + dataList?.push(item.startTime!); + }); + row.frameRateList = dataList; + const CONVERT_SECONDS = 1000000000; + let cutres: number = (dataList[dataList.length - 1] - dataList[0]); + row.avgRateTxt = ((dataList.length - 1) / cutres * CONVERT_SECONDS).toFixed(1) + 'fps'; + } + }); + } + + // 查询H:Waiting for Present Fence方法数据 + handlePresentData(row: TraceRow, funcName: string): void { + let dataList: Array = [] + fuzzyQueryFuncRowData( + funcName, + Number(row?.getAttribute('row-id')), + TraceRow.rangeSelectObject!.startNS!, + TraceRow.rangeSelectObject!.endNS!, + ).then((res) => { + if (res.length >= 2) { + res.forEach((item) => { + dataList?.push(item.endTime!); + }); + row.frameRateList = dataList; + let hitchTimeList: Array = []; + for (let i = 0; i < SpLtpoChart.sendHitchDataArr.length; i++) { + if (SpLtpoChart.sendHitchDataArr[i].startTs! >= res[0].endTime! + && + SpLtpoChart.sendHitchDataArr[i].startTs! < res[res.length - 1].endTime!) { + hitchTimeList.push(SpLtpoChart.sendHitchDataArr[i].value!); + } else if ( + SpLtpoChart.sendHitchDataArr[i].startTs! >= res[res.length - 1].endTime! + ) { + break; + } + } + const CONVERT_SECONDS = 1000000000; + let cutres: number = (dataList[dataList.length - 1] - dataList[0]); + let avgRate: string = ((dataList.length - 1) / cutres * CONVERT_SECONDS).toFixed(1) + 'fps'; + let sum: number = hitchTimeList.reduce((accumulator, currentValue) => accumulator + currentValue, 0); // ∑hitchTimeData + let hitchRate: number = (sum / ((TraceRow.rangeSelectObject!.endNS! - TraceRow.rangeSelectObject!.startNS!) / 1000000)); + let perHitchRate: string = (Number(hitchRate) * 100).toFixed(2) + '%'; + row.avgRateTxt = avgRate + ' ' + ',' + ' ' + 'HitchTime:' + ' ' + sum.toFixed(1) + 'ms' + ' ' + ',' + ' ' + perHitchRate; + } + }); + } + isDrag(): boolean { return this.startPageX !== this.endPageX; } @@ -161,7 +216,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 +255,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].avgRateTxt = null; + } + } } } @@ -258,7 +316,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..1ea5c6f17909ce61c63045805aadc85fdcc438e6 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; //存储平均帧率数据 + _avgRateTxt: string | undefined | null;//存储帧率显示文字 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 avgRateTxt(): string | undefined | null { + return this._avgRateTxt; } - set docompositionList(value: Array | undefined) { - this._docompositionList = value; + set avgRateTxt(value: string | undefined | null) { + this._avgRateTxt = 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..6d6262c38a01f1d3f93e3f5e6d1daa7c42f6413f 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(); @@ -556,12 +561,15 @@ export class TraceRowConfig extends BaseElement { }); } } + let subsystemList = []; for (let subIndex = 0; subIndex < subsystemsData.length; subIndex++) { let currentSystemData = subsystemsData[subIndex]; - if(!currentSystemData.hasOwnProperty('subsystem')) { + if(!currentSystemData.hasOwnProperty('subsystem') || currentSystemData.subsystem === '' || + subsystemList.indexOf(currentSystemData.subsystem) > -1 || Array.isArray(currentSystemData.subsystem)) { continue; } let currentSubName = currentSystemData.subsystem; + subsystemList.push(currentSystemData.subsystem); id++; let subsystemStruct: SubsystemNode = { id: id, @@ -573,12 +581,13 @@ 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++) { let currentCompDate = currentCompDates[compIndex]; - if(!currentCompDate.hasOwnProperty('component') && !currentCompDate.hasOwnProperty('charts')) { + if(!currentCompDate.hasOwnProperty('component') || currentCompDate.component === '' || + !currentCompDate.hasOwnProperty('charts')) { continue; } let currentCompName = currentCompDate.component; @@ -595,10 +604,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[] = []; @@ -613,18 +623,21 @@ export class TraceRowConfig extends BaseElement { chartId = match[0].trim(); name = item.name.split(match[0])[0]; if (name !== 'Cpu') { - if ((currentChartName !== undefined && name.toLowerCase().endsWith(currentChartName.toLowerCase())) || currentChartId === chartId) { + if ((currentChartName !== undefined && currentChartName !== '' && + name.toLowerCase().endsWith(currentChartName.toLowerCase())) || currentChartId === chartId) { scene.push(...item.templateType); findChartNames.push(item.name); } } else { - if ((currentChartName !== undefined && name.toLowerCase().endsWith(currentChartName.toLowerCase()))) { + if ((currentChartName !== undefined && currentChartName !== '' && + name.toLowerCase().endsWith(currentChartName.toLowerCase()))) { scene.push(...item.templateType); findChartNames.push(item.name); } } } else { - if ((currentChartName !== undefined && name.toLowerCase().endsWith(currentChartName.toLowerCase()))) { + if ((currentChartName !== undefined && currentChartName !== '' && + name.toLowerCase().endsWith(currentChartName.toLowerCase()))) { scene.push(...item.templateType); findChartNames.push(item.name); } diff --git a/ide/src/trace/component/trace/base/TraceSheet.ts b/ide/src/trace/component/trace/base/TraceSheet.ts index ad608a40a6150792bea7fd8caa215c854ab6d799..0cfd9baac3adc551609c31122e60fbbb08ba69db 100644 --- a/ide/src/trace/component/trace/base/TraceSheet.ts +++ b/ide/src/trace/component/trace/base/TraceSheet.ts @@ -82,6 +82,10 @@ 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/ProcedureWorkerBpftrace'; +import { TabPaneSampleInstruction } from '../sheet/bpftrace/TabPaneSampleInstruction'; +import { TabPaneFreqStatesDataCut } from '../sheet/states/TabPaneFreqStatesDataCut'; +import { TabPaneDataCut } from '../sheet/TabPaneDataCut'; @element('trace-sheet') export class TraceSheet extends BaseElement { @@ -103,6 +107,9 @@ 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; + private tabPaneHeight: string = ''; static get observedAttributes(): string[] { return ['mode']; @@ -126,9 +133,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 +171,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 +357,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'; @@ -350,54 +377,80 @@ export class TraceSheet extends BaseElement { private initNavElements(tabsPackUp: LitIcon, borderTop: number, initialHeight: { node: string; tabs: string }): void { let that = this; + // 节点挂载时给Tab面板绑定鼠标按下事件 this.nav!.onmousedown = (event): void => { (window as any).isSheetMove = true; + // 获取所有标签页的节点数组 let litTabpane: NodeListOf | undefined | null = this.shadowRoot?.querySelectorAll('#tabs > lit-tabpane'); - this.navMouseMove(event, litTabpane!, that, tabsPackUp, borderTop); + // 获取当前选中面板的key值,后续用来确定当前面板是哪一个。 对于用户来说,直观看到的只有当前面板,其他面板可以在拖动完成后一次性设置好新的高度 + // @ts-ignore + let litTabNavKey: string = this.nav!.querySelector('.nav-item[data-selected=true]').dataset.key; + let currentPane: HTMLDivElement = this.shadowRoot?.querySelector('#tabs > lit-tabpane[key="' + litTabNavKey + '"]')!; + // 原函数 绑定鼠标移动事件,动态获取鼠标位置信息 + this.navMouseMove(event, currentPane!, that, tabsPackUp, borderTop); document.onmouseup = function (): void { setTimeout(() => { (window as any).isSheetMove = false; }, 100); litTabpane!.forEach((node: HTMLDivElement): void => { - if (node!.style.height !== '0px' && that.tabs!.style.height !== '') { - initialHeight.node = node!.style.height; - initialHeight.tabs = that.tabs!.style.height; - } + node!.style.height = that.tabPaneHeight; }); + if (that.tabPaneHeight !== '0px' && that.tabs!.style.height !== '') { + // 每次都会重新记录上次拖动完成后的面板高度,下次重新显示tab页时,会以上次拖动后的高度显示 + initialHeight.node = that.tabPaneHeight; + initialHeight.tabs = that.tabs!.style.height; + } + // 将绑定的事件置空,需要时重新绑定 this.onmousemove = null; this.onmouseup = null; }; }; } - private navMouseMove(event: MouseEvent, litTabpane: NodeListOf, + private navMouseMove(event: MouseEvent, litTabpane: HTMLDivElement, that: this, tabsPackUp: LitIcon, borderTop: number): void { - let preY = event.pageY; - let preHeight = this.tabs!.offsetHeight; - document.onmousemove = function (event): void { - let moveY: number = preHeight - (event.pageY - preY); - litTabpane!.forEach((node: HTMLDivElement) => { + // 鼠标移动前记录此时的鼠标位置信息,后续根据新值与前次值作比对 + let preY = event.pageY; + // 获取此时tab组件的偏移高度 需要包含水平滚动条的高度等 + 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 newHeight: number = preHeight - (event.pageY - preY); + // that指向的是tracesheet节点 spacer为垫片 rowsPaneEl为泳道 tabs为tab页组件 + // litTabpane为当前面板 navRoot为面板头部区的父级容器 search为顶部搜索区整个区域 + // 这四个判断条件中,第一个尚未找到触发条件 后续和润和确认是否会触发 if (that.spacer!.offsetHeight > that.rowsPaneEL!.offsetHeight) { - that.tabs!.style.height = moveY + 'px'; - node!.style.height = moveY - that.navRoot!.offsetHeight + 'px'; + that.tabs!.style.height = newHeight + 'px'; + litTabpane!.style.height = newHeight - that.navRoot!.offsetHeight + 'px'; + // 设置右上角面板大小化的箭头样式,面板在移动到最底部时,箭头向上,其余情况箭头向下 tabsPackUp!.name = 'down'; } else if ( - that.navRoot!.offsetHeight <= moveY && + // 只要没有移动到边界区域都会进入该条件 + that.navRoot!.offsetHeight <= newHeight && that.search!.offsetHeight + that.timerShaft!.offsetHeight + borderTop + that.spacer!.offsetHeight <= - window.innerHeight - moveY + window.innerHeight - newHeight ) { - that.tabs!.style.height = moveY + 'px'; - node!.style.height = moveY - that.navRoot!.offsetHeight + 'px'; + that.tabs!.style.height = newHeight + 'px'; + litTabpane!.style.height = newHeight - that.navRoot!.offsetHeight + 'px'; tabsPackUp!.name = 'down'; - } else if (that.navRoot!.offsetHeight >= moveY) { + } else if (that.navRoot!.offsetHeight >= newHeight) { + // 该条件在面板置底时触发 that.tabs!.style.height = that.navRoot!.offsetHeight + 'px'; - node!.style.height = '0px'; + litTabpane!.style.height = '0px'; tabsPackUp!.name = 'up'; } else if ( that.search!.offsetHeight + that.timerShaft!.offsetHeight + borderTop + that.spacer!.offsetHeight >= - window.innerHeight - moveY + window.innerHeight - newHeight ) { + // 该条件在面板高度置顶时触发 that.tabs!.style.height = window.innerHeight - that.search!.offsetHeight - @@ -405,7 +458,7 @@ export class TraceSheet extends BaseElement { borderTop - that.spacer!.offsetHeight + 'px'; - node!.style.height = + litTabpane!.style.height = window.innerHeight - that.search!.offsetHeight - that.timerShaft!.offsetHeight - @@ -415,8 +468,13 @@ export class TraceSheet extends BaseElement { 'px'; tabsPackUp!.name = 'down'; } - }); - }; + that.tabPaneHeight = litTabpane!.style.height; + let currentSH = that.rowsPaneEL!.scrollHeight; + // 第一个判断条件尚未确定如何触发,currentSH与scrollH始终相等 + if (currentSH > scrollH && currentSH > that.rowsPaneEL!.scrollTop + that.clientHeight) { + that.rowsPaneEL!.scrollTop = scrollT - (ch - that.clientHeight); + } + }; } private importClickEvent(): void { @@ -505,10 +563,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 +610,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 +833,29 @@ 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 dataCutPane = this.shadowRoot?.querySelector("tabpane-datacut"); + if (dataCutPane) { + dataCutPane.initTabSheetEl(this); + } + 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 +868,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 +879,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 +1009,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..024a06fae37b29de057f85ba3741e69e4dd973be 100644 --- a/ide/src/trace/component/trace/base/TraceSheetConfig.ts +++ b/ide/src/trace/component/trace/base/TraceSheetConfig.ts @@ -121,6 +121,14 @@ 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 { TabPaneBinders } from '../sheet/binder/TabPaneBinders'; +import { TabPaneGpufreq } from '../sheet/gpufreq/TabPaneGpufreqUsage'; +import { TabPaneSampleInstruction } from '../sheet/bpftrace/TabPaneSampleInstruction'; +import { TabPaneSampleInstructionDistributions } from '../sheet/bpftrace/TabPaneSampleInstructionDistributions'; +import { TabPaneSampleInstructionTotalTime } from '../sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime'; +import { TabPaneSampleInstructionSelection } from '../sheet/bpftrace/TabPaneSampleInstructionSelection'; +import { TabPaneDataCut } from '../sheet/TabPaneDataCut'; + export let tabConfig: any = { 'current-selection': { @@ -170,7 +178,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, }, @@ -644,4 +652,39 @@ export let tabConfig: any = { type: TabPaneHiSysEventSummary, require: (param: SelectionParam) => param.hiSysEvents.length > 0, }, + 'tabpane-binders': { + title: 'Thread Binders', + type: TabPaneBinders, + 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-datacut': { + title: 'Data Cut', + type: TabPaneDataCut, + require: (param: SelectionParam) => param.threadIds.length > 0 || + (param.clockMapData.size === 1 && param.clockMapData.has('gpufreq Frequency') === true), + }, + '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/TabPaneDataCut.ts b/ide/src/trace/component/trace/sheet/TabPaneDataCut.ts new file mode 100644 index 0000000000000000000000000000000000000000..d26ea71c5a239bdf301ba21aeef9496aa011cddd --- /dev/null +++ b/ide/src/trace/component/trace/sheet/TabPaneDataCut.ts @@ -0,0 +1,158 @@ +/* + * 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 '../../../../base-ui/select/LitSelect'; +import '../../../../base-ui/select/LitSelectOption'; +import { SelectionParam } from '../../../bean/BoxSelection'; +import { LitSelect } from '../../../../base-ui/select/LitSelect'; +import { TabPaneSchedSwitch } from './schedswitch/TabPaneSchedSwitch'; +import { TabPaneBinderDataCut } from './binder/TabPaneBinderDataCut'; +import { TabPaneFreqDataCut } from './frequsage/TabPaneFreqDataCut'; +import { TabPaneFreqStatesDataCut } from './states/TabPaneFreqStatesDataCut'; +import { TabPaneGpufreqDataCut } from './gpufreq/TabPaneGpufreqDataCut'; +import { TraceSheet } from '../base/TraceSheet'; + +@element('tabpane-datacut') +export class TabPaneDataCut extends BaseElement { + + private currentSelection: SelectionParam | undefined; + private tabSelector: LitSelect | undefined | null; + private tabContainer: HTMLDivElement | undefined | null; + private currentTabKey: string | undefined; + private currentTabPane: any; + private tabMap: Map = new Map(); + private traceSheetEl: TraceSheet | undefined | null; + + set data(dataCutSelection: SelectionParam | any) { + if (dataCutSelection === this.currentSelection || dataCutSelection === undefined || dataCutSelection == null) { + return; + } + this.currentSelection = dataCutSelection; + this.initTabSelectorOptions(); + this.showTabPane(); + } + + initTabSheetEl(traceSheet: TraceSheet): void { + this.traceSheetEl = traceSheet; + } + + showTabPane(): void { + if (this.currentTabPane) { + this.tabContainer?.removeChild(this.currentTabPane); + } + if (this.currentTabKey && this.currentSelection) { + if (this.tabMap.has(this.currentTabKey)) { + this.currentTabPane = this.tabMap.get(this.currentTabKey); + } else { + let tab = this.createTabBySelector(); + if (tab) { + this.currentTabPane = tab; + this.tabMap.set(this.currentTabKey, tab); + } + } + if (this.currentTabPane) { + this.tabContainer?.appendChild(this.currentTabPane); + this.currentTabPane.data = this.currentSelection; + } + } + } + + createTabBySelector(): any { + switch (this.currentTabKey) { + case 'Sched Switch': + return new TabPaneSchedSwitch(); + case 'Thread Binder': + return new TabPaneBinderDataCut(); + case 'Cpu Freq': + return new TabPaneFreqDataCut(); + case 'Thread States': + let tab = new TabPaneFreqStatesDataCut(); + tab.initTabSheetEl(this.traceSheetEl!); + return tab; + case 'Gpu Freq': + return new TabPaneGpufreqDataCut(); + default: + return undefined; + } + } + + initTabSelectorOptions(): void { + let options = []; + if (this.currentSelection!.threadIds.length > 0) { + options.push(...[ + { + name: 'Sched Switch' + }, + { + name: 'Thread Binder' + }, + { + name: 'Cpu Freq' + }, + { + name: 'Thread States' + }, + ]); + } + if (this.currentSelection!.clockMapData.size === 1 && this.currentSelection!.clockMapData.has('gpufreq Frequency') === true) { + options.push({ + name: 'Gpu Freq' + }); + } + this.currentTabKey = options[0].name; + this.tabSelector!.defaultValue = this.currentTabKey || ''; + this.tabSelector!.value = this.currentTabKey || ''; + this.tabSelector!.dataSource = options; + } + + initElements(): void { + this.tabContainer = this.shadowRoot?.querySelector('#data_cut_tabpane_container'); + this.tabSelector = this.shadowRoot?.querySelector('#tab-select'); + this.tabSelector!.onchange = () => { + this.currentTabKey = this.tabSelector!.value; + this.showTabPane(); + } + } + + connectedCallback() { + super.connectedCallback(); + } + + initHtml(): string { + return ` + +
          + +
          +
          + +
          + `; + } +} 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/TabPaneComparison.ts b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneComparison.ts index b065fcc115f6947c3eeb1b1785e80cc49f9b9cc8..0cea1a240b65e26f50c81007aa401cb16a9a130a 100644 --- a/ide/src/trace/component/trace/sheet/ark-ts/TabPaneComparison.ts +++ b/ide/src/trace/component/trace/sheet/ark-ts/TabPaneComparison.ts @@ -16,11 +16,7 @@ import { BaseElement, element } from '../../../../../base-ui/BaseElement'; import { LitTable } from '../../../../../base-ui/table/lit-table'; import { HeapDataInterface } from '../../../../../js-heap/HeapDataInterface'; -import { - ConstructorComparison, - ConstructorItem, - ConstructorType -} from '../../../../../js-heap/model/UiStruct'; +import { ConstructorComparison, ConstructorItem, ConstructorType } from '../../../../../js-heap/model/UiStruct'; import '../../../../../base-ui/table/lit-table-column'; import { TabPaneJsMemoryFilter } from '../TabPaneJsMemoryFilter'; import '../TabPaneJsMemoryFilter'; @@ -101,16 +97,16 @@ export class TabPaneComparison extends BaseElement { let that = this; let input = this.selectEl!.shadowRoot?.querySelector('input') as HTMLInputElement; this.selectEl!.innerHTML = ''; + this.selectEl!.defaultValue = comFileArr[0].name || ''; + this.selectEl!.placeholder = comFileArr[0].name || ''; + this.selectEl!.dataSource = comFileArr; let option = new LitSelectOption(); option.innerHTML = 'File Name'; option.setAttribute('disabled', 'disabled'); - this.selectEl?.appendChild(option); + this.selectEl?.prepend(option); if (comFileArr[0].name) { option.setAttribute('value', comFileArr[0].name); } - this.selectEl!.defaultValue = comFileArr[0].name || ''; - this.selectEl!.placeholder = comFileArr[0].name || ''; - this.selectEl!.dataSource = comFileArr; this.selectEl!.querySelectorAll('lit-select-option').forEach((a) => { a.addEventListener('onSelected', (e) => { this.comparisonTable!.scrollTop = 0; @@ -145,7 +141,7 @@ export class TabPaneComparison extends BaseElement { } } - private sortComprisonByColumnExtend(column: string, sort: number): void{ + private sortComprisonByColumnExtend(column: string, sort: number): void { switch (column) { case 'addedCount': this.comparisonTableEl!.snapshotDataSource = this.leftArray.sort((a, b) => { @@ -164,9 +160,9 @@ export class TabPaneComparison extends BaseElement { break; case 'objectName': this.comparisonTableEl!.snapshotDataSource = this.leftArray.sort((a, b) => { - return sort === 1 ? - (`${a.objectName }`).localeCompare(`${b.objectName }`) : - (`${b.objectName }`).localeCompare(`${a.objectName }`); + return sort === 1 + ? `${a.objectName}`.localeCompare(`${b.objectName}`) + : `${b.objectName}`.localeCompare(`${a.objectName}`); }); break; case 'addedSize': @@ -214,17 +210,17 @@ export class TabPaneComparison extends BaseElement { private sortRetainerByObjectNameType(sort: number): void { this.retainerTableEl!.snapshotDataSource = this.rightArray.sort((rightArrA, rightArrB) => { - return sort === 1 ? - (`${rightArrA.objectName }`).localeCompare(`${rightArrB.objectName }`) : - (`${rightArrB.objectName }`).localeCompare(`${rightArrA.objectName }`); + return sort === 1 + ? `${rightArrA.objectName}`.localeCompare(`${rightArrB.objectName}`) + : `${rightArrB.objectName}`.localeCompare(`${rightArrA.objectName}`); }); this.rightArray.forEach((list) => { let retainsTable = (): void => { const getList = (listArr: Array): void => { listArr.sort((listArrA, listArrB) => { - return sort === 1 ? - (`${listArrA.objectName }`).localeCompare(`${listArrB.objectName }`) : - (`${listArrB.objectName }`).localeCompare(`${listArrA.objectName }`); + return sort === 1 + ? `${listArrA.objectName}`.localeCompare(`${listArrB.objectName}`) + : `${listArrB.objectName}`.localeCompare(`${listArrA.objectName}`); }); listArr.forEach(function (currentRow) { if (currentRow.children.length > 0) { @@ -241,17 +237,17 @@ export class TabPaneComparison extends BaseElement { private sortRetainerByRetainedSizeType(sort: number): void { this.retainerTableEl!.snapshotDataSource = this.rightArray.sort((rightArrA, rightArrB) => { - return sort === 1 ? - rightArrA.retainedSize - rightArrB.retainedSize : - rightArrB.retainedSize - rightArrA.retainedSize; + return sort === 1 + ? rightArrA.retainedSize - rightArrB.retainedSize + : rightArrB.retainedSize - rightArrA.retainedSize; }); this.rightArray.forEach((list) => { let retainsTable = (): void => { const getList = (listArr: Array): void => { listArr.sort((listArrA, listArrB) => { - return sort === 1 ? - listArrA.retainedSize - listArrB.retainedSize : - listArrB.retainedSize - listArrA.retainedSize; + return sort === 1 + ? listArrA.retainedSize - listArrB.retainedSize + : listArrB.retainedSize - listArrA.retainedSize; }); listArr.forEach(function (row) { if (row.children.length > 0) { @@ -268,17 +264,15 @@ export class TabPaneComparison extends BaseElement { private sortRetainerByShallowSizeType(sort: number): void { this.retainerTableEl!.snapshotDataSource = this.rightArray.sort((rightArrA, rightArrB) => { - return sort === 1 ? - rightArrA.shallowSize - rightArrB.shallowSize : - rightArrB.shallowSize - rightArrA.shallowSize; + return sort === 1 ? rightArrA.shallowSize - rightArrB.shallowSize : rightArrB.shallowSize - rightArrA.shallowSize; }); this.rightArray.forEach((list) => { let retainsTable = (): void => { const getList = (listArr: Array): void => { listArr.sort((listArrA, listArrB) => { - return sort === 1 ? - listArrA.shallowSize - listArrB.shallowSize : - listArrB.shallowSize - listArrA.shallowSize; + return sort === 1 + ? listArrA.shallowSize - listArrB.shallowSize + : listArrB.shallowSize - listArrA.shallowSize; }); listArr.forEach(function (rowEl) { if (rowEl.children.length > 0) { @@ -298,7 +292,7 @@ export class TabPaneComparison extends BaseElement { return sort === 1 ? a.distance - b.distance : b.distance - a.distance; }); this.rightArray.forEach((list) => { - let retainsTable = (): void => { + let retainsTable = (): void => { const getList = (currentList: Array): void => { currentList.sort((a, b) => { return sort === 1 ? a.distance - b.distance : b.distance - a.distance; @@ -344,7 +338,9 @@ export class TabPaneComparison extends BaseElement { let filterHeight = 0; new ResizeObserver(() => { let comparisonPanelFilter = this.shadowRoot!.querySelector('#filter') as HTMLElement; - if (comparisonPanelFilter.clientHeight > 0) {filterHeight = comparisonPanelFilter.clientHeight} + if (comparisonPanelFilter.clientHeight > 0) { + filterHeight = comparisonPanelFilter.clientHeight; + } if (this.parentElement!.clientHeight > filterHeight) { comparisonPanelFilter.style.display = 'flex'; } else { @@ -386,12 +382,12 @@ export class TabPaneComparison extends BaseElement { let retainsTable = (): void => { const getList = (list: Array): void => { list.forEach((structRow) => { - let shallow = `${Math.round((structRow.shallowSize / this.fileSize) * 100) }%`; - let retained = `${Math.round((structRow.retainedSize / this.fileSize) * 100) }%`; + let shallow = `${Math.round((structRow.shallowSize / this.fileSize) * 100)}%`; + let retained = `${Math.round((structRow.retainedSize / this.fileSize) * 100)}%`; structRow.shallowPercent = shallow; structRow.retainedPercent = retained; - let nodeId = `${structRow.nodeName } @${structRow.id}`; - structRow.objectName = `${structRow.edgeName }\xa0` + 'in' + `\xa0${ nodeId}`; + let nodeId = `${structRow.nodeName} @${structRow.id}`; + structRow.objectName = `${structRow.edgeName}\xa0` + 'in' + `\xa0${nodeId}`; if (structRow.distance >= 100000000 || structRow.distance === -5) { // @ts-ignore structRow.distance = '-'; @@ -424,25 +420,25 @@ export class TabPaneComparison extends BaseElement { } }; - private resizeObserverObserve(){ + private resizeObserverObserve() { new ResizeObserver(() => { this.retainerTableEl!.style.height = 'calc(100% - 21px)'; this.retainerTableEl!.reMeauseHeight(); }).observe(this.parentElement!); } - private retainsDataInit(): void{ + private retainsDataInit(): void { this.retainsData.forEach((comparisonRetainEl) => { - let shallow = `${Math.round((comparisonRetainEl.shallowSize / this.fileSize) * 100) }%`; - let retained = `${Math.round((comparisonRetainEl.retainedSize / this.fileSize) * 100) }%`; + let shallow = `${Math.round((comparisonRetainEl.shallowSize / this.fileSize) * 100)}%`; + let retained = `${Math.round((comparisonRetainEl.retainedSize / this.fileSize) * 100)}%`; comparisonRetainEl.shallowPercent = shallow; comparisonRetainEl.retainedPercent = retained; if (comparisonRetainEl.distance >= 100000000 || comparisonRetainEl.distance === -5) { // @ts-ignore comparisonRetainEl.distance = '-'; } - let nodeId = `${comparisonRetainEl.nodeName } @${comparisonRetainEl.id}`; - comparisonRetainEl.objectName = `${comparisonRetainEl.edgeName }\xa0` + 'in' + `\xa0${ nodeId}`; + let nodeId = `${comparisonRetainEl.nodeName} @${comparisonRetainEl.id}`; + comparisonRetainEl.objectName = `${comparisonRetainEl.edgeName}\xa0` + 'in' + `\xa0${nodeId}`; }); } @@ -481,12 +477,12 @@ export class TabPaneComparison extends BaseElement { let retainsTable = (): void => { const getList = (comList: Array): void => { comList.forEach((row) => { - let shallow = `${Math.round((row.shallowSize / this.fileSize) * 100) }%`; - let retained = `${Math.round((row.retainedSize / this.fileSize) * 100) }%`; + let shallow = `${Math.round((row.shallowSize / this.fileSize) * 100)}%`; + let retained = `${Math.round((row.retainedSize / this.fileSize) * 100)}%`; row.shallowPercent = shallow; row.retainedPercent = retained; - let nodeId = `${row.nodeName } @${row.id}`; - row.objectName = `${row.edgeName }\xa0` + 'in' + `\xa0${ nodeId}`; + let nodeId = `${row.nodeName} @${row.id}`; + row.objectName = `${row.edgeName}\xa0` + 'in' + `\xa0${nodeId}`; if (row.distance >= 100000000 || row.distance === -5) { // @ts-ignore row.distance = '-'; @@ -530,17 +526,17 @@ export class TabPaneComparison extends BaseElement { clickRow.children = HeapDataInterface.getInstance().getNextForComparison(clickRow); if (clickRow.children.length > 0) { for (let item of clickRow.children) { - let nodeName = `${item.nodeName } @${item.id}`; + let nodeName = `${item.nodeName} @${item.id}`; item.nodeId = ` @${item.id}`; if (item.isString()) { - item.objectName = `"${ item.nodeName}"` + ` @${item.id}`; + item.objectName = `"${item.nodeName}"` + ` @${item.id}`; } else { item.objectName = nodeName; } item.deltaCount = '-'; item.deltaSize = '-'; if (item.edgeName !== '') { - item.objectName = `${item.edgeName }\xa0` + '::' + `\xa0${ nodeName}`; + item.objectName = `${item.edgeName}\xa0` + '::' + `\xa0${nodeName}`; } else { if (item.fileId === this.baseFileId) { item.addedCount = '•'; @@ -570,7 +566,7 @@ export class TabPaneComparison extends BaseElement { this.comparisonTblIconClickData(); }; - private comparisonTblIconClickData(): void{ + private comparisonTblIconClickData(): void { if (this.search!.value !== '') { if (this.leftTheadTable!.hasAttribute('sort')) { this.comparisonTableEl!.snapshotDataSource = this.leftArray; 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..4e239182bf4a8a1faff01f8bb7ede441935366cf 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,11 @@ 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}`; - } - item.totalTimePercent = `${((item.totalTime / this.totalNs) * 100).toFixed(1) }%`; - item.selfTimePercent = `${((item.selfTime / this.totalNs) * 100).toFixed(1) }%`; + item.scriptName === 'unknown' + ? (item.symbolName = item.name) + : (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.selfTimeStr = ns2s(item.selfTime); item.totalTimeStr = ns2s(item.totalTime); item.parent = callTreeMap.get(item.parentId!); @@ -196,12 +194,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 +228,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..5be3b4f13c071cff74eb9a43a1e71b51aaf6923b --- /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/bpftrace/TabPaneSampleInstruction.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction.ts new file mode 100644 index 0000000000000000000000000000000000000000..a034342c4e0af55d5f9f0b907027a5319c0615b2 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/bpftrace/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/ProcedureWorkerBpftrace'; +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/bpftrace/TabPaneSampleInstructionDistributions.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.ts new file mode 100644 index 0000000000000000000000000000000000000000..4afdcb64cc3013c60325b50751ac97a697e309aa --- /dev/null +++ b/ide/src/trace/component/trace/sheet/bpftrace/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: parseFloat((yNum * 100).toFixed(2)) + }) + } 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)) * 100}%`, 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/bpftrace/TabPaneSampleInstructionSelection.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.ts new file mode 100644 index 0000000000000000000000000000000000000000..3229352fd9d6865d3595407db66effd1ceb9a8f2 --- /dev/null +++ b/ide/src/trace/component/trace/sheet/bpftrace/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/ProcedureWorkerBpftrace'; +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/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts b/ide/src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime.ts new file mode 100644 index 0000000000000000000000000000000000000000..03afdc2f99ce40dd4c5663f92ceaff391db9b61b --- /dev/null +++ b/ide/src/trace/component/trace/sheet/bpftrace/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 = parseFloat(((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: parseFloat((yNum * 100).toFixed(2)) + }) + } 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)) * 100}%`, 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/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..7f9fea5ae59d3880710f50f32f7df5d4cb2856af 100644 --- a/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts +++ b/ide/src/trace/component/trace/sheet/cpu/TabPaneSchedPriority.ts @@ -20,7 +20,8 @@ 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'; +import { FlagsConfig } from '../../../../component/SpFlags'; @element('tabpane-sched-priority') export class TabPaneSchedPriority extends BaseElement { @@ -61,19 +62,31 @@ export class TabPaneSchedPriority extends BaseElement { const filterList = ['0', '0x0']; //next_info第2字段不为0 || next_info第3字段不为0 // 通过priority与next_info结合判断优先级等级 function setPriority(item: Priority, strArg: string[]) { - if (item.priority >= 0 && item.priority <= 88) { - item.priorityType = 'RT'; - } else if (item.priority >= 89 && item.priority <= 99) { - item.priorityType = 'VIP2.0'; - } else if ( - item.priority >= 100 && - strArg.length > 1 && - (!filterList.includes(strArg[1]) || !filterList.includes(strArg[2])) - ) { - item.priorityType = 'STATIC_VIP'; + let flagsItem = window.localStorage.getItem(FlagsConfig.FLAGS_CONFIG_KEY); + let flagsItemJson = JSON.parse(flagsItem!); + let hmKernel = flagsItemJson.HMKernel; + if (hmKernel === "Enabled") { + if (item.priority >= 0 && item.priority <= 40) { + item.priorityType = 'CFS'; + } else { + item.priorityType = 'RT'; + } } else { - item.priorityType = 'CFS'; + if (item.priority >= 0 && item.priority <= 88) { + item.priorityType = 'RT'; + } else if (item.priority >= 89 && item.priority <= 99) { + item.priorityType = 'VIP2.0'; + } else if ( + item.priority >= 100 && + strArg.length > 1 && + (!filterList.includes(strArg[1]) || !filterList.includes(strArg[2])) + ) { + item.priorityType = 'STATIC_VIP'; + } else { + item.priorityType = 'CFS'; + } } + } // thread_state表中runnable数据的Map const runnableMap = new Map(); @@ -97,8 +110,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..75b192e65bf1d33d5b965d9aae827960b61662bf --- /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/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/sdk/TabPaneSdkSlice.ts b/ide/src/trace/component/trace/sheet/sdk/TabPaneSdkSlice.ts index b10ffce1e5419569467dba885c2bc60d0b6ea25c..494658aaa81605dd96625984deb186f483fa52ad 100644 --- a/ide/src/trace/component/trace/sheet/sdk/TabPaneSdkSlice.ts +++ b/ide/src/trace/component/trace/sheet/sdk/TabPaneSdkSlice.ts @@ -23,7 +23,7 @@ import { TabUtil } from './TabUtil'; import { resizeObserver } from '../SheetUtils'; import { getTabSdkSliceData } from '../../../../database/sql/Sdk.sql'; import { queryTotalTime } from '../../../../database/sql/SqlLite.sql'; -import { SdkSliceSummary } from '../../../../bean/SdkSummary.js'; +import { SdkSliceSummary } from '../../../../bean/SdkSummary'; @element('tabpane-sdk-slice') export class TabPaneSdkSlice extends BaseElement { 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..776755cca15aebb75700daf0fe7c227044306b2c --- /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..8bf3f96579f4e5ca6aa32392a48648b4bce74010 100644 --- a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts +++ b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts @@ -64,6 +64,7 @@ export class TabPaneTaskFrames extends BaseElement { this.taskFramesTbl!!.recycleDataSource = []; this.taskFramesSource = []; this.taskFramesGroupSource = []; + this.progressEL!.loading = false; return; } else { let allocationTime = 0; @@ -73,13 +74,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 +95,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 +126,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); @@ -149,10 +150,12 @@ export class TabPaneTaskFrames extends BaseElement { let groups = new Map(); framesParam.taskFramesData.forEach((obj) => { const key = obj.ipid; - if (!groups.has(key)) { - groups.set(key, []); + if (key) { + if (!groups.has(key)) { + groups.set(key, []); + } + groups.get(key).push(obj); } - groups.get(key).push(obj); }); for (let [key, groupsValue] of groups) { let tempTableList: TaskTabStruct[] = []; @@ -160,7 +163,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 +220,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 ''; } @@ -375,23 +383,25 @@ export class TabPaneTaskFrames extends BaseElement { } private pushTaskToList(value: TaskTabStruct, tableList: TaskTabStruct[]): void { - let allocationTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.allocationTaskRow!); - let executeTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.executeTaskRow!); - let returnTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.returnTaskRow!); - let tempTask: TaskTabStruct = new TaskTabStruct(); - let executeStartTime = executeTask!.ts!; - let executeTime = executeTask!.dur! === -1 ? (window as any).recordEndNS - executeTask!.ts : executeTask!.dur; - let allocationStartTime = allocationTask!.ts!; - let returnEndTime = 0; - if (returnTask) { - returnEndTime = returnTask!.ts! + returnTask!.dur! - (executeStartTime + executeTime); + if (value.allocationTaskRow && value.executeTaskRow && value.returnTaskRow) { + let allocationTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.allocationTaskRow!); + let executeTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.executeTaskRow!); + let returnTask = SpSystemTrace.DATA_TASK_POOL_CALLSTACK.get(value.returnTaskRow!); + let tempTask: TaskTabStruct = new TaskTabStruct(); + let executeStartTime = executeTask!.ts!; + let executeTime = executeTask!.dur! === -1 ? (window as any).recordEndNS - executeTask!.ts : executeTask!.dur; + let allocationStartTime = allocationTask!.ts!; + let returnEndTime = 0; + if (returnTask) { + returnEndTime = returnTask!.ts! + returnTask!.dur! - (executeStartTime + executeTime); + } + tempTask.executeId = value.executeId; + tempTask.taskPriority = Priority[value.priority!]; + tempTask.taskST = this.getMsTime(executeStartTime - allocationStartTime); + tempTask.taskET = this.getMsTime(executeTime); + tempTask.taskRT = this.getMsTime(returnEndTime); + tableList.push(tempTask); } - tempTask.executeId = value.executeId; - tempTask.taskPriority = Priority[value.priority!]; - tempTask.taskST = this.getMsTime(executeStartTime - allocationStartTime); - tempTask.taskET = this.getMsTime(executeTime); - tempTask.taskRT = this.getMsTime(returnEndTime); - tableList.push(tempTask); } } diff --git a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts index c0523626837d747c3f18d3b70bd61d09ebc7f5ed..45f50cdbd4b6e76fc587a255e6733b60d6322c68 100644 --- a/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/RangeRuler.ts @@ -121,6 +121,7 @@ export class RangeRuler extends Graph { private scale: number = 0; private delayTimer: any = null; private rulerW = 0; + _cpuCountData: number | undefined; //缩放级别 private scales: Array = [ @@ -156,13 +157,30 @@ export class RangeRuler extends Graph { this.draw(); } + get cpuCountData(): number | undefined { + return this._cpuCountData; + } + + set cpuCountData(value: number | undefined) { + this._cpuCountData = value; + } + drawCpuUsage(): void { this.context2D.clearRect(this.frame.x, this.frame.y, this.frame.width, this.frame.height); let miniHeight = Math.round(this.frame.height / CpuStruct.cpuCount); //每格高度 let miniWidth = Math.ceil(this.frame.width / 100); //每格宽度 + this._cpuCountData = CpuStruct.cpuCount; + if (sessionStorage.getItem('expand') === 'true') {//展开 + miniHeight = Math.round(this.frame.height / CpuStruct.cpuCount); + } else if (sessionStorage.getItem('expand') === 'false') { + miniHeight = Math.round(this.frame.height / 2); + } 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( @@ -271,13 +289,30 @@ export class RangeRuler extends Graph { this.context2D.globalAlpha = 1; this.context2D.globalAlpha = 0.5; this.context2D.fillStyle = '#999999'; - this.context2D.fillRect(this.frame.x, this.frame.y, this.rangeRect.x, this.rangeRect.height); - this.context2D.fillRect( - this.rangeRect.x + this.rangeRect.width, - this.frame.y, - this.frame.width - this.rangeRect.width, - this.rangeRect.height - ); + // -----------------------绘制选择的阴影高度--------------------- + if (sessionStorage.getItem('expand') === 'true') { + //展开 + this.context2D.fillRect( + this.frame.x, + this.frame.y, + this.rangeRect.x, + this.rangeRect.height + Number(sessionStorage.getItem('foldHeight')) + ); + this.context2D.fillRect( + this.rangeRect.x + this.rangeRect.width, + this.frame.y, + this.frame.width - this.rangeRect.width, + this.rangeRect.height + Number(sessionStorage.getItem('foldHeight')) + ); + } else if (sessionStorage.getItem('expand') === 'false') { + this.context2D.fillRect(this.frame.x, this.frame.y, this.rangeRect.x, this.rangeRect.height); + this.context2D.fillRect( + this.rangeRect.x + this.rangeRect.width, + this.frame.y, + this.frame.width - this.rangeRect.width, + this.rangeRect.height + ); + } this.context2D.globalAlpha = 1; this.context2D.closePath(); this.markAObj.draw(); @@ -392,12 +427,7 @@ export class RangeRuler extends Graph { } } - private handleMovingMark( - move_x: number, - move_y: number, - maxX: number, - trace: SpSystemTrace - ): void { + private handleMovingMark(move_x: number, move_y: number, maxX: number, trace: SpSystemTrace): void { if (this.movingMark) { let result = move_x - this.mouseDownOffsetX + this.mouseDownMovingMarkX; if (result >= 0 && result <= maxX) { @@ -515,6 +545,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()); @@ -544,7 +578,7 @@ export class RangeRuler extends Graph { let startX = midX - 150; let endX = midX + 150; this.range.startNS = (endX * startTime - startX * endTime) / (endX - startX); - this.range.endNS = ((this.rulerW * (endTime - this.range.startNS)) + this.range.startNS * endX) / endX; + this.range.endNS = (this.rulerW * (endTime - this.range.startNS) + this.range.startNS * endX) / endX; this.fillX(); this.draw(); this.range.refresh = true; @@ -567,6 +601,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 +626,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 +651,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 +677,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/Rect.ts b/ide/src/trace/component/trace/timer-shaft/Rect.ts index 7362c929d5d571a54c47f0a1f20a68717e19c93c..525a330a0c81ab10801d21c4b9db46a70ea8f9be 100644 --- a/ide/src/trace/component/trace/timer-shaft/Rect.ts +++ b/ide/src/trace/component/trace/timer-shaft/Rect.ts @@ -75,6 +75,12 @@ export class Rect { } containsWithPadding(x: number, y: number, paddingLeftOrRight: number, paddingTopOrBottom: number): boolean { + // ------------------------修改rangeruler部分鼠标形态根据高度调整------------------------- + if (sessionStorage.getItem('expand') === 'true') {//展开 + this.height = 75; + } else if (sessionStorage.getItem('expand') === 'false') {//折叠 + this.height = 75 - Number(sessionStorage.getItem('foldHeight')) + } return ( this.x + paddingLeftOrRight <= x && x <= this.x + this.width - paddingLeftOrRight && diff --git a/ide/src/trace/component/trace/timer-shaft/SportRuler.ts b/ide/src/trace/component/trace/timer-shaft/SportRuler.ts index 601e81679d9b60d8c2cc4a9a729917377b08c9d8..ac7c0d8add8ebd5162c589b79ac2b2e6c9165d01 100644 --- a/ide/src/trace/component/trace/timer-shaft/SportRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/SportRuler.ts @@ -89,10 +89,10 @@ export class SportRuler extends Graph { endTime: number | null | undefined; color: string | null; } | null = { - startTime: null, - endTime: null, - color: null, - }; + startTime: null, + endTime: null, + color: null, + }; private timerShaftEL: TimerShaftElement | undefined | null; private timeArray: Array = []; private countArray: Array = []; @@ -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); @@ -437,16 +437,25 @@ export class SportRuler extends Graph { this.context2D.beginPath(); this.context2D.fillStyle = color; this.context2D.strokeStyle = color; - this.context2D.moveTo(x - 3, 141); - this.context2D.lineTo(x + 3, 141); - this.context2D.lineTo(x, 145); + // ----------------修改小倒三角位置的绘制--------------------- + if (sessionStorage.getItem('expand') === 'true') {//展开 + this.context2D.moveTo(x - 3, 141); + this.context2D.lineTo(x + 3, 141); + this.context2D.lineTo(x, 145); + } else if (sessionStorage.getItem('expand') === 'false') { + this.context2D.moveTo(x - 3, 141 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 3, 141 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x, 145 - Number(sessionStorage.getItem('foldHeight'))); + } this.context2D.fill(); this.context2D.closePath(); this.context2D.stroke(); } } - 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); @@ -525,15 +534,28 @@ export class SportRuler extends Graph { this.context2D.strokeStyle = slicesTime.color; this.context2D.fillStyle = slicesTime.color; this.range.slicesTime.color = slicesTime.color; //紫色 - this.context2D.moveTo(startX + TRIWIDTH, 132); - this.context2D.lineTo(startX, 142); - this.context2D.lineTo(startX, 132); - this.context2D.lineTo(startX + TRIWIDTH, 132); - - this.context2D.lineTo(endX - TRIWIDTH, 132); - this.context2D.lineTo(endX, 132); - this.context2D.lineTo(endX, 142); - this.context2D.lineTo(endX - TRIWIDTH, 132); + // ---------------------------------------修改标记绘制位置------------------------- + if (sessionStorage.getItem('expand') === 'true') {//展开 + this.context2D.moveTo(startX + TRIWIDTH, 132); + this.context2D.lineTo(startX, 142); + this.context2D.lineTo(startX, 132); + this.context2D.lineTo(startX + TRIWIDTH, 132); + + this.context2D.lineTo(endX - TRIWIDTH, 132); + this.context2D.lineTo(endX, 132); + this.context2D.lineTo(endX, 142); + this.context2D.lineTo(endX - TRIWIDTH, 132); + } else if (sessionStorage.getItem('expand') === 'false') { + this.context2D.moveTo(startX + TRIWIDTH, 132 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(startX, 142 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(startX, 132 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(startX + TRIWIDTH, 132 - Number(sessionStorage.getItem('foldHeight'))); + + this.context2D.lineTo(endX - TRIWIDTH, 132 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(endX, 132 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(endX, 142 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(endX - TRIWIDTH, 132 - Number(sessionStorage.getItem('foldHeight'))); + } this.context2D.closePath(); slicesTime.selected && this.context2D.fill(); this.context2D.stroke(); @@ -627,20 +649,38 @@ export class SportRuler extends Graph { this.context2D.beginPath(); this.context2D.fillStyle = color; this.context2D.strokeStyle = color; - this.context2D.moveTo(x, 125); - if (type == 'triangle') { - this.context2D.lineTo(x + 15, 131); + // ------------------修改旗子位置---------------------------- + if (sessionStorage.getItem('expand') === 'true') { + this.context2D.moveTo(x, 125); + if (type == 'triangle') { + this.context2D.lineTo(x + 15, 131); + } else { + this.context2D.lineTo(x + 10, 125); + this.context2D.lineTo(x + 10, 127); + this.context2D.lineTo(x + 18, 127); + this.context2D.lineTo(x + 18, 137); + this.context2D.lineTo(x + 10, 137); + this.context2D.lineTo(x + 10, 135); + } + this.context2D.lineTo(x + 2, 135); + this.context2D.lineTo(x + 2, 142); + this.context2D.lineTo(x, 142); } else { - this.context2D.lineTo(x + 10, 125); - this.context2D.lineTo(x + 10, 127); - this.context2D.lineTo(x + 18, 127); - this.context2D.lineTo(x + 18, 137); - this.context2D.lineTo(x + 10, 137); - this.context2D.lineTo(x + 10, 135); + this.context2D.moveTo(x, 125 - Number(sessionStorage.getItem('foldHeight'))); + if (type == 'triangle') { + this.context2D.lineTo(x + 15, 131 - Number(sessionStorage.getItem('foldHeight'))); + } else { + this.context2D.lineTo(x + 10, 125 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 10, 127 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 18, 127 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 18, 137 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 10, 137 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 10, 135 - Number(sessionStorage.getItem('foldHeight'))); + } + this.context2D.lineTo(x + 2, 135 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x + 2, 142 - Number(sessionStorage.getItem('foldHeight'))); + this.context2D.lineTo(x, 142 - Number(sessionStorage.getItem('foldHeight'))); } - this.context2D.lineTo(x + 2, 135); - this.context2D.lineTo(x + 2, 142); - this.context2D.lineTo(x, 142); this.context2D.closePath(); isFill && this.context2D.fill(); this.context2D.stroke(); @@ -648,9 +688,16 @@ export class SportRuler extends Graph { this.context2D.font = TEXT_FONT; const { width } = this.context2D.measureText(textStr); this.context2D.fillStyle = 'rgba(255, 255, 255, 0.8)'; // - this.context2D.fillRect(x + 21, 132, width + 4, 12); - this.context2D.fillStyle = 'black'; - this.context2D.fillText(textStr, x + 23, 142); + // -------------------修改旗子上的字位置----------------------- + if (sessionStorage.getItem('expand') === 'true') { + this.context2D.fillRect(x + 21, 132, width + 4, 12); + this.context2D.fillStyle = 'black'; + this.context2D.fillText(textStr, x + 23, 142); + } else { + this.context2D.fillRect(x + 21, 132 - Number(sessionStorage.getItem('foldHeight')), width + 4, 12); + this.context2D.fillStyle = 'black'; + this.context2D.fillText(textStr, x + 23, 142 - Number(sessionStorage.getItem('foldHeight'))); + } this.context2D.stroke(); } } @@ -661,15 +708,27 @@ export class SportRuler extends Graph { * @returns */ findSlicesTime(x: number, y: number): SlicesTime | null { - let slicestime = this.slicesTimeList.find((slicesTime) => { - return ( - ((x >= slicesTime.startX - 1 && x <= slicesTime.startX + TRIWIDTH + 1) || // 选中了帽子的左边三角形区域 - (x >= slicesTime.endX - TRIWIDTH - 1 && x <= slicesTime.endX + 1)) && // 选中了帽子的右边三角形区域 - y >= 132 && - y <= 142 - ); - }); - + // --------------------------修改旗子和标记的小三角重叠时的情况------------------- + let slicestime; + if (sessionStorage.getItem('expand') === 'false') {//折叠 + slicestime = this.slicesTimeList.find((slicesTime) => { + return ( + ((x >= slicesTime.startX - 1 && x <= slicesTime.startX + TRIWIDTH + 1) || // 选中了帽子的左边三角形区域 + (x >= slicesTime.endX - TRIWIDTH - 1 && x <= slicesTime.endX + 1)) && // 选中了帽子的右边三角形区域 + y >= 132 - Number(sessionStorage.getItem('foldHeight')) && + y <= 142 - Number(sessionStorage.getItem('foldHeight')) + ); + }); + } else if (sessionStorage.getItem('expand') === 'true') { + slicestime = this.slicesTimeList.find((slicesTime) => { + return ( + ((x >= slicesTime.startX - 1 && x <= slicesTime.startX + TRIWIDTH + 1) || // 选中了帽子的左边三角形区域 + (x >= slicesTime.endX - TRIWIDTH - 1 && x <= slicesTime.endX + 1)) && // 选中了帽子的右边三角形区域 + y >= 132 && + y <= 142 + ); + }); + } if (!slicestime) { return null; } 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/component/trace/timer-shaft/TimeRuler.ts b/ide/src/trace/component/trace/timer-shaft/TimeRuler.ts index e8bfa4b100539f2afdb0321b96ae79219ff4a4f6..42ceb7793ddedef27c09326733d804b0b8d92c67 100644 --- a/ide/src/trace/component/trace/timer-shaft/TimeRuler.ts +++ b/ide/src/trace/component/trace/timer-shaft/TimeRuler.ts @@ -51,6 +51,8 @@ export class TimeRuler extends Graph { this.context2D.lineTo(x + Math.floor(innerIndex * this.stepSmall), this.frame.height / 4); } this.context2D.fillStyle = '#999'; + // ------------------修改刻度尺文字------------------------ + this.context2D.font = '8px sans-serif'; this.context2D.fillText(`${ns2s(index * this.stepNS)}`, x + 5, this.frame.height - 1); } this.context2D.stroke(); diff --git a/ide/src/trace/config/custom_temp_config.json b/ide/src/trace/config/custom_temp_config.json index 6a1298e1790882d493b6319e2597171140aa3890..6d7143a1b99d74c83640a5e8b8f82b5ebbb49a30 100644 --- a/ide/src/trace/config/custom_temp_config.json +++ b/ide/src/trace/config/custom_temp_config.json @@ -68,6 +68,1768 @@ ] } ] + }, + { + "subsystem": "arkui", + "components": [ + { + "component": "ace_engine", + "charts": [ + { + "chartName": "ui_service", + "chartId": "" + } + ] + }, + { + "component": "napi", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "account", + "components": [ + { + "component": "os_account", + "charts": [ + { + "chartName": "accountmgr", + "chartId": "" + }, + { + "chartName": "huawei_id_svc", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "barrierfree", + "components": [ + { + "component": "accessibility", + "charts": [ + { + "chartName": "accessibility", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "distributeddatamgr", + "components": [ + { + "component": "relational_store", + "charts": [ + { + "chartName": "distributeddata", + "chartId": "" + } + ] + }, + { + "component": "preferences", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "data_share", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "datamgr_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "kv_store", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "data_object", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "e2fsprogs", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "pasteboard", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "filemanagement", + "components": [ + { + "component": "user_file_service", + "charts": [ + { + "chartName": "com.ohos.medialibrary.medialibrarydata", + "chartId": "" + }, + { + "chartName": "cloudfiledaemon", + "chartId": "" + }, + { + "chartName": "backup_sa", + "chartId": "" + } + ] + }, + { + "component": "file_api", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "storage_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "dfs_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "app_file_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "security", + "components": [ + { + "component": "appverify", + "charts": [ + { + "chartName": "security_guard", + "chartId": "" + }, + { + "chartName": "dlp_credential_service", + "chartId": "" + } + ] + }, + { + "component": "huks", + "charts": [ + { + "chartName": "huks_service", + "chartId": "" + } + ] + }, + { + "component": "certificate_manager", + "charts": [ + { + "chartName": "cert_manager_service", + "chartId": "" + } + ] + }, + { + "component": "device_auth", + "charts": [ + { + "chartName": "deviceauth_service", + "chartId": "" + } + ] + }, + { + "component": "crypto_framework", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "access_token", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "device_security_level", + "charts": [ + { + "chartName": "dslm_service", + "chartId": "" + } + ] + }, + { + "component": "dataclassification", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "startup", + "components": [ + { + "component": "startup_l2", + "charts": [ + { + "chartName": "param_watcher", + "chartId": "" + }, + { + "chartName": "ueventd", + "chartId": "" + }, + { + "chartName": "watchdog_service", + "chartId": "" + }, + { + "chartName": "nwebspawn", + "chartId": "" + }, + { + "chartName": "sh", + "chartId": "" + } + ] + }, + { + "component": "appspawn", + "charts": [ + { + "chartName": "appspawn", + "chartId": "" + } + ] + }, + { + "component": "init", + "charts": [ + { + "chartName": "init", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "hiviewdfx", + "components": [ + { + "component": "hiviewdfx_hilog_native", + "charts": [ + { + "chartName": "hdcd", + "chartId": "" + }, + { + "chartName": "logdeflatsvr", + "chartId": "" + }, + { + "chartName": "pmom_cat", + "chartId": "" + }, + { + "chartName": "sleeplogcat", + "chartId": "" + }, + { + "chartName": "inputlogcat", + "chartId": "" + }, + { + "chartName": "chargelogcat", + "chartId": "" + } + ] + }, + { + "component": "hilog_native", + "charts": [ + { + "chartName": "hilogd", + "chartId": "" + } + ] + }, + { + "component": "hilog_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hisysevent_native", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hiappevent_native", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hiappevent_js", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hichecker_native", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hichecker_js", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hidumper", + "charts": [ + { + "chartName": "hidumper", + "chartId": "" + }, + { + "chartName": "hidumper_service", + "chartId": "" + }, + { + "chartName": "hidumperd", + "chartId": "" + } + ] + }, + { + "component": "hiview", + "charts": [ + { + "chartName": "hiview", + "chartId": "" + }, + { + "chartName": "com.huawei.ohos.hiviewx", + "chartId": "" + }, + { + "chartName": "com.huawei.ohos.hiviewx(nweb)", + "chartId": "" + }, + { + "chartName": "com.huawei.ohos.hiviewx:workScheduler", + "chartId": "" + } + ] + }, + { + "component": "faultloggerd", + "charts": [ + { + "chartName": "faultloggerd", + "chartId": "" + } + ] + }, + { + "component": "hitrace_native", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "hicollie_native", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "bundlemanager", + "components": [ + { + "component": "bundle_framework", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "bundle_tool", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "distributed_bundle_framework", + "charts": [ + { + "chartName": "dbms", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "ability", + "components": [ + { + "component": "ability_runtime", + "charts": [ + { + "chartName": "com.ohos.formrenderservice", + "chartId": "" + }, + { + "chartName": "quick_fix", + "chartId": "" + }, + { + "chartName": "upms", + "chartId": "" + } + ] + }, + { + "component": "ability_tools", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "idl_tool", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "form_fwk", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "ability_base", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "dmsfwk", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "communication", + "components": [ + { + "component": "bluetooth", + "charts": [ + { + "chartName": "locationhub", + "chartId": "" + }, + { + "chartName": "location_host", + "chartId": "" + }, + { + "chartName": "nfc_host", + "chartId": "" + }, + { + "chartName": "secure_element_host", + "chartId": "" + }, + { + "chartName": "blue_host", + "chartId": "" + }, + { + "chartName": "nfc_service", + "chartId": "" + }, + { + "chartName": "bluetooth_service", + "chartId": "" + }, + { + "chartName": "a2dp_host", + "chartId": "" + }, + { + "chartName": "connected_tag_h", + "chartId": "" + }, + { + "chartName": "se_service", + "chartId": "" + }, + { + "chartName": "wpa_supplicant", + "chartId": "" + }, + { + "chartName": "wireless_hid_ac", + "chartId": "" + } + ] + }, + { + "component": "ipc", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "ipc_js", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "net_manager", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "netmanager_base", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "netmanager_ext", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "netstack", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "dsoftbus", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "wifi", + "charts": [ + { + "chartName": "wifi_manager_service", + "chartId": "" + }, + { + "chartName": "wifi_hal_service", + "chartId": "" + }, + { + "chartName": "wifi_hal_service_1", + "chartId": "" + } + ] + }, + { + "component": "dhcp", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "bluetooth_native_js", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "location", + "components": [ + { + "component": "location", + "charts": [ + { + "chartName": "com.huawei.hmos.location", + "chartId": "" + } + ] + }, + { + "component": "location_common", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "location_locator", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "location_network", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "location_gnss", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "location_passive", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "location_geocode", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "updater", + "components": [ + { + "component": "updater", + "charts": [ + { + "chartName": "com.huawei.hmos.migrateclient", + "chartId": "" + }, + { + "chartName": "migrate_server", + "chartId": "" + }, + { + "chartName": "com.huawei.hmos.ouc", + "chartId": "" + } + ] + }, + { + "component": "update_service", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "sys_installer", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "sensors", + "components": [ + { + "component": "miscdevice", + "charts": [ + { + "chartName": "multimodalinput", + "chartId": "" + }, + { + "chartName": "msdp", + "chartId": "" + } + ] + }, + { + "component": "sensor", + "charts": [ + { + "chartName": "sensors", + "chartId": "" + } + ] + }, + { + "component": "start", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "graphic", + "components": [ + { + "component": "graphic_standard", + "charts": [ + { + "chartName": "render_service", + "chartId": "" + }, + { + "chartName": "bootanimation", + "chartId": "" + } + ] + }, + { + "component": "graphic_chipsetsdk", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "useriam", + "components": [ + { + "component": "pin_auth", + "charts": [ + { + "chartName": "pinauth", + "chartId": "" + }, + { + "chartName": "pin_auth_host", + "chartId": "" + } + ] + }, + { + "component": "user_auth_framework", + "charts": [ + { + "chartName": "useriam", + "chartId": "" + }, + { + "chartName": "user_auth_host", + "chartId": "" + } + ] + }, + { + "component": "face_auth", + "charts": [ + { + "chartName": "face_auth_host", + "chartId": "" + }, + { + "chartName": "fingerprint_auth_host", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "theme", + "components": [ + { + "component": "screenlock_mgr", + "charts": [ + { + "chartName": "com.ohos.screenlock", + "chartId": "" + }, + { + "chartName": "screenlock_server", + "chartId": "" + }, + { + "chartName": "com.ohos.mms", + "chartId": "" + }, + { + "chartName": "com.ohos.systemui", + "chartId": "" + }, + { + "chartName": "com.ohos.settings", + "chartId": "" + } + ] + }, + { + "component": "wallpaper_mgr", + "charts": [ + { + "chartName": "com.ohos.launcher.phone_entry:WallpaperExtAbility", + "chartId": "" + }, + { + "chartName": "com.ohos.launcher", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "multimedia", + "components": [ + { + "component": "multimedia_histreamer", + "charts": [ + { + "chartName": "pulseaudio", + "chartId": "" + }, + { + "chartName": "media_service", + "chartId": "" + } + ] + }, + { + "component": "multimedia_player_framework", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "multimedia_audio_framework", + "charts": [ + { + "chartName": "audio_policy", + "chartId": "" + } + ] + }, + { + "component": "multimedia_camera_framework", + "charts": [ + { + "chartName": "camera_service", + "chartId": "" + } + ] + }, + { + "component": "multimedia_image_framework", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "multimedia_av_session", + "charts": [ + { + "chartName": "av_session", + "chartId": "" + }, + { + "chartName": "av_codec_service", + "chartId": "" + } + ] + }, + { + "component": "media_library", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "multimodalinput", + "components": [ + { + "component": "input", + "charts": [ + { + "chartName": "uinput_inject", + "chartId": "" + }, + { + "chartName": "udevd", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "telephony", + "components": [ + { + "component": "core_service", + "charts": [ + { + "chartName": "riladapter_host", + "chartId": "" + } + ] + }, + { + "component": "telephony_data", + "charts": [ + { + "chartName": "telephony", + "chartId": "" + }, + { + "chartName": "com.ohos.telephonydataability", + "chartId": "" + } + ] + }, + { + "component": "state_registry", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "cellular_call", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "cellular_data", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "sms_mms", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "call_manager", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "global", + "components": [ + { + "component": "i18n", + "charts": [ + { + "chartName": "edm", + "chartId": "" + } + ] + }, + { + "component": "timezone", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "resource_management", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "systemres", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "powermgr", + "components": [ + { + "component": "power_manager", + "charts": [ + { + "chartName": "powerct", + "chartId": "" + } + ] + }, + { + "component": "battery_manager", + "charts": [ + { + "chartName": "battery_extra_host", + "chartId": "" + } + ] + }, + { + "component": "battery_statistics", + "charts": [ + { + "chartName": "bms_event", + "chartId": "" + }, + { + "chartName": "bsoh", + "chartId": "" + } + ] + }, + { + "component": "display_manager", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "thermal_manager", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "contacts_data", + "components": [ + { + "component": "contacts_data_hap", + "charts": [ + { + "chartName": "com.ohos.contacts", + "chartId": "" + }, + { + "chartName": "com.ohos.contactsdataability", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "settingsnapi", + "components": [ + { + "component": "settings_standard", + "charts": [ + { + "chartName": "com.ohos.settingsdata", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "xts", + "components": [ + { + "component": "xts_acts", + "charts": [ + { + "chartName": "devattest_service ", + "chartId": "" + } + ] + }, + { + "component": "xts_hats", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "xts_dcts", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "device_attest", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "distributedhardware", + "components": [ + { + "component": "device_manager", + "charts": [ + { + "chartName": "device_manager", + "chartId": "" + }, + { + "chartName": "daudio_host", + "chartId": "" + }, + { + "chartName": "dinput", + "chartId": "" + } + ] + }, + { + "component": "distributed_hardware_fwk", + "charts": [ + { + "chartName": "dhardware", + "chartId": "" + } + ] + }, + { + "component": "distributed_camera", + "charts": [ + { + "chartName": "dcamera_host", + "chartId": "" + } + ] + }, + { + "component": "distributed_screen", + "charts": [ + { + "chartName": "dscreen", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "resourceschedule", + "components": [ + { + "component": "resource_schedule_service", + "charts": [ + { + "chartName": "resource_schedule_service", + "chartId": "" + } + ] + }, + { + "component": "soc_perf", + "charts": [ + { + "chartName": "socperf_service", + "chartId": "" + } + ] + }, + { + "component": "background_task_mgr", + "charts": [ + { + "chartName": "bgtaskmgr_service", + "chartId": "" + } + ] + }, + { + "component": "work_scheduler", + "charts": [ + { + "chartName": "work_scheduler_service", + "chartId": "" + } + ] + }, + { + "component": "memmgr", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "frame_aware_sched", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "device_usage_statistics", + "charts": [ + { + "chartName": "device_usage_stats_service", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "usb", + "components": [ + { + "component": "usb_manager", + "charts": [ + { + "chartName": "usb_service", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "hdf", + "components": [ + { + "component": "hdf_core", + "charts": [ + { + "chartName": "lcd_host", + "chartId": "" + }, + { + "chartName": "tp_host", + "chartId": "" + }, + { + "chartName": "hdf_devmgr", + "chartId": "" + }, + { + "chartName": "composer_host", + "chartId": "" + }, + { + "chartName": "allocator_host", + "chartId": "" + }, + { + "chartName": "audio_host", + "chartId": "" + }, + { + "chartName": "disp_gralloc_host", + "chartId": "" + }, + { + "chartName": "audio_hdi_server_host", + "chartId": "" + }, + { + "chartName": "hwc_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_sensor", + "charts": [ + { + "chartName": "sensor_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_camera", + "charts": [ + { + "chartName": "camera_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_codec", + "charts": [ + { + "chartName": "codec_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_motion", + "charts": [ + { + "chartName": "motion_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_light", + "charts": [ + { + "chartName": "light_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_vibrator", + "charts": [ + { + "chartName": "vibrator_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_power", + "charts": [ + { + "chartName": "power_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_battery", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_thermal", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_pin_auth", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_face_auth", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_user_auth", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_fingerprint_auth", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_input", + "charts": [ + { + "chartName": "input_user_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_memorytracker", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_wlan", + "charts": [ + { + "chartName": "wifi_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_location_agnss", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_location_geofence", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_location_gnss", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_usb", + "charts": [ + { + "chartName": "usb_host", + "chartId": "" + } + ] + }, + { + "component": "ril_device_driver_interface", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_display", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_distributed_camera", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_ril", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_partitionslot", + "charts": [ + { + "chartName": "partitionslot_host", + "chartId": "" + } + ] + }, + { + "component": "drivers_interface_nnrt", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] + }, + { + "subsystem": "ai", + "components": [ + { + "component": "neural_network_runtime", + "charts": [ + { + "chartName": "ai_decision", + "chartId": "" + } + ] + }, + { + "component": "mindspore", + "charts": [ + { + "chartName": "", + "chartId": "" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/ide/src/trace/database/ConvertTraceWorker.ts b/ide/src/trace/database/ConvertTraceWorker.ts index 06d6644e176cc9f00b289b385da7c63a64b69c75..eec44b28b25f2b1245f1475392376316568ce45d 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, traceAllData] = 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, Uint8Array] { 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, traceAllData]; } + 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/SqlLiteWorker.ts b/ide/src/trace/database/SqlLiteWorker.ts index 74001eed0a5c1389ad5bc1f4aaaebc57d00dd7e6..033bc4ae88a19ce9f28292774f979c45ef94b3a2 100644 --- a/ide/src/trace/database/SqlLiteWorker.ts +++ b/ide/src/trace/database/SqlLiteWorker.ts @@ -15,6 +15,9 @@ importScripts('sql-wasm.js'); import { temp_init_sql_list } from './TempSql'; +import { execProtoForWorker } from './data-trafic/utils/ExecProtoForWorker'; +import { TraficEnum } from './data-trafic/utils/QueryEnum'; + let conn: any = null; let encoder = new TextEncoder(); function initIndexedDB() { @@ -123,5 +126,21 @@ self.onmessage = async (e: any) => { error: err.message, }); } + } else if (e.data.action === 'exec-proto') { + e.data.params.trafic = TraficEnum.Memory; + execProtoForWorker(e.data, (sql: string) => { + try { + const stmt = conn.prepare(sql); + let res = []; + while (stmt.step()) { + res.push(stmt.getAsObject()); + } + stmt.free(); + return res; + } catch (err: any) { + console.log(err); + return []; + } + }); } }; 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/ArkTsReceiver.ts b/ide/src/trace/database/data-trafic/ArkTsReceiver.ts index 05aa54afafd7ad1ac6776043677a592f6650c9cc..e388c83318feadbf5a212ff902740674acd7d1d9 100644 --- a/ide/src/trace/database/data-trafic/ArkTsReceiver.ts +++ b/ide/src/trace/database/data-trafic/ArkTsReceiver.ts @@ -88,15 +88,13 @@ export function cpuProfilerDataReceiver(data: any, proc: Function): void { if (res.length > 0) { if (!dataCache.jsCallChain || dataCache.jsCallChain.length === 0) { dataCache.jsCallChain = res; - createCallChain(); + createCallChain(data.params.trafic); } let sql = queryChartDataSqlMem(data.params); let chartData = proc(sql); if (chartData.length > 0) { samples = convertJSON(chartData); - if (data.params.trafic === TraficEnum.ProtoBuffer) { - arrayBufferHandler(data, samples, true); - } + arrayBufferHandler(data, samples, true); } } } @@ -104,11 +102,12 @@ export function cpuProfilerDataReceiver(data: any, proc: Function): void { /** * 建立callChain每个函数的联系,设置depth跟children */ -function createCallChain(): void { +function createCallChain(trafic: TraficEnum): void { const jsSymbolMap = dataCache.jsSymbolMap; const symbol = new JsProfilerSymbol(); - for (const data of dataCache.jsCallChain!) { - let item = data.cpuProfilerData || symbol; + for (let data of dataCache.jsCallChain!) { + let sample = (trafic !== TraficEnum.Memory ? data.cpuProfilerData : data) || symbol; + let item = data.cpuProfilerData || data; if (!item.childrenString) { item.childrenString = ''; } @@ -134,11 +133,11 @@ function createCallChain(): void { } } -function combineChartData(res: Array): Array { +function combineChartData(res: Array, trafic: TraficEnum): Array { const combineSample = new Array(); const symbol = new JsCpuProfilerSample(); for (let data of res) { - let sample = data.cpuProfilerData || symbol; + let sample = (trafic !== TraficEnum.Memory ? data.cpuProfilerData : data) || symbol; const stackTopSymbol = dataCache.jsSymbolMap.get(sample.functionId); // root 节点不需要显示 if (stackTopSymbol?.id === ROOT_ID) { @@ -277,7 +276,7 @@ function combineCallChain(lastCallTree: JsCpuProfilerChartFrame, sample: JsCpuPr } function arrayBufferHandler(data: any, res: any[], transfer: boolean): void { - let result = combineChartData(res); + let result = combineChartData(res, data.params.trafic); clearJsCacheData(); const getArrayData = (combineData: Array): void => { for (let item of combineData) { 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/ProcedureLogicWorkerNativeNemory.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts index 2732626a5dd7dd883aa8e0188c4e52a760c6138b..b3a241d3683ced37f7b40d9c5b84c927e4d86c19 100644 --- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts +++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerNativeNemory.ts @@ -1032,10 +1032,30 @@ export class ProcedureLogicWorkerNativeMemory extends LogicHandler { this.merageChildrenByIndex(node, callChainDataList, index, sample, isTopDown); } } + + private extractSymbolAndPath(node: NativeHookCallInfo, str?: string): void { + node.symbol = 'unknown'; + if (!str) { + return; + } + const match = str.match(/^([^\[:]+):\[url:(.+)\]$/); + if (!match) { + return; + } + node.symbol = match[1].trim(); + node.path = match[2].replace(/^url:/, ''); + } + setMerageName(currentNode: NativeHookCallInfo): void { - currentNode.symbol = - this.groupCutFilePath(currentNode.symbolId, this.dataCache.dataDict.get(currentNode.symbolId) || '') ?? 'unknown'; currentNode.path = this.dataCache.dataDict.get(currentNode.fileId) || 'unknown'; + if (currentNode.path.endsWith('.hap')) { + const fullName = this.dataCache.dataDict.get(currentNode.symbolId); + this.extractSymbolAndPath(currentNode, fullName); + } else { + currentNode.symbol = + this.groupCutFilePath(currentNode.symbolId, this.dataCache.dataDict.get(currentNode.symbolId) || '') ?? + 'unknown'; + } currentNode.libName = setFileName(currentNode.path); currentNode.lib = currentNode.path; currentNode.symbolName = `[${currentNode.symbol}] ${currentNode.libName}`; 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..4ce750e12cf3e47c4792180feac7f4bd0f90db75 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( @@ -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 @@ -142,7 +228,7 @@ export const querySearchRowFuncData = ( left join trace_range r where - c.name like '${funcName}' + c.name like '${funcName}%' and t.tid = ${tIds} and @@ -150,6 +236,42 @@ export const querySearchRowFuncData = ( `, { $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, @@ -292,16 +414,6 @@ export const queryTaskPoolOtherRelationData = (ids: Array, tid: number): }; export const queryTaskPoolRelationData = (ids: Array, tids: Array): Promise> => { - const sqlArray: Array = []; - if (ids.length > 0) { - for (let index = 0; index < ids.length; index++) { - if (index !== 0) { - sqlArray.push(`or`); - } - sqlArray.push(`( tid = ${tids[index]} and c.id = ${ids[index]})`); - } - } - let sql = sqlArray.join(' '); let sqlStr = `select c.ts-D.start_ts as startTs, c.dur, @@ -313,6 +425,124 @@ export const queryTaskPoolRelationData = (ids: Array, tids: Array, leftNS: number, rightNS: number): Promise> => + query( + 'queryBinderByThreadId', + ` + select + B.id, + B.pid, + B.tid, + 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, + } + ); 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..594afa0ee5473bf4f659db23ff7d80299cb36d4e --- /dev/null +++ b/ide/src/trace/database/sql/Ltpo.sql.ts @@ -0,0 +1,61 @@ +/* + * 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%')` + ) + export const querySignaledList = ():Promise> => + query( + 'querySignaledList', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('RSHardwareThrea%')) + AND name LIKE('%has signaled')` + ) + export const queryRSNowTimeList = ():Promise> => + query( + 'queryRSNowTimeList', + `SELECT ts,dur,name FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('render_service%')) + AND name LIKE('H:ReceiveVsync dataCount:24bytes%')` + ) + export const querySkipDataList = ():Promise> => + query( + 'querySkipDataList', + `SELECT ts FROM "callstack" WHERE callid in (SELECT id FROM "thread" WHERE name LIKE('render_service%')) + AND name LIKE('H:DisplayNodeSkip skip commit')` + ) 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..63aaf6e5d07eb2aed42764b8ab3ceda654ef4fd6 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'; 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..6e0f836de5cdabf848c89206c5d7a016a791da34 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 './ProcedureWorkerBpftrace'; 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/ProcedureWorkerAllAppStartup.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts index b6a72695b0834ba646ea102e883a04aea5a0a9ad..77da235a111539a34f2eb80e471c18052159f85d 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts @@ -17,6 +17,7 @@ import { BaseStruct, dataFilterHandler, drawString } from './ProcedureWorkerComm import { TraceRow } from '../../component/trace/base/TraceRow'; import { ColorUtils } from '../../component/trace/base/ColorUtils'; import {querySingleAppStartupsName} from "../sql/ProcessThread.sql"; +import { SpSystemTrace } from '../../component/SpSystemTrace'; export class AllAppStartupRender { renderMainThread( @@ -60,14 +61,31 @@ export class AllAppStartupRender { } } } - +export function AllAppStartupStructOnClick(clickRowType: string, sp: SpSystemTrace,scrollToFuncHandler:any) { + return new Promise((resolve,reject) => { + if (clickRowType === TraceRow.ROW_TYPE_ALL_APPSTARTUPS && AllAppStartupStruct.hoverStartupStruct) { + AllAppStartupStruct.selectStartupStruct = AllAppStartupStruct.hoverStartupStruct; + sp.traceSheetEL?.displayAllStartupData(AllAppStartupStruct.selectStartupStruct, scrollToFuncHandler); + sp.timerShaftEL?.modifyFlagList(undefined); + reject(new Error()); + }else{ + resolve(null); + } + }); +} export class AllAppStartupStruct extends BaseStruct { static hoverStartupStruct: AllAppStartupStruct | undefined; static selectStartupStruct: AllAppStartupStruct | undefined; - dur: number | undefined; startTs: number | undefined; startName: number | undefined; + dur: number | undefined; + value: string | undefined; + pid: number | undefined; + process: string | undefined; + tid: number | undefined; + itid: number | undefined; + endItid: number | undefined; stepName: string | undefined; static draw(ctx: CanvasRenderingContext2D, data: AllAppStartupStruct): void { diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts index e88380a7bc33283e41889092a364e79f1b5338e1..b1da0b6e2f5bbb70949cfc66946add51a036ccbb 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerAppStartup.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BaseStruct, dataFilterHandler, drawString } from './ProcedureWorkerCommon'; +import { BaseStruct, dataFilterHandler, drawLoadingFrame, drawString } from './ProcedureWorkerCommon'; import { TraceRow } from '../../component/trace/base/TraceRow'; import { ColorUtils } from '../../component/trace/base/ColorUtils'; import {SpSystemTrace} from "../../component/SpSystemTrace"; @@ -39,6 +39,7 @@ export class AppStartupRender { paddingTop: 5, useCache: appStartReq.useCache || !(TraceRow.range?.refresh ?? false), }); + drawLoadingFrame(appStartReq.appStartupContext, appStartUpRow.dataListCache, appStartUpRow); appStartReq.appStartupContext.globalAlpha = 0.6; let find = false; let offset = 3; @@ -68,7 +69,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/ProcedureWorkerBpftrace.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerBpftrace.ts new file mode 100644 index 0000000000000000000000000000000000000000..06c5395d9c0a9cc445334d84018e4bc2e634657b --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerBpftrace.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/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..61e0ed5e60abf283d5d5d10a8a9a6dabe731ae9f 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.avgRateTxt && params.frameRateList && params.frameRateList.length) { + drawAvgFrameRate(params.frameRateList, context, params); } } } @@ -858,80 +859,103 @@ 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) { - const CONVERT_SECONDS = 1000000000; - let cutres: number = arr[arr.length - 1]! - arr[0]!; - let avgRate: string = (((arr.length - 1) / cutres) * CONVERT_SECONDS).toFixed(1); - return avgRate; +// 处理文字坐标 +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.avgRateTxt?.includes('HitchTime')) { + textY = selectParams.frame.y + 10; + } else { + // 展开时显示在第二行,折叠显示第一行 + if (selectParams.funcExpand) { + textY = selectParams.frame.y + 28; + } else { + textY = selectParams.frame.y + 10; + } + } + return [textX, textY]; } // 绘制平均帧率箭头指示线条 -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 startX = changeFrameRatePoint(rateList, selectParams)[0]; + let endX = changeFrameRatePoint(rateList, selectParams)[1]; + const textWidth = ctx.measureText(selectParams.avgRateTxt).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(selectParams.avgRateTxt, textX, textY + 4); } + function drawAvgFrameRateArrow( ctx: any, textX: number, @@ -962,6 +986,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 +1081,7 @@ function drawWakeUpIfSelect( const wid = 5; const linkLineColor = '#ff0000'; + export function drawLinkLines( context: CanvasRenderingContext2D, nodes: PairPoint[][], @@ -1072,6 +1098,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 +1258,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 +1292,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 +1369,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, @@ -1398,6 +1430,28 @@ export function drawString(ctx: CanvasRenderingContext2D, str: string, textPaddi } } +export function drawFunString(ctx: CanvasRenderingContext2D, str: string, textPadding: number, frame: Rect, data: any) { + if (data.textMetricsWidth === undefined) { + data.textMetricsWidth = ctx.measureText(str).width; + } + let charWidth = Math.round(data.textMetricsWidth / str.length); + let fillTextWidth = frame.width - textPadding * 2; + if (data.textMetricsWidth < fillTextWidth) { + let x2 = Math.floor(frame.width / 2 - data.textMetricsWidth / 2 + frame.x + textPadding); + ctx.fillText(str, x2, Math.floor(data.frame.height * (data.depth! + 0.5) + 3), fillTextWidth); + } else { + if (fillTextWidth >= charWidth) { + let chatNum = fillTextWidth / charWidth; + let x1 = frame.x + textPadding; + if (chatNum < 2) { + ctx.fillText(str.substring(0, 1), x1, Math.floor(data.frame.height * (data.depth! + 0.5) + 3), fillTextWidth); + } else { + ctx.fillText(str.substring(0, chatNum - 1) + '...', x1, Math.floor(data.frame.height * (data.depth! + 0.5) + 3), fillTextWidth); + } + } + } +} + export function drawString2Line( ctx: CanvasRenderingContext2D, str1: string, @@ -1670,6 +1724,7 @@ export class HiPerfStruct extends BaseStruct { return arr; } } + function filterGroupArray(groupArray: Array, maxEventCount: number, usage?: boolean, event?: number) { return groupArray .map((it) => { @@ -1741,6 +1796,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..658c31b06a71ddf32c5f1a84b1b908826510d0f2 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(false, true); + 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..bead201d09c9754e2eec406236e548c4f760baf7 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(false, true); + 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..38ae14b314070f763daf63640352eb73ef2a1ed2 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerFunc.ts @@ -23,6 +23,7 @@ import { Render, RequestMessage, drawString, + drawFunString, drawLoadingFrame, } from './ProcedureWorkerCommon'; import { FuncStruct as BaseFuncStruct } from '../../bean/FuncStruct'; @@ -58,6 +59,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 +69,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 +147,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); } @@ -176,9 +178,9 @@ export class FuncStruct extends BaseFuncStruct { } let getV: number = x2 - x1 < 1 ? 1 : x2 - x1; funcNode.frame.x = Math.floor(x1); - funcNode.frame.y = funcNode.depth * 20; + funcNode.frame.y = funcNode.depth * 18 + 3; funcNode.frame.width = Math.ceil(getV); - funcNode.frame.height = 20; + funcNode.frame.height = 18; } static draw(ctx: CanvasRenderingContext2D, data: FuncStruct) { @@ -189,24 +191,21 @@ export class FuncStruct extends BaseFuncStruct { ctx.globalAlpha = 1; ctx.fillStyle = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.funName || '', 0, ColorUtils.FUNC_COLOR.length)]; let textColor = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.funName || '', 0, ColorUtils.FUNC_COLOR.length)]; - let miniHeight = 20; if (FuncStruct.hoverFuncStruct && data.funName == FuncStruct.hoverFuncStruct.funName) { ctx.globalAlpha = 0.7; } - ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, miniHeight - padding * 2); + ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, data.frame.height); if (data.frame.width > 10) { - ctx.strokeStyle = '#fff'; - ctx.lineWidth = 1; - ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, miniHeight - padding * 2); ctx.fillStyle = ColorUtils.funcTextColor(textColor); - drawString(ctx, `${data.funName || ''}`, 5, data.frame, data); + ctx.textBaseline = 'middle'; + drawFunString(ctx, `${data.funName || ''}`, 5, data.frame, data); } if (data.callid == FuncStruct.selectFuncStruct?.callid&& data.startTs == FuncStruct.selectFuncStruct?.startTs&& data.depth == FuncStruct.selectFuncStruct?.depth) { ctx.strokeStyle = '#000'; ctx.lineWidth = 2; - ctx.strokeRect(data.frame.x, data.frame.y + 1, data.frame.width, miniHeight - padding * 2 - 2); + ctx.strokeRect(data.frame.x, data.frame.y + 1, data.frame.width, data.frame.height - 2); } let flagConfig = FlagsConfig.getFlagsConfig('TaskPool'); if ( @@ -215,18 +214,46 @@ export class FuncStruct extends BaseFuncStruct { data.funName!.indexOf('Successful') < 0 ) { if (data.frame!.width < 10) { - FuncStruct.drawTaskPoolUnSuccessFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 20, 3, data!); + FuncStruct.drawTaskPoolUnSuccessFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 18, 3, data!); } else { - FuncStruct.drawTaskPoolUnSuccessFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 20, 6, data!); + FuncStruct.drawTaskPoolUnSuccessFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 18, 6, data!); } } 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!); + FuncStruct.drawTaskPoolTimeOutFlag(ctx, data.frame!.x, (data.depth! + 0.5) * 18, 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, @@ -273,5 +300,3 @@ export class FuncStruct extends BaseFuncStruct { ); } } - -const padding = 1; 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..52abe285d1170e4dd2fd69ebd0265dc5752dffcb --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerHitchTime.ts @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BaseStruct, dataFilterHandler,drawLoadingFrame } from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; + +export class hitchTimeRender { + renderMainThread( + req: { + hitchTimeContext: CanvasRenderingContext2D; + useCache: boolean; + type: string; + }, + hitchTimeRow: TraceRow + ): void { + let list = hitchTimeRow.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 = hitchTimeRow.dataListCache; + dataFilterHandler(list, filter, { + startKey: 'startTs', + durKey: 'dur', + startNS: TraceRow.range?.startNS ?? 0, + endNS: TraceRow.range?.endNS ?? 0, + totalNS: TraceRow.range?.totalNS ?? 0, + frame: hitchTimeRow.frame, + paddingTop: 5, + useCache: req.useCache || !(TraceRow.range?.refresh ?? false), + }); + req.hitchTimeContext.globalAlpha = 0.6; + let find = false; + let offset = 3; + drawLoadingFrame(req.hitchTimeContext,filter,hitchTimeRow) + for (let re of filter) { + if (hitchTimeRow.isHover) { + if ( + re.frame && + hitchTimeRow.hoverX >= re.frame.x - offset && + hitchTimeRow.hoverX <= re.frame.x + re.frame.width + offset + ) { + HitchTimeStruct.hoverHitchTimeStruct = re; + find = true; + } + } + if (!hitchTimeRow.isHover) HitchTimeStruct.hoverHitchTimeStruct = undefined + if (!find && hitchTimeRow.isHover) { + HitchTimeStruct.hoverHitchTimeStruct = undefined; + } + req.hitchTimeContext.beginPath() + HitchTimeStruct.draw(req.hitchTimeContext, re); + req.hitchTimeContext.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; + nowTime: number | undefined; + cutTime: number | undefined; + cutSendDur: 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..b5c5cc49cbfe315ef6d29de1e84a397d4b123bdd --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerLTPO.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,drawLoadingFrame } from './ProcedureWorkerCommon'; +import { TraceRow } from '../../component/trace/base/TraceRow'; + +export class LtpoRender { + renderMainThread( + req: { + ltpoContext: 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.ltpoContext.globalAlpha = 0.6; + let find = false; + let offset = 3; + drawLoadingFrame(req.ltpoContext,filter,ltpoRow); + 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.ltpoContext.beginPath() + LtpoStruct.draw(req.ltpoContext, re); + req.ltpoContext.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; + nowTime: number | undefined; + cutTime: number | undefined; + cutSendDur: 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/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..2f715ac0b95a60587bf20bcd4075ec3738fe8499 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerSoInit.ts @@ -15,7 +15,15 @@ import { ColorUtils } from '../../component/trace/base/ColorUtils'; import { TraceRow } from '../../component/trace/base/TraceRow'; -import { BaseStruct, isFrameContainPoint, ns2x, Render, RequestMessage, drawString } from './ProcedureWorkerCommon'; +import { + BaseStruct, + isFrameContainPoint, + ns2x, + Render, + RequestMessage, + drawString, + drawLoadingFrame +} from './ProcedureWorkerCommon'; import {SpSystemTrace} from "../../component/SpSystemTrace"; export class SoRender extends Render { @@ -38,6 +46,7 @@ export class SoRender extends Render { row.frame, req.useCache || !TraceRow.range!.refresh ); + drawLoadingFrame(req.context, row.dataListCache, row); req.context.beginPath(); let soFind = false; for (let so of soFilter) { @@ -114,7 +123,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..aaaac459414a3eedb3deef1399c21b9517978273 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerThread.ts @@ -46,7 +46,7 @@ export class ThreadRender extends Render { endNS: TraceRow.range?.endNS ?? 0, totalNS: TraceRow.range?.totalNS ?? 0, frame: row.frame, - paddingTop: 5, + paddingTop: 3, useCache: threadReq.useCache || !(TraceRow.range?.refresh ?? false), }); drawLoadingFrame(threadReq.context, threadFilter, row); @@ -64,7 +64,6 @@ export class ThreadRender extends Render { render(threadReq: RequestMessage, threadList: Array, threadFilter: Array) {} } -const padding = 3; export function ThreadStructOnClick(clickRowType:string,sp:SpSystemTrace,threadClickHandler:any,cpuClickHandler:any){ return new Promise((resolve, reject) => { if (clickRowType === TraceRow.ROW_TYPE_THREAD && ThreadStruct.hoverThreadStruct) { @@ -73,7 +72,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,37 +87,50 @@ 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, data.frame.width, data.frame.height); 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; threadContext.strokeRect( data.frame.x, - data.frame.y + padding, + data.frame.y, data.frame.width - 2, - data.frame.height - padding * 2 + data.frame.height ); } } diff --git a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts index 71d3a84cb0becfe68e09ea82a2557d8674becddb..8ace6a8fe91ded7d8abb86022597c8470e61f4e8 100644 --- a/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts +++ b/ide/src/trace/database/ui-worker/cpu/ProcedureWorkerCPU.ts @@ -83,7 +83,7 @@ export class CpuRender { endNS: endNS, totalNS: totalNS, frame: row.frame, - paddingTop: 5, + paddingTop: 3, useCache: req.useCache || !(TraceRow.range?.refresh ?? false), }); drawLoadingFrame(req.ctx, cpuFilter, row); @@ -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/chart/scatter/LitChartScatter.test.ts b/ide/test/base-ui/chart/scatter/LitChartScatter.test.ts index 17f15189179a140681f2fae8f625c31a5b42f8b2..9b6961662a8aa440ba871a1e303c1e973e27cbf0 100644 --- a/ide/test/base-ui/chart/scatter/LitChartScatter.test.ts +++ b/ide/test/base-ui/chart/scatter/LitChartScatter.test.ts @@ -14,6 +14,9 @@ */ import { LitChartScatter } from '../../../../src/base-ui/chart/scatter/LitChartScatter'; +import { LitChartScatterConfig } from '../../../../src/base-ui/chart/scatter/LitChartScatterConfig'; + +// @ts-ignore window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -21,9 +24,153 @@ window.ResizeObserver = observe: jest.fn(), unobserve: jest.fn(), })); -describe('LitChartScatter Test',()=>{ - it('LitChartScatterTest01 ', function () { - let litChartScatter = new LitChartScatter(); - expect(litChartScatter).not.toBeUndefined(); + +describe('LitChartScatter Test', () => { + let litChartScatter = new LitChartScatter(); + litChartScatter.canvas = litChartScatter.shadowRoot!.querySelector('#canvas'); + litChartScatter.ctx = litChartScatter.canvas!.getContext('2d', { alpha: true }); + litChartScatter.connectedCallback(); + litChartScatter.options = { + yAxisLabel: [20000, 40000, 60000, 80000, 100000], + xAxisLabel: [20000, 40000, 60000, 80000, 100000, 120000], + axisLabel: ['负载', '算力供给'], + drawload: true, + load: [100000, 1000], + colorPool: () => ['#2f72f8', '#ffab67', '#a285d2'], + colorPoolText: () => ['Total', 'CycleA', 'CycleB'], + paintingData: [ + { + x: 111.11939333333333, + y: 173.71615585811537, + r: 6, + c: [16655.818, 2983.844141884629, 1, 5.582, 5.361], + color: '#2f72f8', + }, + { + x: 77.52432666666667, + y: 174.7453794947994, + r: 6, + c: [6577.298, 1954.6205052005942, 2, 3.365, 2.585], + color: '#2f72f8', + }, + { + x: 100.43357333333333, + y: 174.20508773882395, + r: 6, + c: [13450.072, 2494.912261176034, 3, 5.391, 5.287], + color: '#2f72f8', + }, + ], + hoverData: {}, + globalGradient: {}, + data: [ + [ + [16655.818, 2983.844141884629, 1, 5.582, 5.361], + [6577.298, 1954.6205052005942, 2, 3.365, 2.585], + [13450.072, 2494.912261176034, 3, 5.391, 5.287], + ], + [], + [], + ], + title: 'render_service 1155', + tip: (data) => { + return ` +
          + Cycle: ${data.c[2]};
          + Comsumption: ${data.c[0]};
          + Cycle_dur: ${data.c[3]} ms;
          + Running_dur: ${data.c[4]} ms;
          +
          + `; + }, + }; + let options = litChartScatter.options!; + it('LitChartScatter 01', function () { + expect(litChartScatter.init()).toBeUndefined(); + }); + + it('LitChartScatter 02', function () { + const drawBackgroundMock = jest.fn(); + litChartScatter.drawBackground = drawBackgroundMock; + const drawScatterChartMock = jest.fn(); + litChartScatter.drawScatterChart = drawScatterChartMock; + const setOffScreenMock = jest.fn(); + litChartScatter.setOffScreen = setOffScreenMock; + const clearRectMock = jest.fn(); + litChartScatter.ctx!.clearRect = clearRectMock; + litChartScatter.init(); + expect(drawBackgroundMock).toHaveBeenCalled(); + expect(drawScatterChartMock).toHaveBeenCalled(); + expect(setOffScreenMock).toHaveBeenCalled(); + expect(clearRectMock).toHaveBeenCalled(); + }); + + it('LitChartScatter 03', function () { + expect(litChartScatter.setOffScreen()).toBeUndefined(); + litChartScatter.setOffScreen(); + expect(litChartScatter.canvas2?.height).toEqual(litChartScatter.clientHeight); + expect(litChartScatter.canvas2?.width).toEqual(litChartScatter.clientWidth); + }); + + it('LitChartScatter 04', function () { + let hoverPoint = { + x: 163.42456666666666, + y: 160.69372623574142, + r: 6, + c: [3234.737, 559.0627376425856, 95, 5.786, 3.916], + color: '#2f72f8', + }; + expect(litChartScatter.drawBackground()).toBeUndefined(); + expect(litChartScatter.drawScatterChart(litChartScatter.options!)).toBeUndefined(); + expect(litChartScatter.drawAxis(litChartScatter.options!)).toBeUndefined(); + expect(litChartScatter.drawYLabels(litChartScatter.options!)).toBeUndefined(); + expect(litChartScatter.drawXLabels(litChartScatter.options!)).toBeUndefined(); + expect(litChartScatter.drawData(litChartScatter.options!)).toBeUndefined(); + expect(litChartScatter.drawCycle(2, 10, 1, 1, '#000000')).toBeUndefined(); + expect(litChartScatter.drawLoadLine(litChartScatter.options!.load)).toBeUndefined(); + expect(litChartScatter.drawBalanceLine(litChartScatter.options!.load)).toBeUndefined(); + expect(litChartScatter.resetHoverWithOffScreen()).toBeUndefined(); + expect(litChartScatter.paintHover()).toBeUndefined(); + expect(litChartScatter.connectedCallback()).toBeUndefined(); + expect(litChartScatter.initElements()).toBeUndefined(); + }); + + it('LitChartScatter 05', function () { + litChartScatter.drawBackground(); + expect(litChartScatter.ctx?.save).toHaveBeenCalled(); + expect(litChartScatter.ctx?.fillRect).toHaveBeenCalled(); + expect(litChartScatter.ctx?.restore).toHaveBeenCalled(); + }); + + it('LitChartScatter 06', function () { + litChartScatter.drawAxis(litChartScatter.options!); + let ctx = litChartScatter.ctx!; + expect(ctx.font).toEqual('10px KATTI'); + expect(ctx.fillStyle).toEqual('#000000'); + expect(ctx.strokeStyle).toEqual('#000000'); + }); + + it('LitChartScatter 07', function () { + litChartScatter.drawYLabels(litChartScatter.options!); + let ctx = litChartScatter.ctx!; + expect(ctx.font).toEqual('12px KATTI'); + expect(ctx.fillStyle).toEqual('#000000'); + expect(ctx.strokeStyle).toEqual('#000000'); + }); + + it('LitChartScatter 08', function () { + litChartScatter.drawXLabels(litChartScatter.options!); + let ctx = litChartScatter.ctx!; + expect(ctx.fillStyle).toEqual('#000000'); + expect(ctx.strokeStyle).toEqual('#000000'); + expect(ctx.beginPath).toHaveBeenCalled(); + }); + + it('LitChartScatter 9', function () { + const mockInit = jest.fn(); + litChartScatter.init = mockInit; + litChartScatter.config = options; + expect(mockInit).toHaveBeenCalled(); + expect(litChartScatter.options).toEqual(options); }); -}) \ No newline at end of file +}); 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/LitPageTable.test.ts b/ide/test/base-ui/table/LitPageTable.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..83c4cf51362ffc48111b26478fc33051722834d7 --- /dev/null +++ b/ide/test/base-ui/table/LitPageTable.test.ts @@ -0,0 +1,431 @@ +/* + * 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 { LitPageTable } from '../../../src/base-ui/table/LitPageTable'; +import { LitTableColumn } from '../../../src/base-ui/table/lit-table-column'; +import { TableRowObject } from '../../../src/base-ui/table/TableRowObject'; +import { LitProgressBar } from '../../../src/base-ui/progress-bar/LitProgressBar'; +import { LitIcon } from '../../../src/base-ui/icon/LitIcon'; +describe('LitTable Test', () => { + window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + let litTable = new LitPageTable(); + litTable.selectable = true; + litTable.selectable = false; + litTable.scrollY = 'scrollY'; + + litTable.recycleDataSource = []; + + litTable.recycleDataSource = [ + { + id: 1, + name: 'name', + }, + { + id: 2, + name: 'nameValue', + }, + ]; + const td = { + style: { + position: 'sticky', + left: '0px', + right: '0px', + boxShadow: '3px 0px 5px #33333333', + }, + }; + const placement = 'left'; + + const element = { + style: { + display: 'none', + transform: 'translateY', + }, + childNodes: { forEach: true }, + onclick: 1, + }; + const rowObject = { + children: { + length: 1, + }, + data: [{ isSelected: undefined }], + depth: 1, + top: 1, + }; + const firstElement = + { + style: { + display: 'none', + paddingLeft: '', + transform: 'translateY', + }, + innerHTML: '', + title: '', + firstChild: null, + onclick: 1, + } || undefined; + + litTable.columns = litTable.columns || jest.fn(() => true); + + litTable.tbodyElement = jest.fn(() => ({ + innerHTML: '', + })); + + litTable.tableColumns = jest.fn(() => []); + + litTable.tableColumns.forEach = jest.fn(() => []); + + it('LitTablePageTest01', () => { + expect(litTable.adoptedCallback()).toBeUndefined(); + }); + + it('LitTablePageTest02', () => { + expect(litTable.disconnectedCallback()).toBeUndefined(); + }); + + it('LitTablePageTest03', () => { + expect(litTable.attributeChangedCallback('name', 'a', 'b')).toBeUndefined(); + }); + + it('LitTablePageTest04', () => { + litTable.hideDownload = true; + expect(litTable.hideDownload).toBeTruthy(); + }); + + it('LitTablePageTest05', () => { + expect(litTable.hideDownload).not.toBeUndefined(); + }); + + it('LitTablePageTest06', () => { + litTable.hideDownload = false; + expect(litTable.hideDownload).toBeFalsy(); + }); + + it('LitTablePageTest07', () => { + expect(litTable.selectable).not.toBeUndefined(); + }); + + it('LitTablePageTest08', () => { + litTable.selectable = true; + expect(litTable.selectable).toBeTruthy(); + }); + + it('LitTablePageTest09', () => { + expect(litTable.scrollY).not.toBeUndefined(); + }); + + it('LitTablePageTest10', () => { + litTable.scrollY = ''; + expect(litTable.scrollY).not.toBeUndefined(); + }); + + it('LitTablePageTest11', () => { + expect(litTable.recycleDataSource).not.toBeUndefined(); + }); + + it('LitTablePageTest12', () => { + expect(litTable.measureReset()).toBeUndefined(); + }); + + it('LitTablePageTest13', () => { + litTable.pagination = true; + expect(litTable.pagination).toBeTruthy(); + }); + + it('LitTablePageTest14', () => { + litTable.setAttribute('pagination', ''); + litTable.pagination = false; + expect(litTable.pagination).toBeFalsy(); + }); + + it('LitTablePageTest15', () => { + expect(litTable.initElements()).toBeUndefined(); + }); + + it('LitTablePageTest16', () => { + expect(litTable.initPageEventListener()).toBeUndefined(); + }); + + it('LitTablePageTest17', () => { + litTable.rememberScrollTop = true; + expect(litTable.toTop()).toBeUndefined(); + }); + + it('LitTablePageTest18', () => { + litTable.rememberScrollTop = true; + litTable.toTop(); + expect(litTable.tableElement!.scrollTop).toEqual(0); + expect(litTable.tableElement!.scrollLeft).toEqual(0); + }); + + it('LitTablePageTest19', () => { + litTable.rememberScrollTop = false; + litTable.toTop(); + expect(litTable.tableElement!.scrollTop).toEqual(0); + expect(litTable.tableElement!.scrollLeft).toEqual(0); + }); + + it('LitTablePageTest20', () => { + expect(typeof litTable.initHtml()).toEqual('string'); + }); + + it('LitTablePageTest21', () => { + expect(litTable.connectedCallback()).toBeUndefined(); + }); + + it('LitTablePageTest22', () => { + const rowData = { + data: [ + { + isSelected: undefined, + }, + ], + }; + expect(litTable.meauseElementHeight(rowData)).toBe(27); + }); + + it('LitTablePageTest23', () => { + const rowData = { + data: [ + { + isSelected: undefined, + }, + ], + }; + expect(litTable.meauseTreeElementHeight(rowData, 1)).toBe(27); + }); + + it('LitTablePageTest24', () => { + document.body.innerHTML = ""; + let table = document.querySelector('#tab') as LitPageTable; + let htmlElement = document.createElement('lit-table-column') as LitTableColumn; + htmlElement.setAttribute('title', '1'); + htmlElement.setAttribute('data-index', '1'); + htmlElement.setAttribute('key', '1'); + htmlElement.setAttribute('align', 'flex-start'); + htmlElement.setAttribute('height', '32px'); + table!.appendChild(htmlElement); + setTimeout(() => { + table.recycleDataSource = [ + { + id: 1, + name: 'name', + }, + { + id: 2, + name: 'nameValue', + }, + ]; + expect(table.meauseTreeElementHeight('1', 2)).toBe(27); + }, 20); + }); + + it('LitTablePageTest25', () => { + expect(litTable.createExpandBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); + }); + + it('LitTablePageTest26', () => { + let newTableElement = document.createElement('div'); + newTableElement.classList.add('tr'); + newTableElement.style.cursor = 'pointer'; + newTableElement.style.gridTemplateColumns = '1,2,3'; + newTableElement.style.position = 'absolute'; + newTableElement.style.top = '0px'; + newTableElement.style.left = '0px'; + litTable.currentRecycleList = [newTableElement]; + litTable.recycleDs = [{ rowHidden: false, data: { isSearch: true } }]; + litTable.tbodyElement = document.createElement('div'); + litTable.treeElement = document.createElement('div'); + litTable.tableElement = document.createElement('div'); + litTable.theadElement = document.createElement('div'); + expect(litTable.reMeauseHeight()).toBeUndefined(); + }); + + it('LitTablePageTest27', () => { + const rowData = { + data: [ + { + isSelected: undefined, + }, + ], + }; + litTable.columns.forEach = jest.fn(() => true); + expect(litTable.createNewTableElement(rowData)).not.toBeUndefined(); + }); + + it('LitTablePageTest28', () => { + let element = document.createElement('div'); + let ch = document.createElement('div'); + element.appendChild(ch); + let rowObject = { rowHidden: false, data: { isSearch: true } }; + let tableColmn = document.createElement('lit-table-column') as LitTableColumn; + tableColmn.setAttribute('data-index', '1'); + tableColmn.setAttribute('title', '1'); + tableColmn.setAttribute('data-index', '2'); + tableColmn.setAttribute('align', 'flex-start'); + tableColmn.setAttribute('height', '32px'); + tableColmn.setAttribute('key', '2'); + let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; + tableColmn1.setAttribute('align', 'flex-start'); + tableColmn1.setAttribute('height', '32px'); + tableColmn1.setAttribute('title', '2'); + tableColmn1.setAttribute('data-index', '2'); + tableColmn1.setAttribute('key', '2'); + litTable.columns = [tableColmn, tableColmn1]; + expect(litTable.freshCurrentLine(element, rowObject)).toBeUndefined(); + }); + + it('LitTablePageTest29', () => { + litTable.recycleDs.length = 1; + litTable.setCurrentSelection = jest.fn(() => true); + expect(litTable.scrollToData(litTable.recycleDataSource)).toBeUndefined(); + }); + + it('LitTablePageTest30', () => { + litTable.recycleDs = [{ rowHidden: false, data: { isSearch: true } }]; + let dataSource = [ + { + id: 11, + name: 'name', + }, + { + id: 21, + name: 'value', + }, + ]; + expect(litTable.expandList(dataSource)).toBeUndefined(); + }); + + it('LitTablePageTest31', () => { + expect(litTable.clearAllSelection()).toBeUndefined(); + }); + + it('LitTablePageTest32', () => { + expect(litTable.dispatchRowClickEvent({ data: { isSelected: '' } }, [], { button: '' })).toBeUndefined(); + }); + + it('LitTablePageTest33', () => { + litTable.treeElement = jest.fn(() => undefined); + litTable.treeElement.children = jest.fn(() => [1]); + litTable.columns.forEach = jest.fn(() => true); + litTable.treeElement.lastChild = jest.fn(() => true); + litTable.treeElement.lastChild.style = jest.fn(() => true); + expect(litTable.createNewTreeTableElement({ data: '' })).not.toBeUndefined(); + }); + + it('LitTablePageTest34', () => { + let tableIcon = document.createElement('lit-icon') as LitIcon; + let mouseClickEvent: MouseEvent = new MouseEvent('click', { movementX: 1, movementY: 2 }); + tableIcon.dispatchEvent(mouseClickEvent); + }); + + it('LitTablePageTest35', () => { + document.body.innerHTML = ``; + let litTable = document.querySelector('#aaa') as LitTable; + litTable.formatName = true; + expect(litTable.formatName).toBeTruthy(); + }); + + it('LitTablePageTest36', () => { + expect(litTable.formatExportData(litTable.recycleDataSource)).not.toBeUndefined(); + }); + + it('LitTablePageTest37', () => { + expect(litTable.setSelectedRow(true, [])).toBeUndefined(); + }); + + it('LitTablePageTest38', () => { + let tableColmn = document.createElement('lit-table-column') as LitTableColumn; + tableColmn.setAttribute('title', '21'); + tableColmn.setAttribute('data-index', '13'); + tableColmn.setAttribute('key', '4'); + tableColmn.setAttribute('align', 'flex-start'); + tableColmn.setAttribute('height', '32px'); + let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; + tableColmn1.setAttribute('title', '52'); + tableColmn1.setAttribute('data-index', '244'); + tableColmn1.setAttribute('key', '25'); + tableColmn1.setAttribute('align', 'flex-start'); + tableColmn1.setAttribute('height', '24px'); + + let tableColmn2 = document.createElement('lit-table-column') as LitTableColumn; + tableColmn2.setAttribute('title', '53'); + tableColmn2.setAttribute('data-index', '35'); + tableColmn2.setAttribute('key', '35'); + tableColmn2.setAttribute('align', 'flex-start'); + tableColmn2.setAttribute('height', '325px'); + litTable.columns = [tableColmn, tableColmn1, tableColmn2]; + let dataSource = [ + { + id: 22, + name: 'name', + }, + { + id: 12, + name: 'nameValue', + }, + ]; + expect(litTable.formatExportData(dataSource)).toBeTruthy(); + }); + + it('LitTablePageTest39', () => { + let element = document.createElement('div'); + litTable.tableElement = document.createElement('div'); + let firstElement = document.createElement('div'); + let ch = document.createElement('div'); + element.appendChild(ch); + let rowObject = { rowHidden: false, data: { isSearch: true } }; + let tableColmn = document.createElement('lit-table-column') as LitTableColumn; + tableColmn.setAttribute('height', '32px'); + tableColmn.setAttribute('title', '16'); + tableColmn.setAttribute('data-index', '1'); + tableColmn.setAttribute('align', 'flex-start'); + tableColmn.setAttribute('height', '36px'); + tableColmn.setAttribute('key', '1'); + let tableColmn1 = document.createElement('lit-table-column') as LitTableColumn; + tableColmn1.setAttribute('key', '2'); + tableColmn1.setAttribute('align', 'flex-start'); + tableColmn1.setAttribute('height', '32px'); + tableColmn1.setAttribute('title', '2'); + tableColmn1.setAttribute('data-index', '2'); + litTable.columns = [tableColmn, tableColmn1]; + expect(litTable.freshCurrentLine(element, rowObject, firstElement)).toBeUndefined(); + }); + it('LitTablePageTest40', () => { + litTable.hideDownload = true; + expect(litTable.hideDownload).toBeTruthy(); + }); + it('LitTablePageTest41', () => { + litTable.hideDownload = false; + expect(litTable.hideDownload).not.toBeUndefined(); + }); + it('LitTablePageTest42', () => { + expect(litTable.createBtn({ expanded: false, data: { status: true } })).not.toBeUndefined(); + }); + it('LitTablePageTest43', () => { + expect(litTable.mouseOut()).toBeUndefined(); + }); + it('LitTablePageTest44', () => { + expect(litTable.setCurrentHover({})).toBeUndefined(); + }); + it('LitTablePageTest45', () => { + expect(litTable.clearAllHover({})).toBeUndefined(); + }); +}); diff --git a/ide/test/base-ui/table/LitTable.test.ts b/ide/test/base-ui/table/LitTable.test.ts index 1d01e2c0bd966d8dcd72907ba3193d4177902ba4..07d963b26607e1e7442c45a9ba66a0bed33c9d8c 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,16 @@ describe('LitTable Test', () => { expect(litTable.expandList(dataSource)).toBeUndefined(); }); - it('LitTableTest24', () => { + it('LitTableTest18', () => { expect(litTable.clearAllSelection()).toBeUndefined(); }); - it('LitTableTest25', () => { - expect(litTable.dispatchRowClickEvent({ data: { isSelected: '' } }, [], {button: ''})).toBeUndefined(); + it('LitTableTest19', () => { + const mockEvent = new MouseEvent('click', { button: 0 }); + expect(() => litTable.dispatchRowClickEvent({ data: { isSelected: '' } }, [], mockEvent)).not.toThrow(); }); - it('LitTableTest26', () => { + it('LitTableTest20', () => { litTable.treeElement = jest.fn(() => undefined); litTable.treeElement.children = jest.fn(() => [1]); litTable.columns.forEach = jest.fn(() => true); @@ -312,25 +305,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 +332,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 +358,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 +419,7 @@ describe('LitTable Test', () => { expect(litTable.formatExportData(dataSource)).toBeTruthy(); }); - it('LitTableTest41', () => { + it('LitTableTest34', () => { let list = [ { memoryTap: 'All Heap', @@ -487,7 +476,7 @@ describe('LitTable Test', () => { expect(litTable.meauseTreeRowElement(list)).toBeTruthy(); }); - it('LitTableTest42', () => { + it('LitTableTest35', () => { let list = [ { memoryTap: 'All Heap', @@ -533,7 +522,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 +555,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 +578,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/hdc/hdcclient/HdcClient.test.ts b/ide/test/hdc/hdcclient/HdcClient.test.ts index e58b1ae0b5cc215fdc85f8a1e7cdcb78b0f088f7..b1cc5e74ad4b3906cdba3c66bc2bfd4a908dc37b 100644 --- a/ide/test/hdc/hdcclient/HdcClient.test.ts +++ b/ide/test/hdc/hdcclient/HdcClient.test.ts @@ -16,30 +16,25 @@ import { HdcClient } from '../../../src/hdc/hdcclient/HdcClient'; describe('HdcClient Test', () => { + let hdcClient = new HdcClient(); it('HdcClientTest01', function () { - let hdcClient = new HdcClient(); expect(hdcClient.bindStream()).toBeUndefined(); }); it('HdcClientTest02', function () { - let hdcClient = new HdcClient(); expect(hdcClient.unbindStream()).toBeTruthy(); }); it('HdcClientTest03', function () { - let hdcClient = new HdcClient(); expect(hdcClient.unbindStopStream()).toBeTruthy(); }); it('HdcClientTest04', async () => { - let hdcClient = new HdcClient(); await expect(hdcClient.connectDevice()).rejects.not.toBeUndefined(); }); it('HdcClientTest05', async () => { - let hdcClient = new HdcClient(); await expect(hdcClient.disconnect()).not; }); it('HdcClientTest06', function () { - let hdcClient = new HdcClient(); let data = { getChannelId: jest.fn(() => -1), }; diff --git a/ide/test/js-heap/utils/Utils.test.ts b/ide/test/js-heap/utils/Utils.test.ts index e233ae5fba1ab9563de1923d51c13c6e9aa0da29..a8eade7e59a87f862eebf018b0630b2697b2d527 100644 --- a/ide/test/js-heap/utils/Utils.test.ts +++ b/ide/test/js-heap/utils/Utils.test.ts @@ -13,8 +13,7 @@ * limitations under the License. */ -import { HeapNodeToConstructorItem } from "../../../src/js-heap/utils/Utils.js"; -import {HeapNode} from "../../../src/js-heap/model/DatabaseStruct.js"; +import { HeapNodeToConstructorItem } from '../../../src/js-heap/utils/Utils'; jest.mock('../../../src/js-heap/model/DatabaseStruct', () => {}); jest.mock('../../../src/js-heap/HeapDataInterface', () => { diff --git a/ide/test/statistics/util/SpStatisticsHttpUtil.test.ts b/ide/test/statistics/util/SpStatisticsHttpUtil.test.ts index 8ff1c6e913cfa24ab74cf42aa4298d2d5ee9863d..e743e6b2816b8ad82b8e14bd33981655a2b9a4d5 100644 --- a/ide/test/statistics/util/SpStatisticsHttpUtil.test.ts +++ b/ide/test/statistics/util/SpStatisticsHttpUtil.test.ts @@ -62,11 +62,11 @@ describe('SpStatisticsHttpUtil Test', () => { }); it('SpStatisticsHttpUtilTest01', () => { const serverInfo = SpStatisticsHttpUtil.getRequestServerInfo(); - expect(serverInfo).toBe('mocked_request_info'); + expect(serverInfo).toBe(''); }); it('SpStatisticsHttpUtilTest02', async () => { await SpStatisticsHttpUtil.getServerTime(); - expect(mockFetch).toHaveBeenCalledWith('https://mocked_request_info/serverTime'); + expect(mockFetch).toHaveBeenCalledWith('https:///serverTime'); expect(SpStatisticsHttpUtil.serverTime).toBe(0); }); it('SpStatisticsHttpUtilTest03', async () => { diff --git a/ide/test/trace/SpApplication.test.ts b/ide/test/trace/SpApplication.test.ts index 787224e308503664b67368ac50e8721d99d06f39..bc6dcd4b28bb93689eddb99128afd6ea378cde7b 100644 --- a/ide/test/trace/SpApplication.test.ts +++ b/ide/test/trace/SpApplication.test.ts @@ -18,121 +18,184 @@ SpStatisticsHttpUtil.initStatisticsServerConfig = jest.fn(() => true); SpStatisticsHttpUtil.addUserVisitAction = jest.fn(() => true); const intersectionObserverMock = () => ({ - observe: () => null, + observe: () => null, }); window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); import { SpApplication } from '../../src/trace/SpApplication'; +import { Theme } from '../../src/trace/component/trace/base/CustomThemeColor'; import { LongTraceDBUtils } from '../../src/trace/database/LongTraceDBUtils'; // @ts-ignore -window.ResizeObserver = window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('spApplication Test', () => { - LongTraceDBUtils.getInstance().indexedDBHelp = jest.fn(()=>{}) - LongTraceDBUtils.getInstance().indexedDBHelp.open = jest.fn(()=>{}) - LongTraceDBUtils.getInstance().createDBAndTable = jest.fn(()=>{ - return { - then: Function - } - }) - document.body.innerHTML = ''; - let spApplication = document.querySelector('#sss') as SpApplication; - it('spApplicationTest01', function () { - spApplication.dark = true; - expect(SpApplication.name).toEqual('SpApplication'); - }); - - it('spApplicationTest02', function () { - spApplication.dark = false; - expect(spApplication.dark).toBeFalsy(); - }); - - 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 () { - spApplication.server = false; - expect(spApplication.server).toBeFalsy(); - }); - - it('spApplicationTest07', function () { - spApplication.querySql = true; - expect(spApplication.querySql).toBeTruthy(); - }); - - it('spApplicationTest08', function () { - spApplication.querySql = false; - expect(spApplication.querySql).toBeFalsy(); - }); - - it('spApplicationTest09', function () { - spApplication.search = true; - expect(spApplication.search).toBeTruthy(); - }); - - it('spApplicationTest10', function () { - spApplication.search = false; - expect(spApplication.search).toBeFalsy(); - }); - - it('spApplicationTest11', function () { - expect(spApplication.removeSkinListener([])).toBeUndefined(); - }); - - it('spApplicationTest15', function () { - expect(spApplication.freshMenuDisable()).toBeUndefined(); - }); - - it('spApplicationTest16', function () { - expect(spApplication.addSkinListener()).toBeUndefined(); - }); - - it('spApplicationTest17', function () { - expect(spApplication.removeSkinListener()).toBeUndefined(); - }); - - it('spApplicationTest18', function () { - spApplication.dispatchEvent(new Event('dragleave')); - }); - - it('spApplicationTest19', 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 () { - spApplication.dark = false; - spApplication.skinChangeArray = ['value']; - expect(spApplication.dark).toBeFalsy(); - }); - - it('spApplicationTest29', function () { - spApplication.querySql = false; - expect(spApplication.querySql).toBeFalsy(); - }); + LongTraceDBUtils.getInstance().indexedDBHelp = jest.fn(() => {}); + LongTraceDBUtils.getInstance().indexedDBHelp.open = jest.fn(() => {}); + LongTraceDBUtils.getInstance().createDBAndTable = jest.fn(() => { + return { + then: Function, + }; + }); + document.body.innerHTML = ''; + let spApplication = document.querySelector('#sss') as SpApplication; + it('spApplicationTest01', function () { + spApplication.dark = true; + expect(SpApplication.name).toEqual('SpApplication'); + }); + + it('spApplicationTest02', function () { + spApplication.dark = false; + expect(spApplication.dark).toBeFalsy(); + }); + + it('spApplicationTest03', function () { + spApplication.server = true; + expect(spApplication.server).toBeTruthy(); + }); + + it('spApplicationTest04', function () { + spApplication.server = false; + expect(spApplication.server).toBeFalsy(); + }); + + it('spApplicationTest05', function () { + spApplication.querySql = true; + expect(spApplication.querySql).toBeTruthy(); + }); + + it('spApplicationTest06', function () { + spApplication.querySql = false; + expect(spApplication.querySql).toBeFalsy(); + }); + + it('spApplicationTest07', function () { + spApplication.search = true; + expect(spApplication.search).toBeTruthy(); + }); + + it('spApplicationTest08', function () { + spApplication.search = false; + expect(spApplication.search).toBeFalsy(); + }); + + it('spApplicationTest09', function () { + expect(spApplication.removeSkinListener([])).toBeUndefined(); + }); + + it('spApplicationTest10', function () { + expect(spApplication.freshMenuDisable(true)).toBeUndefined(); + }); + + it('spApplicationTest11', function () { + expect(spApplication.addSkinListener()).toBeUndefined(); + }); + + it('spApplicationTest12', function () { + expect(spApplication.removeSkinListener()).toBeUndefined(); + }); + + it('spApplicationTest13', function () { + spApplication.dispatchEvent(new Event('dragleave')); + }); + + it('spApplicationTest14', function () { + spApplication.dispatchEvent(new Event('drop')); + spApplication.removeSkinListener = jest.fn(() => undefined); + expect(spApplication.removeSkinListener({})).toBeUndefined(); + }); + + it('spApplicationTest15', function () { + spApplication.dark = false; + expect(spApplication.dark).toBeFalsy(); + }); + + it('spApplicationTest16', function () { + spApplication.querySql = false; + expect(spApplication.querySql).toBeFalsy(); + }); + + it('spApplicationTest17', function () { + expect(spApplication.initHtml()).not.toBeUndefined(); + }); + + it('spApplicationTest18', function () { + const mockFn = jest.fn(); + SpStatisticsHttpUtil.initStatisticsServerConfig = mockFn; + SpStatisticsHttpUtil.addUserVisitAction = mockFn; + LongTraceDBUtils.getInstance().createDBAndTable().then = mockFn; + expect(spApplication.initPlugin()).toBeUndefined(); + spApplication.initPlugin(); + expect(mockFn).toHaveBeenCalled(); + }); + + it('spApplicationTest19', function () { + expect(spApplication.initElements()).toBeUndefined(); + }); + + it('spApplicationTest20', function () { + expect(spApplication.getFileTypeAndPages('aa_gg', false, [100, 200, 300])).not.toBeUndefined(); + expect(spApplication.getFileTypeAndPages('aa_gg', true, [100, 200, 300])).not.toBeUndefined(); + }); + + it('spApplicationTest21', function () { + let str = 'aaa'; + let buffer = new ArrayBuffer(str.length * 2); + expect(spApplication.longTraceFileReadMessagePush(100, false, 1, 100, 20, 'i', buffer)).toBeUndefined(); + expect(spApplication.longTraceFileReadMessagePush(1, true, 1, 100, 20, 'i', buffer)).toBeUndefined(); + }); + + it('spApplicationTest22', function () { + spApplication.longTraceTypeMessageMap = null; + expect(spApplication.longTraceFileReadMessageHandler(2, 'sss')).toBeUndefined(); + }); + + it('spApplicationTest23', function () { + spApplication.longTraceTypeMessageMap!.set(2, [ + { + startIndex: 1, + endIndex: 2, + size: 5, + fileType: 's', + }, + ]); + expect(spApplication.longTraceFileReadMessageHandler(2, 'sss')).toBeUndefined(); + }); + + it('spApplicationTest24', function () { + spApplication.longTraceTypeMessageMap!.set(2, [ + { + startIndex: 1, + endIndex: 2, + size: 5, + fileType: 's', + }, + ]); + expect(spApplication.longTraceFileReadMessageHandler(1, 'sss')).toBeUndefined(); + }); + + it('spApplicationTest25', function () { + expect(spApplication.changeTheme(Theme.DARK)).toBeUndefined(); + }); + + it('spApplicationTest26', function () { + expect(spApplication.changeTheme(Theme.DARK, ['#00ff00'])).toBeUndefined(); + }); + + it('spApplicationTest27', function () { + expect(spApplication.changeTheme(Theme.LIGHT, ['#00ff00'])).toBeUndefined(); + }); + + it('spApplicationTest28', function () { + expect(spApplication.freshMenuDisable(true)).toBeUndefined(); + }); + + it('spApplicationTest29', function () { + spApplication.initElements(); + expect(spApplication.freshMenuDisable(false)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/bean/BoxSelection.test.ts b/ide/test/trace/bean/BoxSelection.test.ts index a8db62ac6e817060e9f7bfa9aa95b9e74110303d..53aa27efc11a9b55c7025ceb26c99307a923d8c8 100644 --- a/ide/test/trace/bean/BoxSelection.test.ts +++ b/ide/test/trace/bean/BoxSelection.test.ts @@ -14,15 +14,51 @@ */ import { SelectionParam, BoxJumpParam, SelectionData, Counter, Fps } from '../../../src/trace/bean/BoxSelection'; +import { TraceRow } from '../../../src/trace/component/trace/base/TraceRow'; +import { SpSystemTrace } from '../../../src/trace/component/SpSystemTrace'; +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/chart/FrameChart', () => { + return {}; +}); + +jest.mock('../../../src/trace/component/trace/sheet/task/TabPaneTaskFrames', () => { + return {}; +}); + +jest.mock('../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree', () => { + return {}; +}); + +jest.mock('../../../src/trace/component/trace/base/TraceSheet', () => { + return {}; +}); + +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +window.IntersectionObserver = jest.fn(); describe('BoxSelection Test', () => { + let sp = new SpSystemTrace(); + let itRow = new TraceRow(); let selectionParam = new SelectionParam(); - let boxJumpParam = new BoxJumpParam(); - let selectionData = new SelectionData(); - let counter = new Counter(); - let fps = new Fps(); - it('BoxSelectionTest01', function () { + it('BoxSelectionTest01', ()=> { + let selectionParam: SelectionParam; selectionParam = { + recordStartNs: 0, cpus: 1, threadIds: 2, trackIds: 1, @@ -33,20 +69,24 @@ describe('BoxSelection Test', () => { rightNs: 1, hasFps: true, statisticsSelectData: 1, + perfAll: true, }; - 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) }, ` + { + recordStartNs: expect.any(Number), + 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), + perfAll: expect.any(Boolean), + }, + ` { "cpus": Any, "funTids": Any, @@ -54,15 +94,19 @@ describe('BoxSelection Test', () => { "heapIds": Any, "leftNs": Any, "nativeMemory": Any, + "perfAll": Any, + "recordStartNs": Any, "rightNs": Any, "statisticsSelectData": 1, "threadIds": Any, "trackIds": Any, } -`); +` + ); }); it('BoxSelectionTest02', function () { + let boxJumpParam: BoxJumpParam; boxJumpParam = { leftNs: 0, rightNs: 0, @@ -72,12 +116,14 @@ 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, @@ -85,10 +131,12 @@ describe('BoxSelection Test', () => { "state": Any, "threadId": Any, } -`); +` + ); }); it('BoxSelectionTest03', function () { + let selectionData: SelectionData; selectionData = { name: 'name', process: 'process', @@ -112,25 +160,27 @@ 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, @@ -152,10 +202,12 @@ describe('BoxSelection Test', () => { "trackId": Any, "wallDuration": Any, } -`); +` + ); }); it('BoxSelectionTest04', function () { + let counter: Counter; counter = { id: 0, trackId: 0, @@ -165,12 +217,14 @@ 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, @@ -178,10 +232,12 @@ describe('BoxSelection Test', () => { "trackId": Any, "value": Any, } -`); +` + ); }); it('BoxSelectionTest05', function () { + let fps: Fps; fps = { startNS: 0, timeStr: '', @@ -189,15 +245,699 @@ 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, "timeStr": Any, } -`); +` + ); + }); + + it('BoxSelectionTest06', function () { + let it: TraceRow = { + intersectionRatio: 0, + isHover: true, + hoverX: 129, + hoverY: 113, + index: 0, + must: true, + isTransferCanvas: true, + isComplete: true, + dataList: [ + { + detail: '自绘制buffer轮转(视频/鼠标等)', + depth: 2, + name: 'ConsumeAndUpdateAllNodes', + parentName: 'unknown-1', + property: [ + { + name: 'ConsumeAndUpdateAllNodes', + detail: '自绘制buffer轮转(视频/鼠标等)', + end: 512062139514826, + begin: 512062139339305, + depth: 2, + instructions: 0, + cycles: 2, + frame: { + x: 0, + y: 40, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 289.8828125, + }, + ], + }, + ], + dataList2: [], + dataListCache: [ + { + name: 'OnReadable', + detail: 'OnVsync信号回调', + end: 512062163748680, + begin: 512062138606492, + depth: 0, + instructions: 132, + cycles: 471, + frame: { + x: 0, + y: 0, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 146.8896484375, + }, + { + name: 'OnReadable', + detail: 'OnVsync信号回调', + end: 512062233204930, + begin: 512062222968471, + depth: 0, + instructions: 144, + cycles: 281, + frame: { + x: 1, + y: 0, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 146.8896484375, + }, + ], + fixedList: [], + sliceCache: [-1, -1], + canvas: [], + dpr: 1, + offscreen: [], + canvasWidth: 0, + canvasHeight: 0, + isLoading: false, + tampName: '', + templateType: {}, + _rangeSelect: true, + _drawType: 0, + _enableCollapseChart: false, + online: false, + translateY: 0, + childrenList: [], + loadingFrame: false, + needRefresh: true, + funcMaxHeight: 0, + sleeping: true, + fragment: {}, + loadingPin1: 0, + loadingPin2: 0, + args: { + alpha: false, + canvasNumber: 0, + contextId: '', + isOffScreen: false, + skeleton: true, + }, + rootEL: {}, + checkBoxEL: { + args: null, + checkbox: {}, + }, + collectEL: { + args: null, + icon: {}, + use: {}, + d: null, + }, + describeEl: {}, + nameEL: {}, + canvasVessel: null, + tipEL: null, + sampleUploadEl: {}, + jsonFileEl: {}, + _frame: { + x: 0, + y: 0, + height: 140, + width: 422, + }, + rowType: 'sample', + }; + + TraceRow.rangeSelectObject = { + startX: 100, + endX: 1000, + startNS: 0, + endNS: 100000, + }; + expect(selectionParam.pushSampleData(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest07', function () { + itRow.rowType = 'cpu-data'; + itRow.rowId = '10'; + expect(selectionParam.pushCpus(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest08', function () { + itRow.rowType = 'cpu-state'; + itRow.rowId = '10'; + expect(selectionParam.pushCpuStateFilterIds(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest09', function () { + itRow.rowType = 'cpu-State'; + itRow.childrenList = []; + expect(selectionParam.pushCpuStateFilterIds(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest10', function () { + itRow.rowType = 'cpu-frequency'; + itRow.childrenList = []; + expect(selectionParam.pushCpuFreqFilter(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest11', function () { + itRow.rowType = 'cpu-freq'; + itRow.rowId = '10'; + itRow.name = 'aaa'; + itRow.childrenList = []; + expect(selectionParam.pushCpuFreqFilter(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest12', function () { + itRow.rowType = 'cpu-frequency-limit'; + itRow.rowId = '10'; + itRow.name = 'aaa'; + itRow.childrenList = []; + expect(selectionParam.pushCpuFreqLimit(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest13', function () { + itRow.setAttribute('cpu', '1'); + itRow.rowType = 'cpu-limit-freq'; + itRow.rowId = '10'; + itRow.childrenList = []; + expect(selectionParam.pushCpuFreqLimit(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest14', function () { + itRow.rowType = 'process'; + itRow.rowId = '99'; + itRow.setAttribute('hasStartup', 'true'); + itRow.setAttribute('hasStaticInit', 'false'); + itRow.expansion = false; + itRow.childrenList = []; + expect(selectionParam.pushProcess(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest15', function () { + itRow.rowType = 'native-memory'; + itRow.rowId = '11'; + itRow.expansion = false; + itRow.childrenList = []; + expect(selectionParam.pushNativeMemory(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest16', function () { + itRow.rowType = 'func'; + itRow.asyncFuncName = '11'; + itRow.expansion = false; + itRow.asyncFuncNamePID = 5; + itRow.rowId = '7'; + expect(selectionParam.pushNativeMemory(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest17', function () { + itRow.rowType = 'heap'; + itRow.rowParentId = '11 12 5'; + itRow.setAttribute('heap-type', 'native_hook_statistic'); + itRow.rowId = '7'; + expect(selectionParam.pushHeap(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest18', function () { + itRow.rowType = 'ability-monitor'; + itRow.rowId = '8'; + itRow.expansion = false; + itRow.childrenList = []; + expect(selectionParam.pushMonitor(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest19', function () { + itRow.rowType = 'hiperf-event'; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest20', function () { + itRow.rowType = 'hiperf-report'; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest21', function () { + itRow.rowType = 'hiperf-callchart'; + itRow.drawType = 7; + itRow.getRowSettingKeys = jest.fn(() => ['5']); + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest22', function () { + itRow.rowType = 'hiperf-process'; + itRow.rowId = '18'; + itRow.expansion = false; + itRow.childrenList = []; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest23', function () { + itRow.rowType = 'hiperf'; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest24', function () { + itRow.rowType = 'hiperf-cpu'; + itRow.index = 5; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest25', function () { + itRow.rowType = 'hiperf-thread'; + itRow.rowId = '5-7'; + expect(selectionParam.pushHiperf(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest26', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemLogicalWrite'; + selectionParam.fileSystemType = []; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.fileSystemType).toEqual([0, 1, 3]); + }); + + it('BoxSelectionTest26', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemLogicalWrite'; + selectionParam.fileSystemType = [1, 1, 1, -1]; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.fileSystemType).toEqual([1, 1, 1, -1, 3]); + }); + + it('BoxSelectionTest27', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemLogicalRead'; + selectionParam.fileSystemType = []; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.fileSystemType).toEqual([0, 1, 2]); + }); + + it('BoxSelectionTest28', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemLogicalRead'; + selectionParam.fileSystemType = [1, 1, -1]; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.fileSystemType).toEqual([1, 1, -1, 2]); + }); + + it('BoxSelectionTest29', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemVirtualMemory'; + selectionParam.fileSystemType = [1, 1, -1]; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.fileSysVirtualMemory).toBeTruthy(); + }); + + it('BoxSelectionTest30', function () { + itRow.rowType = 'file-system-cell'; + itRow.rowId = 'FileSystemDiskIOLatency'; + selectionParam.fileSystemType = [1, 1, -1]; + expect(selectionParam.pushFileSystem(itRow, sp)).toBeUndefined(); + selectionParam.pushFileSystem(itRow, sp); + expect(selectionParam.diskIOLatency).toBeTruthy(); + }); + + it('BoxSelectionTest31', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '55'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'dma-vmTracker'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest32', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '100'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'sys-memory-gpu'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest33', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '100'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'purgeable-total-vm'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest34', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '100'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'purgeable-pin-vm'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest35', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '110'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'smaps'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest36', function () { + itRow.rowType = 'VmTracker'; + itRow.rowId = '10'; + itRow.expansion = false; + let child = new TraceRow(); + child.rowType = 'VmTracker-shm'; + itRow.childrenList = [child]; + expect(selectionParam.pushVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest37', function () { + itRow.rowType = 'janks'; + itRow.rowId = '50'; + itRow.name == 'Actual Timeline'; + itRow.rowParentId === 'frameTime'; + itRow.dataListCache = []; + expect(selectionParam.pushJank(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest38', function () { + TraceRow.range = { + refresh: true, + xsTxt: ['a'], + startX: 100, + endX: 1000, + startNS: 0, + endNS: 100000, + slicesTime: { + color: 'red', + startTime: 1000, + endTime: 5000, + }, + scale: 5000, + totalNS: 10000, + xs: [100], + }; + itRow.rowType = 'heap-timeline'; + itRow.rowId = '50'; + itRow.name == 'Actual Timeline'; + itRow.rowParentId === 'frameTime'; + itRow.dataListCache = []; + expect(selectionParam.pushHeapTimeline(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest39', function () { + itRow.rowType = 'js-cpu-profiler-cell'; + itRow.rowId = '50'; + itRow.dataListCache = []; + expect(selectionParam.pushJsCpuProfiler(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest40', function () { + itRow.rowType = 'sys-memory-gpu'; + itRow.rowId = '40'; + itRow.childrenList = []; + expect(selectionParam.pushSysMemoryGpu(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest41', function () { + itRow.rowType = 'sdk'; + itRow.rowId = '45'; + itRow.childrenList = []; + expect(selectionParam.pushSDK(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest42', function () { + itRow.rowType = 'sdk-counter'; + itRow.rowId = '47'; + expect(selectionParam.pushSDK(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest43', function () { + itRow.rowType = 'sdk-slice'; + itRow.rowId = '98'; + expect(selectionParam.pushSDK(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest44', function () { + itRow.rowType = 'smaps'; + itRow.rowId = '98'; + expect(selectionParam.pushVmTrackerSmaps(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest45', function () { + itRow.rowType = 'irq-group'; + itRow.rowId = '98'; + itRow.childrenList = []; + expect(selectionParam.pushIrq(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest46', function () { + itRow.rowType = 'irq'; + itRow.rowId = '98'; + itRow.setAttribute('callId', '45'); + itRow.childrenList = []; + expect(selectionParam.pushIrq(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest47', function () { + itRow.rowType = 'sys-memory-gpu-gl'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushSysMemoryGpuGl(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest48', function () { + itRow.rowType = 'frame-dynamic'; + itRow.rowId = '98'; + itRow.dataListCache = []; + itRow.setAttribute('model-name', 'dd'); + expect(selectionParam.pushFrameDynamic(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest49', function () { + itRow.rowType = 'frame-spacing'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushFrameSpacing(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest50', function () { + itRow.rowType = 'frame-animation'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushFrameAnimation(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest51', function () { + itRow.rowType = 'sys-memory-gpu-window'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushSysMemoryGpuWindow(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest52', function () { + itRow.rowType = 'sys-memory-gpu-total'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushSysMemoryGpuTotal(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest53', function () { + itRow.rowType = 'sys-memory-gpu-graph'; + itRow.rowId = '98'; + itRow.dataListCache = []; + expect(selectionParam.pushSysMemoryGpuGraph(itRow)).toBeUndefined(); + }); + + it('BoxSelectionTest54', function () { + itRow.rowType = 'static-init'; + itRow.rowId = '98'; + expect(selectionParam.pushStaticInit(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest55', function () { + itRow.rowType = 'app-startup'; + itRow.rowId = '98'; + itRow.rowParentId = '55'; + expect(selectionParam.pushAppStartUp(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest56', function () { + itRow.rowType = 'thread'; + itRow.rowId = '98'; + expect(selectionParam.pushThread(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest57', function () { + itRow.rowType = 'mem'; + itRow.rowId = '98'; + expect(selectionParam.pushVirtualMemory(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest58', function () { + itRow.rowType = 'virtual-memory-cell'; + itRow.rowId = '98'; + expect(selectionParam.pushVirtualMemory(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest59', function () { + itRow.rowType = 'fps'; + itRow.rowId = '98'; + expect(selectionParam.pushFps(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest60', function () { + itRow.rowType = 'cpu-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushCpuAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest61', function () { + itRow.rowType = 'memory-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushMemoryAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest62', function () { + itRow.rowType = 'disk-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushDiskAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest63', function () { + itRow.rowType = 'network-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushNetworkAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest64', function () { + itRow.rowType = 'dma-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushDmaAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest65', function () { + itRow.rowType = 'gpu-memory-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushGpuMemoryAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest66', function () { + itRow.rowType = 'power-energy'; + itRow.rowId = '98'; + expect(selectionParam.pushPowerEnergy(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest67', function () { + itRow.rowType = 'system-energy'; + itRow.rowId = '98'; + expect(selectionParam.pushSystemEnergy(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest68', function () { + itRow.rowType = 'anomaly-energy'; + itRow.rowId = '98'; + expect(selectionParam.pushAnomalyEnergy(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest69', function () { + itRow.rowType = 'VmTracker-shm'; + itRow.rowId = '98'; + expect(selectionParam.pushVmTrackerShm(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest70', function () { + itRow.rowType = 'clock-group'; + itRow.rowId = '98'; + expect(selectionParam.pushClock(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest71', function () { + itRow.rowType = 'gpu-memory-vmTracker'; + itRow.rowId = '98'; + expect(selectionParam.pushGpuMemoryVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest72', function () { + itRow.rowType = 'dma-vmTracker'; + itRow.rowId = '98'; + expect(selectionParam.pushDmaVmTracker(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest73', function () { + itRow.rowType = 'purgeable-total-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushPugreable(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest74', function () { + itRow.rowType = 'purgeable-pin-ability'; + itRow.rowId = '98'; + expect(selectionParam.pushPugreablePinAbility(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest75', function () { + itRow.rowType = 'purgeable-total-vm'; + itRow.rowId = '98'; + expect(selectionParam.pushPugreableTotalVm(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest76', function () { + itRow.rowType = 'purgeable-pin-vm'; + itRow.rowId = '98'; + expect(selectionParam.pushPugreablePinVm(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest77', function () { + itRow.rowType = 'logs'; + itRow.rowId = '98'; + expect(selectionParam.pushLogs(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest78', function () { + itRow.rowType = 'hi-sysevent'; + itRow.rowId = '98'; + expect(selectionParam.pushHiSysEvent(itRow, sp)).toBeUndefined(); + }); + + it('BoxSelectionTest79', function () { + itRow.rowType = 'sample'; + itRow.rowId = '98'; + expect(selectionParam.pushSelection(itRow, sp)).toBeUndefined(); }); }); 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..b14140642786d52d8220ef52f87a4c86fda5f771 100644 --- a/ide/test/trace/component/SpRecordTrace.test.ts +++ b/ide/test/trace/component/SpRecordTrace.test.ts @@ -16,8 +16,9 @@ import { SpRecordTrace } from '../../../src/trace/component/SpRecordTrace'; import { EventCenter } from '../../../src/trace/component/trace/base/EventCenter'; import '../../../src/trace/SpApplication'; +import { LitButton } from '../../../src/base-ui/button/LitButton'; import { SpApplication } from '../../../src/trace/SpApplication'; -import { BaseElement } from '../../../src/base-ui/BaseElement'; +import { HdcDeviceManager } from '../../../src/hdc/HdcDeviceManager'; declare global { interface Window { SmartEvent: { @@ -72,7 +73,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 +85,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 +102,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 +129,206 @@ 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('SpRecordTraceTest21', function () { + spRecordTrace.record_template = 'record_template'; + expect(spRecordTrace.record_template).toBeTruthy(); }); - 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('SpRecordTraceTest22', function () { + spRecordTrace.initConfigPage(); + spRecordTrace.makeRequest(); + expect(spRecordTrace.spVmTracker).not.toBeUndefined(); }); - 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('SpRecordTraceTest23', function () { + let addButtonClick = new CustomEvent('click', { + detail: { + ...{}, + data: { + }, + } }); - }); - 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, + spRecordTrace.addButton.dispatchEvent(addButtonClick); + let deviceSelectMousedown = new CustomEvent('mousedown', { + detail: { + ...{}, + data: { + }, + } }); - }); - 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, + spRecordTrace.deviceSelect.dispatchEvent(deviceSelectMousedown); + let deviceSelectChange = new CustomEvent('change', { + detail: { + ...{}, + data: { + }, + } }); - }); - 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, + spRecordTrace.deviceSelect.dispatchEvent(deviceSelectChange); + let deviceVersionChange = new CustomEvent('change', { + detail: { + ...{}, + data: { + }, + } + }); + spRecordTrace.deviceVersion.dispatchEvent(deviceVersionChange); + let disconnectButtonClick = new CustomEvent('click', { + detail: { + ...{}, + data: { + }, + } }); + spRecordTrace.disconnectButton.dispatchEvent(disconnectButtonClick); + let cancelButtonClick = new CustomEvent('click', { + detail: { + ...{}, + data: { + }, + } + }); + spRecordTrace.cancelButton.dispatchEvent(cancelButtonClick); + let itemAddProbe = new CustomEvent('addProbe', { + detail: { + ...{}, + data: { + }, + } + }); + spRecordTrace.spRecordPerf.dispatchEvent(itemAddProbe); + spRecordTrace.spAllocations.dispatchEvent(itemAddProbe); + spRecordTrace.probesConfig.dispatchEvent(itemAddProbe); + spRecordTrace.spRecordTemplate.dispatchEvent(itemAddProbe); + + let spRecordTemplateDelProbe = new CustomEvent('delProbe', { + detail: { + ...{}, + data: { + }, + } + }); + SpRecordTrace.selectVersion = '4.0'; + SpApplication.isLongTrace = true; + spRecordTrace.spRecordTemplate.dispatchEvent(spRecordTemplateDelProbe); + spRecordTrace.record_template = false; + spRecordTrace.probesConfig = { + traceEvents: ['input'], + traceConfig: ['Scheduling details', 'CPU Frequency and idle states', 'High frequency memory', 'Advanced ftrace config', + 'Syscalls', 'Board voltages & frequency'], + recordAbility: true, + memoryConfig: ['Kernel meminfo', 'Virtual memory stats'] + } + spRecordTrace.spAllocations = { + appProcess: 'process', + startSamp: true, + startup_mode: true, + record_statistics: true, + response_lib_mode: true, + sample_interval: true, + recordJsStack: true, + expandPids: ['dsad', 'fgt', 'yu'] + } + spRecordTrace.spRecordPerf.getPerfConfig = jest.fn(()=> ['12,gtr', '15,frehtr', '24,init']); + spRecordTrace.spRecordPerf.startSamp = true; + spRecordTrace.spFileSystem.getSystemConfig = jest.fn(()=> ['12,gtr', '15,frehtr', '24,init']); + spRecordTrace.spFileSystem.startFileSystem = true; + spRecordTrace.spFileSystem.startVirtualMemory = true; + spRecordTrace.spFileSystem.startIo = true; + spRecordTrace.spSdkConfig.getPlugName = jest.fn(()=> 'cpu'); + spRecordTrace.spSdkConfig.startSamp = true; + spRecordTrace.spHiSysEvent.startSamp = true; + spRecordTrace.spArkTs = { + startSamp: true, + process: 'init' + } + spRecordTrace.spHiLog = { + recordHilog: 'init', + appProcess: 'init', + } + expect(spRecordTrace.makeRequest().pluginConfigs).not.toBeUndefined(); }); - it('SpRecordTraceTest37', function () { - spRecordTrace.record_template = 'record_template'; - expect(spRecordTrace.record_template).toBeTruthy(); + + it('SpRecordTraceTest24', function () { + let evData = { + detail: { + elementId: 'TaskPool' + }, + preventDefault: ()=>{} + }; + HdcDeviceManager.findDevice = jest.fn(() => { + return { + then: ()=>{} + } + }); + HdcDeviceManager.connect = jest.fn(() => { + return { + then: ()=>{} + } + }); + spRecordTrace.hintEl = document.createElement('span') as HTMLSpanElement; + spRecordTrace.devicePrompt = document.createElement('span') as HTMLSpanElement; + spRecordTrace.recordButton = document.createElement('lit-button') as LitButton; + + spRecordTrace.deviceSelect = document.createElement('select') as HTMLSelectElement; + let optionEl = document.createElement('option') as HTMLOptionElement; + spRecordTrace.deviceSelect.add(optionEl); + spRecordTrace.deviceSelect.selectedIndex = 0; + + spRecordTrace.deviceVersion = document.createElement('select') as HTMLSelectElement; + let versionOptionEl = document.createElement('option') as HTMLOptionElement; + spRecordTrace.deviceVersion.add(versionOptionEl); + spRecordTrace.deviceVersion.selectedIndex = 0; + spRecordTrace.sp = { + search: false + } + spRecordTrace.recordTempAddProbe(evData); + spRecordTrace.recordTempDelProbe(evData); + spRecordTrace.recordAddProbeEvent(); + spRecordTrace.addButtonClickEvent(evData); + spRecordTrace.deviceSelectMouseDownEvent(evData); + spRecordTrace.deviceSelectChangeEvent(); + spRecordTrace.deviceVersionChangeEvent(); + spRecordTrace.disconnectButtonClickEvent(); + spRecordTrace.recordButtonMouseDownEvent(evData); + spRecordTrace.cancelRecordListener(); }); }); diff --git a/ide/test/trace/component/SpSystemTrace.test.ts b/ide/test/trace/component/SpSystemTrace.test.ts index c010accca432701d1958e489ee44be2fbe41b190..28616fa188c28ccc809563bc51f2426e760af735 100644 --- a/ide/test/trace/component/SpSystemTrace.test.ts +++ b/ide/test/trace/component/SpSystemTrace.test.ts @@ -12,13 +12,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +jest.mock('../../../src/trace/component/trace/TimerShaftElement', () => { + return { + sportRuler: { + frame: { + contains: {} + } + }, + canvas: { + offsetLeft: 0 + }, + isScaling: true, + displayCollect: ()=>{}, + removeEventListener: ()=>{}, + drawTriangle: ()=>{}, + setSlicesMark: ()=>{}, + removeTriangle: ()=>{}, + }; +}); +jest.mock('../../../src/trace/component/trace/base/TraceSheet', () => { + return { + clearMemory: () => {} + }; +}); 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', () => { @@ -27,9 +51,6 @@ jest.mock('../../../src/js-heap/logic/HeapLoader', () => { jest.mock('../../../src/js-heap/model/DatabaseStruct', () => { return {}; }); -jest.mock('../../../src/trace/component/trace/base/TraceSheet', () => { - return {}; -}); jest.mock('../../../src/trace/database/SqlLite'); const intersectionObserverMock = () => ({ observe: () => null, @@ -46,14 +67,18 @@ window.ResizeObserver = })); describe('SpSystemTrace Test', () => { - let spSystemTrace = new SpSystemTrace(); + let spSystemTrace = new SpSystemTrace({ + canvasNumber: 1, + alpha: true, + contextId: '2d', + isOffScreen: true, + }); const offset = 1; const callback = true; const rowId = ''; const rowParentId = ''; const rowType = ''; let smooth = true; - spSystemTrace.initElements = jest.fn(() => true); it('SpSystemTraceTest01', function () { @@ -78,28 +103,20 @@ describe('SpSystemTrace Test', () => { }); it('SpSystemTraceTest06', function () { - spSystemTrace.timerShaftEL = jest.fn(() => null); - spSystemTrace.timerShaftEL.sportRuler = jest.fn(() => undefined); - spSystemTrace.timerShaftEL.sportRuler.frame = jest.fn(() => ''); - spSystemTrace.timerShaftEL.canvas = jest.fn(() => undefined); - spSystemTrace.timerShaftEL.canvas.offsetLeft = jest.fn(() => 1); - spSystemTrace.timerShaftEL.sportRuler.frame.contains = jest.fn(() => true); spSystemTrace.documentOnMouseUp = jest.fn(() => true); expect(spSystemTrace.documentOnMouseUp('MouseUp')).toBeTruthy(); }); it('SpSystemTraceTest07', function () { - spSystemTrace.timerShaftEL = jest.fn(() => undefined); - spSystemTrace.timerShaftEL.isScaling = jest.fn(() => true); expect(spSystemTrace.documentOnMouseMove('MouseMove')).toBeUndefined(); }); 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 () { @@ -107,7 +124,6 @@ describe('SpSystemTrace Test', () => { }); it('SpSystemTraceTest12', function () { - spSystemTrace.timerShaftEL.removeEventListener = jest.fn(() => true); expect(spSystemTrace.disconnectedCallback()).toBeUndefined(); }); @@ -120,59 +136,41 @@ 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 () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.onClickHandler()).toBeUndefined(); }); it('SpSystemTraceTest17', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.search()).toBeUndefined(); }); it('SpSystemTraceTest18', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.searchCPU()).not.toBeUndefined(); }); it('SpSystemTraceTest22', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); - procedurePool.clearCache = jest.fn(() => true); - spSystemTrace.traceSheetEL = jest.fn(() => true); - spSystemTrace.traceSheetEL.clearMemory = jest.fn(() => true); - spSystemTrace.traceSheetEL.setAttribute = jest.fn(() => true); - expect(spSystemTrace.reset()).toBeUndefined(); + // procedurePool.clearCache = jest.fn(() => true); + // 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(spSystemTrace); + spSystemTrace.timerShaftEL!.displayCollect = jest.fn(() => true); + spSystemTrace.timerShaftEL!.collecBtn = jest.fn(() => {}); + spSystemTrace.timerShaftEL!.reset = jest.fn(() => {}); + spSystemTrace.timerShaftEL!.collecBtn.removeAttribute = jest.fn(() => {}); + expect(spSystemTrace.reset(()=>{})).toBeUndefined(); }); it('SpSystemTraceTest23', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let structs = [ { length: 1, @@ -183,37 +181,20 @@ describe('SpSystemTrace Test', () => { let currentIndex = 1; TraceRow.range = jest.fn(() => undefined); TraceRow.range.startNS = jest.fn(() => 1); + spSystemTrace.timerShaftEL.drawTriangle = jest.fn(()=>{}); expect(spSystemTrace.showStruct(previous, currentIndex, structs)).not.toBeUndefined(); }); it('SpSystemTraceTest24', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); TraceRow.range = jest.fn(() => undefined); TraceRow.range.startNS = jest.fn(() => 1); expect(spSystemTrace.closeAllExpandRows()).toBeUndefined(); }); it('SpSystemTraceTest25', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); spSystemTrace.rowsPaneEL = jest.fn(() => true); spSystemTrace.rowsPaneEL.scroll = jest.fn(() => true); expect(spSystemTrace.scrollToProcess()).toBeUndefined(); }); it('SpSystemTraceTest26', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); spSystemTrace.rowsPaneEL = jest.fn(() => true); spSystemTrace.rowsPaneEL.scroll = jest.fn(() => true); let anomalyTraceRow = TraceRow.skeleton(); @@ -222,30 +203,12 @@ describe('SpSystemTrace Test', () => { expect(spSystemTrace.scrollToDepth()).toBeUndefined(); }); it('SpSystemTraceTest28', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.refreshFavoriteCanvas()).toBeUndefined(); }); it('SpSystemTraceTest29', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); - expect(spSystemTrace.expansionAllParentRow({ id: 1 })).toBeUndefined(); + expect(spSystemTrace.expansionAllParentRow({id: 1})).toBeUndefined(); }); it('SpSystemTraceTest30', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let it = { name: '', rowType: '', @@ -255,12 +218,6 @@ describe('SpSystemTrace Test', () => { expect(spSystemTrace.createPointEvent(it)).toBe(''); }); it('SpSystemTraceTest31', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let a = { rowEL: { translateY: 1, @@ -280,39 +237,19 @@ describe('SpSystemTrace Test', () => { expect(spSystemTrace.addPointPair(a, b)).toBeUndefined(); }); it('SpSystemTraceTest32', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); + spSystemTrace.timerShaftEL.setSlicesMark = jest.fn(()=>{}) expect(spSystemTrace.setSLiceMark()).toBeUndefined(); }); it('SpSystemTraceTest33', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); + spSystemTrace.rangeSelect = new RangeSelect(spSystemTrace); + // spSystemTrace.traceSheetEL.setMode = jest.fn(() => true); + spSystemTrace.timerShaftEL.removeTriangle = jest.fn(()=>{}) expect(spSystemTrace.clickEmptyArea()).toBeUndefined(); }); it('SpSystemTraceTest34', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.isWASDKeyPress()).toBeFalsy(); }); it('SpSystemTraceTest35', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let selectJankStruct = { frame_type: 'frameTime', type: '', @@ -336,34 +273,18 @@ describe('SpSystemTrace Test', () => { expect(spSystemTrace.drawJankLine(null, selectJankStruct, data)).toBeUndefined(); }); it('SpSystemTraceTest36', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let ev = { maxDuration: 1, timestamp: '', }; + spSystemTrace.rangeSelect = new RangeSelect(spSystemTrace); + spSystemTrace.traceSheetEL.setMode = jest.fn(() => true); expect(spSystemTrace.sliceMarkEventHandler(ev)).toBeUndefined(); }); it('SpSystemTraceTest37', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); expect(spSystemTrace.searchSdk([''], '')).toStrictEqual(['']); }); it('SpSystemTraceTest38', function () { - let spSystemTrace = new SpSystemTrace({ - canvasNumber: 1, - alpha: true, - contextId: '2d', - isOffScreen: true, - }); let funcStract = { tid: 1, pid: 0, diff --git a/ide/test/trace/component/chart/FrameChart.test.ts b/ide/test/trace/component/chart/FrameChart.test.ts index 18399b1efb90af5d8f9691320a09ac9928f7f4f3..fa6206d569255da76de70b5ccae157bde6b6a848 100644 --- a/ide/test/trace/component/chart/FrameChart.test.ts +++ b/ide/test/trace/component/chart/FrameChart.test.ts @@ -13,9 +13,8 @@ * limitations under the License. */ -import { FrameChart, Module } from '../../../../src/trace/component/chart/FrameChart'; -import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -import { ChartMode, ChartStruct } from '../../../../src/trace/bean/FrameChartStruct'; +import { FrameChart } from '../../../../src/trace/component/chart/FrameChart'; +import { ChartMode } from '../../../../src/trace/bean/FrameChartStruct'; jest.mock('../../../../src/trace/component/SpSystemTrace', () => { return {}; @@ -46,8 +45,6 @@ jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { describe('FrameChart Test', () => { let node = [{ children: '' }, { children: { length: 0 } }]; - let node1 = [{ children: '' }, { children: { length: 10 } }]; - let selectData = [(length = 1)]; document.body.innerHTML = ''; let frameChart = new FrameChart(); frameChart.data = [{ @@ -105,19 +102,17 @@ describe('FrameChart Test', () => { }); it('FrameChartTest07', function () { - expect(frameChart.updateCanvas()).toBeUndefined(); + expect(frameChart.updateCanvas(true, 23)).toBeUndefined(); }); it('FrameChartTest08', function () { frameChart.translationDraw = jest.fn(() => true); - frameChart.lastCanvasXInScale = 0; expect(frameChart.translationByScale()).toBe(undefined); }); it('FrameChartTest09', function () { frameChart.translationDraw = jest.fn(() => true); frameChart.canvasX = 4; - frameChart.lastCanvasXInScale = 1; expect(frameChart.translationByScale()).toBe(undefined); }); @@ -151,56 +146,27 @@ describe('FrameChart Test', () => { }); it('FrameChartTest16', function () { - frameChart.mode = false; - expect(frameChart.mode).toBeFalsy(); - }); - - it('FrameChartTest17', function () { - frameChart.caldrawArgs = jest.fn(() => true); - expect(frameChart.caldrawArgs()).toBeTruthy(); - }); - - it('FrameChartTest18', function () { expect(frameChart.data).toBeFalsy(); }); - it('FrameChartTest19', function () { + it('FrameChartTest18', function () { expect(frameChart.addChartClickListener(() => {})).toBeUndefined(); }); - it('FrameChartTest20', function () { + it('FrameChartTest19', function () { expect(frameChart.removeChartClickListener(() => {})).toBeUndefined(); }); - it('FrameChartTest21', function () { - frameChart._mode = 1; - frameChart.drawScale = jest.fn(() => true); - expect(frameChart.drawScale()).toBeTruthy(); - }); - - it('FrameChartTest22', function () { - frameChart._mode = 2; - frameChart.drawScale = jest.fn(() => true); - expect(frameChart.drawScale()).toBeTruthy(); - }); - - it('FrameChartTest23', function () { - frameChart._mode = 3; - frameChart.drawScale = jest.fn(() => true); - expect(frameChart.drawScale()).toBeTruthy(); - }); - - it('FrameChartTest24', function () { + it('FrameChartTest20', function () { expect(frameChart.resetTrans()).toBeUndefined(); }); - it('FrameChartTest25', function () { + it('FrameChartTest21', function () { expect(frameChart.onMouseClick({ button: 2 })).toBeUndefined(); }); - it('FrameChartTest26', function () { + it('FrameChartTest22', function () { frameChart._mode = ChartMode.Byte; - frameChart.drawScale = jest.fn(() => true); frameChart.currentData = [ { drawSize: 10, @@ -215,9 +181,8 @@ describe('FrameChart Test', () => { ]; expect(frameChart.calculateChartData()).not.toBeUndefined(); }); - it('FrameChartTest27', function () { + it('FrameChartTest23', function () { frameChart._mode = ChartMode.Count; - frameChart.drawScale = jest.fn(() => true); frameChart.currentData = [ { drawSize: 23, @@ -232,9 +197,8 @@ describe('FrameChart Test', () => { ]; expect(frameChart.calculateChartData()).not.toBeUndefined(); }); - it('FrameChartTest28', function () { + it('FrameChartTest24', function () { frameChart._mode = ChartMode.Duration; - frameChart.drawScale = jest.fn(() => true); frameChart.currentData = [ { drawSize: 78, @@ -249,7 +213,7 @@ describe('FrameChart Test', () => { ]; expect(frameChart.calculateChartData()).not.toBeUndefined(); }); - it('FrameChartTest29 ', function () { + it('FrameChartTest25 ', function () { let node = [ { parent: [ @@ -268,4 +232,57 @@ describe('FrameChart Test', () => { }] expect(frameChart.setParentDisplayInfo(node, module)).toBeUndefined(); }); + + it('FrameChartTest26 ', function () { + let module = [{ + drawCount: 0, + drawDur: 78, + drawSize: 9, + }]; + let nodeData = { + children: [{ + isChartSelect: false, + drawCount: 0, + drawEventCount: 0, + drawSize: 0, + drawDur: 0, + children: [] + },{ + isChartSelect: true, + drawCount: 0, + drawEventCount: 0, + drawSize: 0, + drawDur: 0, + children: [] + }] + } + frameChart.selectInit(); + frameChart.setRootValue(); + frameChart.clearOtherDisplayInfo(nodeData); + frameChart.setParentDisplayInfo(nodeData, module, true); + frameChart.setChildrenDisplayInfo(nodeData); + frameChart.searchDataByCoord([nodeData], 20, 10); + frameChart.showTip(); + frameChart.setSelectStatusRecursive(nodeData, true); + frameChart.clickRedraw(); + frameChart.scale(0); + frameChart.translationDraw(); + frameChart.nodeInCanvas(nodeData); + frameChart.nodeInCanvas({ + frame: { + x: 0, + y: 2, + width: 20, + height: 30 + } + }); + frameChart.onMouseClick({ + button: 0 + }); + frameChart.updateTipContent(); + frameChart.getCurrentPercent(nodeData, true); + frameChart.getCurrentPercentOfThread(nodeData); + frameChart.resizeChange(); + expect(frameChart.getCurrentPercentOfProcess(nodeData)).toBe(''); + }); }); diff --git a/ide/test/trace/component/chart/PerfDataQuery.test.ts b/ide/test/trace/component/chart/PerfDataQuery.test.ts index 16cbd288e110a062ff1db24eb43b440574e9c9f9..6e8c050b467c8a818c9db307b5a5f86a28cbe390 100644 --- a/ide/test/trace/component/chart/PerfDataQuery.test.ts +++ b/ide/test/trace/component/chart/PerfDataQuery.test.ts @@ -13,14 +13,40 @@ * limitations under the License. */ -import { perfDataQuery } from '../../../../src/trace/component/chart/PerfDataQuery'; - +import '../../../../src/trace/component/chart/SpHiPerf'; +import { SpHiPerf } from '../../../../src/trace/component/chart/SpHiPerf'; +import '../../../../src/trace/component/chart/PerfDataQuery'; +import { PerfDataQuery } from '../../../../src/trace/component/chart/PerfDataQuery'; +const perfSql = require('../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../src/trace/database/sql/Perf.sql'); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + 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', () => {}); jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { return {} }); describe('perfDataQuery Test', () => { + SpHiPerf.stringResult = { + existA: true, + existF: false, + fValue: 1, + }; + let perfFiles = perfSql.queryPerfFiles; + perfFiles.mockResolvedValue([]); + let perfDataQuery = new PerfDataQuery(); it('perfDataQueryTest01 ', function () { + perfDataQuery.initPerfCache(); + perfDataQuery.initPerfCallChainMap(); + perfDataQuery.getLibName('id', 0); + perfDataQuery.getLibName('id', -1); expect(perfDataQuery.initPerfFiles).not.toBeUndefined(); }); }); diff --git a/ide/test/trace/component/chart/SpAbilityMonitor.test.ts b/ide/test/trace/component/chart/SpAbilityMonitor.test.ts index 2f48fe51438eac8a32df8a50971f4496eb5e9833..6831811abd4416c09e1b0ffea85d0ad69b9a82a7 100644 --- a/ide/test/trace/component/chart/SpAbilityMonitor.test.ts +++ b/ide/test/trace/component/chart/SpAbilityMonitor.test.ts @@ -13,19 +13,27 @@ * limitations under the License. */ +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); 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 +74,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 +91,7 @@ describe('SpAbilityMonitorChart Test', () => { }, ]); - let netWorkDiskIo = sqlit.queryNetWorkMaxData; + let netWorkDiskIo = sqlite.queryNetWorkMaxData; netWorkDiskIo.mockResolvedValue([ { maxIn: 1, @@ -146,14 +153,10 @@ 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 htmlElement: any = document.createElement('sp-system-trace'); + let spAbilityMonitor = new SpAbilityMonitorChart(htmlElement); + 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..203e3ad770300eca1a2507237a6e7475c497f065 --- /dev/null +++ b/ide/test/trace/component/chart/SpAllAppStartups.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. + */ + +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); + +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 htmlElement: any = document.createElement('sp-system-trace'); + let appStartUpsChart = new SpAllAppStartupsChart(htmlElement); + 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).toBeUndefined(); + }); +}); diff --git a/ide/test/trace/component/chart/SpArkTsChart.test.ts b/ide/test/trace/component/chart/SpArkTsChart.test.ts index fde12c20bd8676607ef224154930de5f247d34c1..ec492b8ad3592b2fb84f3da53617ea09f729cf33 100644 --- a/ide/test/trace/component/chart/SpArkTsChart.test.ts +++ b/ide/test/trace/component/chart/SpArkTsChart.test.ts @@ -13,14 +13,30 @@ * limitations under the License. */ import { SpArkTsChart } from '../../../../src/trace/component/chart/SpArkTsChart'; -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/component/SpSystemTrace', () => { + return {}; +}); -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'); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('SpArkTsChart Test', () => { + let htmlElement: any = document.createElement('sp-system-trace'); + let arkTsChart = new SpArkTsChart(htmlElement); let jsCpuProfilerConfig = sqlite.queryJsCpuProfilerConfig; let cpuProfilerConfigData = [ { @@ -39,17 +55,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..57e21efa228c9a6edc4eeb28b61898bad8126b37 100644 --- a/ide/test/trace/component/chart/SpChartManager.test.ts +++ b/ide/test/trace/component/chart/SpChartManager.test.ts @@ -17,12 +17,14 @@ 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'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); -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 +34,8 @@ window.ResizeObserver = window.ResizeObserver || unobserve: jest.fn(), })); describe('SpChartManager Test', () => { - let chartManager = new SpChartManager(); + let htmlElement: any = document.createElement('sp-system-trace'); + let chartManager = new SpChartManager(htmlElement); 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..a4949af6219ce88c97aa274fd83b5046cad5a9a3 100644 --- a/ide/test/trace/component/chart/SpClockChart.test.ts +++ b/ide/test/trace/component/chart/SpClockChart.test.ts @@ -13,12 +13,24 @@ * limitations under the License. */ -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpClockChart } from '../../../../src/trace/component/chart/SpClockChart'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); -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'); +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); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -28,7 +40,8 @@ window.ResizeObserver = })); describe('SpClockChart Test', () => { - let clockChart = new SpClockChart(new SpChartManager()); + let htmlElement: any = document.createElement('sp-system-trace'); + let clockChart = new SpClockChart(htmlElement); let queryClock = sqlite.queryClockData; let queryClockData = [ diff --git a/ide/test/trace/component/chart/SpCpuChart.test.ts b/ide/test/trace/component/chart/SpCpuChart.test.ts index 0a834e692719a4449a8136aee6acf3ea107cee37..8b56ebb448431e3b8f080eafbab04f6b48b69739 100644 --- a/ide/test/trace/component/chart/SpCpuChart.test.ts +++ b/ide/test/trace/component/chart/SpCpuChart.test.ts @@ -13,13 +13,19 @@ * limitations under the License. */ -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; import { SpCpuChart } from '../../../../src/trace/component/chart/SpCpuChart'; import { HeapNode } from '../../../../src/js-heap/model/DatabaseStruct'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); -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'); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -30,12 +36,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([]); @@ -46,8 +53,8 @@ describe('SpCpuChart Test', () => { cpu: 3, }, ]); - let ss = new SpChartManager(); - let trace = new SpCpuChart(ss); + let htmlElement: any = document.createElement('sp-system-trace'); + let trace = new SpCpuChart(htmlElement); it('SpMpsChart01', async function () { await trace.init(); expect(trace).toBeDefined(); diff --git a/ide/test/trace/component/chart/SpEBPFChart.test.ts b/ide/test/trace/component/chart/SpEBPFChart.test.ts index a2f6ef95b24bbd08ebf07c6c4fb70bc492497e7f..d74b9d928037425f4c7c39e6064d66e5e57d55a5 100644 --- a/ide/test/trace/component/chart/SpEBPFChart.test.ts +++ b/ide/test/trace/component/chart/SpEBPFChart.test.ts @@ -14,14 +14,26 @@ */ 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'); +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 {}; }); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; -jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +import { EBPFChartStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEBPF'; +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -39,16 +51,23 @@ describe('SpFileSystemChart Test', () => { ioCount: 2, }, ]); - - let ss = new SpChartManager(); - let spEBPFChart = new SpEBPFChart(ss); + let getDiskIOProcess = sqlite.getDiskIOProcess; + getDiskIOProcess.mockResolvedValue([ + { + name: 'kworker/u8:4', + ipid: 2, + pid: 186, + } + ]); + let htmlElement: any = document.createElement('sp-system-trace'); + let spEBPFChart = new SpEBPFChart(htmlElement); spEBPFChart.initFileCallchain = jest.fn(() => true); it('SpMpsChart01', function () { spEBPFChart.init(); expect(spEBPFChart).toBeDefined(); }); it('SpMpsChart02', function () { - ss.displayTip = jest.fn(() => true); - expect(spEBPFChart.focusHandler(TraceRow)).toBeUndefined(); + spEBPFChart.trace.displayTip = jest.fn(); + expect(spEBPFChart.focusHandler(new TraceRow())).toBeUndefined(); }); }); diff --git a/ide/test/trace/component/chart/SpFpsChart.test.ts b/ide/test/trace/component/chart/SpFpsChart.test.ts index 28f27b29fac15a3a736599d4cba6ddea20e60fa6..83ca85c83282c23d240a78e054b8b5dbcc21fd66 100644 --- a/ide/test/trace/component/chart/SpFpsChart.test.ts +++ b/ide/test/trace/component/chart/SpFpsChart.test.ts @@ -14,14 +14,22 @@ */ 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'); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +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 {}; }); - +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -30,7 +38,8 @@ window.ResizeObserver = unobserve: jest.fn(), })); describe('spFpsChart Test', () => { - let spFpsChart = new SpFpsChart(new SpChartManager()); + let htmlElement: any = document.createElement('sp-system-trace'); + let spFpsChart = new SpFpsChart(htmlElement); let fpsMock = sqlit.getFps; fpsMock.mockResolvedValue([ { startNS: 0, fps: 1 }, diff --git a/ide/test/trace/component/chart/SpFrameTimeChart.test.ts b/ide/test/trace/component/chart/SpFrameTimeChart.test.ts index 74d9b3b6880f71e943c001dd1d76b37045c40af2..bf2b95d2eecee97227069bdbaf3525985913dfe8 100644 --- a/ide/test/trace/component/chart/SpFrameTimeChart.test.ts +++ b/ide/test/trace/component/chart/SpFrameTimeChart.test.ts @@ -14,22 +14,29 @@ */ import { SpFrameTimeChart } from '../../../../src/trace/component/chart/SpFrameTimeChart'; -import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); 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,10 +46,8 @@ window.ResizeObserver = })); describe('SpFrameTimeChart Test', () => { - let trace = new SpSystemTrace(); - let manager = new SpChartManager(trace); - let spFrameTimeChart = new SpFrameTimeChart(manager); - + let htmlElement: any = document.createElement('sp-system-trace'); + let spFrameTimeChart = new SpFrameTimeChart(htmlElement); let queryFrameTime = sqlite.queryFrameTimeData; let queryFrameTimeData = [ { @@ -51,7 +56,7 @@ describe('SpFrameTimeChart Test', () => { ]; queryFrameTime.mockResolvedValue(queryFrameTimeData); - let queryExpectedFrame = sqlite.queryExpectedFrameDate; + let queryExpectedFrame = jankSqlite.queryExpectedFrameDate; let queryExpectedFrameDate = [ { dur: 2585, @@ -64,7 +69,7 @@ describe('SpFrameTimeChart Test', () => { ]; queryExpectedFrame.mockResolvedValue(queryExpectedFrameDate); - let queryActualFrame = sqlite.queryActualFrameDate; + let queryActualFrame = jankSqlite.queryActualFrameDate; let queryActualFrameDate = [ { dur: 6878, @@ -93,7 +98,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 +108,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 +122,7 @@ describe('SpFrameTimeChart Test', () => { let data = [ { id: 12, - appName: "name" + appName: 'name' } ]; dynamicIdAndName.mockResolvedValue(data); @@ -125,7 +130,7 @@ describe('SpFrameTimeChart Test', () => { let animationTimeRange = sqlite.queryAnimationTimeRangeData; let rangeData = [ { - status: "Response delay", + status: 'Response delay', startTs: 225, endTs: 6355 } @@ -137,15 +142,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 +196,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..1043e2eb1e7ca9cbc33194832195cddec41da32a 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. @@ -13,21 +13,26 @@ * limitations under the License. */ -import { queryCpuCount } from '../../../../src/trace/database/SqlLite'; - -window.ResizeObserver = window.ResizeObserver || - jest.fn().mockImplementation(() => ({ - disconnect: jest.fn(), - observe: jest.fn(), - unobserve: jest.fn(), - })); -import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; + jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; + }); 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'); + const intersectionObserverMock = () => ({ + observe: () => null, + }); + window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); + window.ResizeObserver = window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); describe('spFpsChart Test', () => { - let spFpsChart = new SpFreqChart(new SpChartManager()); + let htmlElement: any = document.createElement('sp-system-trace'); + let spFpsChart = new SpFreqChart(htmlElement); let mockGetCpuLimitFreq = sqlit.getCpuLimitFreq; mockGetCpuLimitFreq.mockResolvedValue([ diff --git a/ide/test/trace/component/chart/SpHiPerf.test.ts b/ide/test/trace/component/chart/SpHiPerf.test.ts index e40a0579e45e3b7087c7280ec2967d141f0a29d9..981ead7cc6f55392bf0d6eccb93720fdee6f9597 100644 --- a/ide/test/trace/component/chart/SpHiPerf.test.ts +++ b/ide/test/trace/component/chart/SpHiPerf.test.ts @@ -14,18 +14,23 @@ */ 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'); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; +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 {}; }); +jest.mock('../../../../src/trace/component/chart/PerfDataQuery',()=>{ + return {} +}) +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || @@ -36,6 +41,7 @@ window.ResizeObserver = })); describe('SpHiPerf Test', () => { + let perfDataQuery = sqlit.perfDataQuery let queryPerfCmdline = sqlit.queryPerfCmdline; queryPerfCmdline.mockResolvedValue([ { @@ -47,10 +53,10 @@ describe('SpHiPerf Test', () => { let queryPerfThread = sqlit.queryPerfThread; queryPerfThread.mockResolvedValue([ { - tid: 2, - threadName: 'threadName', - pid: 2, - processName: 'processName', + tid: 11, + threadName: "ksoftirqd/0", + pid: 11, + processName: "ksoftirqd/0" }, { tid: 1, @@ -128,14 +134,26 @@ describe('SpHiPerf Test', () => { id:1, report_value:'sched:sched_waking', }]) - let ss = new SpChartManager(); - let spHiPerf = new SpHiPerf(ss); + let htmlElement: any = document.createElement('sp-system-trace'); + let spHiPerf = new SpHiPerf(htmlElement); it('SpHiPerf01', function () { spHiPerf.init(); expect(spHiPerf).toBeDefined(); }); it('SpHiPerf02', function () { - ss.displayTip = jest.fn(()=>true); - expect(spHiPerf.hoverTip()).toBeUndefined(); + let cpuData = [ + { + cpu_id: 0 + } + ] + let threadData = [ + { + tid: 11, + threadName: "ksoftirqd/0", + pid: 11, + processName: "ksoftirqd/0" + } + ] + expect(spHiPerf.setCallTotalRow(new TraceRow(),cpuData,threadData)).not.toBeUndefined() }); }); diff --git a/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts b/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts index 4ae12593df6046b3cfd3f281ba70c7205a160894..73290200d98b88a15cd8ab5eb0ba8c7461ef4b14 100644 --- a/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts +++ b/ide/test/trace/component/chart/SpHiSysEnergyChart.test.ts @@ -13,17 +13,24 @@ * 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/trace/component/SpSystemTrace', () => { + return {}; +}); +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 {}; }); - +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -32,12 +39,13 @@ 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); + let htmlElement: any = document.createElement('sp-system-trace'); + let spHiSysEnergyChart = new SpHiSysEnergyChart(htmlElement); let htmlDivElement = document.createElement('div'); htmlDivElement.setAttribute('id', 'appNameList'); @@ -57,9 +65,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 +103,7 @@ describe('SpHiSysEnergyChart Test', () => { ]; sysEventAppName.mockResolvedValue(appName); + let querySystemLocationData = sqlite.querySystemLocationData; let querySystemLockData = sqlite.querySystemLockData; let querySystemSchedulerData = sqlite.querySystemSchedulerData; @@ -190,18 +207,14 @@ 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()); - }); - - it('SpHiSysEnergyChartTest6', function () { - expect(spHiSysEnergyChart.initHtml).toMatchInlineSnapshot(`undefined`); + expect(spHiSysEnergyChart.getPowerData([])).toBeTruthy(); }); - it('SpHiSysEnergyChartTest7', function () { + it('SpHiSysEnergyChartTest06', function () { expect(htmlDivElement.onclick).toBe(null); }); }); diff --git a/ide/test/trace/component/chart/SpHiSysEventChart.test.ts b/ide/test/trace/component/chart/SpHiSysEventChart.test.ts index ab3091981eb22a70c86197cf81cb6b4c1a79dde2..d9292ac9b7059bfaf07d927d59e0a233f3b1c832 100644 --- a/ide/test/trace/component/chart/SpHiSysEventChart.test.ts +++ b/ide/test/trace/component/chart/SpHiSysEventChart.test.ts @@ -14,35 +14,58 @@ */ 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'); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + 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'); +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); +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 hiSysEventList = sqlite.queryHiSysEventData; - let hiSysEventListData = [{ - id: 1, - domain:'STARTUP', - eventName: 'PROCESS_EXIT', - eventType: '4', - ts: 1, - tz: 'dad', - pid: 1, - tid: 1, - uid: 1, - info: '', - level: 'MINOR', - seq: '92860', - contents: 'APP_PID', - dur: 1, - depth: 1, - }] - hiSysEventList.mockResolvedValue(hiSysEventListData); - it('SpHiSysEventChart01', function () { + let spHiSysEvent; + let hiSysEventList; + let hiSysEventListData; + beforeEach(() => { + let htmlElement: any = document.createElement('sp-system-trace'); + spHiSysEvent = new SpHiSysEventChart(htmlElement); + hiSysEventList = jest.spyOn(sqlite, 'queryHiSysEventData'); + hiSysEventListData = [{ + id: 1, + domain: 'STARTUP', + eventName: 'PROCESS_EXIT', + eventType: '4', + ts: 1, + tz: 'dad', + pid: 1, + tid: 1, + uid: 1, + info: '', + level: 'MINOR', + seq: '92860', + contents: 'APP_PID', + dur: 1, + depth: 1, + }]; + hiSysEventList.mockResolvedValue(hiSysEventListData); + }); + it('SpHiSysEventChartTest01', 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..467119f4633b196c33f711deff4b4d42018f8955 100644 --- a/ide/test/trace/component/chart/SpIrqChart.test.ts +++ b/ide/test/trace/component/chart/SpIrqChart.test.ts @@ -13,10 +13,13 @@ * limitations under the License. */ -import { SpSystemTrace } from "../../../../src/trace/component/SpSystemTrace"; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); -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 || @@ -25,17 +28,16 @@ window.ResizeObserver = observe: jest.fn(), unobserve: jest.fn(), })); -window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); const intersectionObserverMock = () => ({ observe: () => null, }); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); -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 trace: any = document.createElement('sp-system-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..189b6dd09b6097e68ed2eff1e03c050eb51196d8 100644 --- a/ide/test/trace/component/chart/SpJsMemoryChart.test.ts +++ b/ide/test/trace/component/chart/SpJsMemoryChart.test.ts @@ -13,9 +13,12 @@ * limitations under the License. */ -const sqlite = require('../../../../src/trace/database/SqlLite'); -jest.mock('../../../../src/trace/database/SqlLite'); - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +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,14 +29,14 @@ 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 {}; }); describe('SpIrqChart Test', () => { - let spArkTsChart = new SpArkTsChart(); + let htmlElement: any = document.createElement('sp-system-trace'); + let spArkTsChart = new SpArkTsChart(htmlElement); let irqList = sqlite.queryIrqList; let irqListData = [ { diff --git a/ide/test/trace/component/chart/SpLogChart.test.ts b/ide/test/trace/component/chart/SpLogChart.test.ts index 3bfb61f0e7b50085e014a3a0558c8be3920070ec..0f8e7a1ea0c10b350ebd35b4db82da2a105d10aa 100644 --- a/ide/test/trace/component/chart/SpLogChart.test.ts +++ b/ide/test/trace/component/chart/SpLogChart.test.ts @@ -13,11 +13,15 @@ * limitations under the License. */ +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); 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 || @@ -28,7 +32,8 @@ window.ResizeObserver = })); describe('SpLogChart Test', () => { - let logChart = new SpLogChart(new SpChartManager()); + let htmlElement: any = document.createElement('sp-system-trace'); + let logChart = new SpLogChart(new SpChartManager(htmlElement)); let queryLog = sqlite.queryLogData; let queryLogData = [ { 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..2a7062c21f7ed334a8524fa77800efa22fc40c47 --- /dev/null +++ b/ide/test/trace/component/chart/SpLtpoChart.test.ts @@ -0,0 +1,139 @@ +/* + * 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. + */ + +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +import { SpLtpoChart } from '../../../../src/trace/component/chart/SpLTPO'; + +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 htmlElement: any = document.createElement('sp-system-trace'); + let ltPoChart = new SpLtpoChart(htmlElement); + 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,ra:te' + } + ]); + + 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' + } + ]); + let rSNowTimeListInfo = sqlit.queryRSNowTimeList; + rSNowTimeListInfo.mockResolvedValue([ + { + ts: 124, + dur: 445, + name: 'Present Fence ffdf' + } + ]); + let signaledListInfo = sqlit.querySignaledList; + signaledListInfo.mockResolvedValue([ + { + ts: 124, + dur: 445, + name: 'Present Fence ffdf' + } + ]); + let skipDataListInfo = sqlit.querySkipDataList; + skipDataListInfo.mockResolvedValue([ + { + ts: 124, + dur: 445, + name: 'Present Fence ffdf' + } + ]); + 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([]); + }); +}); diff --git a/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts b/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts index 01be3a6e16de62d17aeaa312c39b006299f7524f..edf1d9d1181e6651c79f193bfdfe76ca4e0a1aed 100644 --- a/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts +++ b/ide/test/trace/component/chart/SpNativeMemoryChart.test.ts @@ -13,15 +13,25 @@ * limitations under the License. */ -import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); 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'); -window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); + +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'); const intersectionObserverMock = () => ({ observe: () => null, }); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); + // @ts-ignore window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -30,8 +40,8 @@ window.ResizeObserver = window.ResizeObserver || observe: jest.fn(), })); describe('SpNativeMemoryChart Test', () => { - let chartManager = new SpSystemTrace(); - let spNativeMemoryChart = new SpNativeMemoryChart(chartManager); + let htmlElement: any = document.createElement('sp-system-trace'); + let spNativeMemoryChart = new SpNativeMemoryChart(htmlElement); let queryNativeHookStatisticsCount = sqlit.queryNativeHookStatisticsCount; queryNativeHookStatisticsCount.mockResolvedValue([ @@ -40,7 +50,7 @@ describe('SpNativeMemoryChart Test', () => { }, ]); - let queryNativeMemoryRealTime = sqlit.queryNativeMemoryRealTime; + let queryNativeMemoryRealTime = memSqlite.queryNativeMemoryRealTime; queryNativeMemoryRealTime.mockResolvedValue([ { ts: 1502013097360370200, @@ -48,7 +58,7 @@ describe('SpNativeMemoryChart Test', () => { }, ]); - let queryBootTime = sqlit.queryBootTime; + let queryBootTime = clockSqlite.queryBootTime; queryBootTime.mockResolvedValue([ { ts: -557295431, @@ -65,7 +75,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..36a8f0820b9bbd276267680a960f417b8bf42f57 100644 --- a/ide/test/trace/component/chart/SpProcessChart.test.ts +++ b/ide/test/trace/component/chart/SpProcessChart.test.ts @@ -12,11 +12,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); 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 +38,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(), @@ -34,8 +46,8 @@ window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() })); describe('SpProcessChart Test', () => { - let manager = new SpSystemTrace(); - let spProcessChart = new SpProcessChart(manager); + let htmlElement: any = document.createElement('sp-system-trace'); + let spProcessChart = new SpProcessChart(htmlElement); let MockqueryProcessAsyncFunc = sqlit.queryProcessAsyncFunc; MockqueryProcessAsyncFunc.mockResolvedValue([ @@ -54,7 +66,7 @@ describe('SpProcessChart Test', () => { argsetid: 6, }, ]); - let processContentCount = sqlit.queryProcessContentCount; + let processContentCount = processSqlite.queryProcessContentCount; processContentCount.mockResolvedValue([ { pid: 1, @@ -64,9 +76,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 +87,7 @@ describe('SpProcessChart Test', () => { threadName: 'thread', }, ]); - let queryProcessMem = sqlit.queryProcessMem; + let queryProcessMem = processSqlite.queryProcessMem; queryProcessMem.mockResolvedValue([ { trackId: 1, @@ -85,14 +97,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 +112,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryProcessByTable = sqlit.queryProcessByTable; + let queryProcessByTable = processSqlite.queryProcessByTable; queryProcessByTable.mockResolvedValue([ { pid: 2, @@ -119,14 +131,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 +160,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryAllActualData = sqlit.queryAllActualData; + let queryAllActualData = jankSqlite.queryAllActualData; queryAllActualData.mockResolvedValue([ { id: 40, @@ -178,7 +190,7 @@ describe('SpProcessChart Test', () => { }, ]); - let queryProcessStartup = sqlit.queryProcessStartup; + let queryProcessStartup = processSqlite.queryProcessStartup; queryProcessStartup.mockResolvedValue([ { 'pid': 3913, @@ -284,7 +296,7 @@ describe('SpProcessChart Test', () => { } ]); - let queryProcessSoInitData = sqlit.queryProcessSoInitData; + let queryProcessSoInitData = processSqlite.queryProcessSoInitData; queryProcessSoInitData.mockResolvedValue([ { 'pid': 3913, @@ -497,7 +509,7 @@ describe('SpProcessChart Test', () => { } } ]); - let processData = sqlit.queryProcessData; + let processData = processSqlite.queryProcessData; processData.mockResolvedValue([ { cpu: 0, dur: 199000, startTime: 259730000 @@ -506,24 +518,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 +550,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 +605,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/SpSampleChart.test.ts b/ide/test/trace/component/chart/SpSampleChart.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b2d7f3e1b2ca755879957af2f48c12ff87f6b12 --- /dev/null +++ b/ide/test/trace/component/chart/SpSampleChart.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 { SpBpftraceChart } from '../../../../src/trace/component/chart/SpBpftraceChart'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); + +const sqlite = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); +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); +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); +describe('SpArkTsChart Test', () => { + let htmlElement: any = document.createElement('sp-system-trace'); + let spSampleChart = new SpBpftraceChart(htmlElement); + let startTime = sqlite.queryStartTime; + let startTimeData = [ + {startTs: 102132121} + ]; + startTime.mockResolvedValue(startTimeData); + it('SpSampleChartTest01', function () { + expect(spSampleChart.init).toBeTruthy(); + }); + it('SpSampleChartTest02 ', function () { + expect(spSampleChart.initSample(startTimeData[0].startTs, false)).toBeTruthy(); + }); +}); diff --git a/ide/test/trace/component/chart/SpSdkChart.test.ts b/ide/test/trace/component/chart/SpSdkChart.test.ts index 3fa5c0e8faa1b6cfd2b43d74815ad25ad9f7f150..f9d43f70bd9e19f7af842335a33a4cc6afee0025 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'); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); 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/SpSegmentationChart.test.ts b/ide/test/trace/component/chart/SpSegmentationChart.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..302fb589f818975139bd5945198be99dadc4715b --- /dev/null +++ b/ide/test/trace/component/chart/SpSegmentationChart.test.ts @@ -0,0 +1,44 @@ +/* + * 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/chart/SpSegmentationChart'; +import { SpSegmentationChart } from '../../../../src/trace/component/chart/SpSegmentationChart'; +import { SpSystemTrace } from '../../../../src/trace/component/SpSystemTrace'; + +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 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(), + })); +describe('SpSegmentationChart Test', () => { + let spSystemTrace = new SpSystemTrace(); + let segmentationChart = new SpSegmentationChart(spSystemTrace); + it('SpSegmentationChartTest01 ', function () { + segmentationChart.init(); + }); +}); diff --git a/ide/test/trace/component/chart/SpVirtualMemChart.test.ts b/ide/test/trace/component/chart/SpVirtualMemChart.test.ts index 4a51934426fc1123d6d008e80d00ea65967bf1e3..fa4a3c7be9d6ba854167ecb371d3f43ae34024d7 100644 --- a/ide/test/trace/component/chart/SpVirtualMemChart.test.ts +++ b/ide/test/trace/component/chart/SpVirtualMemChart.test.ts @@ -12,30 +12,34 @@ * 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 { 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'; -jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { +import { SpVirtualMemChart } from '../../../../src/trace/component/chart/SpVirtualMemChart'; +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { return {}; }); -window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); -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, }); - +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); +// @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 {}; +}); +jest.mock('../../../../src/js-heap/model/DatabaseStruct'); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +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 htmlElement: any = document.createElement('sp-system-trace'); + let spVirtualMemChart = new SpVirtualMemChart(htmlElement); + let MockVirtualMemory = memorySqlite.queryVirtualMemory; MockVirtualMemory.mockResolvedValue([ { id: 0, @@ -43,7 +47,7 @@ describe('SpVirtualMemChart Test', () => { }, ]); - let MockVirtualMemoryData = sqlit.queryVirtualMemoryData; + let MockVirtualMemoryData = memorySqlite.queryVirtualMemoryData; MockVirtualMemoryData.mockResolvedValue([ { startTime: 0, @@ -62,9 +66,9 @@ describe('SpVirtualMemChart Test', () => { canvasNumber: 1, alpha: false, contextId: '2d', - isOffScreen: SpSystemTrace.isCanvasOffScreen, + isOffScreen: htmlElement.isCanvasOffScreen, }); - spVirtualMemChart.initVirtualMemoryRow(folder, 2, 'name', 2); + spVirtualMemChart.initVirtualMemoryRow(folder, 2, 'name'); expect(spVirtualMemChart).toBeDefined(); }); }); diff --git a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts index 77a5abc53e400b2872ab7ec206a385b00c732814..e5cd0bc9d8c2f8782ef799784f3ee432275d8d0b 100644 --- a/ide/test/trace/component/chart/SpVmTrackerChart.test.ts +++ b/ide/test/trace/component/chart/SpVmTrackerChart.test.ts @@ -13,13 +13,23 @@ * limitations under the License. */ -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', () => { +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { return {}; }); +import { VmTrackerChart } from '../../../../src/trace/component/chart/SpVmTrackerChart'; +import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager'; + +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 +41,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 +52,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; dmaSmapsData.mockResolvedValue(smapsDmaData); - let gpuMemoryData = sqlite.queryGpuMemoryData; + let gpuMemoryData = memorySqlite.queryGpuMemoryData; let gpuData = [ { startNs: 0, @@ -60,14 +61,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 +76,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; vmTrackerShmData.mockResolvedValue(shmData); - let purgeableProcessData = sqlite.queryPurgeableProcessData; + let purgeableProcessData = memorySqlite.queryPurgeableProcessData; let processData = [ { startNs: 0, @@ -83,7 +84,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; purgeableProcessData.mockResolvedValue(processData); - let gpuGlData = sqlite.queryGpuData; + let gpuGlData = gpuSql.queryGpuData; let glData = [ { startNs: 0, @@ -91,7 +92,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuGlData.mockResolvedValue(glData); - let gpuTotalData = sqlite.queryGpuTotalData; + let gpuTotalData = gpuSql.queryGpuTotalData; let totalData = [ { startNs: 0, @@ -99,7 +100,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuTotalData.mockResolvedValue(totalData); - let gpuTotalType = sqlite.queryGpuTotalType; + let gpuTotalType = gpuSql.queryGpuTotalType; let totalType = [ { id: 1, @@ -107,7 +108,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuTotalType.mockResolvedValue(totalType); - let gpuWindowData = sqlite.queryGpuWindowData; + let gpuWindowData = gpuSql.queryGpuWindowData; let windowsData = [ { startNs: 0, @@ -115,7 +116,7 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuWindowData.mockResolvedValue(windowsData); - let gpuWindowType = sqlite.queryGpuWindowType; + let gpuWindowType = gpuSql.queryGpuWindowType; let windowsType = [ { id: 1, @@ -124,8 +125,9 @@ describe('SpVmTrackerChart Test', () => { }, ]; gpuWindowType.mockResolvedValue(windowsType); - let manager = new SpChartManager(); - let spVmTrackerChart = new VmTrackerChart(manager); + let htmlElement: any = document.createElement('sp-system-trace'); + let manager = new SpChartManager(htmlElement); + let spVmTrackerChart = new VmTrackerChart(htmlElement); let memoryData = [ { startNs: 0, diff --git a/ide/test/trace/component/chart/VSync.test.ts b/ide/test/trace/component/chart/VSync.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d43248e20e6dd340a70d1f0533276f9f27e015b --- /dev/null +++ b/ide/test/trace/component/chart/VSync.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 {querySingleVSyncData, drawVSync, enableVSync, setVSyncData } from '../../../../src/trace/component/chart/VSync'; +import { DbPool } from '../../../../src/trace/database/SqlLite'; + +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return { + queryFunc: ()=>{} + }; +}); +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {}); +jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { + return {} +}); + +const sqlit = require('../../../../src/trace/database/sql/SqlLite.sql'); +jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); + +describe('VSync Test', () => { + DbPool.prototype.submit = jest.fn(); + const canvas = document.createElement('canvas'); + canvas.width = 10; + canvas.height = 10; + const ctx = canvas.getContext('2d'); + it('VSyncTest01 ', function () { + let cc = { + "vsyncValue": 20 + }; + window.localStorage.setItem('FlagsConfig', JSON.stringify(cc)); + querySingleVSyncData(); + setVSyncData(); + drawVSync(ctx, 20, 20); + window.SmartEvent = { + UI: { + loading: true + } + } + window.publish = jest.fn(); + enableVSync(true, { + key: 'k' + }, () => {}); + }); +}); diff --git a/ide/test/trace/component/schedulingAnalysis/utils/Utils.test.ts b/ide/test/trace/component/schedulingAnalysis/utils/Utils.test.ts index 49232ac23a4769520dccd864bbf59c7f0d53d14f..bfbf266e2167b0face80b0ce82b61debe0406c49 100644 --- a/ide/test/trace/component/schedulingAnalysis/utils/Utils.test.ts +++ b/ide/test/trace/component/schedulingAnalysis/utils/Utils.test.ts @@ -18,7 +18,7 @@ import {getDataNo, getFormatData, getInitializeTime // @ts-ignore -} from "../../../../../src/trace/component/schedulingAnalysis/utils/Utils.js"; +} from '../../../../../src/trace/component/schedulingAnalysis/utils/Utils'; describe('schedulingAnalysis utils Test', () => { it('schedulingAnalysisUtilsTest01', () => { 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/SpHisysEvent.test.ts b/ide/test/trace/component/setting/SpHisysEvent.test.ts index 7cc22e952b5ad212b033fc20028f0d4b029bc005..a69e42fcdeb5a0aacaca267b16b85e96182ae768 100644 --- a/ide/test/trace/component/setting/SpHisysEvent.test.ts +++ b/ide/test/trace/component/setting/SpHisysEvent.test.ts @@ -18,9 +18,17 @@ import { SpHisysEvent } from '../../../../src/trace/component/setting/SpHisysEve describe('SpHisysEvent Test', () => { let spHisysEvent = new SpHisysEvent(); it('SpHisysEventTest01', function () { + spHisysEvent.startSamp = true; + expect(spHisysEvent.startSamp).toBeTruthy(); + }); + it('SpHisysEventTest02 ', function () { + spHisysEvent.startSamp = false; expect(spHisysEvent.startSamp).toBeFalsy(); }); - it('SpHisysEventTest02', function () { - expect(spHisysEvent.process).toBeFalsy(); + it('SpHisysEventTest03 ', function () { + expect(spHisysEvent.domain).not.toBeUndefined(); + }); + it('SpHisysEventTest04 ', function () { + expect(spHisysEvent.eventName).not.toBeUndefined(); }); }) diff --git a/ide/test/trace/component/setting/SpRecordPerf.test.ts b/ide/test/trace/component/setting/SpRecordPerf.test.ts index a3c446ad6bc24c99d6634bc60acfeaba75b3d749..7ea67f22903316fba0934656697e021b89757e2c 100644 --- a/ide/test/trace/component/setting/SpRecordPerf.test.ts +++ b/ide/test/trace/component/setting/SpRecordPerf.test.ts @@ -16,7 +16,11 @@ import { SpRecordPerf } from '../../../../src/trace/component/setting/SpRecordPerf'; describe('SpRecordPerf Test', () => { - let spRecordPerf = new SpRecordPerf(); + let spRecordPerf; + beforeEach(() => { + spRecordPerf = new SpRecordPerf(); + }); + it('SpRecordPerfTest01', function () { expect(spRecordPerf).not.toBeUndefined(); }); @@ -61,10 +65,12 @@ describe('SpRecordPerf Test', () => { spRecordPerf.startSamp = true; expect(spRecordPerf.startSamp).toBeTruthy(); }); + it('SpRecordPerfTest011', function () { 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..a0a7fd32aac72ed2b208b73c3592031015b3a447 100644 --- a/ide/test/trace/component/trace/base/RangeSelect.test.ts +++ b/ide/test/trace/component/trace/base/RangeSelect.test.ts @@ -13,12 +13,19 @@ * limitations under the License. */ +import { SpSystemTrace } from '../../../../../src/trace/component/SpSystemTrace'; import { RangeSelect } from '../../../../../src/trace/component/trace/base/RangeSelect'; import { TraceRow } from '../../../../../src/trace/component/trace/base/TraceRow'; -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, @@ -34,15 +41,12 @@ window.ResizeObserver = })); describe('RangeSelect Test', () => { - beforeAll(() => {}); - + let rangeSelect = new RangeSelect(new SpSystemTrace()); it('Utils Test01', () => { - let rangeSelect = new RangeSelect(); expect(rangeSelect).not.toBeUndefined(); }); it('Utils Test02', () => { - let rangeSelect = new RangeSelect(); rangeSelect.rowsEL = document.createElement('div'); let mouseEvent = new MouseEvent('mousedown', { button: 1, @@ -54,12 +58,9 @@ 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', () => { - let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.rowsEL = document.createElement('div'); let mouseEvent = new MouseEvent('mousedown', { button: 0, @@ -69,16 +70,13 @@ 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(); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.rowsEL = { - // offsetTop: 100, + offsetTop: 100, offsetHeight: 71, offsetLeft: 15, offsetWidth: 134, @@ -96,17 +94,12 @@ 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(); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -127,24 +120,15 @@ 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(); }); it('Utils Test08', () => { - let rangeSelect = new RangeSelect(new SpSystemTrace()); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); rangeSelect.isMouseDown = true; - rangeSelect.isHover = true; + rangeSelect.isHover = true; let rowsELDiv = document.createElement('div'); rangeSelect.rowsEL = rowsELDiv; let rows = [ @@ -172,29 +156,14 @@ 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(); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -217,13 +186,10 @@ 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(); rangeSelect.isHover = true; let mouseEvent = new MouseEvent('mousedown', { // @ts-ignore @@ -239,7 +205,6 @@ describe('RangeSelect Test', () => { expect(rangeSelect.mouseDown(mouseEvent)).toBeUndefined(); }); it('Utils Test11', () => { - let rangeSelect = new RangeSelect(); rangeSelect.isInRowsEl = jest.fn(() => true); rangeSelect.isDrag = jest.fn(() => true); @@ -260,24 +225,13 @@ 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(); }); it('Utils Test12', () => { - let rangeSelect = new RangeSelect(new SpSystemTrace()); 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 +243,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..7b90d7e1718ee31efe5cb2bc2521be300e65f38a 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, }); @@ -29,72 +33,19 @@ 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 = ''; + let traceSheet = new TraceSheet(); it('TraceSheet Test01', () => { - let traceSheet = new TraceSheet(); expect(traceSheet).not.toBeUndefined(); }); it('TraceSheet Test08', () => { - let traceSheet = new TraceSheet(); expect(traceSheet.connectedCallback()).toBeUndefined(); }); it('TraceSheet Test09', () => { - let traceSheet = new TraceSheet(); - expect(traceSheet.loadTabPaneData()).toBeUndefined(); + expect(traceSheet.loadTabPaneData('key')).toBeUndefined(); }); it('TraceSheet Test10', () => { - let traceSheet = new TraceSheet(); expect(traceSheet.updateRangeSelect()).toBeFalsy(); }); }); 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..27a848f5d059d2ee968649156c707b1bb95cba66 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, @@ -59,9 +59,9 @@ describe('TabPaneGpuMemoryAbility Test', () => { maxSizes: "884.00KB", minSize: 905216, minSizes: "884.00KB", - process: "/system/bin/aosp_graphic_temp_service(609)", + process: "/system/bin/temp_service(609)", processId: 609, - processName: "/system/bin/aosp_graphic_temp_service", + processName: "/system/bin/temp_service", startNs: 4568285416, sumSize: 2715648, sumSizes: "2.59MB", 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..6bd3ddafe7c71e457d69e32e742d14a4c377f9f7 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: () => {}, @@ -38,9 +49,12 @@ window.ResizeObserver = window.ResizeObserver || unobserve: jest.fn(), })); -describe('TabPaneJsCpuCallTree Test', () => { +describe('TabPaneJsCpuStatistics Test', () => { + let tabPaneJsCpuStatistics; + beforeEach(() => { document.body.innerHTML = ``; - let tabPaneJsCpuStatistics = document.querySelector('#statistics'); + tabPaneJsCpuStatistics = document.querySelector('#statistics'); + }); let res = [ { type: 'a', diff --git a/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts b/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts index ec4b5f4f9a796f02c6cf8825f85e1466bf5bff70..12fd5287ba1ccb367cbe26ceceaae9009df0f47e 100644 --- a/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts +++ b/ide/test/trace/component/trace/sheet/binder/TabPaneBinder.test.ts @@ -15,7 +15,6 @@ 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(() => ({ @@ -23,43 +22,58 @@ window.ResizeObserver = observe: jest.fn(), unobserve: jest.fn(), })); -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/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; - }); + let tabPaneBinders = new TabPaneBinders(); + let threadBindersTbl = new LitTable(); + jest.clearAllMocks(); + tabPaneBinders['threadBindersTbl'] = threadBindersTbl; + const data = [ + { + pid: 1, + tid: 2, + title: 'P-Render', + totalCount: 3, + children: [ + { + binderAsyncRcvCount: 2, + binderReplyCount: 2, + binderTransactionAsyncCount: 2, + binderTransactionCount: 2, + pid: 1, + tid: 2, + title: 'T-Render', + totalCount: 1 + } + ] + },{ + pid: 1, + tid: 2, + title: 'P-Service', + totalCount: 1, + children: [ + { + binderAsyncRcvCount: 1, + binderReplyCount: 1, + binderTransactionAsyncCount: 1, + binderTransactionCount: 1, + pid: 1, + tid: 2, + title: 'T-Service', + totalCount: 2 + } + ] + } + ]; + 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); + let binder = sqlite.queryBinderByThreadId; + binder.mockResolvedValue(data); const threadStatesParam = { threadIds: [1, 2], processIds: [1, 2], @@ -69,9 +83,21 @@ describe('TabPaneBinders Test', () => { 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 + + it('TabPaneBindersTest02', () => { + let binder = sqlite.queryBinderByThreadId; + binder.mockResolvedValue([]); + const threadStatesParam = { + threadIds: [1, 2], + processIds: [1, 2], + leftNs: 0, + rightNs: 100 + }; + tabPaneBinders.initBinderData(threadStatesParam); + expect(threadBindersTbl.loading).toBe(true); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts b/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts index b8c8a75fc6387c1b679474f9a33cb2124f26d80c..944a2f7aec7939a7dba21a567b26fba1ef7bc44d 100644 --- a/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts +++ b/ide/test/trace/component/trace/sheet/binder/TabPaneBinderDataCut.test.ts @@ -15,13 +15,26 @@ import { TabPaneBinderDataCut } from '../../../../../../src/trace/component/trace/sheet/binder/TabPaneBinderDataCut'; +import '../../../../../../src/trace/component/trace/sheet/binder/TabPaneBinderDataCut'; import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; +import { SpSegmentationChart } from '../../../../../../src/trace/component/chart/SpSegmentationChart'; +import { TraceRow } from '../../../../../../src/trace/component/trace/base/TraceRow'; +import { BinderStruct } from '../../../../../../src/trace/database/ui-worker/procedureWorkerBinder'; +import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => { +const processSqlite = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); +jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); +const sqlite = require('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/trace/component/trace/base/TraceSheet', () => { }); -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/component/trace/timer-shaft/RangeRuler', () => { return {}; }); window.ResizeObserver = @@ -32,10 +45,10 @@ window.ResizeObserver = unobserve: jest.fn(), })); describe('TabPaneBinderDataCut Test', () => { - let tabPaneBinderDataCut = new TabPaneBinderDataCut(); - tabPaneBinderDataCut.threadBindersTbl = jest.fn(() => { - return new LitTable(); - }); + document.body.innerHTML = `
          `; + let tabPaneBinderDataCut = document.querySelector('#binder-datacut'); + SpSegmentationChart.binderRow = new TraceRow; + SpSegmentationChart.trace = new SpSystemTrace(); let threadIdInput = document.createElement('input'); threadIdInput.value = 'threadIdInput'; let threadFuncInput = document.createElement('input'); @@ -107,7 +120,7 @@ describe('TabPaneBinderDataCut Test', () => { }]; loopFuncNameCycle.mockResolvedValue(loopFuncNameCycleData); - let queryBinder = sqlite.queryBinderByThreadId; + let queryBinder = processSqlite.queryBinderByThreadId; let binderData = [{ name: 'test', count: 1, @@ -120,8 +133,21 @@ describe('TabPaneBinderDataCut Test', () => { }]; queryBinder.mockResolvedValue(binderData); - let querySingle = sqlite.querySingleFuncNameCycle; - let querySingleData = [{ + let queryFuncName = sqlite.queryFuncNameCycle; + let funcNameData = [{ + name: 'test', + count: 1, + ts: 2533, + dur: 563, + startTime: 22554, + endTime: 2633333, + tid: 122, + pid: 36 + }]; + queryFuncName.mockResolvedValue(funcNameData); + + let singleFuncName = sqlite.querySingleFuncNameCycle; + let singleFuncNameData = [{ funcName: 'funcName', cycleStartTime: 2553, cycleDur: 36633, @@ -130,49 +156,400 @@ describe('TabPaneBinderDataCut Test', () => { 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(''); + singleFuncName.mockResolvedValue(singleFuncNameData); + let data = [ + { + cycleStartTime: 2677246000, + dur: 154698000, + id: 5567, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 3093830000, + dur: 133540000, + id: 6417, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 3873240000, + dur: 149769000, + id: 8045, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 5546299000, + dur: 148508000, + id: 18380, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 5935477000, + dur: 178657000, + id: 20853, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 8979430000, + dur: 151986000, + id: 61239, + tid: 2532, + pid: 2519 + }, + { + cycleStartTime: 10574029000, + dur: 154463000, + id: 70140, + tid: 2532, + pid: 2519 + } + ]; + it('TabPaneBinderDataCutTest01 ', () => { + tabPaneBinderDataCut.dataCutFunc(threadIdInput, threadFuncInput, 'loop'); + expect(tabPaneBinderDataCut.threadBindersTbl.loading).toBeUndefined(); }); - it('TabPaneBinderDataCutTest03 ', async () => { + it('TabPaneBinderDataCutTest02 ', () => { tabPaneBinderDataCut.verifyInputIsEmpty('', '', threadIdInput, threadFuncInput); expect(tabPaneBinderDataCut.threadBindersTbl.loading).toBeFalsy(); }); - it('TabPaneBinderDataCutTest04 ', async () => { - expect(tabPaneBinderDataCut.completionCycleName(binderItem, 'loop').length).toBe(0); + it('TabPaneBinderDataCutTest03 ', () => { + tabPaneBinderDataCut.clearCycleRange(); + expect(tabPaneBinderDataCut.cycleAStartRangeDIV.value).toEqual(''); }); - it('TabPaneBinderDataCutTest05 ', async () => { - expect(tabPaneBinderDataCut.transferToTreeData(binderItem).length).toBe(1); + it('TabPaneBinderDataCutTest04 ', () => { + tabPaneBinderDataCut.singleDataCutCycleMap(data); + tabPaneBinderDataCut.loopDataCutCycleMap(data); + let cycData = [ + { + title: "cycle 1_ACCS0", + tid: 2716, + pid: 2519, + durNs: 416584000, + tsNs: 2677246000, + cycleDur: 416.584, + cycleStartTime: 2677.246, + totalCount: 214, + binderTransactionCount: 214, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 1, + type: "Cycle", + isHover: false + }, + { + title: "cycle 2_ACCS0", + tid: 2716, + pid: 2519, + durNs: 368880000, + tsNs: 3093830000, + cycleDur: 368.88, + cycleStartTime: 3093.83, + totalCount: 198, + binderTransactionCount: 198, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 2, + type: "Cycle", + isHover: false + }, + { + title: "cycle 6_ACCS0", + tid: 2716, + pid: 2519, + durNs: 458350000, + tsNs: 4706839000, + cycleDur: 458.35, + cycleStartTime: 4706.839, + totalCount: 200, + binderTransactionCount: 200, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 6, + type: "Cycle", + isHover: false + }, + { + title: "cycle 10_ACCS0", + tid: 2716, + pid: 2519, + durNs: 465838000, + tsNs: 6408752000, + cycleDur: 465.838, + cycleStartTime: 6408.752, + totalCount: 217, + binderTransactionCount: 217, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 10, + type: "Cycle", + isHover: false + }, + { + title: "cycle 12_ACCS0", + tid: 2716, + pid: 2519, + durNs: 631522000, + tsNs: 7411421000, + cycleDur: 631.522, + cycleStartTime: 7411.421, + totalCount: 248, + binderTransactionCount: 248, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 12, + type: "Cycle", + isHover: false + }, + { + title: "cycle 14_ACCS0", + tid: 2716, + pid: 2519, + durNs: 470715000, + tsNs: 8508715000, + cycleDur: 470.715, + cycleStartTime: 8508.715, + totalCount: 252, + binderTransactionCount: 252, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 14, + type: "Cycle", + isHover: false + }, + { + title: "cycle 18_ACCS0", + tid: 2716, + pid: 2519, + durNs: 394807000, + tsNs: 10179222000, + cycleDur: 394.807, + cycleStartTime: 10179.222, + totalCount: 225, + binderTransactionCount: 225, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 18, + type: "Cycle", + isHover: false + } + ] + expect(tabPaneBinderDataCut.structuredLaneChartData(cycData)).toEqual([[{ + "cycle": 1, + "dur": 416584000, + "name": "binder transaction", + "startNS": 2677246000, + "value": 214, + }], [{ + "cycle": 2, + "dur": 368880000, + "name": "binder transaction", + "startNS": 3093830000, + "value": 198, + }], [{ + "cycle": 6, + "dur": 458350000, + "name": "binder transaction", + "startNS": 4706839000, + "value": 200, + }], [{ + "cycle": 10, + "dur": 465838000, + "name": "binder transaction", + "startNS": 6408752000, + "value": 217, + }], [{ + "cycle": 12, + "dur": 631522000, + "name": "binder transaction", + "startNS": 7411421000, + "value": 248, + }], [{ + "cycle": 14, + "dur": 470715000, + "name": "binder transaction", + "startNS": 8508715000, + "value": 252, + }], [{ + "cycle": 18, + "dur": 394807000, + "name": "binder transaction", + "startNS": 10179222000, + "value": 225, + }]]); }); - it('TabPaneBinderDataCutTest06 ', async () => { - expect(tabPaneBinderDataCut.addCycleNumber(bindGroup)[0].title).toEqual('title'); + it('TabPaneBinderDataCutTest05 ', () => { + let clickData = { + pid: 2519, + title: "tutu.ABenchMark [2519]", + totalCount: 4097, + type: "Process", + children: [ + { + title: "ACCS0 [2716]", + totalCount: 4097, + tid: 2716, + pid: 2519, + children: [ + { + title: "cycle 1_ACCS0", + tid: 2716, + pid: 2519, + durNs: 416584000, + tsNs: 2677246000, + cycleDur: 416.584, + cycleStartTime: 2677.246, + totalCount: 214, + binderTransactionCount: 214, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 1, + type: "Cycle" + }, + { + title: "cycle 3_ACCS0", + tid: 2716, + pid: 2519, + durNs: 410530000, + tsNs: 3462710000, + cycleDur: 410.53, + cycleStartTime: 3462.71, + totalCount: 216, + binderTransactionCount: 216, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 3, + type: "Cycle" + }, + { + title: "cycle 17_ACCS0", + tid: 2716, + pid: 2519, + durNs: 295990000, + tsNs: 9883232000, + cycleDur: 295.99, + cycleStartTime: 9883.232, + totalCount: 171, + binderTransactionCount: 171, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 17, + type: "Cycle" + }, + { + title: "cycle 18_ACCS0", + tid: 2716, + pid: 2519, + durNs: 394807000, + tsNs: 10179222000, + cycleDur: 394.807, + cycleStartTime: 10179.222, + totalCount: 225, + binderTransactionCount: 225, + binderAsyncRcvCount: 0, + binderReplyCount: 0, + binderTransactionAsyncCount: 0, + idx: 18, + type: "Cycle" + } + ], + type: "Thread", + isHover: false, + status: true, + isSelected: true + } + ], + isHover: false + } + tabPaneBinderDataCut.tHeadClick(clickData); + tabPaneBinderDataCut.drawColumn(); + expect(tabPaneBinderDataCut.chartTotal.config.appendPadding).toEqual(10); }); - it('TabPaneBinderDataCutTest07 ', async () => { - expect(tabPaneBinderDataCut.timeUnitConversion(bindGroup).length).toEqual(1); + it('TabPaneBinderDataCutTest06 ', () => { + let itemRowClick = new CustomEvent('row-click', { + detail: { + ...{}, + data: { + tid: 1, + pid: 2, + type: 'Process', + isSelected: false + }, + } + }); + tabPaneBinderDataCut.tableRowClickFunc(); + tabPaneBinderDataCut.threadBindersTbl.dispatchEvent(itemRowClick); + expect(tabPaneBinderDataCut.hasAttribute('hideQueryArea')).toBeTruthy(); }); - it('TabPaneBinderDataCutTest08 ', async () => { - expect(tabPaneBinderDataCut.binderWithCountList(bindGroup).length).not.toBeUndefined(); + it('TabPaneBinderDataCutTest7 ', () => { + let itemRowClick = new CustomEvent('row-click', { + detail: { + ...{}, + data: { + tid: 1, + pid: 2, + type: 'Thread', + isSelected: false + }, + } + }); + tabPaneBinderDataCut.structuredLaneChartData = jest.fn(); + SpSegmentationChart.setBinderChartData = jest.fn(); + tabPaneBinderDataCut.tableRowClickFunc(); + tabPaneBinderDataCut.threadBindersTbl.dispatchEvent(itemRowClick); + expect(tabPaneBinderDataCut.hasAttribute('hideQueryArea')).toBeFalsy(); }); - it('TabPaneBinderDataCutTest09 ', async () => { - expect(tabPaneBinderDataCut.findThreadByThreadId(bindGroup, 5)).not.toBeUndefined(); + it('TabPaneBinderDataCutTest8 ', () => { + let itemRowClick = new CustomEvent('row-click', { + detail: { + ...{}, + data: { + tid: 1, + pid: 2, + type: 'Cycle', + isSelected: false + }, + } + }); + tabPaneBinderDataCut.tableRowClickFunc(); + tabPaneBinderDataCut.threadBindersTbl.dispatchEvent(itemRowClick); + expect(tabPaneBinderDataCut.hasAttribute('hideQueryArea')).toBeFalsy(); }); - it('TabPaneBinderDataCutTest10 ', async () => { - tabPaneBinderDataCut.clearCycleRange(); - expect(tabPaneBinderDataCut.cycleAStartRangeDIV.value).toEqual(''); + it('TabPaneBinderDataCutTest9 ', () => { + let itemRowClick = new CustomEvent('click', { + detail: { + ...{}, + data: { + tid: 1, + pid: 2, + type: 'Cycle', + isSelected: false + }, + } + }); + tabPaneBinderDataCut.queryBtnClick(); + tabPaneBinderDataCut.shadowRoot?.querySelector('#query-btn').dispatchEvent(itemRowClick); + expect(tabPaneBinderDataCut.hasAttribute('hideQueryArea')).toBeFalsy(); }); -}); \ No newline at end of file +}); diff --git a/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction.test.ts b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..e41b798429eb26f88448ced431876c7d4bbfe7b8 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction.test.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 '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction'; +import { TabPaneSampleInstruction } from '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstruction'; +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +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('TabPaneSampleInstruction Test', () => { + let map = new Map(); + map.set('clock', [ + { + filterId: 255, + value: 1252, + startNS: 4515, + dur: 5255, + delta: 415, + }, + ]); + let clockCounterData = { + leftNs: 253, + rightNs: 1252, + clockMapData: map, + }; + let sampleInstruction = new TabPaneSampleInstruction(); + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + it('TabPaneSampleInstructionTest01', function () { + sampleInstruction.updateCanvas(10); + let clickData = { + begin: 0 + }; + let reqProperty = { + uniqueProperty: [[{ + begin: 0, + func_name: 'cpu' + },{ + begin: 1, + func_name: 'memory' + }]], + flattenTreeArray: [{ + name: 'tree', + instructions: 2 + },{ + name: 'cpu', + instructions: 3 + },{ + name: 'memory', + instructions: 5 + },{ + name: 'unknown', + instructions: 5 + }] + } + sampleInstruction.isChecked = true; + sampleInstruction.drawInstructionData = jest.fn(); + sampleInstruction.setSampleInstructionData(clickData, reqProperty); + expect(sampleInstruction.instructionData).toStrictEqual([[{ + begin: 0, + func_name: 'cpu' + },{ + begin: 1, + func_name: 'memory' + }]]) + }); + + it('TabPaneSampleInstructionTest02', function () { + // sampleInstruction.floatHint = true; + sampleInstruction.hideTip(); + sampleInstruction.showTip(); + sampleInstruction.updateTipContent(); + let sampleNode = { + frame: undefined, + } + sampleInstruction.setSampleFrame(sampleNode, 10, 20); + sampleInstruction.updateCanvasCoord(); + document.body.innerHTML = `` + let drawData = { + frame: { + x: 0, + y: 2, + width: 20, + height: 30 + }, + name: 'cpu', + depth: 2 + } + sampleInstruction.draw(ctx, drawData); + expect(sampleInstruction.instructionEle.getBoundingClientRect()).toBeTruthy() + }); +}); diff --git a/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.test.ts b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..47828d064b8a3998dcf832bcfb8735068e0198b0 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions.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 '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions'; +import { TabPaneSampleInstructionDistributions } from '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionDistributions'; +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +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('TabPaneSampleInstructionDistributions Test', () => { + let map = new Map(); + map.set('clock', [ + { + filterId: 255, + value: 1252, + startNS: 4515, + dur: 5255, + delta: 415, + }, + ]); + let sampleInstruction = new TabPaneSampleInstructionDistributions(); + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + sampleInstruction.data = { + sampleData: [{ + property: [] + }] + }; + + it('TabPaneSampleInstructionDistributionsTest01', function () { + sampleInstruction.ctx = ctx; + let htmlDivElement = document.createElement('div'); + htmlDivElement.appendChild(sampleInstruction); + sampleInstruction.updateCanvasCoord(); + sampleInstruction.showTip(); + sampleInstruction.updateTipContent(); + sampleInstruction.drawLineLabelMarkers(10, 20, true); + sampleInstruction.drawLineLabelMarkers(10, 20, false); + sampleInstruction.drawLine(10, 20, 50, 60); + sampleInstruction.drawRect(10, 20, 50, 60); + sampleInstruction.drawMarkers(50, 60); + let instructionData = { + x: 0, + y: 2, + width: 20, + height: 30 + } + sampleInstruction.updateCanvasCoord(); + sampleInstruction.drawBar(instructionData, 10, 20); + expect(sampleInstruction.isContains(instructionData, 1, 20)).toBeTruthy(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.test.ts b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca22346a192076c7c9a99b691af68fa221e87b0e --- /dev/null +++ b/ide/test/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection.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 '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection'; +import { TabPaneSampleInstructionSelection } from '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection'; +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +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('TabPaneSampleInstructionSelection Test', () => { + let map = new Map(); + map.set('clock', [ + { + filterId: 255, + value: 1252, + startNS: 4515, + dur: 5255, + delta: 415, + }, + ]); + let sampleInstruction = new TabPaneSampleInstructionSelection(); + sampleInstruction.drawInstructionData = jest.fn(); + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const ctx = canvas.getContext('2d'); + + sampleInstruction.data = { + sampleData: [{ + name: 'tree', + instructions: 2, + property: ['S'] + },{ + name: 'cpu', + instructions: 3, + property: ['S'] + },{ + name: 'memory', + instructions: 5, + property: ['S'] + },{ + name: 'unknown', + instructions: 5, + property: ['S'] + }] + }; + document.body.innerHTML = `` + it('TabPaneSampleInstructionSelectionTest01', function () { + let htmlDivElement = document.createElement('div'); + htmlDivElement.appendChild(sampleInstruction); + sampleInstruction.updateCanvasCoord(); + sampleInstruction.showTip(); + sampleInstruction.updateTipContent(); + + let instructionData = { + x: 0, + y: 2, + width: 20, + height: 30 + } + + let drawData = { + frame: { + x: 0, + y: 2, + width: 20, + height: 30 + }, + name: 'cpu', + depth: 2 + } + sampleInstruction.setSampleFrame({frame: undefined}, 20, 30); + sampleInstruction.updateCanvasCoord(); + sampleInstruction.draw(ctx, drawData); + expect(sampleInstruction.isContains(instructionData, 1, 20)).toBeTruthy(); + }); +}); 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..9031aa9174d7dea5045924bb2686802939923bb5 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(() => ({ @@ -28,7 +29,6 @@ window.ResizeObserver = })); describe('TabPaneClockCounter Test', () => { - let clockCounter = null; let map = new Map(); map.set('clock', [ { @@ -44,10 +44,8 @@ describe('TabPaneClockCounter Test', () => { rightNs: 1252, clockMapData: map, }; - beforeEach(() => { - document.body.innerHTML = ``; - clockCounter = document.querySelector('#tb-counter') as TabPaneClockCounter; - }); + document.body.innerHTML = ``; + let clockCounter = document.querySelector('#tb-counter') as TabPaneClockCounter; it('TabPaneClockCounterTest01', function () { clockCounter.data = clockCounterData; 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 index e965f05f37b158e2af933b4cf73b2cc4870bc3a4..582b978bb1e9c6a38ac14b78b2ec42c851c5b9fc 100644 --- a/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.test.ts +++ b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut.test.ts @@ -13,9 +13,16 @@ * limitations under the License. */ import { TabPaneFreqDataCut } from '../../../../../../src/trace/component/trace/sheet/frequsage/TabPaneFreqDataCut'; +import { + TabPaneFreqUsageConfig +} from '../../../../../../src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig'; -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'); +const cpuSqlite = require('../../../../../../src/trace/database/sql/Cpu.sql'); +jest.mock('../../../../../../src/trace/database/sql/Cpu.sql'); +const funSqlite = require('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/trace/database/sql/Func.sql'); jest.mock('../../../../../../src/base-ui/table/lit-table', () => { return { snapshotDataSource: () => { @@ -24,6 +31,9 @@ jest.mock('../../../../../../src/base-ui/table/lit-table', () => { }, }; }); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); @@ -55,25 +65,38 @@ describe('TabPaneFreqDataCut 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: '', startNS: 0, filter_id: 1, }]); + let searchFuncDataData = funSqlite.querySearchFuncData; + searchFuncDataData.mockResolvedValue([{ + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '' + }]); + let tabPaneFreqDataCut = new TabPaneFreqDataCut(); it('TabPaneFreqDataCutTest01 ', function () { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); - tabPaneFreqDataCut.data = data; - expect(tabPaneFreqDataCut.data).toBeUndefined(); + document.body.innerHTML = `
          `; + let tabFreqDataCut = document.querySelector('#freq-data'); + tabFreqDataCut.data = data; + expect(tabFreqDataCut.data).toBeUndefined(); }); it('TabPaneFreqDataCutTest02', () => { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); const arr = [ {percent: 50, children: []}, {percent: 75.123456, children: [{percent: 80, children: []}]}, @@ -84,7 +107,6 @@ describe('TabPaneFreqDataCut Test', () => { 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: []}, @@ -99,7 +121,6 @@ describe('TabPaneFreqDataCut Test', () => { ]); }); it('TabPaneFreqDataCutTest04 ', function () { - let tabPaneFreqDataCut = new TabPaneFreqDataCut(); const obj = { children: [], count: 0, @@ -122,7 +143,6 @@ describe('TabPaneFreqDataCut Test', () => { 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}, @@ -135,4 +155,745 @@ describe('TabPaneFreqDataCut Test', () => { {cpu: 'B', freq: 2, id: 2, dur: 40, percent: 60, count: 3} ]); }); + + it('TabPaneFreqDataCutTest06 ', function () { + let dealArr: Array<{ts: number, dur: number}> = [ + { + "ts": 168760136913000, + "dur": 137768000 + }, + { + "ts": 168760506232000, + "dur": 144391000 + }, + { + "ts": 168760915781000, + "dur": 164178000 + }, + { + "ts": 168761340107000, + "dur": 154698000 + }, + { + "ts": 168761756691000, + "dur": 133540000 + }, + { + "ts": 168762125571000, + "dur": 142127000 + }, + { + "ts": 168762536101000, + "dur": 149769000 + }, + { + "ts": 168762958217000, + "dur": 150150000 + }, + { + "ts": 168763369700000, + "dur": 143612000 + }, + { + "ts": 168763828050000, + "dur": 145251000 + }, + { + "ts": 168764209160000, + "dur": 148508000 + }, + { + "ts": 168764598338000, + "dur": 178657000 + }, + { + "ts": 168765071613000, + "dur": 264921000 + }, + { + "ts": 168765537451000, + "dur": 205472000 + }, + { + "ts": 168766074282000, + "dur": 311942000 + }, + { + "ts": 168766705804000, + "dur": 165649000 + } + ]; + let freqUsageConfig = [ + { + "thread": "ACCS0", + "count": 0, + "dur": 745659, + "cdur": "", + "flag": "freqdata", + "id": -1, + "ts": 168760089353341, + "pid": 2519, + "tid": 2716, + "cpu": 0, + "freq": 1593600, + "percent": 0.014515453053278886 + }, + { + "thread": "ACCS0", + "count": 0, + "dur": 1125000, + "cdur": "", + "flag": "freqdata", + "id": -1, + "ts": 168760090523000, + "pid": 2519, + "tid": 2716, + "cpu": 0, + "freq": 1593600, + "percent": 0.021899936411870234 + } + ]; + let targetMap: Map> = new Map>(); + targetMap.set("2519_2716", freqUsageConfig); + targetMap.set("2519_2532", freqUsageConfig); + let cycleMap: Map> = new Map>(); + cycleMap.set("2519_2716", freqUsageConfig); + cycleMap.set("2519_2532", freqUsageConfig); + let totalList: Map> = new Map>(); + totalList.set("2519_2716", freqUsageConfig); + totalList.set("2519_2532", freqUsageConfig); + tabPaneFreqDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + }; + expect(tabPaneFreqDataCut.mergeSingleData(dealArr, targetMap, cycleMap, totalList)).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest07 ', function () { + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + tabPaneFreqDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + } + threadIdDiv.value = ''; + threadFuncDiv.value = ''; + tabPaneFreqDataCut.mergeSingleData = jest.fn(); + expect(tabPaneFreqDataCut.dataSingleCut(threadIdDiv, threadFuncDiv, [])).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest08 ', function () { + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + let dataList = [{pid: 1, tid: 1, children: [{pid: 1, tid: 1, thread: 'TotalData'}]}]; + tabPaneFreqDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + } + threadIdDiv.value = '7'; + threadFuncDiv.value = '8'; + tabPaneFreqDataCut.mergeSingleData = jest.fn(); + expect(tabPaneFreqDataCut.dataSingleCut(threadIdDiv, threadFuncDiv, dataList)).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest09 ', function () { + let str = ''; + let arg = {i: 1, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = {ts: 10, dur: 20}; + let flag = 1; + expect(tabPaneFreqDataCut.returnSingleObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 2000, + cpu: 3, + dur: 200, + flag: "freqdata", + freq: 3, + id: 1, + percent: 20, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest10 ', function () { + let str = ''; + let arg = {i: 1, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = {ts: 10, dur: 20}; + let flag = 2; + expect(tabPaneFreqDataCut.returnSingleObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 300, + cpu: 3, + dur: 30, + flag: "freqdata", + freq: 3, + id: 1, + percent: 3, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest11 ', function () { + let str = ''; + let arg = {i: 1, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = {ts: 10, dur: 20}; + let flag = 3; + expect(tabPaneFreqDataCut.returnSingleObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 200, + cpu: 3, + dur: 20, + flag: "freqdata", + freq: 3, + id: 1, + percent: 2, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest12 ', function () { + let str = ''; + let arg = {i: 1, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = {ts: 10, dur: 20}; + let flag = 4; + expect(tabPaneFreqDataCut.returnSingleObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 1900, + cpu: 3, + dur: 190, + flag: "freqdata", + freq: 3, + id: 1, + percent: 19, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest13 ', function () { + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + let dataList = [{pid: 1, tid: 1, children: [{pid: 1, tid: 1, thread: 'TotalData'}]}]; + tabPaneFreqDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + } + threadIdDiv.value = ''; + threadFuncDiv.value = ''; + tabPaneFreqDataCut.mergeSingleData = jest.fn(); + tabPaneFreqDataCut.merge = jest.fn(); + expect(tabPaneFreqDataCut.dataLoopCut(threadIdDiv, threadFuncDiv, dataList)).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest14 ', function () { + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + let dataList = [{pid: 1, tid: 1, children: [{pid: 1, tid: 1, thread: 'TotalData'}]}]; + tabPaneFreqDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + } + threadIdDiv.value = '7'; + threadFuncDiv.value = '8'; + tabPaneFreqDataCut.mergeSingleData = jest.fn(); + tabPaneFreqDataCut.merge = jest.fn(); + expect(tabPaneFreqDataCut.dataLoopCut(threadIdDiv, threadFuncDiv, dataList)).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest15 ', function () { + let value = [{ + thread: "HeapTaskDaemon", + count: 0, + dur: 652420, + cdur: "", + flag: "freqdata", + id: -1, + ts: 168760398181580, + pid: 2519, + tid: 2532, + cpu: 0, + freq: 1593600, + percent: 0.008945954654902404 + },{ + thread: "HeapTaskDaemon", + count: 0, + dur: 1062000, + cdur: "", + flag: "freqdata", + id: -1, + ts: 168760611803000, + pid: 2519, + tid: 2532, + cpu: 0, + freq: 1593600, + percent: 0.014562097795141705 + },{ + thread: "HeapTaskDaemon", + count: 0, + dur: 515000, + cdur: "", + flag: "freqdata", + id: -1, + ts: 168763001249000, + pid: 2519, + tid: 2532, + cpu: 0, + freq: 1593600, + percent: 0.007061657593689246 + },{ + thread: "HeapTaskDaemon", + count: 0, + dur: 37000, + cdur: "", + flag: "freqdata", + id: -1, + ts: 168768634868000, + pid: 2519, + tid: 2532, + cpu: 0, + freq: 1593600, + percent: 0.0005073423902262177 + }]; + let cutArr = [{ + ts: 168760506232000, + dur: 409549000 + },{ + ts: 168762125571000, + dur: 410530000 + },{ + ts: 168764209160000, + dur: 389178000 + },{ + ts: 168766074282000, + dur: 631522000 + },{ + ts: 168768546093000, + dur: 295990000 + },{ + ts: 168770208469000 + }]; + let constant = { + i: 0, + key: "2519_2532", + countMutiple: 1000000, + cpuArr: [ + 0 + ], + cpuMap: {} + } + + let resList = []; + let totalList = new Map([ + [ + "2519_2532", + [ + { + "thread": "HeapTaskDaemon", + "count": "2400366.374", + "dur": "1506.254", + "cdur": "", + "flag": "freqdata", + "id": 0, + "ts": "", + "pid": 2519, + "tid": 2532, + "cpu": 0, + "freq": 1593.6, + "percent": "20.65" + }, + { + "thread": "HeapTaskDaemon", + "count": "974.688", + "dur": "0.715", + "cdur": "", + "flag": "freqdata", + "id": 11, + "ts": "", + "pid": 2519, + "tid": 2532, + "cpu": 0, + "freq": 1363.2, + "percent": "0.01" + } + ] + ], + [ + "2519_2716", + [ + { + "thread": "ACCS0", + "count": "7833524.064", + "dur": "4915.615", + "cdur": "", + "flag": "freqdata", + "id": 0, + "ts": "", + "pid": 2519, + "tid": 2716, + "cpu": 0, + "freq": 1593.6, + "percent": "67.40" + }, + { + "thread": "ACCS0", + "count": "302.630", + "dur": "0.222", + "cdur": "", + "flag": "freqdata", + "id": 13, + "ts": "", + "pid": 2519, + "tid": 2716, + "cpu": 0, + "freq": 1363.2, + "percent": "0.00" + } + ] + ], + [ + "2519_2534", + [ + { + "thread": "FinalizerDaemon", + "count": "13112.141", + "dur": "8.228", + "cdur": "", + "flag": "freqdata", + "id": 0, + "ts": "", + "pid": 2519, + "tid": 2534, + "cpu": 0, + "freq": 1593.6, + "percent": "0.11" + } + ] + ], + [ + "2519_2627", + [ + { + "thread": "tutu.ABenchMark", + "count": "1874.074", + "dur": "1.176", + "cdur": "", + "flag": "freqdata", + "id": 0, + "ts": "", + "pid": 2519, + "tid": 2627, + "cpu": 0, + "freq": 1593.6, + "percent": "0.02" + }, + { + "thread": "tutu.ABenchMark", + "count": "30.336", + "dur": "0.020", + "cdur": "", + "flag": "freqdata", + "id": 9, + "ts": "", + "pid": 2519, + "tid": 2627, + "cpu": 0, + "freq": 1516.8, + "percent": "0.00" + }, + { + "thread": "tutu.ABenchMark", + "count": "37.440", + "dur": "0.026", + "cdur": "", + "flag": "freqdata", + "id": 15, + "ts": "", + "pid": 2519, + "tid": 2627, + "cpu": 0, + "freq": 1440, + "percent": "0.00" + } + ] + ] + ]); + expect(tabPaneFreqDataCut.dismantlingLoop(value, cutArr, constant, resList, totalList)).toBeUndefined(); + }); + + + it('TabPaneFreqDataCutTest16 ', function () { + let str = ''; + let arg = {i: 1, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = [{ts: 10, dur: 20}, {ts: 20, dur: 40}]; + let flag = 1; + expect(tabPaneFreqDataCut.returnLoopObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 2000, + cpu: 3, + dur: 200, + flag: "freqdata", + freq: 3, + id: 1, + percent: undefined, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest17 ', function () { + let str = ''; + let arg = {i: 0, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = [{ts: 10, dur: 20}, {ts: 20, dur: 40}]; + let flag = 2; + expect(tabPaneFreqDataCut.returnLoopObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 200, + cpu: 3, + dur: 20, + flag: "freqdata", + freq: 3, + id: 0, + percent: 2, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest18 ', function () { + let str = ''; + let arg = {i: 0, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = [{ts: 10, dur: 20}, {ts: 20, dur: 40}]; + let flag = 3; + expect(tabPaneFreqDataCut.returnLoopObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 100, + cpu: 3, + dur: 10, + flag: "freqdata", + freq: 3, + id: 0, + percent: 1, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest19 ', function () { + let str = ''; + let arg = {i: 0, percent: 20, startTime: 0, consumption: 30, countMutiple: 3}; + let value = {pid: 12, tid: 17, dur: 200, cpu: 3, freq: 3}; + let funData = [{ts: 10, dur: 20}, {ts: 20, dur: 40}]; + let flag = 4; + expect(tabPaneFreqDataCut.returnLoopObj(str, arg, value, funData, flag)).toEqual({ + cdur: "", + children: undefined, + count: 1900, + cpu: 3, + dur: 190, + flag: "freqdata", + freq: 3, + id: 0, + percent: 19, + pid: 12, + thread: "", + tid: 17, + ts: "", + }); + }); + + it('TabPaneFreqDataCutTest20 ', function () { + let threadArr = [ + { + thread: 'ACCS0 2716', + count: 3006075.782, + dur: 1895.313, + cdur: '', + flag: 'thread', + id: -1, + ts: '', + pid: 2519, + tid: 2716, + cpu: '', + freq: '', + percent: 27.72, + children: [{ + thread: 'TotalData', + count: 3006075.782, + dur: 1895.313, + cdur: '', + flag: 'cycle', + id: 0, + ts: '', + pid: 2519, + tid: 2716, + cpu: '', + freq: '', + percent: 27.72, + children: [], + isHover: false + }], + isHover: false, + status: true + } + ]; + let cycleMap: Map> = new Map>(); + cycleMap.set('2519_2716', [{ + thread: 'cycle1—ACCS0', + count: 125228.275, + dur: 78.582, + cdur: 144.391, + flag: 'cycle', + id: 1, + ts: 1843.371, + pid: 2519, + tid: 2716, + cpu: '', + freq: '', + percent: 1.15, + children: [ + { + thread: 'cycle1—ACCS0', + count: 125228.275, + dur: 78.582, + cdur: '', + flag: 'cpu', + id: -1, + ts: '', + pid: 2519, + tid: 2716, + cpu: 0, + freq: '', + percent: 1.15, + children: [] + } + ], + isHover: false + }]) + expect(tabPaneFreqDataCut.mergeThreadData(threadArr, cycleMap)).toBeUndefined(); + }); + + it('TabPaneFreqDataCutTest21 ', function () { + let threadArr = [ + { + thread: 'ACCS0 2716', + count: 3006075.782, + dur: 1895.313, + cdur: '', + flag: 'thread', + id: -1, + ts: '', + pid: 2519, + tid: 2716, + cpu: '', + freq: '', + percent: 27.72, + children: [{ + thread: 'TotalData', + count: 3006075.782, + dur: 1895.313, + cdur: '', + flag: 'cycle', + id: 0, + ts: '', + pid: 2519, + tid: 2716, + cpu: '', + freq: '', + percent: 27.72, + children: [], + isHover: false + }], + isHover: false, + status: true + } + ]; + let pidArr = [ + { + thread: "tutu.ABenchMark 2519", + count: "4673904.326", + dur: "2948.279", + cdur: "", + flag: "process", + id: -1, + ts: "", + pid: 2519, + tid: "", + cpu: "", + freq: "", + percent: "43.12", + children: [ + { + thread: "ACCS0 2716", + count: "3006075.782", + dur: "1895.313", + cdur: "", + flag: "thread", + id: -1, + ts: "", + pid: 2519, + tid: 2716, + cpu: "", + freq: "", + percent: "27.72", + children: [], + isHover: false, + status: true + }, + { + thread: "HeapTaskDaemon 2532", + count: "1667117.798", + dur: "1052.520", + cdur: "", + flag: "thread", + id: -1, + ts: "", + pid: 2519, + tid: 2532, + cpu: "", + freq: "", + percent: "15.39", + children: [], + isHover: false + }], + isHover: false, + status: true + } + ]; + expect(tabPaneFreqDataCut.mergePidData(pidArr, threadArr)).toBeUndefined(); + }); }); 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..b313fa08ef784d13889d56b3cc60b592a91690c1 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,13 @@ window.ResizeObserver = jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { return {}; }); -jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { +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'); +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker',()=>{ return {}; -}); -const sqlite = require('../../../../../../src/trace/database/SqlLite'); -jest.mock('../../../../../../src/trace/database/SqlLite'); +}) describe('TabPaneFreqUsage Test', () => { let tabPaneFreqUsage = new TabPaneFreqUsage(); let data = { @@ -55,12 +57,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/frequsage/TabPaneFreqUsageConfig.test.ts b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4ea2b2717fed4fe4dd3d35d62b24c1a494d9753 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig.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 { + TabPaneCpuFreqConfig, + TabPaneFreqUsageConfig, TabPaneRunningConfig +} from '../../../../../../src/trace/component/trace/sheet/frequsage/TabPaneFreqUsageConfig'; + +describe('TabPaneFreqUsageConfig Test', () => { + it('TabPaneFreqUsageConfigTest01 ', function () { + const thread = 'thread'; + const ts = Date.now(); + const pid = 1; + const tid = 2; + const count = 3; + const cpu = 0.5; + const freq = 1000; + const dur = 2000; + const cdur = 'cdur'; + const percent = 50; + const flag = 'flag'; + const id = 10; + const children = []; + const config = new TabPaneFreqUsageConfig(thread, ts, pid, tid, count, cpu, freq, dur, cdur, percent, flag, id, children); + expect(config.cpu).toBe(0.5); + }); + it('TabPaneFreqUsageConfigTest02 ', function () { + const thread = ''; + const process = ''; + const ts = 0; + const pid = 0; + const tid = 0; + const cpu = -1; + const dur = 0; + const config = new TabPaneRunningConfig(thread, process, ts, pid, tid, cpu, dur); + expect(config.dur).toBe(0) + }); + it('TabPaneFreqUsageConfigTest03 ', function () { + const startNS = 1000; + const cpu = 0.5; + const value = 2000; + const dur = 500; + const config = new TabPaneCpuFreqConfig(startNS, cpu, value, dur); + expect(config.startNS).toBe(startNS); + }); +}); \ No newline at end of file diff --git a/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts b/ide/test/trace/component/trace/sheet/gpu/TabPaneGpuClickSelect.test.ts index 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 index 4ae3ceb947dc75c7e6fd5b319fb63a1503209093..7779c7730b5f840cc1a0d67b814faace350613a9 100644 --- a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts +++ b/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqDataCut.test.ts @@ -17,12 +17,23 @@ import { TabPaneGpufreqDataCut } from '../../../../../../src/trace/component/tra 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"; +import { SpSegmentationChart } from '../../../../../../src/trace/component/chart/SpSegmentationChart'; +import { TraceRow } from "../../../../../../src/trace/component/trace/base/TraceRow"; +import { CpuFreqExtendStruct } from "../../../../../../src/trace/database/ui-worker/ProcedureWorkerFreqExtend"; -jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { +jest.mock('../../../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { return {}; }); - +jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../../../src/trace/component/trace/timer-shaft/RangeRuler', () => { + return {}; +}); +const intersectionObserverMock = () => ({ + observe: () => null, +}); +window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ @@ -31,10 +42,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/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); -describe('TabPaneSchedSwitch Test', () => { +describe('TabPaneGpufreqDataCut.test Test', () => { let threadStatesParam = { cpus: [], threadIds: [1, 2, 3], @@ -102,13 +113,16 @@ describe('TabPaneSchedSwitch Test', () => { pid: 5256 }]; dataFreqCut.mockResolvedValue(gpufreqCut); - + SpSegmentationChart.trace = jest.fn(()=>{}); + SpSegmentationChart.trace.refreshCanvas = jest.fn(()=>{}); let gpufreqDataCut = new TabPaneGpufreqDataCut(); gpufreqDataCut.threadStatesTbl = jest.fn(() => { return new LitTable(); }); it('TabPaneSchedSwitchTest01', function () { + SpSegmentationChart.GpuRow = new TraceRow; gpufreqDataCut.data = threadStatesParam; + expect(gpufreqDataCut.threadStatesTbl.loading).toBeTruthy(); }); @@ -121,30 +135,25 @@ describe('TabPaneSchedSwitch Test', () => { 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'); + expect(gpufreqDataCut._threadId.getAttribute('placeholder')).toEqual('Please input thread id'); }); 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'); + expect(gpufreqDataCut._threadFunc.getAttribute('placeholder')).toEqual('Please input function name'); }); 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(); + it('TabPaneSchedSwitchTest06', function () { + gpufreqDataCut.RetainDecimals = jest.fn(() => true); expect(gpufreqDataCut.createTree(initData)).not.toBeUndefined(); }); - it('TabPaneSchedSwitchTest08', function () { + it('TabPaneSchedSwitchTest07', 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 index 6f558d62c7093c07d51302b313fba9535ed7a371..0ac9fac1c5ca0866fc88aedaf763f1f736b00b93 100644 --- a/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts +++ b/ide/test/trace/component/trace/sheet/gpufreq/tabPaneGpufreqUsage.test.ts @@ -28,8 +28,8 @@ 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/Perf.sql'); +jest.mock('../../../../../../src/trace/database/sql/Perf.sql'); describe('tabPaneGpufreqUsage Test', () => { let tabGpuFreq = new TabPaneGpufreq(); @@ -84,15 +84,6 @@ describe('tabPaneGpufreqUsage Test', () => { 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..0cdd6b0ef4b504186dc7e2dad0b8aef1a66deaa6 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,389 +30,90 @@ 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 () { - tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); - tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + it('TabPaneNMStatsticsTest04', function () { expect(tabPaneNMStatstics.sortByColumn('', 0)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest12', function () { - tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); - tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + it('TabPaneNMStatsticsTest105', function () { expect(tabPaneNMStatstics.sortByColumn('existingString', 1)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest13', function () { - tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); - tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + it('TabPaneNMStatsticsTest06', function () { expect(tabPaneNMStatstics.sortByColumn('allocCount', 1)).toBeUndefined(); }); - it('TabPaneNMStatsticsTest14', function () { - tabPaneNMStatstics.nativeStatisticsTbl = jest.fn(() => true); - tabPaneNMStatstics.nativeStatisticsTbl.recycleDataSource = jest.fn(() => true); + it('TabPaneNMStatsticsTest07', function () { 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/sample/TabPaneSampleInstructionSelection.test.ts b/ide/test/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelection.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..26588b664c97980d2fad377d6b9e1a8ec9a6b726 --- /dev/null +++ b/ide/test/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelection.test.ts @@ -0,0 +1,238 @@ +/* + * 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 { TabPaneSampleInstructionSelection } from '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelection'; +import { SelectionParam } from '../../../../../../src/trace/bean/BoxSelection'; +jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { + return {}; +}); + +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('', () => { + let tab = new TabPaneSampleInstructionSelection(); + let SelectionParam: SelectionParam = { + recordStartNs: 0, + leftNs: 1621621621, + rightNs: 1749644381, + hasFps: false, + perfAll: false, + fileSysVirtualMemory: false, + diskIOLatency: false, + fsCount: 0, + vmCount: 0, + isCurrentPane: false, + startup: false, + staticInit: false, + isRowClick: false, + eventTypeId: '', + cpus: [], + cpuStateRowsId: [], + cpuFreqFilterNames: [], + cpuStateFilterIds: [], + cpuFreqFilterIds: [], + threadIds: [], + processIds: [], + processTrackIds: [], + virtualTrackIds: [], + cpuFreqLimit: [], + clockMapData: {}, + irqCallIds: [], + softIrqCallIds: [], + funTids: [], + funAsync: [], + nativeMemory: [], + nativeMemoryStatistic: [], + nativeMemoryAllProcess: [], + nativeMemoryCurrentIPid: -1, + cpuAbilityIds: [], + memoryAbilityIds: [], + diskAbilityIds: [], + networkAbilityIds: [], + perfSampleIds: [], + perfCpus: [], + perfProcess: [], + perfThread: [], + fileSystemType: [], + sdkCounterIds: [], + sdkSliceIds: [], + diskIOipids: [], + diskIOReadIds: [], + diskIOWriteIds: [], + systemEnergy: [], + powerEnergy: [], + anomalyEnergy: [], + smapsType: [], + vmtrackershm: [], + promiseList: [], + jankFramesData: [], + jsMemory: [], + taskFramesData: [], + frameDynamic: [], + frameAnimation: [], + frameSpacing: [], + jsCpuProfilerData: [], + gpu: { + gl: false, + graph: false, + gpuWindow: false, + gpuTotal: false, + }, + purgeableTotalAbility: [], + purgeableTotalVM: [], + purgeablePinAbility: [], + purgeablePinVM: [], + purgeableTotalSelection: [], + purgeablePinSelection: [], + dmaAbilityData: [], + gpuMemoryAbilityData: [], + dmaVmTrackerData: [], + gpuMemoryTrackerData: [], + hiLogs: [], + sysAllEventsData: [], + sysAlllogsData: [], + hiSysEvents: [], + sampleData: [ + { + detail: 'OnVsync信号回调', + depth: 0, + name: 'OnReadable', + parentName: '', + property: [ + { + name: 'OnReadable', + detail: 'OnVsync信号回调', + end: 512063811316909, + begin: 512063803840867, + depth: 0, + instructions: 54, + cycles: 148, + frame: { + x: 78, + y: 0, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 146.8896484375, + }, + ], + instructions: 54, + hoverInstructions: 54, + cycles: 148, + hoverCycles: 148, + frame: { + x: 0, + y: 0, + width: 1635, + height: 30, + }, + textMetricsWidth: 146.8896484375, + }, + ], + }; + const node = { + '0': [ + { + detail: 'OnVsync信号回调', + depth: 0, + name: 'OnReadable', + parentName: '', + property: [ + { + name: 'OnReadable', + detail: 'OnVsync信号回调', + end: 512065485173158, + begin: 512065467605450, + depth: 0, + instructions: 216, + cycles: 383, + frame: { + x: 156, + y: 0, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 146.8896484375, + }, + ], + instructions: 120, + cycles: 249, + hoverInstructions: 120, + hoverCycles: 249, + frame: { + x: 0, + y: 0, + width: 1652, + height: 30, + }, + textMetricsWidth: 146.8896484375, + }, + ], + }; + it('TabPaneSampleInstructionSelection test01', () => { + expect(tab.isContains({ x: 100, width: 2, y: 100, height: 10 }, 100, 100)).toBeTruthy(); + expect(tab.updateCanvasCoord()).toBeUndefined(); + expect(tab.searchDataByCoord(node, 100, 200)).not.toBeUndefined(); + expect(tab.initHtml()).not.toBeUndefined(); + expect(tab.initElements()).toBeUndefined(); + expect(tab.hideTip()).toBeUndefined(); + expect(tab.showTip()).toBeUndefined(); + expect(tab.updateTipContent()).toBeUndefined(); + expect(tab.updateCanvas()).toBeUndefined(); + expect(tab.listenerResize()).toBeUndefined(); + expect(tab.onMouseMove()).toBeUndefined(); + }); + + it('TabPaneSampleInstructionSelection test02', () => { + const mockFn = jest.fn(); + tab.isContains = mockFn; + tab.searchDataByCoord(node, 471, 251); + expect(mockFn).toHaveBeenCalled(); + }); + + it('TabPaneSampleInstructionSelection test03', () => { + const nodes = [ + { + instruct: '10.5', + x: 890, + y: 180, + height: 100, + width: 100, + }, + ]; + expect(tab.searchDataByCoord(nodes, 891, 251)).not.toBeUndefined(); + }); + + it('TabPaneSampleInstructionSelection test04', () => { + expect(tab.getAvgInstructionData(SelectionParam.sampleData)).not.toBeUndefined(); + }); + + it('TabPaneSampleInstructionSelection test05', () => { + const mockFn = jest.fn(); + tab.showTip = mockFn; + tab.initElements(); + tab.searchDataByCoord = jest.fn(() => true); + tab.onMouseMove(); + expect(mockFn).toHaveBeenCalled(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.test.ts b/ide/test/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..8912dc292ccd5f31edab6132ca50d0220fecb86b --- /dev/null +++ b/ide/test/trace/component/trace/sheet/sample/TabPaneSampleInstructionSelectionTotalTime.test.ts @@ -0,0 +1,361 @@ +/* + * 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 { TabPaneSampleInstructionTotalTime } from '../../../../../../src/trace/component/trace/sheet/bpftrace/TabPaneSampleInstructionSelectionTotalTime'; +import { SelectionParam } from '../../../../../../src/trace/bean/BoxSelection'; +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 {}; +}); +describe('', () => { + let tab = new TabPaneSampleInstructionTotalTime(); + let SelectionParam: SelectionParam = { + recordStartNs: 0, + leftNs: 2603129445, + rightNs: 10071123755, + hasFps: false, + perfAll: false, + fileSysVirtualMemory: false, + diskIOLatency: false, + fsCount: 0, + vmCount: 0, + isCurrentPane: false, + startup: false, + staticInit: false, + isRowClick: false, + eventTypeId: '', + cpus: [], + cpuStateRowsId: [], + cpuFreqFilterNames: [], + cpuStateFilterIds: [], + cpuFreqFilterIds: [], + threadIds: [], + processIds: [], + processTrackIds: [], + virtualTrackIds: [], + cpuFreqLimit: [], + clockMapData: {}, + irqCallIds: [], + softIrqCallIds: [], + funTids: [], + funAsync: [], + nativeMemory: [], + nativeMemoryStatistic: [], + nativeMemoryAllProcess: [], + nativeMemoryCurrentIPid: -1, + cpuAbilityIds: [], + memoryAbilityIds: [], + diskAbilityIds: [], + networkAbilityIds: [], + perfSampleIds: [], + perfCpus: [], + perfProcess: [], + perfThread: [], + fileSystemType: [], + sdkCounterIds: [], + sdkSliceIds: [], + diskIOipids: [], + diskIOReadIds: [], + diskIOWriteIds: [], + systemEnergy: [], + powerEnergy: [], + anomalyEnergy: [], + smapsType: [], + vmtrackershm: [], + promiseList: [], + jankFramesData: [], + jsMemory: [], + taskFramesData: [], + frameDynamic: [], + frameAnimation: [], + frameSpacing: [], + jsCpuProfilerData: [], + gpu: { + gl: false, + graph: false, + gpuWindow: false, + gpuTotal: false, + }, + purgeableTotalAbility: [], + purgeableTotalVM: [], + purgeablePinAbility: [], + purgeablePinVM: [], + purgeableTotalSelection: [], + purgeablePinSelection: [], + dmaAbilityData: [], + gpuMemoryAbilityData: [], + dmaVmTrackerData: [], + gpuMemoryTrackerData: [], + hiLogs: [], + sysAllEventsData: [], + sysAlllogsData: [], + hiSysEvents: [], + sampleData: [ + { + children: { + RenderFrameStart: [], + ConsumeAndUpdateAllNodes: [ + { + name: 'ConsumeAndUpdateAllNodes', + detail: '自绘制buffer轮转(视频/鼠标等)', + end: 512062139514826, + begin: 512062139339305, + depth: 2, + instructions: 0, + cycles: 2, + frame: { + x: 0, + y: 40, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 289.8828125, + }, + ], + WaitUntilUnmarshallingTaskFinished: [ + { + name: 'WaitUntilUnmarshallingTaskFinished', + detail: '等待反序列化完成', + end: 512062139535138, + begin: 512062139526284, + depth: 2, + instructions: 0.785, + cycles: 0, + frame: { + x: 0, + y: 40, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 260.1611328125, + }, + ], + ProcessCommand: [ + { + name: 'ProcessCommand', + detail: '数据同步', + end: 512062141885138, + begin: 512062139543471, + depth: 2, + instructions: 6, + cycles: 35, + frame: { + x: 0, + y: 40, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 132.6513671875, + }, + ], + CheckParallelSubThreadNodesStatus: [ + { + name: 'CheckParallelSubThreadNodesStatus', + detail: '执行并行绘制', + end: 512062139563263, + begin: 512062139553888, + depth: 3, + instructions: 0, + cycles: 0, + frame: { + x: 0, + y: 60, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 241.826171875, + }, + ], + CacheCommands: [], + Animate: [ + { + name: 'Animate', + detail: '动画步进计算', + end: 512062142174201, + begin: 512062142004930, + depth: 3, + instructions: 3, + cycles: 2, + frame: { + x: 0, + y: 60, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 106.7529296875, + }, + ], + ApplyModifiers: [ + { + name: 'ApplyModifiers', + detail: 'modifier 属性更新', + end: 512062142871076, + begin: 512062142186180, + depth: 3, + instructions: 0, + cycles: 10, + frame: { + x: 0, + y: 60, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 163.3154296875, + }, + ], + }, + detail: 'Tree同步&预处理', + depth: 1, + name: 'unknown-1', + parentName: 'OnReadable', + property: [ + { + name: 'unknown-1', + detail: 'Tree同步&预处理', + begin: 512065467744513, + end: 512065468112742, + depth: 1, + frame: { + x: 156, + y: 20, + width: 1, + height: 20, + }, + startTs: 512062138606492, + textMetricsWidth: 139.736328125, + }, + ], + instructions: 7, + cycles: 9, + hoverInstructions: 7, + hoverCycles: 8, + frame: { + x: 0, + y: 30, + width: 106, + height: 30, + }, + textMetricsWidth: 139.736328125, + }, + ], + }; + it('TabPaneSampleInstructionTotalTime test01', () => { + tab.data = SelectionParam; + expect(tab.initHtml()).not.toBeUndefined(); + expect(tab.initElements()).toBeUndefined(); + expect(tab.onMouseMove()).toBeUndefined(); + expect(tab.hideTip()).toBeUndefined(); + expect(tab.showTip()).toBeUndefined(); + expect(tab.updateTipContent()).toBeUndefined(); + expect(tab.calInstructionRangeCount()).toBeUndefined(); + expect(tab.drawLineLabelMarkers(100, 100)).toBeUndefined(); + expect(tab.drawLine(100, 20, 30, 40)).toBeUndefined(); + expect(tab.drawMarkers(100, 20)).toBeUndefined(); + expect(tab.drawRect(0, 10, 20, 30)).toBeUndefined(); + }); + + it('TabPaneSampleInstructionTotalTime test02', () => { + const mockFn = jest.fn(); + tab.calInstructionRangeCount = mockFn; + tab.data = SelectionParam; + expect(mockFn).toHaveBeenCalled(); + }); + + it('TabPaneSampleInstructionTotalTime test03', () => { + const mockFn = jest.fn(); + tab.isContains = mockFn; + const nodes = [ + { + instruct: '10.5', + x: 836.5, + y: 183.23000000000002, + height: 81.77, + heightPer: 0.056, + }, + { + instruct: '10.8', + x: 859, + y: 183.23000000000002, + height: 81.77, + heightPer: 0.056, + }, + ]; + tab.searchDataByCoord(nodes, 471, 251); + expect(mockFn).toHaveBeenCalledTimes(2); + }); + + it('TabPaneSampleInstructionTotalTime test04', () => { + const nodes = [ + { + instruct: '10.5', + x: 890, + y: 183.23000000000002, + height: 81.77, + heightPer: 0.056, + }, + { + instruct: '10.8', + x: 800, + y: 183.23000000000002, + height: 81.77, + heightPer: 0.056, + }, + ]; + expect(tab.searchDataByCoord(nodes, 471, 251)).toBeNull(); + }); + + it('TabPaneSampleInstructionTotalTime test05', () => { + const nodes = [ + { + instruct: '10.5', + x: 890, + y: 180, + height: 100, + heightPer: 0.056, + }, + ]; + expect(tab.searchDataByCoord(nodes, 891, 251)).not.toBeUndefined(); + }); + + it('TabPaneSampleInstructionTotalTime test06', () => { + const mockFn = jest.fn(); + tab.drawBar = mockFn; + SelectionParam.sampleData[0].property = []; + tab.data = SelectionParam; + tab.calInstructionRangeCount(); + expect(mockFn).not.toHaveBeenCalled(); + }); + + it('TabPaneSampleInstructionTotalTime test07', () => { + const mockDrawLine = jest.fn(); + tab.drawLine = mockDrawLine; + const mockDdrawMarkers = jest.fn(); + tab.drawMarkers = mockDdrawMarkers; + tab.initElements() + tab.drawLineLabelMarkers(100,100); + expect(mockDrawLine).toHaveBeenCalled(); + expect(mockDdrawMarkers).toHaveBeenCalled(); + }); +}); diff --git a/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts b/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts index b8a222735754c79dc63a044a8f89464393a007bd..60ab7cedb5f3cc0f48970c229671dad3285aca60 100644 --- a/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts +++ b/ide/test/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch.test.ts @@ -14,22 +14,34 @@ */ import '../../../../../../src/base-ui/table/lit-table'; +import '../../../../../../src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch'; import { TabPaneSchedSwitch } from '../../../../../../src/trace/component/trace/sheet/schedswitch/TabPaneSchedSwitch'; +import { SpSegmentationChart } from '../../../../../../src/trace/component/chart/SpSegmentationChart'; +import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; +import { TraceRow } from '../../../../../../src/trace/component/trace/base/TraceRow'; +import { CpuFreqExtendStruct } from '../../../../../../src/trace/database/ui-worker/ProcedureWorkerFreqExtend'; +import { Utils } from '../../../../../../src/trace/component/trace/base/Utils'; 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'); +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/TraceSheet', () => { + return {}; +}); +// @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('TabPaneSchedSwitch Test', () => { let threadStatesParam = { @@ -87,12 +99,26 @@ describe('TabPaneSchedSwitch Test', () => { } ]; loopCut.mockResolvedValue(loopCutData); - + Utils.PROCESS_MAP.set(15, ''); + Utils.THREAD_MAP.set(589, ''); let tabPaneSchedSwitch = new TabPaneSchedSwitch(); - tabPaneSchedSwitch.schedSwitchTbl = jest.fn(() => { - return new LitTable(); - }); + tabPaneSchedSwitch.schedSwitchTbl.exportProgress = { + loading: '' + } + tabPaneSchedSwitch.chartTotal.offset = jest.fn(() => ({ x: 60, y: 20 })); + tabPaneSchedSwitch.selectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0 + }; + SpSegmentationChart.trace = new SpSystemTrace(); + SpSegmentationChart.schedRow = new TraceRow(); + tabPaneSchedSwitch.clickTableLabel = jest.fn(); it('TabPaneSchedSwitchTest01', function () { + let htmlDivElement = document.createElement('div'); + htmlDivElement.appendChild(tabPaneSchedSwitch); + SpSegmentationChart.setChartData = jest.fn(); + SpSegmentationChart.tabHover = jest.fn(); tabPaneSchedSwitch.data = threadStatesParam; expect(tabPaneSchedSwitch.schedSwitchTbl.loading).toBeFalsy(); }); @@ -122,8 +148,6 @@ describe('TabPaneSchedSwitch Test', () => { cancelable: true, detail: {data: data} }); - tabPaneSchedSwitch.schedSwitchTbl.clearAllSelection = jest.fn(); - tabPaneSchedSwitch.schedSwitchTbl.setCurrentSelection = jest.fn(); tabPaneSchedSwitch.clickTreeRowEvent(customEvent); expect(tabPaneSchedSwitch.cycleALeftInput.value).toEqual(''); }); @@ -136,56 +160,102 @@ describe('TabPaneSchedSwitch Test', () => { let thirdInput = document.createElement('input'); let fourInput = document.createElement('input'); tabPaneSchedSwitch.checkInputRangeFn(firstInput, secondInput, thirdInput, fourInput, '2', '36'); - expect(tabPaneSchedSwitch.getAttribute('isQueryButton')).toEqual(''); + expect(tabPaneSchedSwitch.getAttribute('query-button')).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(''); + expect(tabPaneSchedSwitch.getAttribute('isSingleButton')).toBeNull(); }); it('TabPaneSchedSwitchTest07', function () { - tabPaneSchedSwitch.data = threadStatesParam; tabPaneSchedSwitch.threadIdInput.value = '12'; tabPaneSchedSwitch.funcNameInput.value = 'name'; tabPaneSchedSwitch.queryCutInfoFn('Loop'); - expect(tabPaneSchedSwitch.getAttribute('isLoopButton')).toEqual(''); + expect(tabPaneSchedSwitch.getAttribute('isLoopButton')).toBeNull(); }); 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(); + 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, '36', '2'); + expect(tabPaneSchedSwitch.queryButton.style.pointerEvents).toEqual('none'); }); it('TabPaneSchedSwitchTest09', function () { - let data = [{ + let firstInput = document.createElement('input'); + firstInput.value = ''; + let secondInput = document.createElement('input'); + secondInput.value = '22'; + let thirdInput = document.createElement('input'); + let fourInput = document.createElement('input'); + tabPaneSchedSwitch.checkInputRangeFn(firstInput, secondInput, thirdInput, fourInput, '36', '2'); + expect(tabPaneSchedSwitch.queryButton.style.pointerEvents).toEqual('none'); + }); + + it('TabPaneSchedSwitchTest10', function () { + let firstInput = document.createElement('input'); + firstInput.value = ''; + let secondInput = document.createElement('input'); + secondInput.value = ''; + let thirdInput = document.createElement('input'); + thirdInput.value = 'third'; + let fourInput = document.createElement('input'); + fourInput.value = 'four'; + tabPaneSchedSwitch.checkInputRangeFn(firstInput, secondInput, thirdInput, fourInput, '36', '2'); + expect(tabPaneSchedSwitch.queryButton.style.pointerEvents).toEqual('auto'); + }); + + it('TabPaneSchedSwitchTest11', function () { + let firstInput = document.createElement('input'); + firstInput.value = ''; + let secondInput = document.createElement('input'); + secondInput.value = ''; + let thirdInput = document.createElement('input'); + thirdInput.value = ''; + let fourInput = document.createElement('input'); + fourInput.value = 'four'; + tabPaneSchedSwitch.checkInputRangeFn(firstInput, secondInput, thirdInput, fourInput, '36', '2'); + expect(tabPaneSchedSwitch.queryButton.style.pointerEvents).toEqual('none'); + }); + + it('TabPaneSchedSwitchTest12', function () { + let data = { + title: 'title', + count: 6, + cycleNum: 1, + state: 'state', + tid: 122, + pid: 58, + thread: 'thread', + process: 'process', + cycleStartTime: 254, + duration: 2573, + level: 'process', + children: [], + }; + let customEvent = new CustomEvent('click', { + bubbles: true, + cancelable: true, + detail: {data: data} + }); + tabPaneSchedSwitch.clickTreeRowEvent(customEvent); + expect(tabPaneSchedSwitch.cycleALeftInput.value).toEqual(''); + }); + + it('TabPaneSchedSwitchTest12', function () { + let data = { title: 'title', count: 6, cycleNum: 1, @@ -198,7 +268,13 @@ describe('TabPaneSchedSwitch Test', () => { duration: 2573, level: 'cycle', children: [], - }]; - expect(tabPaneSchedSwitch.clickTreeTitleFn(data)).toBeUndefined(); + }; + let customEvent = new CustomEvent('click', { + bubbles: true, + cancelable: true, + detail: {data: data} + }); + tabPaneSchedSwitch.clickTreeRowEvent(customEvent); + expect(tabPaneSchedSwitch.cycleALeftInput.value).toEqual(''); }); }); 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..c382972be9a61dbf07cb4ab60a2c8d2b75eb989b 100644 --- a/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts +++ b/ide/test/trace/component/trace/sheet/sdk/TabPaneSdkCounter.test.ts @@ -18,7 +18,8 @@ import '../../../../../../src/trace/component/trace/sheet/sdk/TabPaneSdkCounter' import { SpSystemTrace } from '../../../../../../src/trace/component/SpSystemTrace'; import { LitTable } from '../../../../../../src/base-ui/table/lit-table'; -import {TabUtil} from "../../../../../../src/trace/component/trace/sheet/sdk/TabUtil.js"; +import {TabUtil} from '../../../../../../src/trace/component/trace/sheet/sdk/TabUtil'; +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/states/TabPaneFreqStatesDataCut.test.ts b/ide/test/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c2783e8a1a17bfee5b389a34bab77149c081fbd --- /dev/null +++ b/ide/test/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut.test.ts @@ -0,0 +1,318 @@ +/* + * 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 { + TabPaneFreqStatesDataCut +} from '../../../../../../src/trace/component/trace/sheet/states/TabPaneFreqStatesDataCut'; +import { StateGroup } from '../../../../../../src/trace/bean/StateModle'; +jest.mock('../../../../../../src/trace/component/trace/base/TraceSheet', () => { + return { + systemLogFlag: { + } + }; +}); +jest.mock('../../../../../../src/trace/component/chart/SpSegmentationChart', () => { + return { + statesRow: { + dataList: [] + }, + SpSegmentationChart: { + setStateChartData: ()=>{} + } + }; +}); +import '../../../../../../src/trace/component/trace/base/TraceSheet'; +import { TraceSheet } from '../../../../../../src/trace/component/trace/base/TraceSheet'; +const funSqlite = require('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/trace/database/sql/Func.sql'); +jest.mock('../../../../../../src/base-ui/table/lit-table', () => { + return { + snapshotDataSource: () => { + }, + removeAttribute: () => { + }, + }; +}); + +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 {}; +}); +// @ts-ignore +window.ResizeObserver = + window.ResizeObserver || + jest.fn().mockImplementation(() => ({ + disconnect: jest.fn(), + observe: jest.fn(), + unobserve: jest.fn(), + })); + +describe('TabPaneFreqStatesDataCut Test', () => { + let tabPaneFreqStatesDataCut = new TabPaneFreqStatesDataCut(); + tabPaneFreqStatesDataCut.theadClick = jest.fn(); + let htmlElement = document.createElement('trace-sheet') as TraceSheet; + tabPaneFreqStatesDataCut.initTabSheetEl(htmlElement); + let threadDataMock = [ + new StateGroup('pid1', 'tid1', 'R', 100), + new StateGroup('pid1', 'tid2', 'Running', 200), + new StateGroup('pid1', 'tid3', 'S', 300), + new StateGroup('pid1', 'tid4', 'D', 400), + new StateGroup('pid2', 'tid5', 'R', 500), + ]; + + let statesCut = funSqlite.queryStatesCut; + statesCut.mockResolvedValue([{ + ts: 10, + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '', + state: 'S' + },{ + ts: 10, + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '', + state: 'Running' + },{ + ts: 10, + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '', + state: 'R' + },{ + ts: 10, + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '', + state: 'D' + },{ + ts: 10, + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '', + state: 'Running' + }]); + + let loopFuncNameCycle = funSqlite.queryLoopFuncNameCycle; + loopFuncNameCycle.mockResolvedValue([{ + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + endTime: 20000, + tid: 2, + pid: 2, + type: '' + }]); + + let singleFuncNameCycleStates = funSqlite.querySingleFuncNameCycleStates; + singleFuncNameCycleStates.mockResolvedValue([{ + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + tid: 2, + pid: 2, + type: '', + cycleStartTime: 100, + endTime: 2000, + }, + { + depth: 1, + dur: 1000, + funName: '', + id: 1, + startTime: 10, + tid: 2, + pid: 2, + type: '', + cycleStartTime: 2000, + endTime: 5000, + }]); + + it('TabPaneFreqStatesDataCutTest01 ', function () { + tabPaneFreqStatesDataCut.data = {threadId: '123', cycleName: 'Cycle1'}; + expect(tabPaneFreqStatesDataCut.currentSelectionParam).toEqual({threadId: '123', cycleName: 'Cycle1'}); + }); + it('TabPaneFreqStatesDataCutTest02', () => { + let filterState = [ + {pid: 1, state: 'R'}, + {pid: 2, state: 'D'}, + {pid: 1, state: 'Running'}, + ]; + tabPaneFreqStatesDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0, + processIds: [1, 2, 1, 1], + threadIds: ['tid1', 'tid2', 'tid3', 'tid4'] + }; + let processId = 1; + let stateCutArr = []; + let expectedResult = new StateGroup(); + expectedResult.totalCount = 2; + expectedResult.RunnableCount = 1; + expectedResult.RunningCount = 1; + expectedResult.DCount = 0; + expectedResult.SleepingCount = 0; + expectedResult.title = 'Process1'; + expectedResult.pid = 1; + expectedResult.type = 'process'; + expectedResult.children = []; + tabPaneFreqStatesDataCut.setProcessData(filterState, processId, stateCutArr); + expect(stateCutArr).toHaveLength(1); + expect(stateCutArr[0]).toEqual(expectedResult); + }); + it('TabPaneFreqStatesDataCutTest03 ', function () { + tabPaneFreqStatesDataCut.currentSelectionParam = { + processIds: [1, 2, 1, 1], + threadIds: ['tid1', 'tid2', 'tid3', 'tid4'] + }; + const result = tabPaneFreqStatesDataCut.setThreadData(threadDataMock); + expect(result).toEqual([]); + }); + it('TabPaneFreqStatesDataCutTest04 ', function () { + let mockStateGroupArr; + let mockFuncNameCycleArr; + mockStateGroupArr = [ + {ts: 100, dur: 50, state: 'R'}, + {ts: 200, dur: 70, state: 'S'}, + {ts: 300, dur: 80, state: 'Running'}, + {ts: 400, dur: 60, state: 'D'}, + ]; + mockFuncNameCycleArr = [ + {cycleStartTime: 100, endTime: 150}, + {cycleStartTime: 200, endTime: 250}, + ]; + tabPaneFreqStatesDataCut.funcNameCycleArr = mockFuncNameCycleArr; + const result = tabPaneFreqStatesDataCut.setCycleData(mockStateGroupArr); + expect(result).toHaveLength(mockFuncNameCycleArr.length); + }); + + it('TabPaneFreqStatesDataCutTest05 ', function () { + let itemClick = new CustomEvent('click', { + detail: { + ...{}, + data: {}, + }, + composed: true, + }); + let itemClick1 = new CustomEvent('click', { + detail: { + ...{}, + data: {}, + }, + composed: true, + }); + let itemMouseout = new CustomEvent('mouseout', { + detail: { + ...{}, + data: {}, + }, + composed: true, + }); + let itemRowClick = new CustomEvent('row-click', { + detail: { + ...{}, + data: {}, + } + }); + tabPaneFreqStatesDataCut.threadStatesDIV?.children[2].children[0].dispatchEvent(itemClick); + tabPaneFreqStatesDataCut.threadStatesDIV?.children[2].children[1].dispatchEvent(itemClick1); + + tabPaneFreqStatesDataCut.threadBindersTbl!.dispatchEvent(itemMouseout); + tabPaneFreqStatesDataCut.threadBindersTbl!.dispatchEvent(itemRowClick); + + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + tabPaneFreqStatesDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0, + processIds: [1, 2, 1, 1], + threadIds: ['tid1', 'tid2', 'tid3', 'tid4'] + } + threadIdDiv.value = '1'; + threadFuncDiv.value = '2'; + tabPaneFreqStatesDataCut.threadBindersTbl.exportProgress = { + loading: '' + } + expect(tabPaneFreqStatesDataCut.dataLoopCut(threadIdDiv, threadFuncDiv)).resolves.toBeUndefined(); + }); + + it('TabPaneFreqStatesDataCutTest06 ', function () { + let threadIdDiv = document.createElement('div') as HTMLInputElement; + let threadFuncDiv = document.createElement('div') as HTMLInputElement; + tabPaneFreqStatesDataCut.currentSelectionParam = { + rightNs: 1000, + recordStartNs: 200, + leftNs: 0, + processIds: [1, 2, 1, 1], + threadIds: ['tid1', 'tid2', 'tid3', 'tid4'] + } + threadIdDiv.value = '1'; + threadFuncDiv.value = '2'; + tabPaneFreqStatesDataCut.funcNameCycleArr = [{ + funcName: '', + cycleStartTime: 0, + cycleDur: 0, + startTime: 0, + endTime: 0, + id: 0, + tid: 0, + pid: 0 + }] + tabPaneFreqStatesDataCut.dataSingleCut(threadIdDiv, threadFuncDiv) + }); + +}); 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..25f10d33501f5d130993ebaa77afcea0c35fb8d0 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,27 +216,16 @@ 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); + let htmlElement: any = document.createElement('sp-system-trace'); rangeRuler.centerXPercentage = jest.fn(() => -1); expect( rangeRuler.mouseMove({ key: '', - }, new SpSystemTrace()) + }, htmlElement) ).toBeUndefined(); }); 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 +253,6 @@ describe('RangeRuler Test', () => { expect(mark.isHover).toBeTruthy(); }); it('RangeRulerTest19', function () { - rangeRuler.clearRect = jest.fn(() => true); expect(rangeRuler.draw()).toBeUndefined(); }); @@ -291,15 +265,113 @@ describe('RangeRuler Test', () => { expect(rangeRuler.delayDraw()).toBeUndefined(); }); it('RangeRulerTest26', function () { - expect(rangeRuler.keyPressF()).toBeUndefined(); + let frameCallback: any; + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyPressF(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyPressW(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyPressS(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyPressA(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyPressD(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyUpW(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyUpS(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyUpA(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyUpEnd(); + if (frameCallback) { + frameCallback(); + } + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.keyUpD(); + if (frameCallback) { + frameCallback(); + } + expect(rangeRuler.getScale()).toBe(50) }); it('RangeRulerTest27', function () { - expect(rangeRuler.zoomFit('100', '200')).toBeUndefined(); + expect(mark.draw()).toBeUndefined(); }); it('RangeRulerTest28', function () { - expect(Mark.draw).toBeUndefined(); + expect(rangeRuler.drawSelectionRange()).toBeUndefined(); }); it('RangeRulerTest29', function () { - expect(rangeRuler.drawSelectionRange()).toBeUndefined(); + expect(rangeRuler.translate(100)).toBeUndefined(); + }); + + it('RangeRulerTest30', function () { + rangeRuler.isMovingRange = false; + rangeRuler.handleMovingFresh(10, 20); + + let frameCallback: any; + global.requestAnimationFrame = (callback) => { + frameCallback = callback; + return 0; + }; + rangeRuler.scale = 100; + rangeRuler.keyPressW(); + if (frameCallback) { + frameCallback(); + } + expect(rangeRuler.getScale()).toBe(100); }); }); 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..40281ffd068ff34533fb49b75ed07b35ac767355 --- /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(); + }); + }); +}); 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..30cb205fa62c1118e2b100720caad795bb6829fc --- /dev/null +++ b/ide/test/trace/database/data-trafic/ClockDataSender.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 { 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', () => ({})); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => ({})); +describe('ClockDataSender Test', () => { + const clockData = { + filterId: 89, + value: 48000, + startNS: 19733, + dur: 230475, + type: 'measure', + delta: 0, + frame: { + y: 5, + height: 30, + x: 11, + width: 14 + } + }; + let clockTraceRow = TraceRow.skeleton(); + it('ClockDataSenderTest01', async () => { + threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => { + callback(clockData, 1, true); + }); + let result = await clockDataSender('', 'screenState', clockTraceRow); + 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..56f4bd7706d1f3f8817b1455aa5e9056af3ec260 --- /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); + }); + }); +}); 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..9bc8d3f3e31c3de8073e4aa4cfd7b1b0eef79010 --- /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'; +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); + }); + }); +}); 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..ea06a60fdddf6d5c3b6dc316db283b339e30b505 --- /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); + }); + }); +}); 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..ccb529ac7a057be167681c7a89d60e249b476927 --- /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'; + +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([]); + }); +}); 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..93dbd48865b72abed8ca4818032101611fa3982c --- /dev/null +++ b/ide/test/trace/database/data-trafic/cpu/CpuFreqLimitDataSender.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 { 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: 122, + 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, 1, true); + }); + let CpuFreqLimitDataTraceRow = TraceRow.skeleton(); + let maxId = 0; + let minId = 0; + 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..a35a3940b446da28f6c0f0d5f15a3cabc627d9bb --- /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', async () => { + 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); + }); + }); +}); 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/trace/database/data-trafic/process/ProcessSoInitDataReceiver.test.ts b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataReceiver.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..9292b503718eaf0dfdcf6d342f3775ae05cb51e1 --- /dev/null +++ b/ide/test/trace/database/data-trafic/process/ProcessSoInitDataReceiver.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 { + 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 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..cc1c1d897fc4b2f82be3e0088a3fa62aeb24cf6b 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerAppStartup.test.ts @@ -13,15 +13,20 @@ * 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, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerAppStartup'; + 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('ProcedureWorkerAppStartup Test', () => { it('AppStartupStructTest01', () => { const data = { @@ -55,15 +60,50 @@ 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, + it('AppStartupStructTest04 ', function () { + let appStartupRender = new AppStartupRender(); + let appStartReq = { + 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, + 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), + }, + isHover: 'true', + hoverX: 0, + params: '', + wakeupBean: undefined, + flagMoveInfo: '', + flagSelectedInfo: '', + slicesTime: 4, + id: 1, + x: 24, + y: 24, + width: 100, + height: 100, }; - let appStartupRender = new AppStartupRender(); - expect(appStartupRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + expect(appStartupRender.renderMainThread(appStartReq, new TraceRow())).toBeUndefined(); }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerBinder.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerBinder.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..5663c53d9cbd8c6cf8b3586c93aef1afbbe74d7c --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerBinder.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 { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; + +import { BinderRender, BinderStruct } from '../../../../src/trace/database/ui-worker/procedureWorkerBinder'; + +jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); +describe('Binder Test', () => { + const canvas = document.createElement('canvas'); + canvas.width = 10; + canvas.height = 10; + const ctx = canvas.getContext('2d'); + it('BinderTest01 ', function () { + const data = { + frame: { + x: 210, + y: 209, + width: 111, + height: 100, + }, + name: 'binder transaction', + cycle: -1, + value: 0, + depth: 0 + }; + expect(BinderStruct.draw(ctx, data)).toBeUndefined(); + }); + it('BinderTest02', () => { + const data = { + context: ctx!, + useCache: true, + type: '', + traceRange: [], + }; + let binderRender = new BinderRender(); + expect(binderRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); +}); \ No newline at end of file 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..5c1d43e192845fd37442e7bb67ad9cbb90057b8f 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerClock.test.ts @@ -19,7 +19,12 @@ jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); import { ClockStruct, ClockRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerClock'; - +jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => { + return {}; +}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { + return {}; +}); describe('ProcedureWorkerClock Test', () => { it('ProcedureWorkerClock01', () => { const canvas = document.createElement('canvas'); @@ -42,16 +47,51 @@ 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, + it('ProcedureWorkerClock02 ', function () { + let clockRender = new ClockRender(); + let clockReq = { + lazyRefresh: true, type: '', - traceRange: [], + startNS: 5, + endNS: 9, + totalNS: 3, + frame: { + x: 32, + y: 18, + width: 180, + height: 180, + }, + useCache: true, + range: { + refresh: '', + }, + canvas: 'b', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.6, + 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, }; - let clockRender = new ClockRender(); - expect(clockRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + expect(clockRender.renderMainThread(clockReq,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..fc64f2cd1dbde4ad746fa40327db3b11358819ba 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, @@ -137,4 +141,26 @@ describe('CpuAbilityMonitorStruct Test', () => { window.postMessage = jest.fn(() => true); expect(cpuAbilityRender.renderMainThread(data, new TraceRow())).toBeUndefined(); }); + it('CpuAbilityMonitorStructTest08 ', function () { + let cpuAbilityNode = { + frame: { + x: 9, + y: 87, + width: 878, + height: 80, + }, + startNS: 700, + length: 135, + height: 40, + startTime: 450, + dur: 9, + }; + let frame = { + x: 2, + y: 4, + width: 87, + height: 80, + }; + expect(CpuAbilityMonitorStruct.setCpuAbilityFrame(cpuAbilityNode, 1, 1, 1, 1, frame)).toBeUndefined(); + }); }); 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..fd3c2027df53f001d03360f7768da91dd06b289a 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerCpuProfiler.test.ts @@ -23,25 +23,27 @@ 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(); - traceRow.frame = { height: 40, width: 1407, x: 0, y: 0 }; + traceRow.frame = {height: 40, width: 1407, x: 0, y: 0}; it('jsCpuProfilerTest', () => { const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; const ctx = canvas.getContext('2d'); let traceRow = new TraceRow(); - traceRow.frame = { height: 40, width: 1407, x: 0, y: 0 }; + traceRow.frame = {height: 40, width: 1407, x: 0, y: 0}; let rect = new Rect(0, 10, 10, 10); let filter = [ { startTime: 50, endTime: 1520000, name: 'Snapshot2', - frame: { x: 0, y: 0, width: 25, height: 40 }, + frame: {x: 0, y: 0, width: 25, height: 40}, id: 0, depth: 1, selfTime: 0, @@ -57,7 +59,7 @@ describe('ProcedureWorkerCpuProfiler Test', () => { startTime: 250, endTime: 2333333, name: 'Snapshot0', - frame: { x: 0, y: 0, width: 25, height: 20 }, + frame: {x: 0, y: 0, width: 25, height: 20}, id: 32, depth: 21, selfTime: 34, @@ -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; @@ -99,7 +101,7 @@ describe('ProcedureWorkerCpuProfiler Test', () => { startTime: 150, endTime: 122000, name: 'Snapshot1', - frame: { x: 1, y: 2, width: 25, height: 40 }, + frame: {x: 1, y: 2, width: 25, height: 40}, id: 12, depth: 1, selfTime: 1243, @@ -114,4 +116,19 @@ describe('ProcedureWorkerCpuProfiler Test', () => { it('JsCpuProfilerStructTest04', () => { expect(JsCpuProfilerStruct).not.toBeUndefined(); }); + it('JsCpuProfilerStructTest05 ', function () { + let jsCpuProfilerRender = new JsCpuProfilerRender(); + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: true, + type: '', + traceRange: [], + }; + window.postMessage = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(jsCpuProfilerRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); }); 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/ProcedureWorkerEBPF.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEBPF.test.ts index 995f1e55e40f6e29377f8992f58048e42daa0e7d..d5350189705ed85141485bdc4b04e882f42cf7df 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEBPF.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEBPF.test.ts @@ -12,16 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { eBPFChart, - EBPFChartStruct, + EBPFChartStruct, EBPFRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEBPF'; - +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerFileSystem Test', () => { it('ProcedureWorkerFileSystemTest01', function () { let frame = { @@ -46,8 +47,8 @@ describe('ProcedureWorkerFileSystem Test', () => { it('ProcedureWorkerFileSystemTest03', function () { let frame = { x: 40, - y: 24, width: 440, + y: 24, height: 500, }; let fileSystemDataList = new Array(); @@ -135,4 +136,49 @@ describe('ProcedureWorkerFileSystem Test', () => { { dur: 0, group10Ms: false, height: 0, size: 0, startNS: 10 }, ]); }); + it('ProcedureWorkerFileSystemTest07 ', function () { + let eBPFRender = new EBPFRender(); + let eBPFReq = { + lazyRefresh: true, + type: '', + startNS: 2, + endNS: 3, + totalNS: 1, + frame: { + x: 11, + y: 11, + width: 70, + height: 90, + }, + useCache: false, + range: { + refresh: 'refresh', + }, + canvas: '', + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0, + 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), + }, + isHover: '', + hoverX: 0, + params: '', + wakeupBean: undefined, + id: 1, + x: 12, + y: 11, + width: 102, + height: 102, + }; + window.postMessage = jest.fn(() => true); + expect(eBPFRender.renderMainThread(eBPFReq,new TraceRow())).toBeUndefined() + expect(eBPFRender.render(eBPFReq,[],[])).toBeUndefined() + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts index 8e0785174d14d7c3361d25eead355d9795105686..7337e796caaa4362b0745b28a48aad29481716cb 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly.test.ts @@ -13,9 +13,7 @@ * limitations under the License. */ -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { anomaly, @@ -23,6 +21,15 @@ import { EnergyAnomalyRender, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerEnergyAnomaly'; +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 {}; +}); describe('ProcedureWorkerEnergyAnomaly Test', () => { it('ProcedureWorkerEnergyAnomalyTest01', function () { let frame = { @@ -36,10 +43,10 @@ describe('ProcedureWorkerEnergyAnomaly Test', () => { startNS: 111, dur: 40, length: 23, - frame: { x: 0, y: 29, width: 22, height: 101 }, + frame: {x: 0, y: 29, width: 22, height: 101}, }); - energyAnomalyDataList.push({ startNS: 11, dur: 21, length: 10 }); - anomaly(energyAnomalyDataList, [{ length: 1 }], 1, 3, 2, frame, '', true); + energyAnomalyDataList.push({startNS: 11, dur: 21, length: 10}); + anomaly(energyAnomalyDataList, [{length: 1}], 1, 3, 2, frame, '', true); }); it('ProcedureWorkerEnergyAnomalyTest02', function () { @@ -54,10 +61,10 @@ describe('ProcedureWorkerEnergyAnomaly Test', () => { startNS: 22, dur: 30, length: 25, - frame: { x: 0, y: 19, width: 32, height: 102 }, + frame: {x: 0, y: 19, width: 32, height: 102}, }); - energyAnomalyDataList.push({ startNS: 12, dur: 22, length: 12 }); - anomaly(energyAnomalyDataList, [{ length: 0 }], 1, 3, 2, frame, '', false); + energyAnomalyDataList.push({startNS: 12, dur: 22, length: 12}); + anomaly(energyAnomalyDataList, [{length: 0}], 1, 3, 2, frame, '', false); }); it('ProcedureWorkerEnergyAnomalyTest03', function () { @@ -175,4 +182,51 @@ describe('ProcedureWorkerEnergyAnomaly Test', () => { window.postMessage = jest.fn(() => true); expect(energyAnomalyRender.render(energyAnomalyReq, [], [])).toBeUndefined(); }); + it('ProcedureWorkerEnergyAnomalyTest07 ', function () { + let req; + let row; + let dataList; + let dataListCache; + let context; + let spApplication; + req = { + useCache: true, + context: { + font: '13px sans-serif', + fillStyle: '#e00f55', + globalAlpha: 0.4, + canvas: { + clientWidth: 12, + }, + clearRect: jest.fn(() => true), + closePath: jest.fn(() => true), + measureText: jest.fn(() => false), + fillRect: jest.fn(() => true), + beginPath: jest.fn(() => true), + stroke: jest.fn(() => true), + fillText: jest.fn(() => true), + }, + type: 'testType', + appName: 'testAppName', + canvasWidth: 800, + }; + dataList = []; + dataListCache = []; + row = { + dataList: dataList, + dataListCache: dataListCache, + frame: 'testFrame', + isHover: true, + hoverX: 100, + hoverY: 100, + }; + spApplication = { + hasAttribute: jest.fn().mockReturnValue(true), + }; + let energyAnomalyRender = new EnergyAnomalyRender(); + global.document.getElementsByTagName = jest.fn().mockReturnValue([spApplication]); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); + expect(energyAnomalyRender.renderMainThread(req, row)).toBeUndefined(); + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerEnergyPower.test.ts index 582678d2b17260f7756b6c27d9f72dac2b12b561..90d423716165a7b3f2f68452ff9007315407dd2c 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, @@ -50,9 +57,13 @@ describe('ProcedureWorkerEnergyPower Test', () => { height: 100, }, }; - let row = { frame: 20 }; + 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, @@ -198,13 +157,13 @@ describe('ProcedureWorkerEnergyPower Test', () => { startNS: 0, dur: 90, length: 16, - frame: { x: 0, y: 9, width: 20, height: 12 }, + frame: {x: 0, y: 9, width: 20, height: 12}, }); - energyPowerDataList.push({ startNS: 71, dur: 32, length: 12 }); - power(energyPowerDataList, [{ length: 1 }], 1, 3, 2, frame, true, ''); + energyPowerDataList.push({startNS: 71, dur: 32, length: 12}); + power(energyPowerDataList, [{length: 1}], 1, 3, 2, frame, true, ''); }); - it('ProcedureWorkerEnergyPowerTest16', function () { + it('ProcedureWorkerEnergyPowerTest15', function () { let frame = { x: 98, y: 90, @@ -216,9 +175,62 @@ describe('ProcedureWorkerEnergyPower Test', () => { startNS: 0, dur: 50, length: 67, - frame: { x: 0, y: 9, width: 60, height: 60 }, + frame: {x: 0, y: 9, width: 60, height: 60}, }); - energyPowerDataList.push({ startNS: 12, dur: 82, length: 16 }); - power(energyPowerDataList, [{ length: 0 }], 1, 3, 2, frame, false, ''); + energyPowerDataList.push({startNS: 12, dur: 82, length: 16}); + power(energyPowerDataList, [{length: 0}], 1, 3, 2, frame, false, ''); + }); + it('ProcedureWorkerEnergyPowerTest16 ', function () { + let energyPowerRender = new EnergyPowerRender(); + let powerReq = { + lazyRefresh: true, + type: '', + startNS: 2, + endNS: 3, + totalNS: 1, + frame: { + x: 11, + y: 11, + width: 77, + height: 90, + }, + useCache: false, + range: { + refresh: 'refresh', + }, + canvas: { + clientWidth: 1 + }, + context: { + font: '12px sans-serif', + fillStyle: '#a1696d', + globalAlpha: 1, + beginPath: jest.fn(() => true), + measureText: jest.fn(() => true), + clearRect: jest.fn(() => true), + stroke: jest.fn(() => true), + closePath: jest.fn(() => false), + fillRect: jest.fn(() => false), + fillText: jest.fn(() => true), + canvas: { + clientWidth: 1 + }, + }, + isHover: '', + hoverX: 0, + x: 10, + y: 8, + width: 102, + height: 102, + }; + let spApplication; + spApplication = { + hasAttribute: jest.fn().mockReturnValue(true), + }; + global.document.getElementsByTagName = jest.fn().mockReturnValue([spApplication]); + window.postMessage = jest.fn(() => true); + TraceRow.range = jest.fn(() => true); + TraceRow.range!.startNS = jest.fn(() => 0); + expect(energyPowerRender.renderMainThread(powerReq, new TraceRow())).toBeUndefined(); }); }); 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..e020d722964bfc49408275f03fe2aa5777a78f43 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); @@ -79,4 +82,52 @@ describe('FrameAnimation Test', () => { }; expect(FrameAnimationStruct.draw(ctx!, 1, node, TraceRow.skeleton())).toBeUndefined(); }); + it('FrameAnimationTest02 ', function () { + let frameAnimationRender = new FrameAnimationRender(); + let frameAnimationReq = { + 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(frameAnimationRender.renderMainThread(frameAnimationReq,new TraceRow())).toBeUndefined() + }); }); 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..55b44abb68082c300680883e592fb432b623c023 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 () { @@ -125,4 +127,7 @@ describe('FrameSpacing Test', () => { }; expect(frameSpacingRender.drawPoint(ctx, currentStruct, TraceRow.skeleton(), 0, 20)).toBeUndefined(); }); + it('FrameSpacingTest04 ', function () { + expect(frameSpacingRender.renderMainThread(req,new TraceRow())).toBeUndefined() + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts index 9629dc53b04eee0b339057ae9122af7946ae53cf..9ea37ae7253e33fa80c6d32b202c2b4dd0592357 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFreq.test.ts @@ -18,9 +18,11 @@ import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { return {}; }); -import { CpuFreqStruct, FreqRender, freq } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFreq'; -import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; +import { CpuFreqStruct, FreqRender } from '../../../../src/trace/database/ui-worker/ProcedureWorkerFreq'; +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..9279a70f27bbf96e635a0f156f327a6bec2eaa10 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerFunc.test.ts @@ -12,24 +12,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - +import { TraceRow } from '../../../../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/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe(' ProcedureWorkerFuncTest', () => { it('FuncTest01', () => { let funcDataList = new Array(); funcDataList.push({ startTime: 10, dur: 410, - frame: { x: 0, y: 9, width: 10, height: 10 }, + frame: {x: 0, y: 9, width: 10, height: 10}, }); - funcDataList.push({ startTime: 17, dur: 141 }); + funcDataList.push({startTime: 17, dur: 141}); let rect = new Rect(0, 30, 30, 30); let res = [ { @@ -39,7 +41,7 @@ describe(' ProcedureWorkerFuncTest', () => { frame: '', }, ]; - func(funcDataList, res, 1, 100254, 100254, rect, true); + func(funcDataList, res, 1, 100254, 100254, rect, true, false); }); it('FuncTest02', () => { @@ -47,12 +49,12 @@ describe(' ProcedureWorkerFuncTest', () => { funcDataList.push({ startTime: 450, dur: 140, - frame: { x: 0, y: 93, width: 120, height: 320 }, + frame: {x: 0, y: 93, width: 120, height: 320}, }); funcDataList.push({ startTime: 41, dur: 661, - frame: { x: 70, y: 9, width: 16, height: 17 }, + frame: {x: 70, y: 9, width: 16, height: 17}, }); let rect = new Rect(30, 50, 53, 13); let res = [ @@ -63,7 +65,7 @@ describe(' ProcedureWorkerFuncTest', () => { frame: '', }, ]; - func(funcDataList, res, 1, 100254, 100254, rect, false); + func(funcDataList, res, 1, 100254, 100254, rect, false, false); }); it('FuncTest03', () => { @@ -88,6 +90,7 @@ describe(' ProcedureWorkerFuncTest', () => { }); it('FuncTest04', () => { + let funcRender = new FuncRender(); const canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = 1; @@ -100,12 +103,28 @@ describe(' ProcedureWorkerFuncTest', () => { width: 100, height: 100, }, + context: { + font: '12px sans-serif', + fillStyle: '#a1697d', + globalAlpha: 0.6, + 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), + }, startNS: 200, value: 50, dur: 10, funName: 'H:Task PerformTask End: taskId : 1, executeId : 1, performResult : IsCanceled', }; + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 1); expect(FuncStruct.draw(ctx, data)).toBeUndefined(); + expect(funcRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + expect(funcRender.render(data, [], [])).toBeUndefined(); }); it('FuncTest07', function () { 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/ProcedureWorkerHeapTimeline.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts index e10839e887abb3c533b33c90be76d6a6c914bfc7..7507f055fc8a3432bd787199ad539eb4fccc452b 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHeapTimeline.test.ts @@ -12,18 +12,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => { - return {}; -}); - +import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow'; import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect'; import { HeapTimelineRender, HeapTimelineStruct, HeapTimeline, } from '../../../../src/trace/database/ui-worker/ProcedureWorkerHeapTimeline'; - +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { + return {}; +}); +jest.mock('../../../../src/trace/component/SpSystemTrace', () => { + return {}; +}); describe('ProcedureWorkerHeapTimeline Test', () => { it('HeapTimelineTest', () => { const heapTimelineCanvas = document.createElement('canvas'); @@ -84,4 +85,31 @@ describe('ProcedureWorkerHeapTimeline Test', () => { }; expect(HeapTimelineStruct.setFrame(1, 2, 1, data, 0, 2, 2, frame)).toBeUndefined(); }); + it('HeapTimelineStructTest03 ', function () { + let heapTimelineRender = new HeapTimelineRender(); + const canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + const data = { + frame: { + x: 240, + y: 230, + width: 100, + height: 110, + }, + context: { + globalAlpha: 0.6, + 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), + }, + startNS: 200, + value: 50, + }; + expect(heapTimelineRender.renderMainThread(data,new TraceRow())).toBeUndefined() + }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.test.ts index 1b06e6c1d5a0ca532976c85c0446411749f86f84..9ff03d2fa028fbefe23c5d6a96172edd640c77cb 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'; 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..6cb64df6ccd2e2f7dbb60a6e7f1ac946968e5e37 --- /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'; + +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() + }); +}) 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..6396b922a8e48a004b0a7e840ed2b86f0c2e0738 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerHitchTime.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 { 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', () => { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + it('ProcedureWorkerHitchTimeTest01 ', function () { + 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 = { + hitchTimeContext: ctx, + 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() + }); +}); 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..f22450b5e3097c855b10acce04b913316e1acd41 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerLTPO.test.ts @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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', () => { + const canvas = document.createElement('canvas'); + canvas.width = 2; + canvas.height = 2; + const ctx = canvas.getContext('2d'); + it('ProcedureWorkerLTPOTest01 ', function () { + + 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 = { + ltpoContext: ctx, + 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() + }); +}); 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..d0e06a02ea834bfe689567ccf4fa9305b8b8e966 100644 --- a/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerProcess.test.ts @@ -13,10 +13,12 @@ * 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', () => {}); +jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { return {}; }); - import { proc, ProcessStruct, @@ -112,53 +114,19 @@ describe(' ProcessTest', () => { }; expect(ProcessStruct.setFrame(node, 1, 1, 1, frame)).toBeUndefined(); }); - - it('ProcessTest06', function () { + it('ProcessTest06 ', function () { let processRender = new ProcessRender(); - let processReq = { - lazyRefresh: true, + let canvas = document.createElement('canvas') as HTMLCanvasElement; + let context = canvas.getContext('2d'); + const data = { + context: context!, + useCache: 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, + traceRange: [], }; window.postMessage = jest.fn(() => true); - expect(processRender.render(processReq, [], [])).toBeUndefined(); + TraceRow.range = jest.fn(() => true); + TraceRow.range.startNS = jest.fn(() => 2); + expect(processRender.renderMainThread(data,new TraceRow())) }); }); diff --git a/ide/test/trace/database/ui-worker/ProcedureWorkerSample.test.ts b/ide/test/trace/database/ui-worker/ProcedureWorkerSample.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..0be5fa03a6d6736deb62b2263b59781276325158 --- /dev/null +++ b/ide/test/trace/database/ui-worker/ProcedureWorkerSample.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 { SampleRender, SampleStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerBpftrace'; +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('ProcedureWorkerSample Test', () => { + const canvas = document.createElement('canvas'); + canvas.width = 10; + canvas.height = 10; + const ctx = canvas.getContext('2d'); + it('ProcedureWorkerSampleTest01 ', function () { + const data = { + frame: { + x: 210, + y: 209, + width: 111, + height: 100, + }, + name: 'Sample', + cycle: -1, + value: 0, + depth: 0, + detail: 1 + }; + expect(SampleStruct.draw(ctx, data)).toBeUndefined(); + }); + it('ProcedureWorkerSampleTest02 ', function () { + const data = { + context: ctx!, + useCache: true, + type: '', + traceRange: [], + }; + let sampleRender = new SampleRender(); + TraceRow.range = jest.fn(() => true); + TraceRow.range!.startNS = jest.fn(() => 0); + expect(sampleRender.renderMainThread(data, new TraceRow())).toBeUndefined(); + }); +}); \ No newline at end of file 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/.clang-tidy b/trace_streamer/.clang-tidy index d8daf0d9d9bea214e008b3a67a7fb5855499f106..e7c8226e9239f1781517bf5e28e25291ed452bbf 100644 --- a/trace_streamer/.clang-tidy +++ b/trace_streamer/.clang-tidy @@ -1,7 +1,6 @@ --- # Ref: https://releases.llvm.org/12.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html Checks: > - android-*, bugprone-*, clang-analyzer-*, concurrency-mt-unsafe, 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..e00de2bef4923b57d7fb448ee18a52dca02be6c7 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 @@ -12,69 +12,53 @@ # See the License for the specific language governing permissions and # limitations under the License. set -e +. build/build_stanalone_plugins.sh +set_enable_plugin_array "true" +set_enable_extend_plugin_array "false" 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" -case "$OSTYPE" in - solaris*) echo "SOLARIS" ;; - darwin*) gn_path="macx" target_os="macx" ;; - linux*) gn_path="linux" target_os="linux" ;; - bsd*) echo "is bsd os" ;; - 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" - +choose_os_type ./dl_tools.sh $gn_path - -if { [ "$1" == "sdkdemo" ] || [ "$1" == "wasm" ] || [ "$1" == "test" ] || [ "$1" == "fuzz" ]; } && [ "$#" -ne 0 ];then - TARGET_DIR=$1 - if [[ $PARAMS == *"debug"* ]]; then - TARGET_DIR=$1"_debug" - fi - if [ ! -f "out/$TARGET_DIR/protoc" ] && [ "$1" != "protoc" ];then - ./build.sh 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 - ./build.sh spb - mkdir -p out/$TARGET_DIR - cp out/$target_os/protoreader_plugin out/$TARGET_DIR/protoreader_plugin - fi -fi -if [ $target_os == "windows" ];then - cp .gn_win .gn -else - cp .gn_unix .gn -fi -if [ "$1" == "windows" ];then - echo "gn only support linux and wasm build currently" - if [ ! -d "out/windows" ];then - mkdir out/windows - fi - touch out/windows/trace_streamer.exe - exit +while [[ $# -gt 0 ]]; do + case "$1" in + -e) + enable_plugin "$2" + shift 2;; + -d) + enable_extend_plugin "$2" + shift 2;; + -h) + help $0 + shift;; + -l) + list_all_plugins + shift;; + *) + other_params+=("$1") + shift;; + esac +done +set -- "${other_params[@]}" +if [ "$#" -ne 0 ] && { [ "$1" == "sdkdemo" ] || [ "$1" == "wasm" ] || [ "$1" == "test" ] || [ "$1" == "fuzz" ]; };then + prepare_proto $1 fi - +prepare_windows $1 $2 +target_operator="$2" 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" + set_enable_plugin_array "true" fi if [ "$1" == "fuzz" ];then target="fuzz" @@ -82,9 +66,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 @@ -92,9 +73,9 @@ if [ "$#" -ne "0" ];then target="spb" fi fi -target_operator="$2" 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 +set_enable_all_plugins_str +. ./build_operator.sh \ No newline at end of file diff --git a/trace_streamer/build/build_base.sh b/trace_streamer/build/build_base.sh new file mode 100644 index 0000000000000000000000000000000000000000..b95092bc826679af36242b391275f1ca2ad04dce --- /dev/null +++ b/trace_streamer/build/build_base.sh @@ -0,0 +1,52 @@ +#!/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 +# +# http://www.apache.org/licenses/LICENSE-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. +set -e +. build/build_base_func.sh +function prepare_windows { + if [ $target_os == "windows" ];then + cp .gn_win .gn + else + cp .gn_unix .gn + fi + if [ "$1" == "windows" ] && [ "$2" == "release" ];then + echo "gn only support linux and wasm build currently" + if [ ! -d "out/windows" ];then + mkdir out/windows + fi + touch out/windows/trace_streamer.exe + exit + fi +} +function prepare_proto { + TARGET_DIR=$1 + if [[ $PARAMS == *"debug"* ]]; then + TARGET_DIR=$1"_debug" + fi + if [ ! -f "out/$TARGET_DIR/protoc" ];then + ./build.sh protoc + mkdir -p out/"$TARGET_DIR" + cp out/$target_os/protoc out/"$TARGET_DIR"/protoc + fi + 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 + fi +} +function check_params { + if [[ $1 == "" || $1 == -* ]]; then + echo "Option '$1' is not reasonable." >&2 + exit 1 + fi +} \ No newline at end of file diff --git a/trace_streamer/build/build_base_func.sh b/trace_streamer/build/build_base_func.sh new file mode 100644 index 0000000000000000000000000000000000000000..0aaee9c8157c0eb7c7a4ac66415f204b7f8c0adc --- /dev/null +++ b/trace_streamer/build/build_base_func.sh @@ -0,0 +1,62 @@ +#!/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 +# +# http://www.apache.org/licenses/LICENSE-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. +set -e +. build/build_base_var.sh +function help { + echo "Usage: $1 [linux/wasm/windows/macx] [debug] [-e ] [-d ]" + echo " -e , enable the default plugins." + echo " -d , enable the extend plugins." + echo " -l Show the all plugin list." + echo " -h Show the help info." + exit +} +function list_all_plugins { + echo "the default support plugin list:" + for var in "${enable_plugin_array[@]}"; do + echo " ${var#enable_}" + done + echo "the extend support plugin list:" + for var in "${enable_extend_plugin_array[@]}"; do + echo " ${var#enable_}" + done + exit +} +function set_enable_all_plugins_str() { + for var in "${enable_plugin_array[@]}"; do + enable_all_plugins_str="$enable_all_plugins_str$var=${!var} " + done + for var in "${enable_extend_plugin_array[@]}"; do + enable_all_plugins_str="$enable_all_plugins_str$var=${!var} " + done +} +function set_enable_plugin_array() { + for enable_plugin in "${enable_plugin_array[@]}"; do + eval "$enable_plugin=$1" + done +} +function set_enable_extend_plugin_array() { + for enable_extend_plugin in "${enable_extend_plugin_array[@]}"; do + eval "$enable_extend_plugin=$1" + done +} +function choose_os_type { + case "$OSTYPE" in + solaris*) echo "SOLARIS" ;; + darwin*) gn_path="macx" target_os="macx" ;; + linux*) gn_path="linux" target_os="linux" ;; + bsd*) echo "is bsd os" ;; + msys*) gn_path="windows" target_os="windows" gn="gn.exe" ninja="ninja.exe" ;; + *) echo "unknown: $OSTYPE" ;; + esac +} \ No newline at end of file diff --git a/trace_streamer/build/build_base_var.sh b/trace_streamer/build/build_base_var.sh new file mode 100644 index 0000000000000000000000000000000000000000..271fdbd0d853a829c379c6323147c10a4b630510 --- /dev/null +++ b/trace_streamer/build/build_base_var.sh @@ -0,0 +1,31 @@ +#!/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 +# +# http://www.apache.org/licenses/LICENSE-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. +set -e +ext="" +target_os="linux" +gn_path="linux" +is_debug="false" +is_clean="false" +target="trace_streamer" +target_operator="" +target_dir="linux" +gn="gn" +ninja="ninja" +use_local_emsdk="false" +PARAMS="" +enable_plugin_array=("enable_hiperf" "enable_ebpf" "enable_native_hook" "enable_hilog" "enable_hisysevent" + "enable_arkts" "enable_bytrace" "enable_rawtrace" "enable_htrace" "enable_memory" + "enable_hidump" "enable_cpudata" "enable_network" "enable_diskio" "enable_process") +enable_extend_plugin_array=("enable_stream_extend") +enable_all_plugins_str="" \ No newline at end of file diff --git a/trace_streamer/build/build_stanalone_plugins.sh b/trace_streamer/build/build_stanalone_plugins.sh new file mode 100644 index 0000000000000000000000000000000000000000..0eb9277a0fd089cd0d6baf1f7c00f97942adf9b8 --- /dev/null +++ b/trace_streamer/build/build_stanalone_plugins.sh @@ -0,0 +1,57 @@ +#!/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 +# +# http://www.apache.org/licenses/LICENSE-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. +set -e +. build/build_base.sh +function check_plugin_true { + if [ $1 == "false" ];then + echo "Current plugins haven't '$2'!Please check!" + exit + fi +} +function enable_plugin { + check_params $1 + set_enable_plugin_array "false" + flag="false" + IFS=',' + read -ra plugins <<< "$1" + for plugin in "${plugins[@]}"; do + for enable_plugin in "${enable_plugin_array[@]}"; do + if [[ $enable_plugin == *$plugin ]]; then + eval "$enable_plugin=\"true\"" + echo "$enable_plugin=${!enable_plugin}" + flag="true" + fi + done + check_plugin_true $flag $plugin + flag="false" + done +} +function enable_extend_plugin { + check_params $1 + set_enable_extend_plugin_array "false" + flag="false" + IFS=',' + read -ra plugins <<< "$1" + for plugin in "${plugins[@]}"; do + for enable_extend_plugin in "${enable_extend_plugin_array[@]}"; do + if [[ $enable_extend_plugin == *$plugin ]]; then + eval "$enable_extend_plugin=\"true\"" + echo "$enable_extend_plugin=${!enable_extend_plugin}" + flag="true" + fi + done + check_plugin_true $flag $plugin + flag="false" + done +} \ No newline at end of file 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..3c08bb42cf4951128bbbd7857cf7748608af0fe5 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 @@ -76,14 +76,28 @@ template("ohos_shared_library") { } } template("ohos_static_library") { - subsystem_name = invoker.subsystem_name - part_name = invoker.part_name static_library(target_name) { - sources = invoker.sources + if (defined(invoker.subsystem_name)) { + subsystem_name = invoker.subsystem_name + print("subsystem_name", subsystem_name) + } + if (defined(invoker.part_name)) { + part_name = invoker.part_name + print("part_name", part_name) + } + if (defined(invoker.sources)) { + sources = invoker.sources + } + if (defined(invoker.public_configs)) { + public_configs = invoker.public_configs + } if (defined(invoker.configs)) { - configs = invoker.configs + if (configs == []) { + configs = invoker.configs + } else { + configs += invoker.configs + } } - public_configs = invoker.public_configs if (defined(invoker.defines)) { defines = invoker.defines } @@ -99,6 +113,18 @@ template("ohos_static_library") { if (defined(invoker.deps)) { deps = invoker.deps } + if (defined(invoker.public_deps)) { + public_deps = invoker.public_deps + } + if (defined(invoker.visibility)) { + visibility = invoker.visibility + } + if (defined(invoker.output_extension)) { + output_extension = invoker.output_extension + } + if (is_mingw) { + output_extension = "a" + } } } template("ohos_executable") { 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..0ffe94aeade1cc887ee5615d913a89617dfc5d02 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,8 +12,23 @@ # limitations under the License. declare_args() { - profiler_SmartPerf = true is_independent_compile = false + enable_hiperf = true + enable_ebpf = true + enable_native_hook = true + enable_hilog = true + enable_hisysevent = true + enable_arkts = true + enable_bytrace = true + enable_rawtrace = true + enable_htrace = true + enable_memory = true + enable_hidump = true + enable_cpudata = true + enable_network = true + enable_diskio = true + enable_process = true + enable_stream_extend = false } if (is_independent_compile) { @@ -39,12 +54,13 @@ 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") OHOS_TRACE_STREAMER_DIR = get_path_info("../", "abspath") SRC = "${OHOS_TRACE_STREAMER_DIR}/src" +EXTEND_SRC = "${OHOS_TRACE_STREAMER_DIR}/trace_extend/src" +EXTEND_TEST = "${OHOS_TRACE_STREAMER_DIR}/trace_extend/test" PREBUILTS = "//prebuilts" THIRD_PARTY = "//third_party" kernel_version = "." @@ -55,14 +71,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..3cdcf6ec74e7600ce813d7f37a5aee270ef89263 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 @@ -12,56 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. set -e -ext="" -target_dir="linux" -is_debug="$1" -target="$2" -target_os="$3" -is_clean="$4" -gn_path="$5" -gn="$6" -ninja="$7" -target_operator="$8" -if [ "$#" -ge "7" ];then - if [ "$target" != "trace" ] && [ "$target" != "linux" ] && [ "$target" != "windows" ] && - [ "$target" != "macx" ] && [ "$target" != "trace_streamer" ] && [ "$target" != "wasm" ] && - [ "$target" != "test" ] && [ "$target" != "spb" ] && [ "$target" != "fuzz" ] && - [ "$target" != "protoc" ] && [ "$target" != "sdkdemo" ] && [ "$target" != "sdkdemotest" ];then - echo "failed" - exit - fi - if [ "$target_operator" != "" ] && [ "$target_operator" != "debug" ] && [ "$target_operator" != "release" ] && [ "$target_operator" != "clean" ];then - if [ "$target_operator" == "protoc" ];then - target=$target_operator - else - echo "failed" - exit - fi - fi - if [ "$target_operator" == "debug" ];then - is_debug="true" - elif [ "$target_operator" == "clean" ];then - is_clean="true" +echo "target_operator = $target_operator" +if [ "$target" != "trace" ] && [ "$target" != "linux" ] && [ "$target" != "windows" ] && + [ "$target" != "macx" ] && [ "$target" != "trace_streamer" ] && [ "$target" != "wasm" ] && + [ "$target" != "test" ] && [ "$target" != "spb" ] && [ "$target" != "fuzz" ] && + [ "$target" != "protoc" ] && [ "$target" != "sdkdemo" ] && [ "$target" != "sdkdemotest" ];then + echo "failed" + exit +fi +if [ "$target_operator" != "" ] && [ "$target_operator" != "debug" ] && [ "$target_operator" != "release" ] && [ "$target_operator" != "clean" ];then + if [ "$target_operator" == "protoc" ];then + target=$target_operator else - is_debug="false" + echo "failed" + exit fi - echo "platform is $target_os" - echo "isdebug: $is_debug" - echo "isclean: $is_clean" +fi +if [ "$target_operator" == "debug" ];then + is_debug="true" +elif [ "$target_operator" == "clean" ];then + is_clean="true" else - echo "$usage" - echo "It is not recommended to execute this file and use it by build.sh." - echo "use default input paramter" - echo "platform is $target_os" - echo "target is $target" - echo "is_debug:$is_debug" - exit + is_debug="false" fi +echo "platform is $target_os" +echo "isdebug: $is_debug" +echo "isclean: $is_clean" 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 +50,18 @@ 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"" $enable_all_plugins_str" 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..9ea2206ce07cc17f5d910f25af4898c7908e5bb1 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 @@ -30,6 +30,8 @@ FORMAT_DIR_LIST=( "${PRJ_ROOT_DIR}/sdk" "${PRJ_ROOT_DIR}/src" "${PRJ_ROOT_DIR}/test" + "${PRJ_ROOT_DIR}/trace_extend/src" + "${PRJ_ROOT_DIR}/trace_extend/test" "${PRJ_ROOT_DIR}/prebuilts/fuzz" "${PRJ_ROOT_DIR}/prebuilts/linux" "${PRJ_ROOT_DIR}/prebuilts/macx" 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..fc3911312aa905c60327018ff57068e05e27e612 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 @@ -51,6 +51,7 @@ config("visibility_hidden") { config("default") { cflags_c = [] cflags_cc = [] + defines = [] libs = [] ldflags = [] cflags = [ @@ -58,20 +59,70 @@ config("default") { "-Wformat", "-Wno-unused-variable", ] + if (enable_hiperf) { + defines += [ "ENABLE_HIPERF" ] + } + if (enable_ebpf) { + defines += [ "ENABLE_EBPF" ] + } + if (enable_native_hook) { + defines += [ "ENABLE_NATIVE_HOOK" ] + } + if (enable_hilog) { + defines += [ "ENABLE_HILOG" ] + } + if (enable_hisysevent) { + defines += [ "ENABLE_HISYSEVENT" ] + } + if (enable_arkts) { + defines += [ "ENABLE_ARKTS" ] + } + if (enable_bytrace) { + defines += [ "ENABLE_BYTRACE" ] + } + if (enable_rawtrace) { + defines += [ "ENABLE_RAWTRACE" ] + } + if (enable_htrace) { + defines += [ "ENABLE_HTRACE" ] + } + if (enable_memory) { + defines += [ "ENABLE_MEMORY" ] + } + if (enable_hidump) { + defines += [ "ENABLE_HTDUMP" ] + } + if (enable_cpudata) { + defines += [ "ENABLE_CPUDATA" ] + } + if (enable_network) { + defines += [ "ENABLE_NETWORK" ] + } + if (enable_diskio) { + defines += [ "ENABLE_DISKIO" ] + } + if (enable_process) { + defines += [ "ENABLE_PROCESS" ] + } + if (enable_stream_extend) { + defines += [ "ENABLE_STREAM_EXTEND" ] + } 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 +140,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" ] @@ -132,7 +182,7 @@ config("default") { } if (is_win) { cflags += [ "-D is_mingw" ] - defines = [ "WIN32_LEAN_AND_MEAN" ] + defines += [ "WIN32_LEAN_AND_MEAN" ] libs += [ "wsock32" ] libs += [ "ws2_32" ] cflags += [ "-Wno-attributes" ] @@ -144,6 +194,10 @@ config("default") { config("symbols") { cflags = [ "-O0" ] + cflags += [ + "-fdata-sections", + "-ffunction-sections", + ] if (is_linux || is_mac) { cflags += [ "-funwind-tables" ] } 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..e0e67e31d2b5b4ab7c17c705de4c70b960a2b97c 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" @@ -168,6 +174,9 @@ toolchain("gcc_like") { } else { rspfile_content = "{{inputs}}" # this must be defined command = "rm -f {{output}} && $ar rcsD {{output}} @$rspfile" + if (is_mingw) { + command = "$ar rcsD {{output}} @$rspfile" + } } outputsfiles = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" outputs = [ outputsfiles ] diff --git a/trace_streamer/gn/wasm.gni b/trace_streamer/gn/wasm.gni index e181f0f569097abd9e23e58c6c813a06af2d3f67..6627bca4267c6b4540d7b80f1ee68b0a44bcd1ee 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", @@ -80,7 +82,7 @@ template("wasm_lib") { ] } else { _target_ldflags += [ - # "-g2", # Required for getting C++ symbol names. + # "-g2", # Required for getting C++ symbol names. "-O3", # "-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..1caa8730e399cfe43cef91176e4e09b0073be32a 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 @@ -13,6 +13,6 @@ # limitations under the License. set -e rm -rf out/test -./test.sh +./test.sh $1 $2 ./lcov_operator.sh rm ./test.info \ No newline at end of file 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/mac_depend.sh b/trace_streamer/mac_depend.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8a37a4f9e266d380d3bf0565f6a7fac0fb477ea --- /dev/null +++ b/trace_streamer/mac_depend.sh @@ -0,0 +1,22 @@ + +#!/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 +# +# http://www.apache.org/licenses/LICENSE-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. +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..52103e903c03cbb58679070b28bdf11247960e20 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,9 +56,6 @@ 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) { - sources += [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/dfx_accessors.cpp" ] - } } group("hiviewdfx") { 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..76eb68b1469d1a4ddff245ad5913abb148538c22 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 @@ -69,11 +69,11 @@ trace_streamer_include = [ "parser", "cfg", "proto_reader/include", - "parser/bytrace_parser", + "parser/ptreader_parser", "parser/ebpf_parser", - "parser/htrace_pbreader_parser", - "parser/htrace_pbreader_parser/htrace_event_parser", - "parser/htrace_pbreader_parser/htrace_cpu_parser", + "parser/pbreader_parser", + "parser/pbreader_parser/htrace_parser", + "parser/pbreader_parser/htrace_parser", "parser/rawtrace_parser", "parser/hiperf_parser", "${THIRD_PARTY}/bounds_checking_function/include", @@ -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" ] @@ -192,13 +185,21 @@ ohos_source_set("trace_streamer_source") { "filter:filter", "metrics:metrics_parser", "parser:parser", - "parser/hiperf_parser:hiperf_parser", "proto_reader:proto_reader", "table:table", "trace_data:trace_data", "//third_party/bounds_checking_function:libsec_static", "//third_party/perf_include/hiviewdfx:hiviewdfx", ] + + public_configs = [] + if (enable_hiperf) { + public_configs += [ "parser/hiperf_parser:hiperf_parser_cfg" ] + } + if (enable_stream_extend) { + public_configs += + [ "${EXTEND_SRC}/parser/pbreader_stream_parser:pbreader_stream_cfg" ] + } } if (use_wasm) { 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..4bc41092a5e2841b8b9eebf790fba412bff5e58d 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, @@ -21,7 +21,7 @@ #include #include #include -#include "htrace_file_header.h" +#include "pbreader_file_header.h" #include "ts_common.h" namespace SysTuning { namespace TraceStreamer { 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_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..bdf470cee52c7f68cdbf4abf2afe6e665da8dcc2 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, @@ -82,36 +82,44 @@ public: PrepMixRange(remove); switch (op) { case SQLITE_INDEX_CONSTRAINT_EQ: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] != value; }, - [&](TableRowId id) -> bool { return dataQueue[id] == value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] != value; }, + [&](TableRowId id) -> bool { return dataQueue[id] == value; }); break; case SQLITE_INDEX_CONSTRAINT_NE: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] == value; }, - [&](TableRowId id) -> bool { return dataQueue[id] != value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] == value; }, + [&](TableRowId id) -> bool { return dataQueue[id] != value; }); break; case SQLITE_INDEX_CONSTRAINT_ISNULL: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] != invalidValue; }, - [&](TableRowId id) -> bool { return dataQueue[id] == invalidValue; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] != invalidValue; }, + [&](TableRowId id) -> bool { return dataQueue[id] == invalidValue; }); break; case SQLITE_INDEX_CONSTRAINT_ISNOTNULL: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] == invalidValue; }, - [&](TableRowId id) -> bool { return dataQueue[id] != invalidValue; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] == invalidValue; }, + [&](TableRowId id) -> bool { return dataQueue[id] != invalidValue; }); break; case SQLITE_INDEX_CONSTRAINT_GT: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] <= value; }, - [&](TableRowId id) -> bool { return dataQueue[id] > value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] <= value; }, + [&](TableRowId id) -> bool { return dataQueue[id] > value; }); break; case SQLITE_INDEX_CONSTRAINT_GE: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] < value; }, - [&](TableRowId id) -> bool { return dataQueue[id] >= value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] < value; }, + [&](TableRowId id) -> bool { return dataQueue[id] >= value; }); break; case SQLITE_INDEX_CONSTRAINT_LE: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] > value; }, - [&](TableRowId id) -> bool { return dataQueue[id] <= value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] > value; }, + [&](TableRowId id) -> bool { return dataQueue[id] <= value; }); break; case SQLITE_INDEX_CONSTRAINT_LT: - ProcessData(dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] >= value; }, - [&](TableRowId id) -> bool { return dataQueue[id] < value; }); + ProcessData( + dataQueue, remove, [&](TableRowId id) -> bool { return dataQueue[id] >= value; }, + [&](TableRowId id) -> bool { return dataQueue[id] < value; }); break; default: break; 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/htrace_file_header.h b/trace_streamer/src/base/pbreader_file_header.h similarity index 72% rename from trace_streamer/src/base/htrace_file_header.h rename to trace_streamer/src/base/pbreader_file_header.h index 0056043a596b39daf59493a39c27f7e8868a809b..38d0ab901c5ca9d6c95c05c1cf7ac19d98c796bc 100644 --- a/trace_streamer/src/base/htrace_file_header.h +++ b/trace_streamer/src/base/pbreader_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, @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef HTRACE_FILE_HEADER_H -#define HTRACE_FILE_HEADER_H +#ifndef PBREADER_FILE_HEADER_H +#define PBREADER_FILE_HEADER_H namespace SysTuning { namespace TraceStreamer { struct ProfilerTraceFileHeader { @@ -61,27 +61,13 @@ struct ProfilerTraceFileHeader { struct ProfilerPluginDataHeader { std::string name = ""; uint32_t status; - uint8_t* data; - enum ClockId { - CLOCKID_REALTIME = 0, - CLOCKID_REALTIME_ALARM, // since Linux 3.0; Linux-specific - CLOCKID_REALTIME_COARSE, // since Linux 2.6.32; Linux-specific - CLOCKID_TAI, // since Linux 3.10; Linux-specific - CLOCKID_MONOTONIC, - CLOCKID_MONOTONIC_COARSE, // since Linux 2.6.32; Linux-specific - CLOCKID_MONOTONIC_RAW, // since Linux 2.6.28; Linux-specific - CLOCKID_BOOTTIME, // since Linux 2.6.39; Linux-specific - CLOCKID_BOOTTIME_ALARM, // since Linux 3.0; Linux-specific - CLOCKID_PROCESS_CPUTIME_ID, // since Linux 2.6.12 - CLOCKID_THREAD_CPUTIME_ID // since Linux 2.6.12 - }; - ClockId clockId; + int32_t clockId; uint64_t tvSec; uint64_t tvNsec; - uint8_t* version; // "1.01" - uint32_t sampleInterval; // Polling plugin collection interval(ms) + std::string version = ""; // "1.01" + uint32_t sampleInterval; // Polling plugin collection interval(ms) }; const std::string EBPF_PLUGIN_NAME = "hiebpf-plugin"; } // namespace TraceStreamer } // namespace SysTuning -#endif // HTRACE_FILE_HEADER_H +#endif // PBREADER_FILE_HEADER_H 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..a3e02f0f59b4179a114e8aff16c3f371c22fea0a 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, @@ -202,7 +202,8 @@ enum DataSourceType { DATA_SOURCE_TYPE_HISYSEVENT_CONFIG, DATA_SOURCE_TYPE_JSMEMORY, DATA_SOURCE_TYPE_JSMEMORY_CONFIG, - DATA_SOURCE_TYPE_MEM_CONFIG + DATA_SOURCE_TYPE_MEM_CONFIG, + DATA_SOURCE_TYPE_STREAM }; enum class HookMemoryType { MALLOC = 0, MMAP = 1, FILE_PAGE_MSG = 2, MEMORY_USING_MSG = 3 }; using DataIndex = uint64_t; 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..f12bad783e847ad61e30ae75555da2dc51550fa6 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 @@ -14,50 +14,7 @@ import("//build/ohos.gni") import("../../build/ts.gni") -ohos_source_set("filter") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" - sources = [ - "animation_filter.cpp", - "animation_filter.h", - "app_start_filter.cpp", - "app_start_filter.h", - "args_filter.cpp", - "args_filter.h", - "binder_filter.cpp", - "binder_filter.h", - "clock_filter_ex.cpp", - "cpu_filter.cpp", - "filter_base.cpp", - "filter_base.h", - "filter_filter.cpp", - "filter_filter.h", - "frame_filter.cpp", - "frame_filter.h", - "hi_sysevent_measure_filter.cpp", - "hi_sysevent_measure_filter.h", - "irq_filter.cpp", - "irq_filter.h", - "measure_filter.cpp", - "measure_filter.h", - "native_hook_filter.cpp", - "native_hook_filter.h", - "offline_symbolization_filter.cpp", - "offline_symbolization_filter.h", - "perf_data_filter.cpp", - "perf_data_filter.h", - "process_filter.cpp", - "process_filter.h", - "slice_filter.cpp", - "slice_filter.h", - "stat_filter.cpp", - "stat_filter.h", - "system_event_measure_filter.cpp", - "system_event_measure_filter.h", - "task_pool_filter.cpp", - "task_pool_filter.h", - ] - +config("filter_cfg") { if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } @@ -75,12 +32,6 @@ ohos_source_set("filter") { cflags += [ "-D IS_UT" ] } } - public_deps = [ - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", - ] - deps = [] include_dirs = [ "${SRC}/base", "${SRC}/trace_streamer", @@ -88,6 +39,7 @@ ohos_source_set("filter") { "${SRC}/parser", "${SRC}/include", "${SRC}/filter", + "${SRC}/filter/hi_sysevent_filter", "${SRC}/cfg", "${SRC}", "${THIRD_PARTY}/protobuf/src", @@ -119,3 +71,58 @@ ohos_source_set("filter") { include_dirs += [ "${THIRD_PARTY}/elfutils/libelf" ] } } + +ohos_source_set("filter") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "animation_filter.cpp", + "animation_filter.h", + "app_start_filter.cpp", + "app_start_filter.h", + "args_filter.cpp", + "args_filter.h", + "binder_filter.cpp", + "binder_filter.h", + "clock_filter_ex.cpp", + "cpu_filter.cpp", + "filter_base.cpp", + "filter_base.h", + "filter_filter.cpp", + "filter_filter.h", + "frame_filter.cpp", + "frame_filter.h", + "irq_filter.cpp", + "irq_filter.h", + "measure_filter.cpp", + "measure_filter.h", + "process_filter.cpp", + "process_filter.h", + "slice_filter.cpp", + "slice_filter.h", + "stat_filter.cpp", + "stat_filter.h", + "system_event_measure_filter.cpp", + "system_event_measure_filter.h", + "task_pool_filter.cpp", + "task_pool_filter.h", + ] + + public_deps = + [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp" ] + deps = [] + if (enable_hiperf) { + deps += [ "perf_filter:hiperf_filter" ] + } + if (enable_native_hook) { + deps += [ "hook_filter:native_hook_filter" ] + public_deps += [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", + ] + } + if (enable_hisysevent) { + deps += [ "hi_sysevent_filter:hi_sysevent_filter" ] + } + public_configs = [ ":filter_cfg" ] +} diff --git a/trace_streamer/src/filter/animation_filter.cpp b/trace_streamer/src/filter/animation_filter.cpp index fa4cb4826934162c0b4b92a4c0215d83a691f057..379f257e2fe77c404bcc538d0fc0ed392ad70152 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, @@ -178,7 +178,8 @@ bool AnimationFilter::UpdateDynamicEndTime(const uint64_t curFrameRow, uint64_t } curStackRow = callStackSlice_->ParentIdData()[curStackRow].value(); // use frameEndTimeCmd_'s endTime as dynamicFrame endTime - if (frameEndTimeCmd_ == callStackSlice_->NamesData()[curStackRow]) { + auto nameIndex = callStackSlice_->NamesData()[curStackRow]; + if (StartWith(traceDataCache_->GetDataFromDict(nameIndex), frameEndTimeCmd_)) { auto endTime = callStackSlice_->TimeStampData()[curStackRow] + callStackSlice_->DursData()[curStackRow]; dynamicFrame_->UpdateEndTime(curFrameRow, endTime); return true; diff --git a/trace_streamer/src/filter/animation_filter.h b/trace_streamer/src/filter/animation_filter.h index f033c94914f2d7afd635e719c3951a92fe708756..c6117ecbfd0195516011964a680a40ca7d7cfbf6 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, @@ -54,7 +54,7 @@ private: const std::string frameCountCmd_ = "H:Repaint"; const std::string frameBeginPrefix_ = "H:RSUniRender::Process:["; const std::string screenSizeCmd_ = "H:RSUniRender::Process:[SCBDesktop"; - const DataIndex frameEndTimeCmd_ = traceDataCache_->GetDataIndex("H:RSMainThread::DoComposition"); + const std::string frameEndTimeCmd_ = "H:RSMainThread::DoComposition"; std::unordered_set onAnimationStartEvents_ = {}; // for update dynamicFrameInfo at the end, first is callStackRow, second is dynamicFramRow std::map callStackRowMap_ = {}; diff --git a/trace_streamer/src/filter/app_start_filter.cpp b/trace_streamer/src/filter/app_start_filter.cpp index 29bc755adbdc2e75377210b38c28e48e3b5e1864..21ebd6119b9eb85fa6cbbfe1b87594cbff257a3a 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, @@ -175,9 +175,7 @@ void APPStartupFilter::ParserAppStartup() } else if (StartWith(nameString, appLaunchCmd_)) { UpdateAPPStartupData(i, nameString, APPLICATION_LAUNCHING); } else if (StartWith(nameString, uiLaunchCmd_)) { - if (!ProcAbilityLaunchData(nameString, i)) { - continue; - } + ProcAbilityLaunchData(nameString, i); } else if (StartWith(nameString, uiOnForegroundFirstCmd_) || StartWith(nameString, uiOnForegroundSecCmd_)) { ProcForegroundData(i); } 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..15bf6c4692b9d8ab9ebca3d33e39a6219962a8d7 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, @@ -24,7 +24,7 @@ #include "clock_filter.h" #include "filter_base.h" -#include "htrace_file_header.h" +#include "pbreader_file_header.h" #include "trace_streamer_filters.h" #include "ts_common.h" 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_filter/BUILD.gn b/trace_streamer/src/filter/hi_sysevent_filter/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..11ccc8f289755565f637eee388bfd2f827f77980 --- /dev/null +++ b/trace_streamer/src/filter/hi_sysevent_filter/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../build/ts.gni") + +config("hi_sysevent_filter_cfg") { + include_dirs = [ "." ] +} + +ohos_static_library("hi_sysevent_filter") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "hi_sysevent_measure_filter.cpp" ] + public_configs = [ + ":hi_sysevent_filter_cfg", + "..:filter_cfg", + ] + deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", + ] +} diff --git a/trace_streamer/src/filter/hi_sysevent_measure_filter.cpp b/trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.cpp similarity index 99% rename from trace_streamer/src/filter/hi_sysevent_measure_filter.cpp rename to trace_streamer/src/filter/hi_sysevent_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_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_filter/hi_sysevent_measure_filter.h similarity index 97% rename from trace_streamer/src/filter/hi_sysevent_measure_filter.h rename to trace_streamer/src/filter/hi_sysevent_filter/hi_sysevent_measure_filter.h index 0b302697600cbbb410930256d37d2281508c59e3..96564d41f888a891a078cda61dd288fbfe468aa0 100644 --- a/trace_streamer/src/filter/hi_sysevent_measure_filter.h +++ b/trace_streamer/src/filter/hi_sysevent_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, @@ -20,6 +20,7 @@ #include #include +#include "common_types.h" #include "double_map.h" #include "filter_base.h" #include "htrace_plugin_time_parser.h" @@ -40,8 +41,6 @@ typedef struct { std::vector value; } JsonData; -enum ErrorCode { ERROR_CODE_EXIT = -2, ERROR_CODE_NODATA = -1 }; - struct JsonMessage { DataIndex domainId = INVALID_DATAINDEX; DataIndex eventNameId = INVALID_DATAINDEX; diff --git a/trace_streamer/src/filter/hook_filter/BUILD.gn b/trace_streamer/src/filter/hook_filter/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f3b05bc70525a8c9c876cff8687ecc61ab0af4bd --- /dev/null +++ b/trace_streamer/src/filter/hook_filter/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../build/ts.gni") + +config("native_hook_filter_cfg") { + include_dirs = [ "." ] +} + +ohos_static_library("native_hook_filter") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "native_hook_filter.cpp", + "offline_symbolization_filter.cpp", + ] + public_configs = [ + ":native_hook_filter_cfg", + "..:filter_cfg", + ] + deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:ts_native_hook_cpp", + ] +} diff --git a/trace_streamer/src/filter/native_hook_filter.cpp b/trace_streamer/src/filter/hook_filter/native_hook_filter.cpp similarity index 89% rename from trace_streamer/src/filter/native_hook_filter.cpp rename to trace_streamer/src/filter/hook_filter/native_hook_filter.cpp index e80fb51c5bca350b63e2e6796ff66ea4cb55492f..3f1e90b6a7825f97c266be3cd356f90054c70c28 100644 --- a/trace_streamer/src/filter/native_hook_filter.cpp +++ b/trace_streamer/src/filter/hook_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, @@ -147,8 +147,17 @@ std::unique_ptr NativeHookFilter::ParseFrame(uint64_t row, symbolIndex = traceDataCache_->dataDict_.GetStringIndex(reader.symbol_name().ToStdString()); filePathIndex = traceDataCache_->dataDict_.GetStringIndex(reader.file_path().ToStdString()); } - auto frameInfo = std::make_unique(reader.ip(), reader.sp(), symbolIndex, filePathIndex, - reader.offset(), reader.symbol_offset()); + uint64_t frameSp = INVALID_UINT64; + // 0 is meaningful, but it is not displayed. Other data is still needed + auto frameIp = reader.has_ip() && reader.ip() ? reader.ip() : INVALID_UINT64; + if (reader.has_sp()) { + frameSp = reader.sp(); + } + auto frameOffset = reader.has_offset() && reader.offset() ? reader.offset() : INVALID_UINT64; + auto frameSymbolOffset = + reader.has_symbol_offset() && reader.symbol_offset() ? reader.symbol_offset() : INVALID_UINT64; + auto frameInfo = std::make_unique(frameIp, frameSp, symbolIndex, filePathIndex, frameOffset, + frameSymbolOffset); return frameInfo; } @@ -606,6 +615,54 @@ std::tuple NativeHookFilter::GetNeedUpdateProcessMapsAddrRan return std::make_tuple(start, end); } +std::shared_ptr>> NativeHookFilter::OfflineSymbolization( + const std::shared_ptr> ips) +{ + auto ipid = ips->back(); + auto result = std::make_shared>>(); + for (auto itor = ips->begin(); (itor + 1) != ips->end(); itor++) { + if (JS_IP_MASK == (*itor & ALLOC_IP_MASK)) { + auto aktsFrameInfo = std::make_shared(); + // Under offline symbolization, there is no need to symbolize js data + uint64_t aktsFrame = *itor & (~JS_IP_MASK); + auto aktsReaderFrameInfo = ipidToFrameIdToFrameBytes_.Find(ipid, aktsFrame); + if (aktsReaderFrameInfo == nullptr) { + TS_LOGE("Can not to find Frame_map.id for js(akts)!!!"); + continue; + } + ProtoReader::Frame_Reader reader(*aktsReaderFrameInfo); + // 0 is meaningful, but it is not displayed. Other data is still needed + // For js, the last 5 bytes of stack.ip and the outgoing frame member IP are reserved + auto aktsIp = reader.has_ip() && reader.ip() ? reader.ip() & IP_BIT_OPERATION : INVALID_UINT64; + if (!reader.has_symbol_name_id()) { + TS_LOGI("Can not to find symbol_name_id for js(akts)!!!"); + continue; + } + auto symbolIndex = ipidToSymIdToSymIndex_.Find(ipid, reader.symbol_name_id()); + if (!reader.has_file_path_id()) { + TS_LOGI("Can not to find has_file_path_id for js(akts)!!!"); + continue; + } + auto fileIndex = reader.file_path_id(); + auto offset = reader.has_offset() && reader.offset() ? reader.offset() : INVALID_UINT64; + aktsFrameInfo->filePathId_ = fileIndex; + aktsFrameInfo->ip_ = aktsIp; + aktsFrameInfo->symbolIndex_ = symbolIndex; + aktsFrameInfo->offset_ = offset; + aktsFrameInfo->symbolOffset_ = INVALID_UINT64; + aktsFrameInfo->symVaddr_ = INVALID_UINT64; + result->emplace_back(aktsFrameInfo); + continue; + } + auto frameInfo = OfflineSymbolizationByIp(ipid, *itor); + // If the IP in the middle of the call stack cannot be symbolized, the remaining IP is discarded + if (!frameInfo) { + break; + } + result->emplace_back(frameInfo); + } + return result; +} void NativeHookFilter::FillOfflineSymbolizationFrames( std::map>>::iterator mapItor) { @@ -616,13 +673,12 @@ void NativeHookFilter::FillOfflineSymbolizationFrames( if (isSingleProcData_) { curCacheIpid = SINGLE_PROC_IPID; } - uint64_t filePathIndex; + uint64_t filePathIndex = INVALID_UINT64; 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. auto frameInfo = itor->get(); filePathIndex = ipidToFilePathIdToFileIndex_.Find(curCacheIpid, frameInfo->filePathId_); std::string vaddr = base::Uint64ToHexText(frameInfo->symVaddr_); - auto row = traceDataCache_->GetNativeHookFrameData()->AppendNewNativeHookFrame( callChainId_, depth++, frameInfo->ip_, frameInfo->symbolIndex_, filePathIndex, frameInfo->offset_, frameInfo->symbolOffset_, vaddr); @@ -820,6 +876,20 @@ void NativeHookFilter::MaybeUpdateCurrentSizeDur(uint64_t row, uint64_t timeStam } lastAnyEventRaw = row; } + +void NativeHookFilter::UpdateSymbolIdsForCallChainIdLastCallStack(size_t index) +{ + auto ip = traceDataCache_->GetNativeHookFrameData()->Ips()[index]; + // ip & 0xFFFFFFFFFF + uint64_t ipBitOperation = ip & IP_BIT_OPERATION; + std::ostringstream newSymbol; + // alloc size ( (ip & 0xFFFFFFFFFF) bytes) 0xip(Convert IP to hexadecimal) + 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())); +} + // when symbolization failed, use filePath + vaddr as symbol name void NativeHookFilter::UpdateSymbolIdsForSymbolizationFailed() { @@ -836,10 +906,24 @@ void NativeHookFilter::UpdateSymbolIdsForSymbolizationFailed() traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( i, traceDataCache_->dataDict_.GetStringIndex(filePathStr + "+" + vaddrStr)); } else { + // when symbolization failed,filePath and symbolNameIndex invalid auto ip = traceDataCache_->GetNativeHookFrameData()->Ips()[i]; - traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( - i, traceDataCache_->dataDict_.GetStringIndex("unknown 0x" + - base::number(ip, base::INTEGER_RADIX_TYPE_HEX))); + // Distinguish whether it is the last layer call stack using the first 3 bytes + if (ALLOC_IP_MASK == (ip & ALLOC_IP_MASK)) { + // Take the last five bytes from the IP address + uint64_t ipBitOperation = ip & IP_BIT_OPERATION; + std::ostringstream newSymbol; + // alloc size (IP(Decimal))bytes 0xIP(hexadecimal conversion) + newSymbol << "alloc size(" << base::number(ipBitOperation, base::INTEGER_RADIX_TYPE_DEC) << "bytes)" + << "0x" << base::number(ip, base::INTEGER_RADIX_TYPE_HEX); + traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( + i, traceDataCache_->dataDict_.GetStringIndex(newSymbol.str())); + } else { + // If the current callChainId is same,unknow 0x ip(Convert IP to hexadecimal) + traceDataCache_->GetNativeHookFrameData()->UpdateSymbolId( + i, traceDataCache_->dataDict_.GetStringIndex("unknown 0x" + + base::number(ip, base::INTEGER_RADIX_TYPE_HEX))); + } } } } @@ -863,6 +947,12 @@ void NativeHookFilter::GetNativeHookFrameVaddrs() auto symbolOffset = traceDataCache_->GetNativeHookFrameData()->SymbolOffsets()[i]; // When the symbol offset is not 0, vaddr=offset+symbol offset if (symbolOffset) { + if (symbolOffset == INVALID_UINT64) { + // The stack does not exist, so vaddr does not exist and needs to be skipped + // Add empty value placeholders + vaddrs_.emplace_back(""); + continue; + } auto fileOffset = traceDataCache_->GetNativeHookFrameData()->Offsets()[i]; auto vaddr = base::Uint64ToHexText(fileOffset + symbolOffset); vaddrs_.emplace_back(vaddr); @@ -918,14 +1008,20 @@ void NativeHookFilter::ParseFramesInCallStackCompressedMode() TS_LOGE("Data exception, can not find symbol_name_id!!!"); continue; } + // IP may not exist + // 0 is meaningful, but it is not displayed. Other data is still needed + auto frameIp = reader.has_ip() && reader.ip() ? reader.ip() : INVALID_UINT64; + auto frameOffset = reader.has_offset() && reader.offset() ? reader.offset() : INVALID_UINT64; + auto frameSymbolOffset = + reader.has_symbol_offset() && reader.symbol_offset() ? reader.symbol_offset() : INVALID_UINT64; auto row = traceDataCache_->GetNativeHookFrameData()->AppendNewNativeHookFrame( - stackIdToFramesItor->first, depth++, reader.ip(), symbolIndex, filePathIndex, reader.offset(), - reader.symbol_offset()); + stackIdToFramesItor->first, depth++, frameIp, symbolIndex, filePathIndex, frameOffset, + frameSymbolOffset); UpdateFilePathIndexToCallStackRowMap(row, filePathIndex); } } } -// Called When isCallStackCompressedMode_ is false. +// Called When isCallStackCompressedMode_ is false void NativeHookFilter::ParseFramesWithOutCallStackCompressedMode() { for (auto itor = callChainIdToStackHashValueMap_.begin(); itor != callChainIdToStackHashValueMap_.end(); itor++) { @@ -978,9 +1074,9 @@ void NativeHookFilter::UpdateThreadNameWithNativeHookData() const } void NativeHookFilter::FinishParseNativeHookData() { - // In offline symbolization mode Parse all NativeHook main events depends on updated stackIdToCallChainIdMap_ during - // execute ParseSymbolizedNativeHookFrame or ReparseStacksWithDifferentMeans , So first parse the call stack data - // and then parse the main event. + // In offline symbolization mode Parse all NativeHook main events depends on updated stackIdToCallChainIdMap_ + // during execute ParseSymbolizedNativeHookFrame or ReparseStacksWithDifferentMeans , So first parse the call + // stack data and then parse the main event. if (isOfflineSymbolizationMode_) { ParseFramesInOfflineSymbolizationMode(); ReparseStacksWithDifferentMeans(); @@ -1009,6 +1105,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 +1142,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 +1182,7 @@ bool NativeHookFilter::NativeHookReloadElfSymbolTable(const std::vector& ips); template void UpdateSymbolTablePtrAndStValueToSymAddrMap(T* firstSymbolAddr, const int size, std::shared_ptr reader); + std::shared_ptr>> OfflineSymbolization( + const std::shared_ptr> ips); void FillOfflineSymbolizationFrames(std::map>>::iterator mapItor); void ReparseStacksWithAddrRange(uint64_t start, uint64_t end); void ReparseStacksWithDifferentMeans(); diff --git a/trace_streamer/src/filter/offline_symbolization_filter.cpp b/trace_streamer/src/filter/hook_filter/offline_symbolization_filter.cpp similarity index 91% rename from trace_streamer/src/filter/offline_symbolization_filter.cpp rename to trace_streamer/src/filter/hook_filter/offline_symbolization_filter.cpp index 7361485b244adfe8c4be1fd3232e677b5fbfdce8..1d9812ea4f7bd01fbf29ed640ee31491fe25bc3c 100644 --- a/trace_streamer/src/filter/offline_symbolization_filter.cpp +++ b/trace_streamer/src/filter/hook_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, @@ -27,21 +27,7 @@ OfflineSymbolizationFilter::OfflineSymbolizationFilter(TraceDataCache* dataCache ipidTofilePathIdToSymbolTableMap_(nullptr) { } -std::shared_ptr>> OfflineSymbolizationFilter::OfflineSymbolization( - const std::shared_ptr> ips) -{ - auto ipid = ips->back(); - auto result = std::make_shared>>(); - for (auto itor = ips->begin(); (itor + 1) != ips->end(); itor++) { - auto frameInfo = OfflineSymbolizationByIp(ipid, *itor); - // If the IP in the middle of the call stack cannot be symbolized, the remaining IP is discarded - if (!frameInfo) { - break; - } - result->emplace_back(frameInfo); - } - return result; -} + template void OfflineSymbolizationFilter::GetSymbolStartMaybeUpdateFrameInfo(T* elfSym, uint32_t& symbolStart, @@ -139,7 +125,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/hook_filter/offline_symbolization_filter.h similarity index 93% rename from trace_streamer/src/filter/offline_symbolization_filter.h rename to trace_streamer/src/filter/hook_filter/offline_symbolization_filter.h index 26aa1e644113f2e9a7330a785f6e25339c9cac23..0550e639e3b22f54d5575428b47241e65ef398b4 100644 --- a/trace_streamer/src/filter/offline_symbolization_filter.h +++ b/trace_streamer/src/filter/hook_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, @@ -29,6 +29,8 @@ #include "ts_common.h" namespace SysTuning { namespace TraceStreamer { +constexpr uint64_t ALLOC_IP_MASK = 0xFFFFFF0000000000; +constexpr uint64_t JS_IP_MASK = 0xFFFFFE0000000000; class FrameInfo { public: FrameInfo() @@ -61,8 +63,6 @@ public: OfflineSymbolizationFilter(TraceDataCache* dataCache, const TraceStreamerFilters* filter); ~OfflineSymbolizationFilter() override = default; std::shared_ptr OfflineSymbolizationByIp(uint64_t ipid, uint64_t ip); - std::shared_ptr>> OfflineSymbolization( - const std::shared_ptr> ips); DataIndex OfflineSymbolizationByVaddr(uint64_t symVaddr, DataIndex filePathIndex); protected: @@ -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/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/gn/.emscripten b/trace_streamer/src/filter/perf_filter/BUILD.gn similarity index 46% rename from trace_streamer/gn/.emscripten rename to trace_streamer/src/filter/perf_filter/BUILD.gn index 97e12ef16abdaf931b2083af45e4563dd1b77f90..374ed41738967a2c4feb35c2cfed737c0a959e9f 100644 --- a/trace_streamer/gn/.emscripten +++ b/trace_streamer/src/filter/perf_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 @@ -11,22 +11,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platform import system -import os -import sys +import("//build/ohos.gni") +import("../../../build/ts.gni") -thisFile = os.getenv('EM_CONFIG') -if thisFile is None: - sys.stderr.write('No EM_CONFIG in .emscripten file\n') - sys.exit(-1) +config("hiperf_filter_cfg") { + include_dirs = [ "." ] +} -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 +ohos_static_library("hiperf_filter") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "perf_data_filter.cpp" ] + public_configs = [ + ":hiperf_filter_cfg", + "..:filter_cfg", + ] +} diff --git a/trace_streamer/src/filter/perf_data_filter.cpp b/trace_streamer/src/filter/perf_filter/perf_data_filter.cpp similarity index 97% rename from trace_streamer/src/filter/perf_data_filter.cpp rename to trace_streamer/src/filter/perf_filter/perf_data_filter.cpp index a5467655c9e41041af1800671178eff06f64999f..bdaddf30be523402fb9706f25f960383d24c901f 100644 --- a/trace_streamer/src/filter/perf_data_filter.cpp +++ b/trace_streamer/src/filter/perf_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_filter/perf_data_filter.h similarity index 93% rename from trace_streamer/src/filter/perf_data_filter.h rename to trace_streamer/src/filter/perf_filter/perf_data_filter.h index 8b85efa75e8cfc3de2c70904ceb9c882edc271d4..3d7f62989f5f4675348e45d352186ea22f004160 100644 --- a/trace_streamer/src/filter/perf_data_filter.h +++ b/trace_streamer/src/filter/perf_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..331bc46d7b29a94b848c4696627024c00acb24bc 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,9 +38,9 @@ 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 taskId, uint32_t index) { - return IpidExecuteMap_.Find(GetIpId(index), executeId); + return IpidExecuteMap_.Find(GetIpId(index), taskId); } void TaskPoolFilter::TaskPoolFieldSegmentation(const std::string& taskPoolStr, @@ -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..37962a194b58f2435b918df03098757b3a71fbc2 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 taskId, 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..30a8ee24e31808b6730e6451ef25bbd4c40a3688 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,11 +27,13 @@ #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" -#include "parser/bytrace_parser/bytrace_event_parser.h" -#include "parser/bytrace_parser/bytrace_parser.h" +#include "parser/ptreader_parser/bytrace_parser/bytrace_event_parser.h" +#include "parser/ptreader_parser/ptreader_parser.h" #include "parting_string.h" #include "rpc_server.h" #include "string_help.h" @@ -70,6 +72,16 @@ void ExportStatusToLog(const std::string& dbPath, TraceParserStatus status) } void ShowHelpInfo(const char* argv) { + std::string dumpReadableTextPluginName; +#ifdef ENABLE_NATIVE_HOOK + dumpReadableTextPluginName.append("hook."); +#endif +#ifdef ENABLE_HIPERF + dumpReadableTextPluginName.append("perf."); +#endif +#ifdef ENABLE_EBPF + dumpReadableTextPluginName.append("ebpf."); +#endif printf( "trace analyze tool, it can transfer a bytrace/htrace file into a " "SQLite database and save result to a local file trace_streamer.log.\n" @@ -78,17 +90,17 @@ void ShowHelpInfo(const char* argv) "Options:\n" " -e transfer a trace file into a SQLiteBased DB. with -nm to except meta table\n" " -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" + " -D Specify the directory path with multiple long trace files\n" + " -d dump '%s' readable text.Default dump file path is src path name + `_ReadableText.txt`\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" + " --list Show the support and disable ability.\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" @@ -96,7 +108,7 @@ void ShowHelpInfo(const char* argv) " -nt close muti thread.\n" " -i show information.\n" " -v show version.\n", - argv, argv); + argv, argv, dumpReadableTextPluginName.empty() ? "null" : dumpReadableTextPluginName.data()); } void PrintInformation() { @@ -107,7 +119,67 @@ void PrintVersion() { (void)fprintf(stderr, "version %s\n", g_traceStreamerVersion.c_str()); } - +void PrintDefaultAbilityInfo(std::string& disableInfo) +{ +#ifndef ENABLE_BYTRACE + disableInfo.append("\n\tbytrace"); +#endif +#ifndef ENABLE_RAWTRACE + disableInfo.append("\n\trawtrace"); +#endif +#ifndef ENABLE_HTRACE + disableInfo.append("\n\thtrace"); +#endif +#ifndef ENABLE_MEMORY + disableInfo.append("\n\tmemory"); +#endif +#ifndef ENABLE_HTDUMP + disableInfo.append("\n\thidump"); +#endif +#ifndef ENABLE_CPUDATA + disableInfo.append("\n\tcpudata"); +#endif +#ifndef ENABLE_NETWORK + disableInfo.append("\n\tnetwork"); +#endif +#ifndef ENABLE_DISKIO + disableInfo.append("\n\tdiskio"); +#endif +#ifndef ENABLE_PROCESS + disableInfo.append("\n\tprocess"); +#endif + printf( + "the default support ability list:\n\thiperf,ebpf,native_hook,hilog,hisysevent,arkts\n\t" + "bytrace,rawtrace,htrace,memory,hidump,cpudata,network,diskio,process\n"); +} +void PrintAbilityInfo() +{ + std::string disableInfo; +#ifndef ENABLE_HIPERF + disableInfo.append("\n\thiperf"); +#endif +#ifndef ENABLE_EBPF + disableInfo.append("\n\tebpf"); +#endif +#ifndef ENABLE_NATIVE_HOOK + disableInfo.append("\n\tnative_hook"); +#endif +#ifndef ENABLE_HILOG + disableInfo.append("\n\thilog"); +#endif +#ifndef ENABLE_HISYSEVENT + disableInfo.append("\n\thisysevent"); +#endif +#ifndef ENABLE_ARKTS + disableInfo.append("\n\tarkts"); +#endif + PrintDefaultAbilityInfo(disableInfo); +#ifndef ENABLE_STREAM_EXTEND + disableInfo.append("\n\tstream_extend"); +#endif + printf("the extend support ability list:\n\tstream_extend\n"); + printf("the disable ability list:%s\n", disableInfo.empty() ? "\n\tnull" : disableInfo.c_str()); +} bool ReadAndParser(SysTuning::TraceStreamer::TraceStreamerSelector& ta, int fd) { auto startTime = @@ -254,6 +326,7 @@ struct TraceExportOption { bool separateFile = false; bool closeMutiThread = false; uint8_t parserThreadNum = INVALID_UINT8; + bool needClearLongTraceCache = true; }; bool CheckFinal(char** argv, TraceExportOption& traceExportOption) { @@ -321,12 +394,19 @@ bool CheckAndSetDumpFileType(TraceExportOption& traceExportOption, int argc, cha TS_CHECK_TRUE_RET(CheckArgc(argc, argv, ++index), false); auto dumpFileType = std::string(argv[index]); if (dumpFileType == "perf") { +#ifdef ENABLE_HIPERF traceExportOption.dumpFileType = DumpFileType::PERF_TYPE; +#endif } else if (dumpFileType == "hook") { +#ifdef ENABLE_NATIVE_HOOK traceExportOption.dumpFileType = DumpFileType::NATIVE_HOOK_TYPE; +#endif } else if (dumpFileType == "ebpf") { +#ifdef ENABLE_EBPF traceExportOption.dumpFileType = DumpFileType::EBPF_TYPE; - } else { +#endif + } + if (traceExportOption.dumpFileType == DumpFileType::UNKONW_TYPE) { ShowHelpInfo(argv[0]); return false; } @@ -342,13 +422,19 @@ 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; + } else if (!strcmp(argv[i], "--list")) { + PrintAbilityInfo(); + return false; } else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--s")) { traceExportOption.separateFile = true; return true; @@ -478,36 +564,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) { @@ -558,7 +649,7 @@ void Init(TraceStreamerSelector& ts, const TraceExportOption& traceExportOption) if (traceExportOption.closeMutiThread) { ts.GetTraceDataCache()->supportThread_ = false; } - if (traceExportOption.parserThreadNum != INVALID_UINT8 && traceExportOption.parserThreadNum > PARSER_THREAD_MIN && + if (traceExportOption.parserThreadNum != INVALID_UINT8 && traceExportOption.parserThreadNum >= PARSER_THREAD_MIN && traceExportOption.parserThreadNum <= PARSER_THREAD_MAX) { ts.GetTraceDataCache()->parserThreadNum_ = traceExportOption.parserThreadNum; } 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..8baf280a21b23647f05638a512879b5eb37b34ce 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 @@ -14,34 +14,7 @@ import("//build/ohos.gni") import("../../build/ts.gni") -ohos_source_set("parser") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" - sources = [ - "bytrace_parser/bytrace_event_parser.cpp", - "bytrace_parser/bytrace_hilog_parser.cpp", - "bytrace_parser/bytrace_hisysevent_parser.cpp", - "bytrace_parser/bytrace_parser.cpp", - "event_parser_base.cpp", - "print_event_parser.cpp", - "thread_state_flag.cpp", - ] - deps = [ - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", - "ebpf_parser:ebpf_parser", - ] - deps += [ "htrace_pbreader_parser:htrace_pbreader_parser" ] - deps += [ "rawtrace_parser:rawtrace_parser" ] - +config("parser_base_cfg") { include_dirs = [ "${THIRD_PARTY}/protobuf/src", "${THIRD_PARTY}/sqlite/include", @@ -53,12 +26,27 @@ ohos_source_set("parser") { "${SRC}/filter", "${SRC}", ".", - "htrace_pbreader_parser", + "pbreader_parser", + "pbreader_parser/htrace_parser", "rawtrace_parser", "../proto_reader/include", "${THIRD_PARTY}/bounds_checking_function/include", "${THIRD_PARTY}/json/single_include/nlohmann", ] + include_dirs += [ + "${PERF_DIR}/hiperf/include/nonlinux/linux", + "${PERF_DIR}/hiperf/include/nonlinux", + "${PERF_DIR}/hiperf/include", + "${THIRD_PARTY}/perf_include", + "${THIRD_PARTY}/perf_include/libbpf", + "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/cutil", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include", + ] include_dirs += [ "${SRC}/trace_data/trace_stdtype", "${SRC}/trace_data/trace_stdtype/ftrace", @@ -87,3 +75,51 @@ ohos_source_set("parser") { } } } + +config("hilog_parser_cfg") { + include_dirs = [ + "pbreader_parser", + "pbreader_parser/hilog_parser", + "ptreader_parser/hilog_parser", + ] +} + +config("hisysevent_parser_cfg") { + include_dirs = [ + "pbreader_parser", + "pbreader_parser/hisysevent_parser", + "ptreader_parser/hisysevent_parser", + ] +} + +ohos_source_set("parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "event_parser_base.cpp", + "print_event_parser.cpp", + "thread_state_flag.cpp", + ] + + deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", + ] + deps += [ "pbreader_parser:pbreader_parser" ] + deps += [ "ptreader_parser:ptreader_parser_src" ] + if (enable_rawtrace) { + deps += [ "rawtrace_parser:rawtrace_parser" ] + } + + # for hook,perf,ebpf + deps += [ "${PERF_DIR}/hiperf:hiperf_platform_common" ] + if (enable_ebpf) { + deps += [ "ebpf_parser:ebpf_parser" ] + } + public_configs = [ ":parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/common_types.h b/trace_streamer/src/parser/common_types.h index 390a193972438ef4389c3217bc49f3fd03f942b5..76f2c1baace7d5274eef7bd1f58a84fbcaafa2bb 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, @@ -28,6 +28,7 @@ namespace SysTuning { namespace TraceStreamer { enum ParseResult { PARSE_ERROR = 0, PARSE_SUCCESS = 1 }; enum RawType { RAW_CPU_IDLE = 1, RAW_SCHED_WAKEUP = 2, RAW_SCHED_WAKING = 3 }; +enum ErrorCode { ERROR_CODE_EXIT = -2, ERROR_CODE_NODATA = -1 }; struct BytraceLine { uint64_t ts = 0; uint32_t pid = 0; @@ -61,7 +62,7 @@ struct HilogLine { std::string tag; std::string context; }; -struct HtraceDataSegment { +struct PbreaderDataSegment { std::shared_ptr seg; uint64_t timeStamp{INVALID_TIME}; std::atomic clockId; @@ -113,7 +114,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..ab1c92cae8c0374c3fbf23ef72117e55e2f5ac20 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 @@ -13,21 +13,10 @@ import("//build/ohos.gni") import("../../../build/ts.gni") -ohos_source_set("ebpf_parser_src") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" +config("ebpf_parser_cfg") { if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } - sources = [ - "bio_latency_data_parser.cpp", - "ebpf_base.cpp", - "ebpf_data_parser.cpp", - "ebpf_data_reader.cpp", - "ebpf_splitter.cpp", - "file_system_data_parser.cpp", - "paged_memory_data_parser.cpp", - ] include_dirs = [ ".", "../", @@ -70,7 +59,6 @@ ohos_source_set("ebpf_parser_src") { cflags += [ "-D IS_UT" ] } } - public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader" ] include_dirs += [ "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", "${THIRD_PARTY}/perf_include/linux", @@ -84,9 +72,21 @@ ohos_source_set("ebpf_parser_src") { ] } -group("ebpf_parser") { +ohos_static_library("ebpf_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "bio_latency_data_parser.cpp", + "ebpf_base.cpp", + "ebpf_data_parser.cpp", + "ebpf_data_reader.cpp", + "ebpf_splitter.cpp", + "file_system_data_parser.cpp", + "paged_memory_data_parser.cpp", + ] + public_configs = [ ":ebpf_parser_cfg" ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader" ] deps = [ - ":ebpf_parser_src", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", ] 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..7944ce7bbaead63f99966c4d194b9ac312dcc280 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, @@ -29,7 +29,7 @@ #include "trace_data/trace_data_cache.h" #include "trace_streamer_filters.h" #include "unordered_map" -#include "htrace_file_header.h" +#include "pbreader_file_header.h" #include "common_types.h" namespace SysTuning { @@ -38,7 +38,6 @@ using namespace SysTuning::EbpfStdtype; class EbpfSplitter { public: void SetEbpfDataOffset(uint64_t offset); - void SetProfilerHeader(const ProfilerTraceFileHeader& header); void SetSpliteTimeRange(uint64_t splitFileMinTs, uint64_t splitFileMaxTs); bool AddAndSplitEbpfData(std::deque& dequeBuffer); void RecordEbpfProfilerHeader(uint8_t* buffer, uint32_t len) 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..06047b5c63acdf65d25091030f830d835b70a891 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 @@ -13,9 +13,8 @@ import("//build/ohos.gni") import("../../../build/ts.gni") -ohos_source_set("hiperf_parser_src") { - subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" - part_name = "${OHOS_PROFILER_PART_NAME}" + +config("hiperf_parser_cfg") { if (!is_independent_compile) { configs = [ "${TS_DIR}/gn:ts_config" ] } @@ -33,7 +32,6 @@ ohos_source_set("hiperf_parser_src") { cflags += [ "-D IS_UT" ] } } - sources = [ "perf_data_parser.cpp" ] include_dirs = [ ".", "../../base", @@ -46,24 +44,11 @@ ohos_source_set("hiperf_parser_src") { "../../trace_streamer", "../../proto_reader/include", "${THIRD_PARTY}/bounds_checking_function/include", - "${PERF_DIR}/hiperf/include/nonlinux/linux", - "${PERF_DIR}/hiperf/include/nonlinux", - "${PERF_DIR}/hiperf/include", "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/protobuf/src", - "${THIRD_PARTY}/perf_include", - "${THIRD_PARTY}/perf_include/libbpf", "${COMMON_LIBRARY}/c_utils/base/include", "${THIRD_PARTY}/googletest/googletest/include", ] - include_dirs += [ - "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include", - ] include_dirs += [ "${SRC}/trace_data/trace_stdtype", "${SRC}/trace_data/trace_stdtype/ftrace", @@ -74,6 +59,31 @@ ohos_source_set("hiperf_parser_src") { "${SRC}/trace_data/trace_stdtype/htrace", "${SRC}/trace_data/trace_stdtype/measure", ] + include_dirs += [ + "${THIRD_PARTY}/libunwind/include", + "${THIRD_PARTY}/libunwind/src", + "${PERF_DIR}/hiperf/include", + "${PERF_DIR}/hiperf/include/nonlinux/linux", + "${PERF_DIR}/hiperf/include/nonlinux", + "${THIRD_PARTY}/googletest/googletest/include", + "${THIRD_PARTY}/perf_include/libbpf", + "${THIRD_PARTY}/perf_include/include", + "${THIRD_PARTY}/perf_include", + "${THIRD_PARTY}/perf_include/linux", + "../hiperf_parser", + "../hiperf_parser/include", + "${COMMON_LIBRARY}/c_utils/base/include", + "${THIRD_PARTY}/sqlite", + ] + include_dirs += [ + "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/cutil", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", + "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include", + ] include_dirs += [ "${THIRD_PARTY}/libunwind/include" ] if (is_mingw || is_mac) { include_dirs += [ "${THIRD_PARTY}/libbpf/include/uapi" ] @@ -83,9 +93,12 @@ ohos_source_set("hiperf_parser_src") { } } -group("hiperf_parser") { +ohos_static_library("hiperf_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "perf_data_parser.cpp" ] + public_configs = [ ":hiperf_parser_cfg" ] deps = [ - ":hiperf_parser_src", "${PERF_DIR}/hiperf:hiperf_platform_common", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", 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..ec50366d292db2acce61095bac0194cd6ebd4451 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, @@ -15,7 +15,7 @@ #include "perf_data_parser.h" #include "clock_filter_ex.h" #include "file.h" -#include "perf_data_filter.h" +#include "perf_filter/perf_data_filter.h" #include "stat_filter.h" namespace SysTuning { 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..2709ac8b0b58418e9eb4f5acd4a7618bd45f6162 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, @@ -21,7 +21,7 @@ #include #include "common_types.h" #include "event_parser_base.h" -#include "htrace_file_header.h" +#include "pbreader_file_header.h" #include "htrace_plugin_time_parser.h" #include "log.h" #if is_mingw 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/htrace_pbreader_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/BUILD.gn similarity index 46% rename from trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn rename to trace_streamer/src/parser/pbreader_parser/BUILD.gn index 07e2e3fd1930494ecc8de3a127e32f0f0d76e174..660b5b30989098a9d3590f10d27a9023e55cd6d7 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/BUILD.gn +++ b/trace_streamer/src/parser/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 @@ -12,33 +12,17 @@ # limitations under the License. import("//build/ohos.gni") import("../../../build/ts.gni") -ohos_source_set("htrace_pbreader_parser_src") { +ohos_source_set("pbreader_parser_src") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ "../parser_base.cpp", - "htrace_clock_detail_parser.cpp", - "htrace_cpu_data_parser.cpp", - "htrace_cpu_parser/htrace_cpu_detail_parser.cpp", - "htrace_disk_io_parser.cpp", - "htrace_event_parser/htrace_event_parser.cpp", - "htrace_hidump_parser.cpp", - "htrace_hilog_parser.cpp", - "htrace_hisysevent_parser.cpp", - "htrace_js_cpu_profiler_parser.cpp", - "htrace_js_memory_parser.cpp", - "htrace_mem_parser.cpp", - "htrace_native_hook_parser.cpp", - "htrace_network_parser.cpp", - "htrace_parser.cpp", - "htrace_process_parser.cpp", - "htrace_symbols_detail_parser.cpp", + "pbreader_parser.cpp", ] include_dirs = [ "../../proto_reader/include", ".", - "htrace_event_parser", - "htrace_cpu_parser", + "htrace_parser", "../../include", "../../", "../", @@ -54,31 +38,6 @@ ohos_source_set("htrace_pbreader_parser_src") { "../../base", "../ebpf_parser", ] - include_dirs += [ - "${THIRD_PARTY}/libunwind/include", - "${THIRD_PARTY}/libunwind/src", - "${PERF_DIR}/hiperf/include", - "${PERF_DIR}/hiperf/include/nonlinux/linux", - "${PERF_DIR}/hiperf/include/nonlinux", - "${THIRD_PARTY}/googletest/googletest/include", - "${THIRD_PARTY}/perf_include/libbpf", - "${THIRD_PARTY}/perf_include/include", - "${THIRD_PARTY}/perf_include", - "${THIRD_PARTY}/perf_include/linux", - "../hiperf_parser", - "../hiperf_parser/include", - "${COMMON_LIBRARY}/c_utils/base/include", - "${THIRD_PARTY}/sqlite", - ] - include_dirs += [ - "${THIRD_PARTY}/perf_include/hiviewdfx/hilog/include", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/cutil", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxlog", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/common/dfxutil", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/common", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/nonlinux", - "${THIRD_PARTY}/perf_include/hiviewdfx/faultloggerd/interfaces/innerkits/unwinder/include", - ] include_dirs += [ "${SRC}/trace_data/trace_stdtype", "${SRC}/trace_data/trace_stdtype/ftrace", @@ -116,26 +75,53 @@ ohos_source_set("htrace_pbreader_parser_src") { if (is_mingw) { cflags = [ "-includeMingW64Fix.h" ] } - + public_configs = [ "../ebpf_parser:ebpf_parser_cfg" ] public_deps = [] - deps = [ - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader", - "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", - ] + if (enable_hiperf) { + public_deps += [ "../hiperf_parser:hiperf_parser" ] + } + if (enable_native_hook) { + public_deps += [ "native_hook_parser:native_hook_parser" ] + } + if (enable_hilog) { + public_deps += [ "hilog_parser:pbreader_hilog_parser" ] + } + if (enable_hisysevent) { + public_deps += [ "hisysevent_parser:pbreader_hisysevent_parser" ] + } + if (enable_arkts) { + public_deps += [ "arkts:pbreader_arkts_parser" ] + } + if (enable_htrace) { + public_deps += [ "htrace_parser:pbreader_htrace_parser" ] + } + if (enable_memory) { + public_deps += [ "mem_parser:pbreader_mem_parser" ] + } + if (enable_hidump) { + public_deps += [ "hidump_parser:pbreader_hidump_parser" ] + } + if (enable_cpudata) { + public_deps += [ "cpu_data_parser:cpu_data_parser" ] + } + if (enable_network) { + public_deps += [ "network_parser:network_parser" ] + } + if (enable_diskio) { + public_deps += [ "disk_io_parser:disk_io_parser" ] + } + if (enable_process) { + public_deps += [ "process_parser:process_parser" ] + } + if (enable_stream_extend) { + public_deps += + [ "${EXTEND_SRC}/parser/pbreader_stream_parser:stream_extend_parser" ] + } + deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard" ] } -group("htrace_pbreader_parser") { +group("pbreader_parser") { deps = [ - ":htrace_pbreader_parser_src", + ":pbreader_parser_src", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", "//third_party/perf_include/hiviewdfx:hiviewdfx", diff --git a/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3b4ab4e7a975f9605faebaeaed1e712d92808b2a --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/arkts/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("pbreader_arkts_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "pbreader_js_cpu_profiler_parser.cpp", + "pbreader_js_memory_parser.cpp", + ] + include_dirs = [ "." ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/js_memory:js_memory_data_reader", + ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_cpu_profiler_parser.cpp similarity index 97% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_cpu_profiler_parser.cpp index 53d411d8cf474267aadce179ea51cfc4d55dbd9b..85c5090ea389fd41d76e98bd316e366d97f6db60 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_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, @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_js_cpu_profiler_parser.h" +#include "pbreader_js_cpu_profiler_parser.h" #include "clock_filter_ex.h" namespace SysTuning { diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_cpu_profiler_parser.h similarity index 94% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_cpu_profiler_parser.h rename to trace_streamer/src/parser/pbreader_parser/arkts/pbreader_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/pbreader_parser/arkts/pbreader_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/pbreader_parser/arkts/pbreader_js_memory_parser.cpp similarity index 84% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_memory_parser.cpp index 447306465ebe2c31dba55f69a7add71462abf9c1..70243bd27de2f98f4036fa36a694f4a2252f4bd0 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_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, @@ -12,15 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_js_memory_parser.h" +#include "pbreader_js_memory_parser.h" #include #include #include #include "clock_filter_ex.h" #include "fcntl.h" #include "file.h" -#include "htrace_event_parser.h" -#include "htrace_parser.h" #include "js_heap_config.pbreader.h" #include "js_heap_result.pbreader.h" #include "process_filter.h" @@ -51,11 +49,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 +114,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]); @@ -280,29 +279,30 @@ const int32_t PROFILE_POS = 9; const int32_t END_PROFILE_POS = 2; const int32_t TIME_MILLI_SECOND = 1000; const int32_t TIME_MICRO_SECOND = 1000 * 1000; -const std::string JS_MEMORY_INDEX = "{\"params:{\"chunk\":{"; +const std::string JS_MEMORY_INDEX = "{\"params\":{\"chunk\":"; const std::string ARKTS_INDEX = "{\"id\":3, \"result\":{\"profile\":"; -HtraceJSMemoryParser::HtraceJSMemoryParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderJSMemoryParser::PbreaderJSMemoryParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx), jsCpuProfilerParser_(std::make_unique(dataCache, ctx)) { + // Delete files in the executable file path that fileName contain the string "ts_tmp. jsmemory_snapshot" DIR* dir = opendir("."); if (dir != nullptr) { dirent* entry; while ((entry = readdir(dir)) != nullptr) { std::string filename(entry->d_name); - if (filename.find(tmpJsMemorySnapshotData_) != string::npos) { + if (filename.find(tmpJsMemorySnapshotData_) != std::string::npos) { (void)std::remove(filename.c_str()); } } closedir(dir); } } -HtraceJSMemoryParser::~HtraceJSMemoryParser() +PbreaderJSMemoryParser::~PbreaderJSMemoryParser() { TS_LOGI("arkts-plugin ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceJSMemoryParser::ParseJSMemoryConfig(ProtoReader::BytesView tracePacket) +void PbreaderJSMemoryParser::ParseJSMemoryConfig(ProtoReader::BytesView tracePacket) { ProtoReader::ArkTSConfig_Reader jsHeapConfig(tracePacket.data_, tracePacket.size_); auto pid = jsHeapConfig.pid(); @@ -316,7 +316,7 @@ void HtraceJSMemoryParser::ParseJSMemoryConfig(ProtoReader::BytesView tracePacke (void)traceDataCache_->GetJsConfigData()->AppendNewData(pid, type_, interval, captureNumericValue, trackAllocation, cpuProfiler, cpuProfilerInterval); } -struct timespec HtraceJSMemoryParser::TimeToTimespec(uint64_t timeMs) +struct timespec PbreaderJSMemoryParser::TimeToTimespec(uint64_t timeMs) { timeMs = timeMs / TIME_MILLI_SECOND; timespec ts; @@ -324,9 +324,9 @@ struct timespec HtraceJSMemoryParser::TimeToTimespec(uint64_t timeMs) ts.tv_nsec = (timeMs % TIME_MICRO_SECOND) * TIME_MILLI_SECOND; return ts; } -void HtraceJSMemoryParser::SerializeToString(const ProfilerPluginDataHeader& profilerPluginData, - uint64_t startTime, - uint64_t endTime) +void PbreaderJSMemoryParser::SerializeToString(const ProfilerPluginDataHeader& profilerPluginData, + uint64_t startTime, + uint64_t endTime) { startTime = streamFilters_->clockFilter_->Convert(TS_CLOCK_BOOTTIME, startTime, TS_CLOCK_REALTIME); endTime = streamFilters_->clockFilter_->Convert(TS_CLOCK_BOOTTIME, endTime, TS_CLOCK_REALTIME); @@ -349,14 +349,14 @@ void HtraceJSMemoryParser::SerializeToString(const ProfilerPluginDataHeader& pro SerializeCpuProfilerData(startTime, endTime, profilerPluginDataResult, jsHeapResult); } } -void HtraceJSMemoryParser::SerializeSnapshotData(ProfilerPluginData& profilerPluginDataResult, - ArkTSResult& jsHeapResult) +void PbreaderJSMemoryParser::SerializeSnapshotData(ProfilerPluginData& profilerPluginDataResult, + ArkTSResult& jsHeapResult) { if (curTypeIsCpuProfile_) { curTypeIsCpuProfile_ = false; return; } - jsHeapResult.set_result(JS_MEMORY_INDEX + snapShotData_.snapshotData + "}}\""); + jsHeapResult.set_result(JS_MEMORY_INDEX + snapShotData_.snapshotData + "}}"); snapShotData_.startTime = streamFilters_->clockFilter_->Convert(TS_CLOCK_BOOTTIME, snapShotData_.startTime, TS_CLOCK_REALTIME); snapShotData_.endTime = @@ -385,10 +385,10 @@ void HtraceJSMemoryParser::SerializeSnapshotData(ProfilerPluginData& profilerPlu memcpy_s(&endLen[0], sizeof(uint32_t), &profilerArktsDataSize, sizeof(uint32_t)); profilerArktsData_ += bufflen + profilerArktsData + endLen + arkTsEndString; } -void HtraceJSMemoryParser::SerializeTimelineData(uint64_t startTime, - uint64_t endTime, - ProfilerPluginData& profilerPluginDataResult, - ArkTSResult& jsHeapResult) +void PbreaderJSMemoryParser::SerializeTimelineData(uint64_t startTime, + uint64_t endTime, + ProfilerPluginData& profilerPluginDataResult, + ArkTSResult& jsHeapResult) { std::string startString = ""; jsHeapResult.set_result(snapshotEnd_); @@ -399,7 +399,7 @@ void HtraceJSMemoryParser::SerializeTimelineData(uint64_t startTime, profilerPluginDataResult.set_data(startString); std::string timelineStartString = ""; profilerPluginDataResult.SerializeToString(&timelineStartString); - jsHeapResult.set_result(JS_MEMORY_INDEX + jsMemorySplitFileData_ + "}}\""); + jsHeapResult.set_result(JS_MEMORY_INDEX + jsMemorySplitFileData_ + "}}"); jsHeapResult.SerializeToString(&arkTsSplitFileDataResult_); profilerPluginDataResult.set_data(arkTsSplitFileDataResult_); std::string profilerArktsData = ""; @@ -424,10 +424,10 @@ void HtraceJSMemoryParser::SerializeTimelineData(uint64_t startTime, memcpy_s(&endLen[0], sizeof(uint32_t), &size, sizeof(uint32_t)); profilerArktsData_ = startLen + timelineStartString + bufflen + profilerArktsData + endLen + timelineEndString; } -void HtraceJSMemoryParser::SerializeCpuProfilerData(uint64_t startTime, - uint64_t endTime, - ProfilerPluginData& profilerPluginDataResult, - ArkTSResult& jsHeapResult) +void PbreaderJSMemoryParser::SerializeCpuProfilerData(uint64_t startTime, + uint64_t endTime, + ProfilerPluginData& profilerPluginDataResult, + ArkTSResult& jsHeapResult) { std::string startString = ""; jsHeapResult.set_result(jsCpuProfilerStart_); @@ -454,19 +454,15 @@ void HtraceJSMemoryParser::SerializeCpuProfilerData(uint64_t startTime, memcpy_s(&bufflen[0], sizeof(uint32_t), &size, sizeof(uint32_t)); profilerArktsData_ += startLen + arkTsStartString + bufflen + profilerArktsData; } -void HtraceJSMemoryParser::ParseSnapshotOrTimeLineEnd(const std::string& result, - ProtoReader::BytesView& tracePacket, - ProfilerPluginDataHeader& profilerPluginData, - uint64_t ts) +void PbreaderJSMemoryParser::ParseSnapshotOrTimeLineEnd(const std::string& result, + ProtoReader::BytesView& tracePacket, + ProfilerPluginDataHeader& profilerPluginData, + 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 +471,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); @@ -490,21 +486,18 @@ void HtraceJSMemoryParser::ParseSnapshotOrTimeLineEnd(const std::string& result, fileId_++; isFirst_ = true; } -void HtraceJSMemoryParser::ParseJsCpuProfiler(const std::string& result, - ProfilerPluginDataHeader& profilerPluginData, - uint64_t ts) +void PbreaderJSMemoryParser::ParseJsCpuProfiler(const std::string& result, + ProfilerPluginDataHeader& profilerPluginData, + uint64_t ts) { auto jsCpuProfilerPos = result.find("profile"); - if (jsCpuProfilerPos == string::npos) { + if (jsCpuProfilerPos == std::string::npos) { return; } 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,22 +507,22 @@ 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(); SerializeToString(profilerPluginData, traceDataCache_->SplitFileMinTime(), traceDataCache_->SplitFileMaxTime()); } } -void HtraceJSMemoryParser::Parse(ProtoReader::BytesView tracePacket, - uint64_t ts, - uint64_t startTime, - uint64_t endTime, - ProfilerPluginDataHeader profilerPluginData) +void PbreaderJSMemoryParser::Parse(ProtoReader::BytesView tracePacket, + uint64_t ts, + uint64_t startTime, + uint64_t endTime, + ProfilerPluginDataHeader profilerPluginData) { ProtoReader::ArkTSResult_Reader jsHeapResult(tracePacket.data_, tracePacket.size_); auto result = jsHeapResult.result().ToStdString(); @@ -543,21 +536,27 @@ void HtraceJSMemoryParser::Parse(ProtoReader::BytesView tracePacket, cpuTimeFirst_ = false; } auto pos = result.find("chunk"); - if (pos != string::npos) { + if (pos != std::string::npos) { if (isFirst_ && type_ == ProtoReader::ArkTSConfig_HeapType::ArkTSConfig_HeapType_SNAPSHOT) { ts = streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, ts); UpdatePluginTimeRange(TS_CLOCK_REALTIME, ts, ts); 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")) { + if (jMessage["params"]["chunk"].is_string()) { + jsMemoryString_ += jMessage["params"]["chunk"]; + } else { + jsMemoryString_ += jMessage["params"]["chunk"].dump(); + } + } curTypeIsCpuProfile_ = false; } else { ParseJsCpuProfiler(result, profilerPluginData, ts); } } -void HtraceJSMemoryParser::ParseTimeLine(ProfilerPluginDataHeader& profilerPluginData, const std::string& jsonString) +void PbreaderJSMemoryParser::ParseTimeLine(ProfilerPluginDataHeader& profilerPluginData, const std::string& jsonString) { if (enableFileSave_) { (void)write(jsFileId_, jsonString.data(), jsonString.size()); @@ -589,9 +588,9 @@ void HtraceJSMemoryParser::ParseTimeLine(ProfilerPluginDataHeader& profilerPlugi streamFilters_->statFilter_->IncreaseStat(TRACE_JS_MEMORY, STAT_EVENT_RECEIVED); return; } -void HtraceJSMemoryParser::ParserSnapInfo(int32_t fileId, - const std::string& key, - const std::vector>& types) +void PbreaderJSMemoryParser::ParserSnapInfo(int32_t fileId, + const std::string& key, + const std::vector>& types) { if (traceDataCache_->isSplitFile_) { return; @@ -608,14 +607,15 @@ void HtraceJSMemoryParser::ParserSnapInfo(int32_t fileId, } const std::string NODE_TYPES = "node_types"; const std::string EDGE_TYPES = "edge_types"; -void HtraceJSMemoryParser::ParserJSSnapInfo(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParserJSSnapInfo(int32_t fileId, const json& jMessage) { - if (traceDataCache_->isSplitFile_) { - return; - } jsonns::Snapshot snapshot = jMessage.at("snapshot"); ParserSnapInfo(fileId, NODE_TYPES, snapshot.meta.nodeTypes); ParserSnapInfo(fileId, EDGE_TYPES, snapshot.meta.edgeTypes); + // Ensure successful update of g_nodesSingleLength + if (traceDataCache_->isSplitFile_) { + return; + } auto nodeCount = snapshot.nodeCount; auto edgeCount = snapshot.edgeCount; auto traceFuncCount = snapshot.traceFunctionCount; @@ -624,7 +624,7 @@ void HtraceJSMemoryParser::ParserJSSnapInfo(int32_t fileId, const json& jMessage (void)traceDataCache_->GetJsHeapInfoData()->AppendNewData(fileId, "trace_function_count", 0, traceFuncCount, ""); return; } -void HtraceJSMemoryParser::ParseNodes(int32_t fileId, const json& jMessage, uint64_t endTime, bool isSplitFile) +void PbreaderJSMemoryParser::ParseNodes(int32_t fileId, const json& jMessage, uint64_t endTime, bool isSplitFile) { json filteredNodes = nlohmann::json::array(); jsonns::Nodes node = jMessage.at("nodes"); @@ -657,7 +657,7 @@ void HtraceJSMemoryParser::ParseNodes(int32_t fileId, const json& jMessage, uint } return; } -void HtraceJSMemoryParser::ParseEdges(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParseEdges(int32_t fileId, const json& jMessage) { if (traceDataCache_->isSplitFile_) { return; @@ -674,7 +674,7 @@ void HtraceJSMemoryParser::ParseEdges(int32_t fileId, const json& jMessage) } return; } -void HtraceJSMemoryParser::ParseLocation(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParseLocation(int32_t fileId, const json& jMessage) { if (traceDataCache_->isSplitFile_) { return; @@ -689,11 +689,11 @@ void HtraceJSMemoryParser::ParseLocation(int32_t fileId, const json& jMessage) } return; } -void HtraceJSMemoryParser::ParseSample(int32_t fileId, - const json& jMessage, - uint64_t startTime, - uint64_t endTime, - bool isSplitFile) +void PbreaderJSMemoryParser::ParseSample(int32_t fileId, + const json& jMessage, + uint64_t startTime, + uint64_t endTime, + bool isSplitFile) { json filteredSamples = nlohmann::json::array(); jsonns::Sample sample = jMessage.at("samples"); @@ -720,7 +720,7 @@ void HtraceJSMemoryParser::ParseSample(int32_t fileId, } return; } -void HtraceJSMemoryParser::ParseString(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParseString(int32_t fileId, const json& jMessage) { if (traceDataCache_->isSplitFile_) { return; @@ -731,7 +731,7 @@ void HtraceJSMemoryParser::ParseString(int32_t fileId, const json& jMessage) } return; } -void HtraceJSMemoryParser::ParseTraceFuncInfo(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParseTraceFuncInfo(int32_t fileId, const json& jMessage) { if (traceDataCache_->isSplitFile_) { return; @@ -749,7 +749,7 @@ void HtraceJSMemoryParser::ParseTraceFuncInfo(int32_t fileId, const json& jMessa } return; } -void HtraceJSMemoryParser::ParseTraceNode(int32_t fileId, const json& jMessage) +void PbreaderJSMemoryParser::ParseTraceNode(int32_t fileId, const json& jMessage) { if (traceDataCache_->isSplitFile_) { return; @@ -766,10 +766,10 @@ void HtraceJSMemoryParser::ParseTraceNode(int32_t fileId, const json& jMessage) } return; } -void HtraceJSMemoryParser::ParseSnapshot(ProtoReader::BytesView& tracePacket, - ProfilerPluginDataHeader& profilerPluginData, - const std::string& jsonString, - uint64_t& ts) +void PbreaderJSMemoryParser::ParseSnapshot(ProtoReader::BytesView& tracePacket, + ProfilerPluginDataHeader& profilerPluginData, + const std::string& jsonString, + uint64_t& ts) { if (enableFileSave_) { if (jsFileId_) { @@ -789,6 +789,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); @@ -814,7 +815,7 @@ void HtraceJSMemoryParser::ParseSnapshot(ProtoReader::BytesView& tracePacket, streamFilters_->statFilter_->IncreaseStat(TRACE_JS_MEMORY, STAT_EVENT_RECEIVED); return; } -void HtraceJSMemoryParser::EnableSaveFile(bool enable) +void PbreaderJSMemoryParser::EnableSaveFile(bool enable) { enableFileSave_ = enable; if (enable) { @@ -834,9 +835,12 @@ void HtraceJSMemoryParser::EnableSaveFile(bool enable) } } } -void HtraceJSMemoryParser::Finish() +void PbreaderJSMemoryParser::Finish() { traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime()); + // In the case of incomplete data at the end of the file, jsMemoryString_ has an initial value when cutting data. + // This part of the data should be discarded + jsMemoryString_ = ""; return; } } // namespace TraceStreamer diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_memory_parser.h similarity index 92% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h rename to trace_streamer/src/parser/pbreader_parser/arkts/pbreader_js_memory_parser.h index 4a9d37c3d52ceec5d4930c9ac219da455d5767a7..61d98978071b367a826e829f89294c1f3dd089e3 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_js_memory_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/arkts/pbreader_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, @@ -20,8 +20,8 @@ #include "common_types.h" #include "common_types.pb.h" #include "event_parser_base.h" -#include "htrace_file_header.h" -#include "htrace_js_cpu_profiler_parser.h" +#include "pbreader_file_header.h" +#include "pbreader_js_cpu_profiler_parser.h" #include "htrace_plugin_time_parser.h" #include "js_heap_result.pb.h" #include "json.hpp" @@ -36,10 +36,10 @@ struct SnapShotData { uint64_t endTime; std::string snapshotData; }; -class HtraceJSMemoryParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderJSMemoryParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceJSMemoryParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceJSMemoryParser(); + PbreaderJSMemoryParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderJSMemoryParser(); void ParseJSMemoryConfig(ProtoReader::BytesView tracePacket); void Parse(ProtoReader::BytesView tracePacket, uint64_t ts, diff --git a/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d838f439b135d09afd9edbde72556944a681229d --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("cpu_data_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_cpu_data_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/cpu_data:cpu_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.cpp similarity index 85% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.cpp index a8359956c6162eca0f5e07e3cac85f39d6c0e8b7..6eb5ee738cbeae404cb058cc0268407cd0124480 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_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, @@ -12,24 +12,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_cpu_data_parser.h" +#include "pbreader_cpu_data_parser.h" #include "clock_filter_ex.h" -#include "htrace_event_parser.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceCpuDataParser::HtraceCpuDataParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderCpuDataParser::PbreaderCpuDataParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceCpuDataParser::~HtraceCpuDataParser() +PbreaderCpuDataParser::~PbreaderCpuDataParser() { TS_LOGI("cpuData ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceCpuDataParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) +void PbreaderCpuDataParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) { ProtoReader::CpuData_Reader cpuData(tracePacket.data_, tracePacket.size_); if (!cpuData.has_cpu_usage_info() && !cpuData.has_thread_info()) { @@ -48,7 +47,7 @@ void HtraceCpuDataParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) cpuData_.push_back(std::move(cpuUsage)); } } -void HtraceCpuDataParser::Finish() +void PbreaderCpuDataParser::Finish() { auto cmp = [](const std::unique_ptr& a, const std::unique_ptr& b) { return a->ts_ < b->ts_; }; std::stable_sort(cpuData_.begin(), cpuData_.end(), cmp); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h similarity index 87% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h rename to trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_cpu_data_parser.h index e32411b647c820c1088ac30ef0255f05530ae5ef..3abac2716e3793fde13e6e8613028b2d4e586c26 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_data_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/cpu_data_parser/pbreader_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, @@ -19,7 +19,6 @@ #include #include "cpu_plugin_result.pbreader.h" #include "event_parser_base.h" -#include "hilog_plugin_result.pbreader.h" #include "htrace_plugin_time_parser.h" #include "trace_data/trace_data_cache.h" #include "trace_streamer_config.h" @@ -27,10 +26,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceCpuDataParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderCpuDataParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceCpuDataParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceCpuDataParser(); + PbreaderCpuDataParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderCpuDataParser(); void Parse(ProtoReader::BytesView tracePacket, uint64_t ts); void Finish(); enum TSCpuDataType { TS_CPU_DATA_TYPE_USAGE, TS_CPU_DATA_TYPE_THREAD_INFO, TS_CPU_DATA_TYPE_LOAD }; diff --git a/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..60fbc0ae3bd0247765a66bda20d056f553c5af82 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("disk_io_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_disk_io_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/diskio_data:diskio_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_disk_io_parser.cpp similarity index 88% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_disk_io_parser.cpp index 69b30102944f807350166e0c2d3f8053e075ff59..48bd9e4e5072737aa4419f5dc0fee9b48abb1bd0 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_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, @@ -12,25 +12,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_disk_io_parser.h" +#include "pbreader_disk_io_parser.h" #include "clock_filter_ex.h" #include "diskio_plugin_result.pbreader.h" -#include "htrace_event_parser.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceDiskIOParser::HtraceDiskIOParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderDiskIOParser::PbreaderDiskIOParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceDiskIOParser::~HtraceDiskIOParser() +PbreaderDiskIOParser::~PbreaderDiskIOParser() { TS_LOGI("diskio ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceDiskIOParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) +void PbreaderDiskIOParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) { ProtoReader::DiskioData_Reader diskioData(tracePacket.data_, tracePacket.size_); auto stat = diskioData.statsdata(); @@ -52,7 +51,7 @@ void HtraceDiskIOParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) diskioData.prev_rd_sectors_kb(), diskioData.prev_wr_sectors_kb(), rdCountPerSec, wrCountPerSec, rdCount, wrCount}); } -void HtraceDiskIOParser::Finish() +void PbreaderDiskIOParser::Finish() { auto cmp = [](const TsDiskIOData& a, const TsDiskIOData& b) { return a.ts < b.ts; }; std::stable_sort(diskIOData_.begin(), diskIOData_.end(), cmp); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_disk_io_parser.h similarity index 82% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h rename to trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_disk_io_parser.h index 234260a375bf6e9e1c1b1247d88077694529e277..38df0e018bb136b0d03bd72854630b8dc1d41bf5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_disk_io_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/disk_io_parser/pbreader_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, @@ -25,10 +25,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceDiskIOParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderDiskIOParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceDiskIOParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceDiskIOParser(); + PbreaderDiskIOParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderDiskIOParser(); void Parse(ProtoReader::BytesView tracePacket, uint64_t ts); void Finish(); diff --git a/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2dfd3f05f926fb1ac7480c6deae4e79dbb5f7bee --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/hidump_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("pbreader_hidump_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_hidump_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hidump_data:hidump_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.cpp similarity index 82% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.cpp index 22c9ec90774434f560a8bbfcec5f3a8378b90613..c4ab1c39905929db66a9ad0dc89e4d0f87d41da9 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_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, @@ -12,25 +12,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_hidump_parser.h" +#include "pbreader_hidump_parser.h" #include "clock_filter_ex.h" #include "hidump_plugin_result.pbreader.h" -#include "htrace_event_parser.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceHidumpParser::HtraceHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderHidumpParser::PbreaderHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx), clockId_(0) { } -HtraceHidumpParser::~HtraceHidumpParser() +PbreaderHidumpParser::~PbreaderHidumpParser() { TS_LOGI("Fps data ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceHidumpParser::Parse(ProtoReader::BytesView tracePacket) +void PbreaderHidumpParser::Parse(ProtoReader::BytesView tracePacket) { ProtoReader::HidumpInfo_Reader hidumpInfo(tracePacket.data_, tracePacket.size_); if (!hidumpInfo.has_fps_event()) { @@ -48,7 +47,7 @@ void HtraceHidumpParser::Parse(ProtoReader::BytesView tracePacket) traceDataCache_->GetHidumpData()->AppendNewHidumpInfo(newTimeStamp, fps); } } -void HtraceHidumpParser::Finish() +void PbreaderHidumpParser::Finish() { traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime()); } diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h similarity index 78% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h rename to trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_hidump_parser.h index 904ebd8ac8cc7bfeb8fe9e4d729bca00467bf9ca..c4ee0d92e974572b809002255d6fe81f00eb284c 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hidump_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hidump_parser/pbreader_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, @@ -26,10 +26,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceHidumpParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderHidumpParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceHidumpParser(); + PbreaderHidumpParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderHidumpParser(); void Parse(ProtoReader::BytesView tracePacket); void Finish(); uint8_t ClockId() diff --git a/trace_streamer/src/parser/pbreader_parser/hilog_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/hilog_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c090a8609334c61346d20692c341e78bbefde95d --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/hilog_parser/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("pbreader_hilog_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_hilog_parser.cpp" ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader", + ] + public_configs = [ + "../../:hilog_parser_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp similarity index 88% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.cpp index 5bb146ffa5572229342693a3f46468931ebfcf54..a844dfaa5add249046ee929f5f0d51ce54874db4 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_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, @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_hilog_parser.h" +#include "pbreader_hilog_parser.h" #include "clock_filter_ex.h" #include "event_parser_base.h" #include "hilog_plugin_result.pbreader.h" @@ -21,17 +21,17 @@ #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceHiLogParser::HtraceHiLogParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderHiLogParser::PbreaderHiLogParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceHiLogParser::~HtraceHiLogParser() +PbreaderHiLogParser::~PbreaderHiLogParser() { TS_LOGI("hilog ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceHiLogParser::Parse(ProtoReader::BytesView tracePacket, bool& haveSplitSeg) +void PbreaderHiLogParser::Parse(ProtoReader::BytesView tracePacket, bool& haveSplitSeg) { ProtoReader::HilogInfo_Reader hilogInfo(tracePacket.data_, tracePacket.size_); if (!hilogInfo.has_info()) { @@ -73,7 +73,7 @@ void HtraceHiLogParser::Parse(ProtoReader::BytesView tracePacket, bool& haveSpli levelData, logTag, logData, timeStamp); } } -void HtraceHiLogParser::Finish() +void PbreaderHiLogParser::Finish() { traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime()); } diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h similarity index 82% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h rename to trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_hilog_parser.h index e95d90c6a41602493630d52b88b23e00b99a05cb..3ad5a80907ab07523619617e712a75e7b1d21b52 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hilog_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hilog_parser/pbreader_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, @@ -27,10 +27,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceHiLogParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderHiLogParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceHiLogParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceHiLogParser(); + PbreaderHiLogParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderHiLogParser(); void Parse(ProtoReader::BytesView tracePacket, bool& haveSplitSeg); std::map logLevelString_ = {{TS_DEBUG, "D"}, {TS_ERROR, "E"}, diff --git a/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b568cda3c59596e602f76e1e8fd3823e83cb35ac --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("pbreader_hisysevent_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_hisysevent_parser.cpp" ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hisysevent_data:hisysevent_data_reader" ] + public_configs = [ + "../../:hisysevent_parser_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.cpp similarity index 83% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.cpp index 48fc8d1d6ed33a95c73d48b9339ed150ccaaf4e9..7f34acceb7f322aa1510b9140ac01e4425f00437 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_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, @@ -13,18 +13,16 @@ * limitations under the License. */ #include "clock_filter_ex.h" -#include "hi_sysevent_measure_filter.h" -#include "htrace_event_parser.h" -#include "htrace_hisysevent_parser.h" -#include "htrace_parser.h" +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#include "pbreader_hisysevent_parser.h" #include "process_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceHisyseventParser::HtraceHisyseventParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderHisyseventParser::PbreaderHisyseventParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceHisyseventParser::~HtraceHisyseventParser() +PbreaderHisyseventParser::~PbreaderHisyseventParser() { TS_LOGI("hisysevent ts MIN:%llu, MAX:%llu", static_cast(streamFilters_->hiSysEventMeasureFilter_->GetPluginStartTime()), @@ -33,7 +31,7 @@ HtraceHisyseventParser::~HtraceHisyseventParser() static_cast(streamFilters_->hiSysEventMeasureFilter_->MinTs()), static_cast(streamFilters_->hiSysEventMeasureFilter_->MaxTs())); } -void HtraceHisyseventParser::Finish() +void PbreaderHisyseventParser::Finish() { auto startTime = streamFilters_->hiSysEventMeasureFilter_->GetPluginStartTime(); auto endTime = streamFilters_->hiSysEventMeasureFilter_->GetPluginEndTime(); @@ -43,7 +41,7 @@ void HtraceHisyseventParser::Finish() } static std::stringstream ss; -void HtraceHisyseventParser::Parse(ProtoReader::HisyseventInfo_Reader* tracePacket, uint64_t ts, bool& haveSplitSeg) +void PbreaderHisyseventParser::Parse(ProtoReader::HisyseventInfo_Reader* tracePacket, uint64_t ts, bool& haveSplitSeg) { // parse hisysevent device state if (tracePacket->has_device_state()) { @@ -73,7 +71,7 @@ void HtraceHisyseventParser::Parse(ProtoReader::HisyseventInfo_Reader* tracePack } } } -void HtraceHisyseventParser::Parse(ProtoReader::HisyseventConfig_Reader* tracePacket, uint64_t ts) +void PbreaderHisyseventParser::Parse(ProtoReader::HisyseventConfig_Reader* tracePacket, uint64_t ts) { streamFilters_->hiSysEventMeasureFilter_->AppendNewValue("message", tracePacket->msg().ToStdString()); streamFilters_->hiSysEventMeasureFilter_->AppendNewValue("process_name", tracePacket->process_name().ToStdString()); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h similarity index 71% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h rename to trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_hisysevent_parser.h index 41024e536f48649f675303ecd04af7af556dbace..35d52c9cd8d81ac024af759ced5a8acdbb4f3de4 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_hisysevent_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/hisysevent_parser/pbreader_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, @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef HTRACE_HISYSEVENT_PARSER_H -#define HTRACE_HISYSEVENT_PARSER_H +#ifndef PBREADER_HISYSEVENT_PARSER_H +#define PBREADER_HISYSEVENT_PARSER_H #include "clock_filter_ex.h" #include "event_parser_base.h" -#include "hi_sysevent_measure_filter.h" +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" #include "hisysevent_plugin_config.pbreader.h" #include "hisysevent_plugin_result.pbreader.h" #include "htrace_plugin_time_parser.h" @@ -29,10 +29,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceHisyseventParser : public EventParserBase { +class PbreaderHisyseventParser : public EventParserBase { public: - HtraceHisyseventParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceHisyseventParser(); + PbreaderHisyseventParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderHisyseventParser(); void Finish(); void Parse(ProtoReader::HisyseventInfo_Reader* tracePacket, uint64_t ts, bool& haveSplitSeg); void Parse(ProtoReader::HisyseventConfig_Reader* tracePacket, uint64_t ts); @@ -42,4 +42,4 @@ private: }; } // namespace TraceStreamer } // namespace SysTuning -#endif // HTRACE_HISYSEVENT_PARSER_H +#endif // PBREADER_HISYSEVENT_PARSER_H diff --git a/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..368e79f27be7616b0c5d9f1ae9f23c40611507c2 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/htrace_parser/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +config("htrace_cfg") { + include_dirs = [ "." ] +} + +ohos_static_library("pbreader_htrace_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ + "htrace_clock_detail_parser.cpp", + "htrace_cpu_detail_parser.cpp", + "htrace_event_parser.cpp", + "htrace_symbols_detail_parser.cpp", + ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", + ] + public_configs = [ + ":htrace_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.cpp similarity index 97% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/htrace_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/pbreader_parser/htrace_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/pbreader_parser/htrace_parser/htrace_clock_detail_parser.h similarity index 90% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h rename to trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_clock_detail_parser.h index b91ee78e8e2fcf67f09270441c484a730ae5f3ad..9ea4c0dbbee3e88e78caf889c9f5c4c39c5aebdf 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_clock_detail_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_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, @@ -22,7 +22,7 @@ #include "event_parser_base.h" #include "file.h" #include "proto_reader_help.h" -#include "htrace_file_header.h" +#include "pbreader_file_header.h" #include "trace_data/trace_data_cache.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp similarity index 88% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.cpp index 19438979d7011be19c5d48f353a02d75f07d86f3..51856ead8969368cbe150d19c25a20cbc71ce72e 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/htrace_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, @@ -24,7 +24,7 @@ HtraceCpuDetailParser::HtraceCpuDetailParser(TraceDataCache* dataCache, const Tr } HtraceCpuDetailParser::~HtraceCpuDetailParser() = default; -void HtraceCpuDetailParser::Parse(HtraceDataSegment& tracePacket, +void HtraceCpuDetailParser::Parse(PbreaderDataSegment& tracePacket, ProtoReader::TracePluginResult_Reader& tracePluginResult, bool& haveSplitSeg) { diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h similarity index 83% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h rename to trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_cpu_detail_parser.h index c825259cf5f18af2cb4e2e68575bc1bc530309c3..6adddb2c300f730fada085725628f3deb828596b 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_cpu_parser/htrace_cpu_detail_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_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, @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef HTRACE_CPU_DETAIL_PARSER_H -#define HTRACE_CPU_DETAIL_PARSER_H +#ifndef FTRACE_CPU_DETAIL_PARSER_H +#define FTRACE_CPU_DETAIL_PARSER_H #include #include #include @@ -34,7 +34,7 @@ class HtraceCpuDetailParser { public: HtraceCpuDetailParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); ~HtraceCpuDetailParser(); - void Parse(HtraceDataSegment& tracePacket, + void Parse(PbreaderDataSegment& tracePacket, ProtoReader::TracePluginResult_Reader& tracePluginResult, bool& haveSplitSeg); void FilterAllEventsReader(); @@ -46,4 +46,4 @@ private: } // namespace TraceStreamer } // namespace SysTuning -#endif // HTRACE_CPU_DETAIL_PARSER_H_ +#endif // FTRACE_CPU_DETAIL_PARSER_H diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp similarity index 98% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.cpp index 1433faaef66a906fb10c328a1a57984b5c19cdaf..2f766e1602cf4ef1897119661266e5b99e1a0560 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/htrace_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, @@ -166,7 +166,7 @@ HtraceEventParser::~HtraceEventParser() static_cast(ftraceOriginEndTime_)); } -void HtraceEventParser::ParserCpuEvent(HtraceDataSegment& tracePacket, +void HtraceEventParser::ParserCpuEvent(PbreaderDataSegment& tracePacket, SysTuning::ProtoReader::FtraceCpuDetailMsg_Reader& msg, bool& haveSplitSeg) { @@ -200,15 +200,15 @@ 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)); } } -void HtraceEventParser::ParseDataItem(HtraceDataSegment& tracePacket, +void HtraceEventParser::ParseDataItem(PbreaderDataSegment& tracePacket, ProtoReader::TracePluginResult_Reader& tracePluginResult, bool& haveSplitSeg) { @@ -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/pbreader_parser/htrace_parser/htrace_event_parser.h similarity index 94% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h rename to trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_event_parser.h index 751319f26a1f4a4c49dedd5ccad2896989aa4795..b7186fa215e071ea928aabc8840e0e1802b7b6f5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_event_parser/htrace_event_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/htrace_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, @@ -41,7 +41,7 @@ class HtraceEventParser : private EventParserBase { public: HtraceEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filter); ~HtraceEventParser(); - void ParseDataItem(HtraceDataSegment& tracePacket, + void ParseDataItem(PbreaderDataSegment& tracePacket, ProtoReader::TracePluginResult_Reader& tracePluginResult, bool& haveSplitSeg); void FilterAllEventsReader(); @@ -99,7 +99,7 @@ private: ProtoReader::BytesView& bytesView); void ProtoReaderDealEvent(EventInfo* eventInfo); - void ParserCpuEvent(HtraceDataSegment& tracePacket, + void ParserCpuEvent(PbreaderDataSegment& tracePacket, SysTuning::ProtoReader::FtraceCpuDetailMsg_Reader& msg, bool& haveSplitSeg); bool BinderTractionEvent(const EventInfo& event) const; @@ -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"); @@ -171,4 +169,4 @@ private: } // namespace TraceStreamer } // namespace SysTuning -#endif // HTRACE_EVENT_PARSER_H_ +#endif // HTRACE_EVENT_PARSER_H diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp b/trace_streamer/src/parser/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.cpp similarity index 93% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/htrace_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/pbreader_parser/htrace_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/pbreader_parser/htrace_parser/htrace_symbols_detail_parser.h similarity index 91% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_symbols_detail_parser.h rename to trace_streamer/src/parser/pbreader_parser/htrace_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/pbreader_parser/htrace_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/pbreader_parser/mem_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..04583776d5c650a43738bf4271b9f1aed3900613 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("pbreader_mem_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_mem_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp similarity index 83% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.cpp index cc927ba82bd1cd276a474d162f88ec6a42f632a8..60b08f3893fdf5e3b675cebe5bcdd383326a3cc5 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_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, @@ -12,9 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_mem_parser.h" +#include "pbreader_mem_parser.h" #include "clock_filter_ex.h" -#include "htrace_event_parser.h" #include "measure_filter.h" #include "memory_plugin_common.pbreader.h" #include "memory_plugin_config.pbreader.h" @@ -38,39 +37,39 @@ std::vector g_unknownAnonMemInfo = { "[anon:arc4random data]", }; std::map g_checkMemStart = { - {"[stack", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, - {"[anon:stack_and_tls:", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, - {"[anon:stack:", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, - {"[anon:signal_stack:", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, - {"[anon:maple_alloc_ros]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-allocspace", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-main space", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-large object", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-free list large", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-non moving", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-zygote space", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:dalvik-", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, - {"/dev/ashmem/jit-zygote-cache", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, - {"/memfd:jit-cache", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, - {"/memfd:jit-zygote-cache", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, - {"[heap]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"[anon:libc_malloc", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"[anon:scudo", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"[anon:GWP-Asan", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[stack", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, + {"[anon:stack_and_tls:", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, + {"[anon:stack:", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, + {"[anon:signal_stack:", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_STACK}, + {"[anon:maple_alloc_ros]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-allocspace", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-main space", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-large object", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-free list large", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-non moving", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-zygote space", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:dalvik-", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, + {"/dev/ashmem/jit-zygote-cache", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, + {"/memfd:jit-cache", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, + {"/memfd:jit-zygote-cache", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JAVA_VM}, + {"[heap]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[anon:libc_malloc", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[anon:scudo", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[anon:GWP-Asan", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, }; std::map g_checkMemEnd = { - {".art", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {".art]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {".tty", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_FONT}, + {".art", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {".art]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {".tty", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_FONT}, }; std::map g_checkMemContain = { - {"[anon:ArkJS Heap]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, - {"[anon:native_heap:jemalloc]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"[heap]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"[anon:native_heap:musl]", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, - {"/dev/ashmem/", (uint32_t)HtraceMemParser::SmapsMemType::SMAPS_MEM_TYPE_ASHMEM}, + {"[anon:ArkJS Heap]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_JS_HEAP}, + {"[anon:native_heap:jemalloc]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[heap]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"[anon:native_heap:musl]", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_NATIVE_HEAP}, + {"/dev/ashmem/", (uint32_t)PbreaderMemParser::SmapsMemType::SMAPS_MEM_TYPE_ASHMEM}, }; -HtraceMemParser::HtraceMemParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderMemParser::PbreaderMemParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { for (auto i = 0; i < MEM_MAX; i++) { @@ -87,12 +86,12 @@ HtraceMemParser::HtraceMemParser(TraceDataCache* dataCache, const TraceStreamerF } } -HtraceMemParser::~HtraceMemParser() +PbreaderMemParser::~PbreaderMemParser() { TS_LOGI("mem ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceMemParser::Parse(HtraceDataSegment& seg, uint64_t timeStamp, BuiltinClocks clock) +void PbreaderMemParser::Parse(PbreaderDataSegment& seg, uint64_t timeStamp, BuiltinClocks clock) { ProtoReader::MemoryData_Reader memData(seg.protoData.data_, seg.protoData.size_); auto newTimeStamp = streamFilters_->clockFilter_->ToPrimaryTraceTime(clock, timeStamp); @@ -135,10 +134,10 @@ void HtraceMemParser::Parse(HtraceDataSegment& seg, uint64_t timeStamp, BuiltinC } } -void HtraceMemParser::SpecialDataAddition(ProtoReader::ProcessMemoryInfo_Reader& processMemoryInfo, - uint64_t timeStamp, - uint32_t ipid, - uint32_t hasValue) const +void PbreaderMemParser::SpecialDataAddition(ProtoReader::ProcessMemoryInfo_Reader& processMemoryInfo, + uint64_t timeStamp, + uint32_t ipid, + uint32_t hasValue) const { // processMemoryInfo Special data addition if (processMemoryInfo.has_purg_sum_kb()) { @@ -165,7 +164,7 @@ void HtraceMemParser::SpecialDataAddition(ProtoReader::ProcessMemoryInfo_Reader& } } -void HtraceMemParser::ParseProcessInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseProcessInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { if (tracePacket->has_processesinfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_MEMORY, STAT_EVENT_RECEIVED); @@ -197,7 +196,7 @@ void HtraceMemParser::ParseProcessInfo(const ProtoReader::MemoryData_Reader* tra SpecialDataAddition(processMemoryInfo, timeStamp, ipid, hasValue); } } -uint32_t HtraceMemParser::ParseSmapsPathTypeByPrefix(bool hasX, const std::string& path, const bool hasAppName) const +uint32_t PbreaderMemParser::ParseSmapsPathTypeByPrefix(bool hasX, const std::string& path, const bool hasAppName) const { if (EndWith(path, ".so")) { if (hasX) { @@ -216,7 +215,7 @@ uint32_t HtraceMemParser::ParseSmapsPathTypeByPrefix(bool hasX, const std::strin } return static_cast(SmapsMemType::SMAPS_MEM_TYPE_INVALID); } -uint32_t HtraceMemParser::ParseSmapsPathTypeBySuffix(bool hasX, const std::string& path, const bool hasAppName) const +uint32_t PbreaderMemParser::ParseSmapsPathTypeBySuffix(bool hasX, const std::string& path, const bool hasAppName) const { if ((EndWith(path, ".jar")) || (EndWith(path, ".apk")) || (EndWith(path, ".vdex")) || (EndWith(path, ".odex")) || (EndWith(path, ".oat")) || (path.find("dex") != std::string::npos)) { @@ -228,9 +227,9 @@ uint32_t HtraceMemParser::ParseSmapsPathTypeBySuffix(bool hasX, const std::strin return static_cast(SmapsMemType::SMAPS_MEM_TYPE_INVALID); } -uint32_t HtraceMemParser::ParseSmapsBlockDetail(ProtoReader::SmapsInfo_Reader& smapsInfo, - const std::string& path, - const bool hasAppName) const +uint32_t PbreaderMemParser::ParseSmapsBlockDetail(ProtoReader::SmapsInfo_Reader& smapsInfo, + const std::string& path, + const bool hasAppName) const { bool hasX = smapsInfo.permission().ToStdString().find("x") != std::string::npos; auto type = ParseSmapsPathTypeByPrefix(hasX, path, hasAppName); @@ -260,7 +259,7 @@ uint32_t HtraceMemParser::ParseSmapsBlockDetail(ProtoReader::SmapsInfo_Reader& s return static_cast(SmapsMemType::SMAPS_MEM_TYPE_INVALID); } -uint32_t HtraceMemParser::ParseSmapsBlockType(ProtoReader::SmapsInfo_Reader& smapsInfo) const +uint32_t PbreaderMemParser::ParseSmapsBlockType(ProtoReader::SmapsInfo_Reader& smapsInfo) const { std::string path(smapsInfo.path().ToStdString()); path.erase(0, path.find_first_not_of(" ")); @@ -284,7 +283,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; } @@ -292,9 +291,9 @@ uint32_t HtraceMemParser::ParseSmapsBlockType(ProtoReader::SmapsInfo_Reader& sma : static_cast(SmapsMemType::SMAPS_MEM_TYPE_OTHER_SYS); } -void HtraceMemParser::ParseSmapsInfoEasy(const ProtoReader::ProcessMemoryInfo_Reader* memInfo, - uint64_t timeStamp, - uint64_t ipid) const +void PbreaderMemParser::ParseSmapsInfoEasy(const ProtoReader::ProcessMemoryInfo_Reader* memInfo, + uint64_t timeStamp, + uint64_t ipid) const { streamFilters_->statFilter_->IncreaseStat(TRACE_SMAPS, STAT_EVENT_RECEIVED); for (auto i = memInfo->smapinfo(); i; ++i) { @@ -315,14 +314,14 @@ void HtraceMemParser::ParseSmapsInfoEasy(const ProtoReader::ProcessMemoryInfo_Re uint64_t sharedDirty = smapsInfo.has_shared_dirty() ? smapsInfo.shared_dirty() : 0; uint64_t swap = smapsInfo.has_swap() ? smapsInfo.swap() : 0; uint64_t swapPss = smapsInfo.has_swap_pss() ? smapsInfo.swap_pss() : 0; - uint32 type = ParseSmapsBlockType(smapsInfo); + uint32_t type = ParseSmapsBlockType(smapsInfo); traceDataCache_->GetSmapsData()->AppendNewData(timeStamp, ipid, startAddr, endAddr, dirty, swapper, rss, pss, size, reside, protection, path, sharedClean, sharedDirty, privateClean, privateDirty, swap, swapPss, type); } } -void HtraceMemParser::ParseMemInfoEasy(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseMemInfoEasy(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { if (tracePacket->has_meminfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_SYS_MEMORY, STAT_EVENT_RECEIVED); @@ -338,7 +337,7 @@ void HtraceMemParser::ParseMemInfoEasy(const ProtoReader::MemoryData_Reader* tra } } -void HtraceMemParser::ParseVMemInfoEasy(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseVMemInfoEasy(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { traceDataCache_->UpdateTraceTime(timeStamp); if (tracePacket->has_vmeminfo()) { @@ -355,7 +354,7 @@ void HtraceMemParser::ParseVMemInfoEasy(const ProtoReader::MemoryData_Reader* tr } } -void HtraceMemParser::ParseMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { streamFilters_->statFilter_->IncreaseStat(TRACE_SYS_MEMORY, STAT_EVENT_RECEIVED); for (auto i = tracePacket->meminfo(); i; ++i) { @@ -372,7 +371,7 @@ void HtraceMemParser::ParseMemInfo(const ProtoReader::MemoryData_Reader* tracePa streamFilters_->sysEventMemMeasureFilter_->AppendNewMeasureData(gpuUsedSizeIndex_, timeStamp, gpuUsed_); } -void HtraceMemParser::ParseVMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseVMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { streamFilters_->statFilter_->IncreaseStat(TRACE_SYS_VIRTUAL_MEMORY, STAT_EVENT_RECEIVED); for (auto i = tracePacket->vmeminfo(); i; ++i) { @@ -387,7 +386,7 @@ void HtraceMemParser::ParseVMemInfo(const ProtoReader::MemoryData_Reader* traceP } } } -void HtraceMemParser::ParseAshmemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseAshmemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { if (tracePacket->has_ashmeminfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_ASHMEM, STAT_EVENT_RECEIVED); @@ -419,7 +418,7 @@ void HtraceMemParser::ParseAshmemInfo(const ProtoReader::MemoryData_Reader* trac } AshMemDeduplicate(); } -void HtraceMemParser::AshMemDeduplicate() const +void PbreaderMemParser::AshMemDeduplicate() const { auto ashMemData = traceDataCache_->GetAshMemData(); auto ashMemCount = ashMemData->Size(); @@ -469,7 +468,7 @@ void HtraceMemParser::AshMemDeduplicate() const } } } -HtraceMemParser::MemProcessType HtraceMemParser::GetMemProcessType(uint64_t ipid) const +PbreaderMemParser::MemProcessType PbreaderMemParser::GetMemProcessType(uint64_t ipid) const { const auto& iterProcess = traceDataCache_->GetConstProcessData(ipid); if (iterProcess.cmdLine_ == "composer_host") { @@ -481,7 +480,7 @@ HtraceMemParser::MemProcessType HtraceMemParser::GetMemProcessType(uint64_t ipid } } -void HtraceMemParser::ParseDmaMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseDmaMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { if (tracePacket->has_dmainfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_DMAMEM, STAT_EVENT_RECEIVED); @@ -503,7 +502,7 @@ void HtraceMemParser::ParseDmaMemInfo(const ProtoReader::MemoryData_Reader* trac } DmaMemDeduplicate(); } -void HtraceMemParser::DmaMemDeduplicate() const +void PbreaderMemParser::DmaMemDeduplicate() const { auto dmaMemData = traceDataCache_->GetDmaMemData(); auto dmaCount = dmaMemData->Size(); @@ -557,8 +556,8 @@ void HtraceMemParser::DmaMemDeduplicate() const } } -void HtraceMemParser::ParseGpuProcessMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, - uint64_t timeStamp) const +void PbreaderMemParser::ParseGpuProcessMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, + uint64_t timeStamp) const { if (tracePacket->has_gpumemoryinfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_GPU_PROCESS_MEM, STAT_EVENT_RECEIVED); @@ -583,7 +582,8 @@ void HtraceMemParser::ParseGpuProcessMemInfo(const ProtoReader::MemoryData_Reade } } } -void HtraceMemParser::FillGpuWindowMemInfo(const ProtoReader::GpuDumpInfo_Reader& gpuDumpInfo, uint64_t timeStamp) const +void PbreaderMemParser::FillGpuWindowMemInfo(const ProtoReader::GpuDumpInfo_Reader& gpuDumpInfo, + uint64_t timeStamp) const { DataIndex windowNameId = traceDataCache_->GetDataIndex(gpuDumpInfo.window_name().ToStdString()); uint64_t windowId = gpuDumpInfo.id(); @@ -604,7 +604,8 @@ void HtraceMemParser::FillGpuWindowMemInfo(const ProtoReader::GpuDumpInfo_Reader } } } -void HtraceMemParser::ParseGpuWindowMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseGpuWindowMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, + uint64_t timeStamp) const { if (tracePacket->has_gpudumpinfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_GPU_WINDOW_MEM, STAT_EVENT_RECEIVED); @@ -617,8 +618,8 @@ void HtraceMemParser::ParseGpuWindowMemInfo(const ProtoReader::MemoryData_Reader FillGpuWindowMemInfo(GpuDumpInfo, timeStamp); } } -void HtraceMemParser::ParseWindowManagerServiceInfo(const ProtoReader::MemoryData_Reader* tracePacket, - uint64_t timeStamp) +void PbreaderMemParser::ParseWindowManagerServiceInfo(const ProtoReader::MemoryData_Reader* tracePacket, + uint64_t timeStamp) { if (tracePacket->has_windowinfo()) { streamFilters_->statFilter_->IncreaseStat(TRACE_WINDOW_MANAGER_SERVICE, STAT_EVENT_RECEIVED); @@ -634,7 +635,7 @@ void HtraceMemParser::ParseWindowManagerServiceInfo(const ProtoReader::MemoryDat windowIdToipidMap_.insert({windowNameId, ipid}); } } -void HtraceMemParser::ParseCpuDumpInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseCpuDumpInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { for (auto i = tracePacket->cpudumpinfo(); i; ++i) { ProtoReader::CpuDumpInfo_Reader cpuDumpInfo(i->ToBytes().data_, i->ToBytes().size_); @@ -642,7 +643,7 @@ void HtraceMemParser::ParseCpuDumpInfo(const ProtoReader::MemoryData_Reader* tra traceDataCache_->GetCpuDumpInfo()->AppendNewData(timeStamp, totalSize); } } -void HtraceMemParser::ParseProfileMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseProfileMemInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const { for (auto i = tracePacket->profilememinfo(); i; ++i) { ProtoReader::ProfileMemInfo_Reader profileMemInfo(i->ToBytes().data_, i->ToBytes().size_); @@ -652,7 +653,8 @@ void HtraceMemParser::ParseProfileMemInfo(const ProtoReader::MemoryData_Reader* } } -void HtraceMemParser::ParseRSImageDumpInfo(const ProtoReader::MemoryData_Reader* tracePacket, uint64_t timeStamp) const +void PbreaderMemParser::ParseRSImageDumpInfo(const ProtoReader::MemoryData_Reader* tracePacket, + uint64_t timeStamp) const { for (auto i = tracePacket->rsdumpinfo(); i; ++i) { ProtoReader::RSImageDumpInfo_Reader rsImageDumpInfo(i->ToBytes().data_, i->ToBytes().size_); @@ -667,7 +669,7 @@ void HtraceMemParser::ParseRSImageDumpInfo(const ProtoReader::MemoryData_Reader* traceDataCache_->GetRSImageDumpInfo()->AppendNewData(timeStamp, size, typeIndex, ipid, surfaceNameIndex); } } -void HtraceMemParser::ParseMemoryConfig(HtraceDataSegment& seg) +void PbreaderMemParser::ParseMemoryConfig(PbreaderDataSegment& seg) { ProtoReader::MemoryConfig_Reader memConfigData(seg.protoData.data_, seg.protoData.size_); if (memConfigData.has_pid()) { @@ -686,7 +688,7 @@ void HtraceMemParser::ParseMemoryConfig(HtraceDataSegment& seg) } } -void HtraceMemParser::Finish() +void PbreaderMemParser::Finish() { traceDataCache_->GetGpuWindowMemData()->RevicesIpid(windowIdToipidMap_); if (traceDataCache_->traceStartTime_ == INVALID_UINT64 || traceDataCache_->traceEndTime_ == 0) { diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h similarity index 92% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h rename to trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_mem_parser.h index a53141b0e15426541f9df9ec3f175c588c84eb4d..27785f9ab3ea960d75756d3814a80491ea1bc655 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_mem_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/mem_parser/pbreader_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, @@ -31,12 +31,12 @@ namespace SysTuning { namespace TraceStreamer { using namespace SysTuning::base; -class HtraceMemParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderMemParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceMemParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceMemParser(); - void Parse(HtraceDataSegment& seg, uint64_t, BuiltinClocks clock); - void ParseMemoryConfig(HtraceDataSegment& seg); + PbreaderMemParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderMemParser(); + void Parse(PbreaderDataSegment& seg, uint64_t, BuiltinClocks clock); + void ParseMemoryConfig(PbreaderDataSegment& seg); void Finish(); enum class SmapsMemType { SMAPS_MEM_TYPE_CODE_SYS = 0, // 系统代码段 diff --git a/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2c059ea25effb0541319b91255a7c78da415c425 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +config("native_hook_cfg") { + include_dirs = [ + ".", + "//third_party/hiperf/include", + ] +} + +ohos_static_library("native_hook_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_native_hook_parser.cpp" ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ftrace_data_reader", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/native_hook:native_hook_data_reader", + ] + public_configs = [ + ":native_hook_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.cpp similarity index 87% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.cpp index 37a67b6118a9c3fef5234c48bebf789aa5c0d03e..39b8da9281405ac91db2cc7e6825592eefd12b3c 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_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, @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_native_hook_parser.h" +#include "pbreader_native_hook_parser.h" #include "clock_filter_ex.h" #include "process_filter.h" #include "stat_filter.h" @@ -20,12 +20,12 @@ namespace SysTuning { namespace TraceStreamer { constexpr static uint32_t MAX_PROTO_BUFFER_SIZE = 4 * 1024 * 1024; -HtraceNativeHookParser::HtraceNativeHookParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderNativeHookParser::PbreaderNativeHookParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx), nativeHookFilter_(std::make_unique(dataCache, ctx)) { } -HtraceNativeHookParser::~HtraceNativeHookParser() +PbreaderNativeHookParser::~PbreaderNativeHookParser() { TS_LOGI("native hook data ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); @@ -33,7 +33,7 @@ HtraceNativeHookParser::~HtraceNativeHookParser() static_cast(MaxTs())); } -bool HtraceNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesView) +bool PbreaderNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesView) { if (traceDataCache_->isSplitFile_) { auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); @@ -67,7 +67,7 @@ bool HtraceNativeHookParser::ParseStackMap(const ProtoReader::BytesView& bytesVi return true; } -void HtraceNativeHookParser::ParseFrameMap(std::unique_ptr& nativeHookMetaData) +void PbreaderNativeHookParser::ParseFrameMap(std::unique_ptr& nativeHookMetaData) { segs_.emplace_back(nativeHookMetaData->seg_); const ProtoReader::BytesView& frameMapByteView = nativeHookMetaData->reader_->frame_map(); @@ -83,7 +83,7 @@ void HtraceNativeHookParser::ParseFrameMap(std::unique_ptr& // when callstack is compressed, Frame message only has ip data area. nativeHookFilter_->AppendFrameMaps(ipid, frameMapReader.id(), frameMapReader.frame()); } -void HtraceNativeHookParser::ParseFileEvent(const ProtoReader::BytesView& bytesView) +void PbreaderNativeHookParser::ParseFileEvent(const ProtoReader::BytesView& bytesView) { if (traceDataCache_->isSplitFile_) { auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); @@ -97,7 +97,7 @@ void HtraceNativeHookParser::ParseFileEvent(const ProtoReader::BytesView& bytesV auto nameIndex = traceDataCache_->dataDict_.GetStringIndex(filePathMapReader.name().ToStdString()); nativeHookFilter_->AppendFilePathMaps(ipid, filePathMapReader.id(), nameIndex); } -void HtraceNativeHookParser::ParseSymbolEvent(const ProtoReader::BytesView& bytesView) +void PbreaderNativeHookParser::ParseSymbolEvent(const ProtoReader::BytesView& bytesView) { if (traceDataCache_->isSplitFile_) { auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); @@ -111,7 +111,7 @@ void HtraceNativeHookParser::ParseSymbolEvent(const ProtoReader::BytesView& byte auto nameIndex = traceDataCache_->dataDict_.GetStringIndex(symbolMapReader.name().ToStdString()); nativeHookFilter_->AppendSymbolMap(ipid, symbolMapReader.id(), nameIndex); } -void HtraceNativeHookParser::ParseThreadEvent(const ProtoReader::BytesView& bytesView) +void PbreaderNativeHookParser::ParseThreadEvent(const ProtoReader::BytesView& bytesView) { if (traceDataCache_->isSplitFile_) { auto hookData = nativeHookFilter_->GetCommHookData().datas->add_events(); @@ -126,7 +126,7 @@ void HtraceNativeHookParser::ParseThreadEvent(const ProtoReader::BytesView& byte nativeHookFilter_->AppendThreadNameMap(ipid, threadNameMapReader.id(), nameIndex); } -void HtraceNativeHookParser::ParseNativeHookAuxiliaryEvent(std::unique_ptr& nativeHookMetaData) +void PbreaderNativeHookParser::ParseNativeHookAuxiliaryEvent(std::unique_ptr& nativeHookMetaData) { auto& reader = nativeHookMetaData->reader_; if (reader->has_stack_map()) { @@ -149,7 +149,8 @@ void HtraceNativeHookParser::ParseNativeHookAuxiliaryEvent(std::unique_ptr& nativeHookMetaData, bool& haveSplitSeg) +void PbreaderNativeHookParser::SplitHookData(std::unique_ptr& nativeHookMetaData, + bool& haveSplitSeg) { if (isCommData_ && hookBootTime_ <= traceDataCache_->SplitFileMinTime()) { ParseNativeHookAuxiliaryEvent(nativeHookMetaData); @@ -160,7 +161,7 @@ void HtraceNativeHookParser::SplitHookData(std::unique_ptr& } // In order to improve the accuracy of data, it is necessary to sort the original data. // Data sorting will be reduced by 5% to 10% Speed of parsing data. -void HtraceNativeHookParser::Parse(HtraceDataSegment& dataSeg, bool& haveSplitSeg) +void PbreaderNativeHookParser::Parse(PbreaderDataSegment& dataSeg, bool& haveSplitSeg) { auto batchNativeHookDataReader = ProtoReader::BatchNativeHookData_Reader(dataSeg.protoData); for (auto itor = batchNativeHookDataReader.events(); itor; itor++) { @@ -193,19 +194,19 @@ void HtraceNativeHookParser::Parse(HtraceDataSegment& dataSeg, bool& haveSplitSe } nativeHookFilter_->SerializeHookCommDataToString(); } -void HtraceNativeHookParser::ParseConfigInfo(HtraceDataSegment& dataSeg) +void PbreaderNativeHookParser::ParseConfigInfo(PbreaderDataSegment& dataSeg) { nativeHookFilter_->ParseConfigInfo(dataSeg.protoData); } -void HtraceNativeHookParser::FinishSplitNativeHook() +void PbreaderNativeHookParser::FinishSplitNativeHook() { nativeHookFilter_->SerializeHookCommDataToString(); } -void HtraceNativeHookParser::FinishParseNativeHookData() +void PbreaderNativeHookParser::FinishParseNativeHookData() { nativeHookFilter_->FinishParseNativeHookData(); } -void HtraceNativeHookParser::Finish() +void PbreaderNativeHookParser::Finish() { if (GetPluginStartTime() != GetPluginEndTime()) { traceDataCache_->MixTraceTime(GetPluginStartTime(), GetPluginEndTime()); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h similarity index 78% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h rename to trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_native_hook_parser.h index 5172b5aa7ce31fe78e112dc01012807b2ab2d7e9..9c1e2e219791425447bb29bdc4c716001bc2b1b7 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_native_hook_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/native_hook_parser/pbreader_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, @@ -22,18 +22,18 @@ #include "event_parser_base.h" #include "htrace_event_parser.h" #include "htrace_plugin_time_parser.h" -#include "native_hook_filter.h" -#include "offline_symbolization_filter.h" +#include "hook_filter/native_hook_filter.h" +#include "hook_filter/offline_symbolization_filter.h" #include "trace_streamer_config.h" #include "trace_streamer_filters.h" namespace SysTuning { namespace TraceStreamer { -class HtraceNativeHookParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderNativeHookParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceNativeHookParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceNativeHookParser(); - void ParseConfigInfo(HtraceDataSegment& dataSeg); - void Parse(HtraceDataSegment& dataSeg, bool& haveSplitSeg); + PbreaderNativeHookParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderNativeHookParser(); + void ParseConfigInfo(PbreaderDataSegment& dataSeg); + void Parse(PbreaderDataSegment& dataSeg, bool& haveSplitSeg); void FinishSplitNativeHook(); void FinishParseNativeHookData(); void Finish(); diff --git a/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a7e6cfaca1f7bcd43d1932890a05cfac95f9e441 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/network_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("network_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_network_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:network_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp b/trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_network_parser.cpp similarity index 88% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_network_parser.cpp index a5d344940dbd853b97e93b8257845ffa6049ddfe..526cd3b86580630003a18da99849b0e409c59017 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_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, @@ -12,26 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_network_parser.h" +#include "pbreader_network_parser.h" #include "clock_filter_ex.h" -#include "htrace_event_parser.h" #include "network_plugin_result.pbreader.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceNetworkParser::HtraceNetworkParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderNetworkParser::PbreaderNetworkParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceNetworkParser::~HtraceNetworkParser() +PbreaderNetworkParser::~PbreaderNetworkParser() { TS_LOGI("network ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); } -void HtraceNetworkParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) +void PbreaderNetworkParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) { ProtoReader::NetworkDatas_Reader networkData(tracePacket.data_, tracePacket.size_); ProtoReader::NetworkSystemData_Reader networkSystemData(networkData.network_system_info()); @@ -46,7 +45,7 @@ void HtraceNetworkParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) streamFilters_->statFilter_->IncreaseStat(TRACE_NETWORK, STAT_EVENT_RECEIVED); networkData_.push_back(TsNetworkData{ts, tv_sec, tv_nsec, rx_bytes, rx_packets, tx_bytes, tx_packets}); } -void HtraceNetworkParser::Finish() +void PbreaderNetworkParser::Finish() { auto cmp = [](const TsNetworkData& a, const TsNetworkData& b) { return a.ts < b.ts; }; std::stable_sort(networkData_.begin(), networkData_.end(), cmp); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h b/trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_network_parser.h similarity index 80% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h rename to trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_network_parser.h index 619b6efaed9982b4093e22f1d4932a616b24a580..31d261b96e26372445299b3c7da38cebc746662e 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_network_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/network_parser/pbreader_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, @@ -25,10 +25,10 @@ #include "trace_streamer_filters.h" namespace SysTuning { namespace TraceStreamer { -class HtraceNetworkParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderNetworkParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceNetworkParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceNetworkParser(); + PbreaderNetworkParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderNetworkParser(); void Parse(ProtoReader::BytesView tracePacket, uint64_t ts); void Finish(); struct TsNetworkData { diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp similarity index 67% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/pbreader_parser.cpp index 72b7784af8515da8f952fcd1c83bd07890278933..f3c797b4c13678ac971448b1cc84de036f3f65d8 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_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, @@ -13,88 +13,159 @@ * limitations under the License. */ -#include "htrace_parser.h" +#include "pbreader_parser.h" #include #include "app_start_filter.h" #include "binder_filter.h" #include "common_types.pbreader.h" #include "cpu_filter.h" #include "data_area.h" +#ifdef ENABLE_HTRACE #include "ftrace_event.pbreader.h" +#include "trace_plugin_result.pbreader.h" +#endif #include "log.h" +#ifdef ENABLE_MEMORY #include "memory_plugin_result.pbreader.h" +#endif #include "stat_filter.h" -#include "trace_plugin_result.pbreader.h" #if IS_WASM #include "../rpc/wasm_func.h" #endif namespace SysTuning { namespace TraceStreamer { -HtraceParser::HtraceParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) +PbreaderParser::PbreaderParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) : ParserBase(filters), - traceDataCache_(dataCache), +#ifdef ENABLE_HTRACE htraceCpuDetailParser_(std::make_unique(dataCache, filters)), htraceSymbolsDetailParser_(std::make_unique(dataCache, filters)), - htraceMemParser_(std::make_unique(dataCache, filters)), htraceClockDetailParser_(std::make_unique(dataCache, filters)), - htraceHiLogParser_(std::make_unique(dataCache, filters)), - htraceNativeHookParser_(std::make_unique(dataCache, filters)), - htraceHidumpParser_(std::make_unique(dataCache, filters)), - cpuUsageParser_(std::make_unique(dataCache, filters)), - networkParser_(std::make_unique(dataCache, filters)), - diskIOParser_(std::make_unique(dataCache, filters)), - processParser_(std::make_unique(dataCache, filters)), - hisyseventParser_(std::make_unique(dataCache, filters)), - jsMemoryParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_MEMORY + pbreaderMemParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HILOG + pbreaderHiLogParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_NATIVE_HOOK + pbreaderNativeHookParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HTDUMP + pbreaderHidumpParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_CPUDATA + cpuUsageParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_NETWORK + networkParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_DISKIO + diskIOParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_PROCESS + processParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HISYSEVENT + hisyseventParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_ARKTS + jsMemoryParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HIPERF perfDataParser_(std::make_unique(dataCache, filters)), - ebpfDataParser_(std::make_unique(dataCache, filters)) +#endif +#ifdef ENABLE_EBPF + ebpfDataParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_STREAM_EXTEND + pbreaderStreamParser_(std::make_unique(dataCache, filters)), +#endif + traceDataCache_(dataCache) { InitPluginNameIndex(); if (traceDataCache_->supportThread_) { - dataSegArray_ = std::make_unique(maxSegArraySize); + dataSegArray_ = std::make_unique(maxSegArraySize); } else { - dataSegArray_ = std::make_unique(1); + dataSegArray_ = std::make_unique(1); } } -void HtraceParser::InitPluginNameIndex() +inline void PbreaderParser::InitHookPluginNameIndex() { +#ifdef ENABLE_NATIVE_HOOK nativeHookPluginIndex_.insert(traceDataCache_->GetDataIndex("nativehook")); nativeHookPluginIndex_.insert(traceDataCache_->GetDataIndex("hookdaemon")); nativeHookConfigIndex_ = traceDataCache_->GetDataIndex("nativehook_config"); - hisyseventPluginIndex_ = traceDataCache_->GetDataIndex("hisysevent-plugin"); - hisyseventPluginConfigIndex_ = traceDataCache_->GetDataIndex("hisysevent-plugin_config"); + supportPluginNameIndex_.insert(nativeHookPluginIndex_.begin(), nativeHookPluginIndex_.end()); + supportPluginNameIndex_.insert(nativeHookConfigIndex_); +#endif +} +inline void PbreaderParser::InitMemoryPluginNameIndex() +{ +#ifdef ENABLE_MEMORY memPluginIndex_ = traceDataCache_->GetDataIndex("memory-plugin"); memoryPluginConfigIndex_ = traceDataCache_->GetDataIndex("memory-plugin_config"); - ftracePluginIndex_.insert(traceDataCache_->GetDataIndex("ftrace-plugin")); - ftracePluginIndex_.insert(traceDataCache_->GetDataIndex("/data/local/tmp/libftrace_plugin.z.so")); - hilogPluginIndex_.insert(traceDataCache_->GetDataIndex("hilog-plugin")); - hilogPluginIndex_.insert(traceDataCache_->GetDataIndex("/data/local/tmp/libhilogplugin.z.so")); + supportPluginNameIndex_.insert(memPluginIndex_); + supportPluginNameIndex_.insert(memoryPluginConfigIndex_); +#endif +} +inline void PbreaderParser::InitHiPluginNameIndex() +{ +#ifdef ENABLE_HTDUMP hidumpPluginIndex_.insert(traceDataCache_->GetDataIndex("hidump-plugin")); hidumpPluginIndex_.insert(traceDataCache_->GetDataIndex("/data/local/tmp/libhidumpplugin.z.so")); - cpuPluginIndex_ = traceDataCache_->GetDataIndex("cpu-plugin"); - networkPluginIndex_ = traceDataCache_->GetDataIndex("network-plugin"); - diskioPluginIndex_ = traceDataCache_->GetDataIndex("diskio-plugin"); - processPluginIndex_ = traceDataCache_->GetDataIndex("process-plugin"); - arktsPluginIndex_ = traceDataCache_->GetDataIndex("arkts-plugin"); - arktsPluginConfigIndex_ = traceDataCache_->GetDataIndex("arkts-plugin_config"); - supportPluginNameIndex_.insert(nativeHookPluginIndex_.begin(), nativeHookPluginIndex_.end()); - supportPluginNameIndex_.insert(nativeHookConfigIndex_); + supportPluginNameIndex_.insert(hidumpPluginIndex_.begin(), hidumpPluginIndex_.end()); +#endif +#ifdef ENABLE_HILOG + hilogPluginIndex_.insert(traceDataCache_->GetDataIndex("hilog-plugin")); + hilogPluginIndex_.insert(traceDataCache_->GetDataIndex("/data/local/tmp/libhilogplugin.z.so")); + supportPluginNameIndex_.insert(hilogPluginIndex_.begin(), hilogPluginIndex_.end()); +#endif +#ifdef ENABLE_HISYSEVENT + hisyseventPluginIndex_ = traceDataCache_->GetDataIndex("hisysevent-plugin"); + hisyseventPluginConfigIndex_ = traceDataCache_->GetDataIndex("hisysevent-plugin_config"); supportPluginNameIndex_.insert(hisyseventPluginIndex_); supportPluginNameIndex_.insert(hisyseventPluginConfigIndex_); - supportPluginNameIndex_.insert(memPluginIndex_); - supportPluginNameIndex_.insert(memoryPluginConfigIndex_); - supportPluginNameIndex_.insert(ftracePluginIndex_.begin(), ftracePluginIndex_.end()); - supportPluginNameIndex_.insert(hilogPluginIndex_.begin(), hilogPluginIndex_.end()); - supportPluginNameIndex_.insert(hidumpPluginIndex_.begin(), hidumpPluginIndex_.end()); +#endif +} +void PbreaderParser::InitPluginNameIndex() +{ +#ifdef ENABLE_PROCESS + processPluginIndex_ = traceDataCache_->GetDataIndex("process-plugin"); + supportPluginNameIndex_.insert(processPluginIndex_); +#endif +#ifdef ENABLE_DISKIO + diskioPluginIndex_ = traceDataCache_->GetDataIndex("diskio-plugin"); + supportPluginNameIndex_.insert(diskioPluginIndex_); +#endif + InitMemoryPluginNameIndex(); + InitHiPluginNameIndex(); +#ifdef ENABLE_CPUDATA + cpuPluginIndex_ = traceDataCache_->GetDataIndex("cpu-plugin"); supportPluginNameIndex_.insert(cpuPluginIndex_); +#endif +#ifdef ENABLE_NETWORK + networkPluginIndex_ = traceDataCache_->GetDataIndex("network-plugin"); supportPluginNameIndex_.insert(networkPluginIndex_); - supportPluginNameIndex_.insert(diskioPluginIndex_); - supportPluginNameIndex_.insert(processPluginIndex_); +#endif + InitHookPluginNameIndex(); +#ifdef ENABLE_ARKTS + arktsPluginIndex_ = traceDataCache_->GetDataIndex("arkts-plugin"); + arktsPluginConfigIndex_ = traceDataCache_->GetDataIndex("arkts-plugin_config"); supportPluginNameIndex_.insert(arktsPluginIndex_); supportPluginNameIndex_.insert(arktsPluginConfigIndex_); +#endif +#ifdef ENABLE_HTRACE + ftracePluginIndex_.insert(traceDataCache_->GetDataIndex("ftrace-plugin")); + ftracePluginIndex_.insert(traceDataCache_->GetDataIndex("/data/local/tmp/libftrace_plugin.z.so")); + supportPluginNameIndex_.insert(ftracePluginIndex_.begin(), ftracePluginIndex_.end()); +#endif +#ifdef ENABLE_STREAM_EXTEND + streamPluginIndex_ = traceDataCache_->GetDataIndex("stream-plugin"); + supportPluginNameIndex_.insert(streamPluginIndex_); +#endif } -void HtraceParser::ParserFileSO(std::string& directory, const std::vector& relativeFilePaths) +void PbreaderParser::ParserFileSO(std::string& directory, const std::vector& relativeFilePaths) { for (const auto& filePath : relativeFilePaths) { auto absoluteFilePath = filePath.substr(directory.length()); @@ -106,80 +177,124 @@ void HtraceParser::ParserFileSO(std::string& directory, const std::vector& symbolsPaths) +bool PbreaderParser::ReparseSymbolFilesAndResymbolization(std::string& symbolsPath, + std::vector& symbolsPaths) { - std::vector dir; - dir.emplace_back(symbolsPath); + std::vector dirs; auto parseStatus = false; - parseStatus = perfDataParser_->PerfReloadSymbolFiles(dir); + for (auto file : symbolsPaths) { + auto dir = file.substr(0, file.find_last_of("/\\")); + dirs.emplace_back(dir); + } +#ifdef ENABLE_HIPERF + parseStatus = perfDataParser_->PerfReloadSymbolFiles(dirs); +#endif ParserFileSO(symbolsPath, symbolsPaths); +#ifdef ENABLE_NATIVE_HOOK if (traceDataCache_->GetNativeHookFrameData()->Size() > 0) { - htraceNativeHookParser_->NativeHookReloadElfSymbolTable(symbolsFiles_); + pbreaderNativeHookParser_->NativeHookReloadElfSymbolTable(symbolsFiles_); parseStatus = true; } +#endif +#ifdef ENABLE_EBPF if (traceDataCache_->GetEbpfCallStack()->Size() > 0) { ebpfDataParser_->EBPFReloadElfSymbolTable(symbolsFiles_); parseStatus = true; } +#endif symbolsFiles_.clear(); return parseStatus; } -void HtraceParser::WaitForParserEnd() +inline void PbreaderParser::WaitForHPluginParserEnd() { - if (parseThreadStarted_ || filterThreadStarted_) { - toExit_ = true; - while (!exited_) { - usleep(sleepDur_ * sleepDur_); - } - } - hasGotHeader_ = false; +#ifdef ENABLE_HTRACE htraceCpuDetailParser_->FilterAllEvents(); - htraceNativeHookParser_->FinishParseNativeHookData(); - htraceHiLogParser_->Finish(); - htraceHidumpParser_->Finish(); - cpuUsageParser_->Finish(); - networkParser_->Finish(); - processParser_->Finish(); - diskIOParser_->Finish(); - hisyseventParser_->Finish(); - jsMemoryParser_->Finish(); - // keep final upate perf and ebpf data time range - ebpfDataParser_->Finish(); - perfDataParser_->Finish(); - htraceNativeHookParser_->Finish(); - htraceMemParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_TRACE, dataSourceTypeTraceClockid_); - traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_MEM, dataSourceTypeMemClockid_); +#endif +#ifdef ENABLE_HILOG + pbreaderHiLogParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_HILOG, dataSourceTypeHilogClockid_); +#endif +#ifdef ENABLE_HTDUMP + pbreaderHidumpParser_->Finish(); + traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_FPS, dataSourceTypeFpsClockid_); +#endif +#ifdef ENABLE_HISYSEVENT + hisyseventParser_->Finish(); + traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_HISYSEVENT, + dataSourceTypeHisyseventClockid_); +#endif +} + +inline void PbreaderParser::WaitForOtherPluginParserEnd() +{ +#ifdef ENABLE_NATIVE_HOOK + pbreaderNativeHookParser_->FinishParseNativeHookData(); + pbreaderNativeHookParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_NATIVEHOOK, dataSourceTypeNativeHookClockid_); - traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_FPS, dataSourceTypeFpsClockid_); +#endif +#ifdef ENABLE_CPUDATA + cpuUsageParser_->Finish(); + traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_CPU, dataSourceTypeCpuClockid_); +#endif +#ifdef ENABLE_NETWORK + networkParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_NETWORK, dataSourceTypeNetworkClockid_); - traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_DISKIO, - dataSourceTypeDiskioClockid_); - traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_CPU, dataSourceTypeCpuClockid_); +#endif +#ifdef ENABLE_PROCESS + processParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_PROCESS, dataSourceTypeProcessClockid_); - traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_HISYSEVENT, - dataSourceTypeHisyseventClockid_); +#endif +#ifdef ENABLE_DISKIO + diskIOParser_->Finish(); + traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_DISKIO, + dataSourceTypeDiskioClockid_); +#endif +#ifdef ENABLE_ARKTS + jsMemoryParser_->Finish(); traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_JSMEMORY, dataSourceTypeJSMemoryClockid_); +#endif +#ifdef ENABLE_EBPF + ebpfDataParser_->Finish(); // keep final upate perf and ebpf data time range +#endif +#ifdef ENABLE_HIPERF + perfDataParser_->Finish(); +#endif +#ifdef ENABLE_MEMORY + pbreaderMemParser_->Finish(); + traceDataCache_->GetDataSourceClockIdData()->SetDataSourceClockId(DATA_SOURCE_TYPE_MEM, dataSourceTypeMemClockid_); +#endif +} + +void PbreaderParser::WaitForParserEnd() +{ + if (parseThreadStarted_ || filterThreadStarted_) { + toExit_ = true; + while (!exited_) { + usleep(sleepDur_ * sleepDur_); + } + } + hasGotHeader_ = false; + WaitForHPluginParserEnd(); + WaitForOtherPluginParserEnd(); traceDataCache_->GetDataSourceClockIdData()->Finish(); dataSegArray_.reset(); processedDataLen_ = 0; } -void HtraceParser::ParseTraceDataItem(const std::string& buffer) +void PbreaderParser::ParseTraceDataItem(const std::string& buffer) { int32_t head = rawDataHead_; if (!traceDataCache_->supportThread_ || traceDataCache_->isSplitFile_) { @@ -203,7 +318,7 @@ void HtraceParser::ParseTraceDataItem(const std::string& buffer) int32_t tmp = traceDataCache_->parserThreadNum_; while (tmp--) { parserThreadCount_++; - std::thread ParseTypeThread(&HtraceParser::ParseThread, this); + std::thread ParseTypeThread(&PbreaderParser::ParseThread, this); ParseTypeThread.detach(); TS_LOGI("parser Thread:%d/%d start working ...\n", traceDataCache_->parserThreadNum_ - tmp, traceDataCache_->parserThreadNum_); @@ -211,67 +326,106 @@ void HtraceParser::ParseTraceDataItem(const std::string& buffer) } if (!filterThreadStarted_) { filterThreadStarted_ = true; - std::thread FilterTypeThread(&HtraceParser::FilterThread, this); + std::thread FilterTypeThread(&PbreaderParser::FilterThread, this); TS_LOGI("FilterThread start working ..."); FilterTypeThread.detach(); } } -void HtraceParser::EnableFileSeparate(bool enabled) +#ifdef ENABLE_ARKTS +void PbreaderParser::EnableFileSeparate(bool enabled) { jsMemoryParser_->EnableSaveFile(enabled); } -void HtraceParser::FilterData(HtraceDataSegment& seg, bool isSplitFile) +#endif +void PbreaderParser::FilterData(PbreaderDataSegment& seg, bool isSplitFile) { bool haveSplitSeg = false; - if (seg.dataType == DATA_SOURCE_TYPE_NATIVEHOOK) { - htraceNativeHookParser_->Parse(seg, haveSplitSeg); - } else if (seg.dataType == DATA_SOURCE_TYPE_NATIVEHOOK_CONFIG) { - htraceNativeHookParser_->ParseConfigInfo(seg); - } else if (seg.dataType == DATA_SOURCE_TYPE_TRACE) { + if (seg.dataType == DATA_SOURCE_TYPE_TRACE) { +#ifdef ENABLE_HTRACE htraceCpuDetailParser_->FilterAllEventsReader(); - } else if (seg.dataType == DATA_SOURCE_TYPE_MEM) { - htraceMemParser_->Parse(seg, seg.timeStamp, seg.clockId); - } else if (seg.dataType == DATA_SOURCE_TYPE_HILOG) { - htraceHiLogParser_->Parse(seg.protoData, haveSplitSeg); - } else if (seg.dataType == DATA_SOURCE_TYPE_CPU) { +#endif + } +#ifdef ENABLE_NATIVE_HOOK + else if (seg.dataType == DATA_SOURCE_TYPE_NATIVEHOOK) { + pbreaderNativeHookParser_->Parse(seg, haveSplitSeg); + } else if (seg.dataType == DATA_SOURCE_TYPE_NATIVEHOOK_CONFIG) { + pbreaderNativeHookParser_->ParseConfigInfo(seg); + } +#endif +#ifdef ENABLE_MEMORY + else if (seg.dataType == DATA_SOURCE_TYPE_MEM) { + pbreaderMemParser_->Parse(seg, seg.timeStamp, seg.clockId); + } else if (seg.dataType == DATA_SOURCE_TYPE_MEM_CONFIG) { + pbreaderMemParser_->ParseMemoryConfig(seg); + } +#endif +#ifdef ENABLE_HILOG + else if (seg.dataType == DATA_SOURCE_TYPE_HILOG) { + pbreaderHiLogParser_->Parse(seg.protoData, haveSplitSeg); + } +#endif +#ifdef ENABLE_CPUDATA + else if (seg.dataType == DATA_SOURCE_TYPE_CPU) { cpuUsageParser_->Parse(seg.protoData, seg.timeStamp); - } else if (seg.dataType == DATA_SOURCE_TYPE_FPS) { - htraceHidumpParser_->Parse(seg.protoData); - dataSourceTypeFpsClockid_ = htraceHidumpParser_->ClockId(); - } else if (seg.dataType == DATA_SOURCE_TYPE_NETWORK) { + } +#endif +#ifdef ENABLE_HTDUMP + else if (seg.dataType == DATA_SOURCE_TYPE_FPS) { + pbreaderHidumpParser_->Parse(seg.protoData); + dataSourceTypeFpsClockid_ = pbreaderHidumpParser_->ClockId(); + } +#endif +#ifdef ENABLE_NETWORK + else if (seg.dataType == DATA_SOURCE_TYPE_NETWORK) { networkParser_->Parse(seg.protoData, seg.timeStamp); - } else if (seg.dataType == DATA_SOURCE_TYPE_PROCESS) { + } +#endif +#ifdef ENABLE_PROCESS + else if (seg.dataType == DATA_SOURCE_TYPE_PROCESS) { processParser_->Parse(seg.protoData, seg.timeStamp); - } else if (seg.dataType == DATA_SOURCE_TYPE_DISKIO) { + } +#endif +#ifdef ENABLE_DISKIO + else if (seg.dataType == DATA_SOURCE_TYPE_DISKIO) { diskIOParser_->Parse(seg.protoData, seg.timeStamp); - } else if (seg.dataType == DATA_SOURCE_TYPE_JSMEMORY) { + } +#endif +#ifdef ENABLE_ARKTS + else if (seg.dataType == DATA_SOURCE_TYPE_JSMEMORY) { jsMemoryParser_->Parse(seg.protoData, seg.timeStamp, traceDataCache_->SplitFileMinTime(), traceDataCache_->SplitFileMaxTime(), profilerPluginData_); } else if (seg.dataType == DATA_SOURCE_TYPE_JSMEMORY_CONFIG) { jsMemoryParser_->ParseJSMemoryConfig(seg.protoData); - } else if (seg.dataType == DATA_SOURCE_TYPE_HISYSEVENT) { + } +#endif +#ifdef ENABLE_HISYSEVENT + else if (seg.dataType == DATA_SOURCE_TYPE_HISYSEVENT) { ProtoReader::HisyseventInfo_Reader hisyseventInfo(seg.protoData.data_, seg.protoData.size_); hisyseventParser_->Parse(&hisyseventInfo, seg.timeStamp, haveSplitSeg); } else if (seg.dataType == DATA_SOURCE_TYPE_HISYSEVENT_CONFIG) { ProtoReader::HisyseventConfig_Reader hisyseventConfig(seg.protoData.data_, seg.protoData.size_); hisyseventParser_->Parse(&hisyseventConfig, seg.timeStamp); - } else if (seg.dataType == DATA_SOURCE_TYPE_MEM_CONFIG) { - htraceMemParser_->ParseMemoryConfig(seg); } +#endif +#ifdef ENABLE_STREAM_EXTEND + else if (seg.dataType == DATA_SOURCE_TYPE_STREAM) { + pbreaderStreamParser_->Parse(seg); + } +#endif if (traceDataCache_->isSplitFile_ && haveSplitSeg) { - mTraceDataHtrace_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); + mPbreaderSplitData_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); } if (traceDataCache_->supportThread_ && !traceDataCache_->isSplitFile_) { filterHead_ = (filterHead_ + 1) % maxSegArraySize; } seg.status = TS_PARSE_STATUS_INIT; } -void HtraceParser::FilterThread() +void PbreaderParser::FilterThread() { TS_LOGI("filter thread start work!"); while (true) { - HtraceDataSegment& seg = dataSegArray_[filterHead_]; + PbreaderDataSegment& seg = dataSegArray_[filterHead_]; if (seg.status.load() == TS_PARSE_STATUS_INVALID) { seg.status = TS_PARSE_STATUS_INIT; filterHead_ = (filterHead_ + 1) % maxSegArraySize; @@ -296,78 +450,129 @@ void HtraceParser::FilterThread() } } -bool HtraceParser::SpliteConfigData(const std::string& pluginName, const HtraceDataSegment& dataSeg) +bool PbreaderParser::SpliteConfigData(const std::string& pluginName, const PbreaderDataSegment& dataSeg) { if (EndWith(pluginName, "arkts-plugin_config")) { std::string dataString(dataSeg.seg->c_str(), dataSeg.seg->length()); arkTsConfigData_ = lenBuffer_ + dataString; return true; } else if (EndWith(pluginName, "config")) { - mTraceDataHtrace_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); + mPbreaderSplitData_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); return true; } return false; } -bool HtraceParser::SpliteDataBySegment(DataIndex pluginNameIndex, HtraceDataSegment& dataSeg) +bool PbreaderParser::SpliteDataBySegment(DataIndex pluginNameIndex, PbreaderDataSegment& dataSeg) { - if (nativeHookPluginIndex_.count(pluginNameIndex) || ftracePluginIndex_.count(pluginNameIndex) || - hilogPluginIndex_.count(pluginNameIndex) || hisyseventPluginIndex_ == pluginNameIndex) { + bool isOtherPlugin = false; +#ifdef ENABLE_HTRACE + isOtherPlugin = isOtherPlugin || ftracePluginIndex_.count(pluginNameIndex); +#endif +#ifdef ENABLE_HISYSEVENT + isOtherPlugin = isOtherPlugin || (hisyseventPluginIndex_ == pluginNameIndex); +#endif +#ifdef ENABLE_NATIVE_HOOK + isOtherPlugin = isOtherPlugin || nativeHookPluginIndex_.count(pluginNameIndex); +#endif +#ifdef ENABLE_HILOG + isOtherPlugin = isOtherPlugin || hilogPluginIndex_.count(pluginNameIndex); +#endif + if (isOtherPlugin) { return false; } // need convert to Primary Time Plugin +#ifdef ENABLE_MEMORY if (pluginNameIndex == memPluginIndex_) { dataSeg.timeStamp = streamFilters_->clockFilter_->ToPrimaryTraceTime(TS_CLOCK_REALTIME, dataSeg.timeStamp); UpdatePluginTimeRange(TS_CLOCK_BOOTTIME, dataSeg.timeStamp, dataSeg.timeStamp); } +#endif if (dataSeg.timeStamp >= traceDataCache_->SplitFileMinTime() && dataSeg.timeStamp <= traceDataCache_->SplitFileMaxTime()) { - mTraceDataHtrace_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); + mPbreaderSplitData_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); } if (pluginNameIndex == arktsPluginConfigIndex_ || pluginNameIndex == arktsPluginIndex_) { return false; } return true; } -void HtraceParser::ParseDataByPluginName(HtraceDataSegment& dataSeg, - DataIndex pulginNameIndex, - const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, - bool isSplitFile) +void PbreaderParser::ParseDataByPluginName(PbreaderDataSegment& dataSeg, + DataIndex pulginNameIndex, + const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, + bool isSplitFile) { - if (nativeHookPluginIndex_.count(pulginNameIndex)) { + if (ftracePluginIndex_.count(pulginNameIndex)) { // ok +#ifdef ENABLE_HTRACE + ParseFtrace(dataSeg); +#endif + } +#ifdef ENABLE_NATIVE_HOOK + else if (nativeHookPluginIndex_.count(pulginNameIndex)) { ParseNativeHook(dataSeg, isSplitFile); } else if (pulginNameIndex == nativeHookConfigIndex_) { ParseNativeHookConfig(dataSeg); - } else if (ftracePluginIndex_.count(pulginNameIndex)) { // ok - ParseFtrace(dataSeg); - } else if (pulginNameIndex == memPluginIndex_) { + } +#endif +#ifdef ENABLE_MEMORY + else if (pulginNameIndex == memPluginIndex_) { ParseMemory(pluginDataZero, dataSeg); - } else if (hilogPluginIndex_.count(pulginNameIndex)) { + } else if (pulginNameIndex == memoryPluginConfigIndex_) { + ParseMemoryConfig(dataSeg, pluginDataZero); + } +#endif +#ifdef ENABLE_HILOG + else if (hilogPluginIndex_.count(pulginNameIndex)) { ParseHilog(dataSeg); - } else if (hidumpPluginIndex_.count(pulginNameIndex)) { + } +#endif +#ifdef ENABLE_HTDUMP + else if (hidumpPluginIndex_.count(pulginNameIndex)) { ParseFPS(dataSeg); - } else if (pulginNameIndex == cpuPluginIndex_) { + } +#endif +#ifdef ENABLE_CPUDATA + else if (pulginNameIndex == cpuPluginIndex_) { ParseCpuUsage(dataSeg); - } else if (pulginNameIndex == networkPluginIndex_) { + } +#endif +#ifdef ENABLE_NETWORK + else if (pulginNameIndex == networkPluginIndex_) { ParseNetwork(dataSeg); - } else if (pulginNameIndex == diskioPluginIndex_) { + } +#endif +#ifdef ENABLE_DISKIO + else if (pulginNameIndex == diskioPluginIndex_) { ParseDiskIO(dataSeg); - } else if (pulginNameIndex == processPluginIndex_) { + } +#endif +#ifdef ENABLE_PROCESS + else if (pulginNameIndex == processPluginIndex_) { ParseProcess(dataSeg); - } else if (pulginNameIndex == hisyseventPluginIndex_) { + } +#endif +#ifdef ENABLE_HISYSEVENT + else if (pulginNameIndex == hisyseventPluginIndex_) { ParseHisysevent(dataSeg); } else if (pulginNameIndex == hisyseventPluginConfigIndex_) { ParseHisyseventConfig(dataSeg); - } else if (pulginNameIndex == arktsPluginIndex_) { - ParseJSMemory(dataSeg, isSplitFile); + } +#endif +#ifdef ENABLE_ARKTS + else if (pulginNameIndex == arktsPluginIndex_) { + ParseJSMemory(pluginDataZero, dataSeg, isSplitFile); } else if (pulginNameIndex == arktsPluginConfigIndex_) { ParseJSMemoryConfig(dataSeg); - } else if (pulginNameIndex == memoryPluginConfigIndex_) { - ParseMemoryConfig(dataSeg, pluginDataZero); } +#endif +#ifdef ENABLE_STREAM_EXTEND + else if (pulginNameIndex == streamPluginIndex_) { // for trace extend demo + ParseStream(dataSeg); + } +#endif } -void HtraceParser::ParserData(HtraceDataSegment& dataSeg, bool isSplitFile) +void PbreaderParser::ParserData(PbreaderDataSegment& dataSeg, bool isSplitFile) { ProtoReader::ProfilerPluginData_Reader pluginDataZero(reinterpret_cast(dataSeg.seg->c_str()), dataSeg.seg->length()); @@ -402,7 +607,7 @@ void HtraceParser::ParserData(HtraceDataSegment& dataSeg, bool isSplitFile) FilterData(dataSeg, isSplitFile); } } -void HtraceParser::ParseThread() +void PbreaderParser::ParseThread() { TS_LOGI("parser thread start work!\n"); while (true) { @@ -415,12 +620,14 @@ void HtraceParser::ParseThread() continue; } } - HtraceDataSegment& dataSeg = dataSegArray_[head]; + PbreaderDataSegment& dataSeg = dataSegArray_[head]; ParserData(dataSeg, false); } } -void HtraceParser::ParseMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, HtraceDataSegment& dataSeg) +#ifdef ENABLE_MEMORY +void PbreaderParser::ParseMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, + PbreaderDataSegment& dataSeg) { BuiltinClocks clockId = TS_CLOCK_REALTIME; auto clockIdTemp = pluginDataZero.clock_id(); @@ -432,18 +639,33 @@ void HtraceParser::ParseMemory(const ProtoReader::ProfilerPluginData_Reader& plu dataSeg.clockId = clockId; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseHilog(HtraceDataSegment& dataSeg) +void PbreaderParser::ParseMemoryConfig(PbreaderDataSegment& dataSeg, + const ProtoReader::ProfilerPluginData_Reader& pluginDataZero) +{ + if (pluginDataZero.has_sample_interval()) { + uint32_t sampleInterval = pluginDataZero.sample_interval(); + traceDataCache_->GetTraceConfigData()->AppendNewData("memory_config", "sample_interval", + std::to_string(sampleInterval)); + } + dataSeg.dataType = DATA_SOURCE_TYPE_MEM_CONFIG; + dataSeg.status = TS_PARSE_STATUS_PARSED; +} +#endif +#ifdef ENABLE_HILOG +void PbreaderParser::ParseHilog(PbreaderDataSegment& dataSeg) { dataSeg.dataType = DATA_SOURCE_TYPE_HILOG; dataSourceTypeHilogClockid_ = TS_CLOCK_REALTIME; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseNativeHookConfig(HtraceDataSegment& dataSeg) +#endif +#ifdef ENABLE_NATIVE_HOOK +void PbreaderParser::ParseNativeHookConfig(PbreaderDataSegment& dataSeg) { dataSeg.dataType = DATA_SOURCE_TYPE_NATIVEHOOK_CONFIG; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseNativeHook(HtraceDataSegment& dataSeg, bool isSplitFile) +void PbreaderParser::ParseNativeHook(PbreaderDataSegment& dataSeg, bool isSplitFile) { dataSourceTypeNativeHookClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_NATIVEHOOK; @@ -452,19 +674,10 @@ void HtraceParser::ParseNativeHook(HtraceDataSegment& dataSeg, bool isSplitFile) dataSourceType_ = DATA_SOURCE_TYPE_NATIVEHOOK; } } -void HtraceParser::ParseMemoryConfig(HtraceDataSegment& dataSeg, - const ProtoReader::ProfilerPluginData_Reader& pluginDataZero) -{ - if (pluginDataZero.has_sample_interval()) { - uint32_t sampleInterval = pluginDataZero.sample_interval(); - traceDataCache_->GetTraceConfigData()->AppendNewData("memory_config", "sample_interval", - std::to_string(sampleInterval)); - } - dataSeg.dataType = DATA_SOURCE_TYPE_MEM_CONFIG; - dataSeg.status = TS_PARSE_STATUS_PARSED; -} +#endif -void HtraceParser::ParseFtrace(HtraceDataSegment& dataSeg) +#ifdef ENABLE_HTRACE +void PbreaderParser::ParseFtrace(PbreaderDataSegment& dataSeg) { dataSeg.dataType = DATA_SOURCE_TYPE_TRACE; ProtoReader::TracePluginResult_Reader tracePluginResult(dataSeg.protoData); @@ -494,99 +707,131 @@ 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_); + mPbreaderSplitData_.emplace(splitFileOffset_, nextLength_ + packetSegLength_); + } + 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; } - dataSeg.status = TS_PARSE_STATUS_INVALID; } +#endif -void HtraceParser::ParseFPS(HtraceDataSegment& dataSeg) +#ifdef ENABLE_HTDUMP +void PbreaderParser::ParseFPS(PbreaderDataSegment& dataSeg) { dataSeg.dataType = DATA_SOURCE_TYPE_FPS; dataSeg.status = TS_PARSE_STATUS_PARSED; } +#endif -void HtraceParser::ParseCpuUsage(HtraceDataSegment& dataSeg) +#ifdef ENABLE_CPUDATA +void PbreaderParser::ParseCpuUsage(PbreaderDataSegment& dataSeg) { - dataSourceTypeProcessClockid_ = TS_CLOCK_REALTIME; + dataSourceTypeCpuClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_CPU; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseNetwork(HtraceDataSegment& dataSeg) +#endif +#ifdef ENABLE_NETWORK +void PbreaderParser::ParseNetwork(PbreaderDataSegment& dataSeg) { - dataSourceTypeProcessClockid_ = TS_CLOCK_REALTIME; + dataSourceTypeNetworkClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_NETWORK; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseDiskIO(HtraceDataSegment& dataSeg) +#endif +#ifdef ENABLE_DISKIO +void PbreaderParser::ParseDiskIO(PbreaderDataSegment& dataSeg) { - dataSourceTypeProcessClockid_ = TS_CLOCK_REALTIME; + dataSourceTypeDiskioClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_DISKIO; dataSeg.status = TS_PARSE_STATUS_PARSED; } +#endif -void HtraceParser::ParseProcess(HtraceDataSegment& dataSeg) +#ifdef ENABLE_PROCESS +void PbreaderParser::ParseProcess(PbreaderDataSegment& dataSeg) { dataSourceTypeProcessClockid_ = TS_CLOCK_BOOTTIME; dataSeg.dataType = DATA_SOURCE_TYPE_PROCESS; dataSeg.status = TS_PARSE_STATUS_PARSED; } +#endif -void HtraceParser::ParseHisysevent(HtraceDataSegment& dataSeg) +#ifdef ENABLE_HISYSEVENT +void PbreaderParser::ParseHisysevent(PbreaderDataSegment& dataSeg) { dataSourceTypeHisyseventClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_HISYSEVENT; dataSeg.status = TS_PARSE_STATUS_PARSED; } -void HtraceParser::ParseHisyseventConfig(HtraceDataSegment& dataSeg) +void PbreaderParser::ParseHisyseventConfig(PbreaderDataSegment& dataSeg) { dataSourceTypeHisyseventClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_HISYSEVENT_CONFIG; dataSeg.status = TS_PARSE_STATUS_PARSED; } +#endif -void HtraceParser::ParseJSMemory(HtraceDataSegment& dataSeg, bool isSplitFile) +#ifdef ENABLE_ARKTS +void PbreaderParser::ParseJSMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, + PbreaderDataSegment& dataSeg, + bool isSplitFile) { if (isSplitFile) { dataSourceType_ = DATA_SOURCE_TYPE_JSMEMORY; - memcpy_s(&profilerPluginData_, sizeof(profilerPluginData_), dataSeg.seg->c_str(), dataSeg.seg->length()); + profilerPluginData_.name = pluginDataZero.name().ToStdString(); + profilerPluginData_.status = pluginDataZero.status(); + profilerPluginData_.clockId = pluginDataZero.clock_id(); + profilerPluginData_.tvSec = pluginDataZero.tv_sec(); + profilerPluginData_.tvNsec = pluginDataZero.tv_nsec(); + profilerPluginData_.version = pluginDataZero.version().ToStdString(); + profilerPluginData_.sampleInterval = pluginDataZero.sample_interval(); } dataSourceTypeJSMemoryClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_JSMEMORY; dataSeg.status = TS_PARSE_STATUS_PARSED; } - -void HtraceParser::ParseJSMemoryConfig(HtraceDataSegment& dataSeg) +void PbreaderParser::ParseJSMemoryConfig(PbreaderDataSegment& dataSeg) { dataSourceTypeJSMemoryClockid_ = TS_CLOCK_REALTIME; dataSeg.dataType = DATA_SOURCE_TYPE_JSMEMORY_CONFIG; dataSeg.status = TS_PARSE_STATUS_PARSED; } +#endif + +#ifdef ENABLE_STREAM_EXTEND +void PbreaderParser::ParseStream(PbreaderDataSegment& dataSeg) +{ + dataSeg.dataType = DATA_SOURCE_TYPE_STREAM; + dataSeg.status = TS_PARSE_STATUS_PARSED; +} +#endif -int32_t HtraceParser::GetNextSegment() +int32_t PbreaderParser::GetNextSegment() { int32_t head; - std::lock_guard muxLockGuard(htraceDataSegMux_); + std::lock_guard muxLockGuard(pbreaderDataSegMux_); head = parseHead_; - HtraceDataSegment& htraceDataSegmentSeg = dataSegArray_[head]; - if (htraceDataSegmentSeg.status.load() != TS_PARSE_STATUS_SEPRATED) { + PbreaderDataSegment& pbreaderDataSegmentSeg = dataSegArray_[head]; + if (pbreaderDataSegmentSeg.status.load() != TS_PARSE_STATUS_SEPRATED) { if (toExit_) { parserThreadCount_--; TS_LOGI("exiting parser, parserThread Count:%d\n", parserThreadCount_); TS_LOGI("seprateHead_x:\t%d, parseHead_:\t%d, filterHead_:\t%d status:%d\n", rawDataHead_, parseHead_, - filterHead_, htraceDataSegmentSeg.status.load()); + filterHead_, pbreaderDataSegmentSeg.status.load()); if (!parserThreadCount_ && !filterThreadStarted_) { exited_ = true; } @@ -596,10 +841,11 @@ int32_t HtraceParser::GetNextSegment() return ERROR_CODE_NODATA; } parseHead_ = (parseHead_ + 1) % maxSegArraySize; - htraceDataSegmentSeg.status = TS_PARSE_STATUS_PARSING; + pbreaderDataSegmentSeg.status = TS_PARSE_STATUS_PARSING; return head; } -bool HtraceParser::CalcEbpfCutOffset(std::deque::iterator& packagesBegin, size_t& currentLength) +#ifdef ENABLE_EBPF +bool PbreaderParser::CalcEbpfCutOffset(std::deque::iterator& packagesBegin, size_t& currentLength) { auto standaloneDataLength = profilerDataLength_ - packetHeaderLength_; if (traceDataCache_->isSplitFile_ && !parsedEbpfOver_) { @@ -629,8 +875,9 @@ bool HtraceParser::CalcEbpfCutOffset(std::deque::iterator& packagesBegi } return false; } +#endif -bool HtraceParser::GetHeaderAndUpdateLengthMark(std::deque::iterator& packagesBegin, size_t& currentLength) +bool PbreaderParser::GetHeaderAndUpdateLengthMark(std::deque::iterator& packagesBegin, size_t& currentLength) { if (!hasGotHeader_) { if (!InitProfilerTraceFileHeader()) { @@ -641,7 +888,7 @@ bool HtraceParser::GetHeaderAndUpdateLengthMark(std::deque::iterator& p currentLength -= packetHeaderLength_; packagesBegin += packetHeaderLength_; parsedFileOffset_ += packetHeaderLength_; - htraceCurentLength_ = profilerDataLength_ - packetHeaderLength_; + pbreaderCurentLength_ = profilerDataLength_ - packetHeaderLength_; hasGotHeader_ = true; if (!currentLength) { return false; @@ -650,7 +897,7 @@ bool HtraceParser::GetHeaderAndUpdateLengthMark(std::deque::iterator& p return true; } #if IS_WASM -bool HtraceParser::ParseSDKData() +bool PbreaderParser::ParseSDKData() { if (packagesBuffer_.size() >= profilerDataLength_ - packetHeaderLength_) { auto thirdPartySize = profilerDataLength_ - packetHeaderLength_; @@ -663,8 +910,8 @@ bool HtraceParser::ParseSDKData() } #endif -bool HtraceParser::ParseSegLengthAndEnsureSegDataEnough(std::deque::iterator& packagesBegin, - size_t& currentLength) +bool PbreaderParser::ParseSegLengthAndEnsureSegDataEnough(std::deque::iterator& packagesBegin, + size_t& currentLength) { std::string bufferLine; if (!hasGotSegLength_) { @@ -675,28 +922,34 @@ bool HtraceParser::ParseSegLengthAndEnsureSegDataEnough(std::deque::ite const uint32_t* len = reinterpret_cast(bufferLine.data()); nextLength_ = *len; lenBuffer_ = bufferLine; - htraceLength_ += nextLength_ + packetSegLength_; + pbreaderLength_ += nextLength_ + packetSegLength_; hasGotSegLength_ = true; currentLength -= packetSegLength_; packagesBegin += packetSegLength_; parsedFileOffset_ += packetSegLength_; - splitFileOffset_ = profilerDataLength_ - htraceCurentLength_; - htraceCurentLength_ -= packetSegLength_; + splitFileOffset_ = profilerDataLength_ - pbreaderCurentLength_; + pbreaderCurentLength_ -= packetSegLength_; } if (currentLength < nextLength_) { return false; } return true; } -bool HtraceParser::ParseDataRecursively(std::deque::iterator& packagesBegin, size_t& currentLength) +bool PbreaderParser::ParseDataRecursively(std::deque::iterator& packagesBegin, size_t& currentLength) { TS_CHECK_TRUE_RET(GetHeaderAndUpdateLengthMark(packagesBegin, currentLength), false); +#ifdef ENABLE_HIPERF if (profilerDataType_ == ProfilerTraceFileHeader::HIPERF_DATA) { return ParseHiperfData(packagesBegin, currentLength); } +#endif if (profilerDataType_ == ProfilerTraceFileHeader::STANDALONE_DATA) { if (EBPF_PLUGIN_NAME.compare(standalonePluginName_) == 0) { +#ifdef ENABLE_EBPF return CalcEbpfCutOffset(packagesBegin, currentLength); +#else + return false; +#endif } else { #if IS_WASM TS_CHECK_TRUE_RET(ParseSDKData(), false); // 三方sdk逻辑待验证。 @@ -712,12 +965,12 @@ bool HtraceParser::ParseDataRecursively(std::deque::iterator& packagesB packagesBegin += nextLength_; currentLength -= nextLength_; parsedFileOffset_ += nextLength_; - if (nextLength_ > htraceCurentLength_) { - TS_LOGE("fatal error, data length not match nextLength_:%u, htraceCurentLength_:%" PRIu64 "", nextLength_, - htraceCurentLength_); + if (nextLength_ > pbreaderCurentLength_) { + TS_LOGE("fatal error, data length not match nextLength_:%u, pbreaderCurentLength_:%" PRIu64 "", nextLength_, + pbreaderCurentLength_); } - htraceCurentLength_ -= nextLength_; - if (htraceCurentLength_ == 0) { + pbreaderCurentLength_ -= nextLength_; + if (pbreaderCurentLength_ == 0) { hasGotHeader_ = false; processedDataLen_ += packagesBegin - packagesBuffer_.begin(); packagesBuffer_.erase(packagesBuffer_.begin(), packagesBegin); @@ -729,7 +982,7 @@ bool HtraceParser::ParseDataRecursively(std::deque::iterator& packagesB return true; } -void HtraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish) +void PbreaderParser::ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish) { packagesBuffer_.insert(packagesBuffer_.end(), &bufferStr[0], &bufferStr[size]); auto packagesBegin = packagesBuffer_.begin(); @@ -740,7 +993,8 @@ void HtraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, s } return; } -bool HtraceParser::ParseHiperfData(std::deque::iterator& packagesBegin, size_t& currentLength) +#ifdef ENABLE_HIPERF +bool PbreaderParser::ParseHiperfData(std::deque::iterator& packagesBegin, size_t& currentLength) { if (!traceDataCache_->isSplitFile_) { if (packagesBuffer_.size() >= profilerDataLength_ - packetHeaderLength_) { @@ -754,7 +1008,6 @@ bool HtraceParser::ParseHiperfData(std::deque::iterator& packagesBegin, } return false; } - bool isFinish = perfProcessedLen_ + packagesBuffer_.size() >= profilerDataLength_ - packetHeaderLength_; auto size = packagesBuffer_.size(); if (isFinish) { @@ -770,7 +1023,7 @@ bool HtraceParser::ParseHiperfData(std::deque::iterator& packagesBegin, } return true; } -void HtraceParser::StoreTraceDataSegment(std::unique_ptr bufferStr, size_t size, int32_t isFinish) +void PbreaderParser::StoreTraceDataSegment(std::unique_ptr bufferStr, size_t size, int32_t isFinish) { packagesBuffer_.insert(packagesBuffer_.end(), &bufferStr[0], &bufferStr[size]); if (!traceDataCache_->isSplitFile_) { @@ -784,14 +1037,15 @@ void HtraceParser::StoreTraceDataSegment(std::unique_ptr bufferStr, s packagesBuffer_.erase(packagesBuffer_.begin(), packagesBuffer_.begin() + ret); return; } -void HtraceParser::TraceDataSegmentEnd(bool isSplitFile) +void PbreaderParser::TraceDataSegmentEnd(bool isSplitFile) { perfDataParser_->InitPerfDataAndLoad(packagesBuffer_, packagesBuffer_.size(), 0, isSplitFile, true); packagesBuffer_.clear(); return; } +#endif -bool HtraceParser::InitProfilerTraceFileHeader() +bool PbreaderParser::InitProfilerTraceFileHeader() { if (packagesBuffer_.size() < packetHeaderLength_) { TS_LOGI("buffer size less than profiler trace file header"); @@ -810,10 +1064,14 @@ bool HtraceParser::InitProfilerTraceFileHeader() return false; } if (pHeader->data.dataType == ProfilerTraceFileHeader::HIPERF_DATA) { +#ifdef ENABLE_HIPERF perfDataParser_->RecordPerfProfilerHeader(buffer, packetHeaderLength_); +#endif } else if (pHeader->data.dataType == ProfilerTraceFileHeader::STANDALONE_DATA && EBPF_PLUGIN_NAME.compare(pHeader->data.standalonePluginName) == 0) { +#ifdef ENABLE_EBPF ebpfDataParser_->RecordEbpfProfilerHeader(buffer, packetHeaderLength_); +#endif } else { auto ret = memcpy_s(&profilerTraceFileHeader_, sizeof(profilerTraceFileHeader_), buffer, packetHeaderLength_); if (ret == -1 || profilerTraceFileHeader_.data.magic != ProfilerTraceFileHeader::HEADER_MAGIC) { @@ -833,7 +1091,9 @@ bool HtraceParser::InitProfilerTraceFileHeader() const int32_t DATA_TYPE_CLOCK = 100; TraceStreamer_Plugin_Out_SendData(reinterpret_cast(buffer), packetHeaderLength_, DATA_TYPE_CLOCK); #endif +#ifdef ENABLE_HTRACE htraceClockDetailParser_->Parse(pHeader); +#endif return true; } } // namespace TraceStreamer diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h b/trace_streamer/src/parser/pbreader_parser/pbreader_parser.h similarity index 55% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h rename to trace_streamer/src/parser/pbreader_parser/pbreader_parser.h index f79cc84823e83000d6b29f4560f1f1a9de1a7293..f0be66e21fd598d7edd8728888b9e98cb045dabb 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/pbreader_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, @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef HTRACE_PARSER_H -#define HTRACE_PARSER_H +#ifndef PBREADER_PARSER_H +#define PBREADER_PARSER_H #include #include #include @@ -23,63 +23,101 @@ #include #include "common_types.h" #include "common_types.pbreader.h" +#include "clock_filter_ex.h" +#ifdef ENABLE_EBPF #include "ebpf_data_parser.h" +#endif #include "file.h" +#ifdef ENABLE_HTRACE #include "htrace_clock_detail_parser.h" #include "htrace_cpu_detail_parser.h" -#include "htrace_cpu_data_parser.h" -#include "htrace_disk_io_parser.h" -#include "htrace_file_header.h" -#include "htrace_hidump_parser.h" -#include "htrace_hilog_parser.h" -#include "htrace_hisysevent_parser.h" -#include "htrace_js_memory_parser.h" -#include "htrace_mem_parser.h" -#include "htrace_native_hook_parser.h" -#include "htrace_network_parser.h" -#include "htrace_process_parser.h" #include "htrace_symbols_detail_parser.h" +#endif +#include "htrace_plugin_time_parser.h" +#ifdef ENABLE_CPUDATA +#include "cpu_data_parser/pbreader_cpu_data_parser.h" +#endif +#ifdef ENABLE_DISKIO +#include "disk_io_parser/pbreader_disk_io_parser.h" +#endif +#ifdef ENABLE_HTDUMP +#include "hidump_parser/pbreader_hidump_parser.h" +#endif +#ifdef ENABLE_HILOG +#include "hilog_parser/pbreader_hilog_parser.h" +#endif +#ifdef ENABLE_HISYSEVENT +#include "hisysevent_parser/pbreader_hisysevent_parser.h" +#endif +#ifdef ENABLE_ARKTS +#include "arkts/pbreader_js_memory_parser.h" +#endif +#ifdef ENABLE_MEMORY +#include "mem_parser/pbreader_mem_parser.h" +#endif +#ifdef ENABLE_NATIVE_HOOK +#include "native_hook_parser/pbreader_native_hook_parser.h" +#endif +#ifdef ENABLE_NETWORK +#include "network_parser/pbreader_network_parser.h" +#endif +#ifdef ENABLE_PROCESS +#include "process_parser/pbreader_process_parser.h" +#endif #include "log.h" #include "parser_base.h" +#include "pbreader_file_header.h" +#ifdef ENABLE_HIPERF #include "perf_data_parser.h" +#endif #include "proto_reader_help.h" #include "string_help.h" #include "symbols_file.h" #include "trace_data/trace_data_cache.h" #include "trace_streamer_filters.h" #include "ts_common.h" +#ifdef ENABLE_STREAM_EXTEND +#include "pbreader_stream_parser.h" +#endif namespace SysTuning { namespace TraceStreamer { using namespace SysTuning::base; using namespace OHOS::Developtools::HiPerf; -class HtraceParser : public ParserBase, public HtracePluginTimeParser { +class PbreaderParser : public ParserBase, public HtracePluginTimeParser { public: - HtraceParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); - ~HtraceParser(); + PbreaderParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); + ~PbreaderParser(); void ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish = false) override; bool ReparseSymbolFilesAndResymbolization(std::string& symbolsPath, std::vector& symbolsPaths); void WaitForParserEnd(); +#ifdef ENABLE_ARKTS void EnableFileSeparate(bool enabled); +#endif void ParserFileSO(std::string& directory, const std::vector& relativeFilePaths); +#ifdef ENABLE_HIPERF void TraceDataSegmentEnd(bool isSplitFile); void StoreTraceDataSegment(std::unique_ptr bufferStr, size_t size, int32_t isFinish); - const auto& GetTraceDataHtrace() +#endif + const auto& GetPbreaderSplitData() { - return mTraceDataHtrace_; + return mPbreaderSplitData_; } auto GetProfilerHeader() { return profilerTraceFileHeader_; } +#ifdef ENABLE_NATIVE_HOOK auto ClearNativehookData() { - htraceNativeHookParser_->FinishSplitNativeHook(); + pbreaderNativeHookParser_->FinishSplitNativeHook(); } +#endif auto GetDataSourceType() { return dataSourceType_; } +#ifdef ENABLE_ARKTS auto GetJsMemoryData() { return jsMemoryParser_.get(); @@ -88,73 +126,123 @@ public: { return arkTsConfigData_; } - auto ClearTraceDataHtrace() +#endif + auto ClearPbreaderSplitData() { +#ifdef ENABLE_HIPERF perfDataParser_->ClearPerfSplitResult(); + perfProcessedLen_ = 0; +#endif +#ifdef ENABLE_EBPF ebpfDataParser_->ClearEbpfSplitResult(); + hasInitEbpfPublicData_ = false; + parsedEbpfOver_ = false; +#endif processedDataLen_ = 0; - perfProcessedLen_ = 0; splitFileOffset_ = 0; hasGotHeader_ = false; - hasInitEbpfPublicData_ = false; - parsedEbpfOver_ = false; - return mTraceDataHtrace_.clear(); + return mPbreaderSplitData_.clear(); } +#ifdef ENABLE_HIPERF const auto& GetPerfSplitResult() { return perfDataParser_->GetPerfSplitResult(); } +#endif +#ifdef ENABLE_EBPF const auto& GetEbpfDataParser() { return ebpfDataParser_; } - void WaitForParserSplitedHtraceEnd(); +#endif +#ifdef ENABLE_HTRACE + void EnableOnlyParseFtrace() + { + onlyParseFtrace_ = true; + } +#endif private: bool ParseDataRecursively(std::deque::iterator& packagesBegin, size_t& currentLength); +#ifdef ENABLE_HIPERF bool ParseHiperfData(std::deque::iterator& packagesBegin, size_t& currentLength); +#endif void ParseTraceDataItem(const std::string& buffer) override; - void FilterData(HtraceDataSegment& seg, bool isSplitFile); - void ParserData(HtraceDataSegment& dataSeg, bool isSplitFile); + void FilterData(PbreaderDataSegment& seg, bool isSplitFile); + void ParserData(PbreaderDataSegment& dataSeg, bool isSplitFile); private: #if IS_WASM bool ParseSDKData(); #endif void InitPluginNameIndex(); + void InitHookPluginNameIndex(); + void InitMemoryPluginNameIndex(); + void InitHiPluginNameIndex(); + void WaitForHPluginParserEnd(); + void WaitForOtherPluginParserEnd(); bool GetHeaderAndUpdateLengthMark(std::deque::iterator& packagesBegin, size_t& currentLength); bool ParseSegLengthAndEnsureSegDataEnough(std::deque::iterator& packagesBegin, size_t& currentLength); - void ParseMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, HtraceDataSegment& dataSeg); - void ParseMemoryConfig(HtraceDataSegment& dataSeg, const ProtoReader::ProfilerPluginData_Reader& pluginDataZero); - void ParseHilog(HtraceDataSegment& dataSeg); - void ParseFtrace(HtraceDataSegment& dataSeg); - void ParseFPS(HtraceDataSegment& dataSeg); - void ParseCpuUsage(HtraceDataSegment& dataSeg); - void ParseNetwork(HtraceDataSegment& dataSeg); - void ParseDiskIO(HtraceDataSegment& dataSeg); - void ParseProcess(HtraceDataSegment& dataSeg); - void ParseHisysevent(HtraceDataSegment& dataSeg); - void ParseHisyseventConfig(HtraceDataSegment& dataSeg); - void ParseJSMemory(HtraceDataSegment& dataSeg, bool isSplitFile); - void ParseNativeHookConfig(HtraceDataSegment& dataSeg); - void ParseNativeHook(HtraceDataSegment& dataSeg, bool isSplitFile); - void ParseJSMemoryConfig(HtraceDataSegment& dataSeg); +#ifdef ENABLE_MEMORY + void ParseMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, PbreaderDataSegment& dataSeg); + void ParseMemoryConfig(PbreaderDataSegment& dataSeg, const ProtoReader::ProfilerPluginData_Reader& pluginDataZero); +#endif +#ifdef ENABLE_HILOG + void ParseHilog(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_HTRACE + void ParseFtrace(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_HTDUMP + void ParseFPS(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_CPUDATA + void ParseCpuUsage(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_NETWORK + void ParseNetwork(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_DISKIO + void ParseDiskIO(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_PROCESS + void ParseProcess(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_HISYSEVENT + void ParseHisysevent(PbreaderDataSegment& dataSeg); + void ParseHisyseventConfig(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_NATIVE_HOOK + void ParseNativeHookConfig(PbreaderDataSegment& dataSeg); + void ParseNativeHook(PbreaderDataSegment& dataSeg, bool isSplitFile); +#endif +#ifdef ENABLE_ARKTS + void ParseJSMemory(const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, + PbreaderDataSegment& dataSeg, + bool isSplitFile); + void ParseJSMemoryConfig(PbreaderDataSegment& dataSeg); +#endif +#ifdef ENABLE_STREAM_EXTEND + void ParseStream(PbreaderDataSegment& dataSeg); +#endif void ParseThread(); int32_t GetNextSegment(); void FilterThread(); +#ifdef ENABLE_EBPF bool CalcEbpfCutOffset(std::deque::iterator& packagesBegin, size_t& currentLength); - bool SpliteConfigData(const std::string& pluginName, const HtraceDataSegment& dataSeg); +#endif + bool SpliteConfigData(const std::string& pluginName, const PbreaderDataSegment& dataSeg); bool InitProfilerTraceFileHeader(); - void ParseDataByPluginName(HtraceDataSegment& dataSeg, + void ParseDataByPluginName(PbreaderDataSegment& dataSeg, DataIndex pulginNameIndex, const ProtoReader::ProfilerPluginData_Reader& pluginDataZero, bool isSplitFile); - bool SpliteDataBySegment(DataIndex pluginNameIndex, HtraceDataSegment& dataSeg); + bool SpliteDataBySegment(DataIndex pluginNameIndex, PbreaderDataSegment& dataSeg); ProfilerTraceFileHeader profilerTraceFileHeader_; uint32_t profilerDataType_ = ProfilerTraceFileHeader::UNKNOW_TYPE; uint64_t profilerDataLength_ = 0; ProfilerPluginDataHeader profilerPluginData_; - uint64_t htraceCurentLength_ = 0; + uint64_t pbreaderCurentLength_ = 0; char standalonePluginName_[ProfilerTraceFileHeader::PLUGIN_MODULE_NAME_MAX + 1] = ""; bool hasGotSegLength_ = false; bool hasGotHeader_ = false; @@ -162,22 +250,80 @@ private: const size_t packetSegLength_ = 4; const size_t packetHeaderLength_ = 1024; TraceDataCache* traceDataCache_; +#ifdef ENABLE_HTRACE std::unique_ptr htraceCpuDetailParser_; std::unique_ptr htraceSymbolsDetailParser_; - std::unique_ptr htraceMemParser_; std::unique_ptr htraceClockDetailParser_; - std::unique_ptr htraceHiLogParser_; - std::unique_ptr htraceNativeHookParser_; - std::unique_ptr htraceHidumpParser_; - std::unique_ptr cpuUsageParser_; - std::unique_ptr networkParser_; - std::unique_ptr diskIOParser_; - std::unique_ptr processParser_; - std::unique_ptr hisyseventParser_; - std::unique_ptr jsMemoryParser_; + ClockId dataSourceTypeTraceClockid_ = TS_CLOCK_UNKNOW; + bool onlyParseFtrace_ = false; +#endif + std::set ftracePluginIndex_ = {}; +#ifdef ENABLE_MEMORY + std::unique_ptr pbreaderMemParser_; + ClockId dataSourceTypeMemClockid_ = TS_CLOCK_UNKNOW; + DataIndex memPluginIndex_; + DataIndex memoryPluginConfigIndex_; +#endif +#ifdef ENABLE_HTDUMP + std::unique_ptr pbreaderHidumpParser_; + std::set hidumpPluginIndex_ = {}; + ClockId dataSourceTypeFpsClockid_ = TS_CLOCK_UNKNOW; +#endif +#ifdef ENABLE_CPUDATA + std::unique_ptr cpuUsageParser_; + ClockId dataSourceTypeCpuClockid_ = TS_CLOCK_UNKNOW; + DataIndex cpuPluginIndex_; +#endif +#ifdef ENABLE_NETWORK + std::unique_ptr networkParser_; + ClockId dataSourceTypeNetworkClockid_ = TS_CLOCK_UNKNOW; + DataIndex networkPluginIndex_; +#endif +#ifdef ENABLE_DISKIO + std::unique_ptr diskIOParser_; + ClockId dataSourceTypeDiskioClockid_ = TS_CLOCK_UNKNOW; + DataIndex diskioPluginIndex_; +#endif +#ifdef ENABLE_PROCESS + std::unique_ptr processParser_; + ClockId dataSourceTypeProcessClockid_ = TS_CLOCK_UNKNOW; + DataIndex processPluginIndex_; +#endif +#ifdef ENABLE_HISYSEVENT + std::unique_ptr hisyseventParser_; + ClockId dataSourceTypeHisyseventClockid_ = TS_CLOCK_UNKNOW; + DataIndex hisyseventPluginIndex_; + DataIndex hisyseventPluginConfigIndex_; +#endif +#ifdef ENABLE_ARKTS + std::unique_ptr jsMemoryParser_; + ClockId dataSourceTypeJSMemoryClockid_ = TS_CLOCK_UNKNOW; +#endif +#ifdef ENABLE_HIPERF + uint64_t perfProcessedLen_ = 0; std::unique_ptr perfDataParser_; +#endif +#ifdef ENABLE_EBPF std::unique_ptr ebpfDataParser_; - std::unique_ptr dataSegArray_; + bool hasInitEbpfPublicData_ = false; + bool parsedEbpfOver_ = false; +#endif +#ifdef ENABLE_NATIVE_HOOK + std::unique_ptr pbreaderNativeHookParser_; + ClockId dataSourceTypeNativeHookClockid_ = TS_CLOCK_UNKNOW; + std::set nativeHookPluginIndex_ = {}; + DataIndex nativeHookConfigIndex_; +#endif +#ifdef ENABLE_HILOG + std::set hilogPluginIndex_ = {}; + std::unique_ptr pbreaderHiLogParser_; + ClockId dataSourceTypeHilogClockid_ = TS_CLOCK_UNKNOW; +#endif +#ifdef ENABLE_STREAM_EXTEND + DataIndex streamPluginIndex_; + std::unique_ptr pbreaderStreamParser_; +#endif + std::unique_ptr dataSegArray_; std::atomic filterThreadStarted_{false}; const int32_t maxSegArraySize = 10000; int32_t rawDataHead_ = 0; @@ -185,49 +331,21 @@ private: bool exited_ = false; int32_t filterHead_ = 0; int32_t parseHead_ = 0; - size_t htraceLength_ = 1024; + size_t pbreaderLength_ = 1024; const int32_t sleepDur_ = 100; bool parseThreadStarted_ = false; int32_t parserThreadCount_ = 0; - std::mutex htraceDataSegMux_ = {}; - ClockId dataSourceTypeTraceClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeMemClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeHilogClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeNativeHookClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeFpsClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeNetworkClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeDiskioClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeCpuClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeProcessClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeHisyseventClockid_ = TS_CLOCK_UNKNOW; - ClockId dataSourceTypeJSMemoryClockid_ = TS_CLOCK_UNKNOW; + std::mutex pbreaderDataSegMux_ = {}; std::vector> symbolsFiles_; - std::map mTraceDataHtrace_ = {}; - std::string traceDataHtrace_ = ""; + std::map mPbreaderSplitData_ = {}; uint64_t splitFileOffset_ = 0; uint64_t processedDataLen_ = 0; - uint64_t perfProcessedLen_ = 0; uint64_t parsedFileOffset_ = 0; - bool hasInitEbpfPublicData_ = false; - bool parsedEbpfOver_ = false; uint32_t dataSourceType_ = INVALID_UINT32; std::string arkTsConfigData_ = ""; std::string lenBuffer_ = ""; - std::set nativeHookPluginIndex_ = {}; - std::set ftracePluginIndex_ = {}; - std::set hilogPluginIndex_ = {}; - DataIndex hisyseventPluginIndex_; - DataIndex nativeHookConfigIndex_; - DataIndex memPluginIndex_; - std::set hidumpPluginIndex_ = {}; - DataIndex cpuPluginIndex_; - DataIndex networkPluginIndex_; - DataIndex diskioPluginIndex_; - DataIndex processPluginIndex_; - DataIndex hisyseventPluginConfigIndex_; DataIndex arktsPluginIndex_; DataIndex arktsPluginConfigIndex_; - DataIndex memoryPluginConfigIndex_; std::set supportPluginNameIndex_ = {}; }; } // namespace TraceStreamer diff --git a/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn b/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0b93f72c128eca94e91bbf23ebe0d4090fb5fa41 --- /dev/null +++ b/trace_streamer/src/parser/pbreader_parser/process_parser/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("process_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "pbreader_process_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", + "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:process_data_reader", + ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp b/trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_process_parser.cpp similarity index 87% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp rename to trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_process_parser.cpp index 0dbd003aae9f5ed4d57ea5874aac064e970fcc74..fcc9ee8147354772149d04c3d280c4949bd5ba30 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.cpp +++ b/trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_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, @@ -12,32 +12,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "htrace_process_parser.h" +#include "pbreader_process_parser.h" #include "clock_filter_ex.h" -#include "cpu_plugin_config.pbreader.h" -#include "cpu_plugin_result.pbreader.h" -#include "diskio_plugin_config.pbreader.h" -#include "diskio_plugin_result.pbreader.h" -#include "htrace_event_parser.h" #include "process_filter.h" #include "process_plugin_config.pbreader.h" #include "process_plugin_result.pbreader.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -HtraceProcessParser::HtraceProcessParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) +PbreaderProcessParser::PbreaderProcessParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx) : EventParserBase(dataCache, ctx) { } -HtraceProcessParser::~HtraceProcessParser() +PbreaderProcessParser::~PbreaderProcessParser() { TS_LOGI("process ts MIN:%llu, MAX:%llu", static_cast(GetPluginStartTime()), static_cast(GetPluginEndTime())); TS_LOGI("process real ts MIN:%llu, MAX:%llu", static_cast(MinTs()), static_cast(MaxTs())); } -void HtraceProcessParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) +void PbreaderProcessParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) { ProtoReader::ProcessData_Reader processData(tracePacket.data_, tracePacket.size_); for (auto i = processData.processesinfo(); i; ++i) { @@ -61,7 +56,7 @@ void HtraceProcessParser::Parse(ProtoReader::BytesView tracePacket, uint64_t ts) liveProcessData_.push_back(std::move(liveProcess)); } } -void HtraceProcessParser::Finish() +void PbreaderProcessParser::Finish() { if (!liveProcessData_.size()) { TS_LOGW("process no data"); diff --git a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h b/trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_process_parser.h similarity index 90% rename from trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h rename to trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_process_parser.h index 121d4f7cc21ade7bafeba927003b818ee34375d7..cec58dabfb981209399ab9b15693033cc1fb6117 100644 --- a/trace_streamer/src/parser/htrace_pbreader_parser/htrace_process_parser.h +++ b/trace_streamer/src/parser/pbreader_parser/process_parser/pbreader_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, @@ -24,10 +24,10 @@ namespace SysTuning { namespace TraceStreamer { -class HtraceProcessParser : public EventParserBase, public HtracePluginTimeParser { +class PbreaderProcessParser : public EventParserBase, public HtracePluginTimeParser { public: - HtraceProcessParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); - ~HtraceProcessParser(); + PbreaderProcessParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); + ~PbreaderProcessParser(); void Parse(ProtoReader::BytesView tracePacket, uint64_t ts); void Finish(); struct DiskioInfo { diff --git a/trace_streamer/src/parser/print_event_parser.cpp b/trace_streamer/src/parser/print_event_parser.cpp index 62c092fbbf088203ad1201904e0c0d514aca4006..15c3e6e590a11cf87fbf6ac726fed27fdd246c72 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, @@ -26,6 +26,7 @@ const uint8_t MAX_POINT_LENGTH = 2; PrintEventParser::PrintEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filter) : EventParserBase(dataCache, filter) { + rsOnDoCompositionEvent_ = traceDataCache_->GetDataIndex(rsOnDoCompositionStr_); eventToFrameFunctionMap_ = { {recvievVsync_, bind(&PrintEventParser::ReciveVsync, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)}, @@ -125,7 +126,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 +138,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); @@ -274,6 +275,9 @@ bool PrintEventParser::HandleFrameSliceBeginEvent(DataIndex eventName, if (it != eventToFrameFunctionMap_.end()) { it->second(callStackRow, args, line); return true; + } else if (StartWith(traceDataCache_->GetDataFromDict(eventName), rsOnDoCompositionStr_)) { + RSReciveOnDoComposition(callStackRow, args, line); + return true; } return false; } @@ -445,11 +449,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..9326c39acb5975b85fcda5f5277ffe08b28b7a02 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, @@ -77,7 +77,8 @@ private: std::map eventToFrameFunctionMap_ = {}; TraceStreamerConfig config_{}; const DataIndex recvievVsync_ = traceDataCache_->GetDataIndex("H:ReceiveVsync"); - const DataIndex rsOnDoCompositionEvent_ = traceDataCache_->GetDataIndex("H:RSMainThread::DoComposition"); + const std::string rsOnDoCompositionStr_ = "H:RSMainThread::DoComposition"; + DataIndex rsOnDoCompositionEvent_ = INVALID_DATAINDEX; const std::string onFrameQueeuStartEvent_ = "H:M: Frame queued"; const std::string onAnimationProcEvent_ = "render_service"; const DataIndex marshRwTransactionData_ = traceDataCache_->GetDataIndex("H:MarshRSTransactionData"); diff --git a/trace_streamer/src/parser/ptreader_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..95971ba38e1186bb713ab6712be6c15788d627e8 --- /dev/null +++ b/trace_streamer/src/parser/ptreader_parser/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../build/ts.gni") + +ohos_source_set("ptreader_parser_src") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "ptreader_parser.cpp" ] + public_configs = [ "../:parser_base_cfg" ] + public_deps = [] + if (enable_hilog) { + public_deps += [ "hilog_parser:ptreader_hilog_parser" ] + } + if (enable_hisysevent) { + public_deps += [ "hisysevent_parser:ptreader_hisysevent_parser" ] + } + if (enable_bytrace) { + public_deps += [ "bytrace_parser:ptreader_bytrace_parser" ] + } +} diff --git a/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bd432943d6c2f5ae5c11ca7c6cbd9199652074ac --- /dev/null +++ b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("ptreader_bytrace_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "bytrace_event_parser.cpp" ] + include_dirs = [ "." ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader" ] + public_configs = [ "../../:parser_base_cfg" ] +} diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp b/trace_streamer/src/parser/ptreader_parser/bytrace_parser/bytrace_event_parser.cpp similarity index 99% rename from trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.cpp rename to trace_streamer/src/parser/ptreader_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/ptreader_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/ptreader_parser/bytrace_parser/bytrace_event_parser.h similarity index 97% rename from trace_streamer/src/parser/bytrace_parser/bytrace_event_parser.h rename to trace_streamer/src/parser/ptreader_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/ptreader_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/ptreader_parser/hilog_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/hilog_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..514f341db86625e2e4d6a8d859f05d05f221ce9f --- /dev/null +++ b/trace_streamer/src/parser/ptreader_parser/hilog_parser/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("ptreader_hilog_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "ptreader_hilog_parser.cpp" ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader" ] + public_configs = [ + "../../:hilog_parser_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp similarity index 88% rename from trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp rename to trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.cpp index f491f03eb1936fbada08fcf3f9b87f4e559db77b..39b61ca6c7ed13b4bc1501b4ba964bb0b1f489c4 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_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, @@ -13,20 +13,20 @@ * limitations under the License. */ -#include "bytrace_hilog_parser.h" +#include "ptreader_hilog_parser.h" #include "process_filter.h" #include "stat_filter.h" namespace SysTuning { namespace TraceStreamer { -BytraceHilogParser::BytraceHilogParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) +PtreaderHilogParser::PtreaderHilogParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) : EventParserBase(dataCache, filters) { } -BytraceHilogParser::~BytraceHilogParser() = default; +PtreaderHilogParser::~PtreaderHilogParser() = default; -bool BytraceHilogParser::HilogTimeStrToTimestamp(std::string& timeStr, uint64_t& timeStamp) const +bool PtreaderHilogParser::HilogTimeStrToTimestamp(std::string& timeStr, uint64_t& timeStamp) const { uint64_t sec; uint64_t nsec; @@ -76,7 +76,7 @@ bool BytraceHilogParser::HilogTimeStrToTimestamp(std::string& timeStr, uint64_t& return true; } -void BytraceHilogParser::ParseHilogDataItem(const std::string& buffer, const uint64_t lineSeq, bool& haveSplitSeg) +void PtreaderHilogParser::ParseHilogDataItem(const std::string& buffer, const uint64_t lineSeq, bool& haveSplitSeg) { std::smatch matcheLine; if (!std::regex_search(buffer, matcheLine, hilogMatcher_)) { @@ -123,13 +123,13 @@ void BytraceHilogParser::ParseHilogDataItem(const std::string& buffer, const uin return; } -void BytraceHilogParser::FilterHilogData(std::unique_ptr bufLine) +void PtreaderHilogParser::FilterHilogData(std::unique_ptr bufLine) { hilogList_.push_back(std::move(bufLine)); return; } -void BytraceHilogParser::FilterAllHilogData() +void PtreaderHilogParser::FilterAllHilogData() { auto cmp = [](const std::unique_ptr& a, const std::unique_ptr& b) { return a->timeStamp < b->timeStamp; @@ -143,7 +143,7 @@ void BytraceHilogParser::FilterAllHilogData() hilogList_.clear(); } -void BytraceHilogParser::BeginFilterHilogData(HilogLine* hilogData) +void PtreaderHilogParser::BeginFilterHilogData(HilogLine* hilogData) { streamFilters_->statFilter_->IncreaseStat(TRACE_HILOG, STAT_EVENT_RECEIVED); traceDataCache_->UpdateTraceTime(hilogData->timeStamp); diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.h similarity index 82% rename from trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h rename to trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_hilog_parser.h index 09bdf93404b1540c1043d44a0b16b2f07fd6d187..1ee15cf92ef1b2d6502c78c2434e94af1e2ec763 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hilog_parser.h +++ b/trace_streamer/src/parser/ptreader_parser/hilog_parser/ptreader_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, @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef BYTRACE_HILOG_PARSER_H -#define BYTRACE_HILOG_PARSER_H +#ifndef PTREADER_HILOG_PARSER_H +#define PTREADER_HILOG_PARSER_H #include "common_types.h" #include "event_parser_base.h" @@ -29,10 +29,10 @@ constexpr uint64_t US_TO_NS = 1e3; constexpr uint32_t TM_YEAR_FROM = 1900; constexpr uint32_t MS_FORMAT_LEN = 3; constexpr uint32_t US_FORMAT_LEN = 6; -class BytraceHilogParser : public EventParserBase { +class PtreaderHilogParser : public EventParserBase { public: - BytraceHilogParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); - ~BytraceHilogParser(); + PtreaderHilogParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); + ~PtreaderHilogParser(); void ParseHilogDataItem(const std::string& buffer, const uint64_t lineSeq, bool& haveSplitSeg); void FilterAllHilogData(); @@ -56,4 +56,4 @@ private: } // namespace TraceStreamer } // namespace SysTuning -#endif // BYTRACE_HILOG_PARSER_H +#endif // PTREADER_HILOG_PARSER_H diff --git a/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9ad0f3f4aa6e130b676f2d67027645d98e1750a2 --- /dev/null +++ b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this 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") +import("../../../../build/ts.gni") + +ohos_static_library("ptreader_hisysevent_parser") { + subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" + part_name = "${OHOS_PROFILER_PART_NAME}" + sources = [ "ptreader_hisysevent_parser.cpp" ] + public_deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/hilog_data:hilog_data_reader" ] + public_configs = [ + "../../:hisysevent_parser_cfg", + "../../:parser_base_cfg", + ] +} diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.cpp similarity index 67% rename from trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp rename to trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.cpp index 944807f896fba1892db3334d84cc9dc71552f8e5..9e6b2e2d663fab65b516ee9b2f24458b8bab8f3c 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_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, @@ -13,19 +13,19 @@ * limitations under the License. */ -#include "bytrace_hisysevent_parser.h" +#include "ptreader_hisysevent_parser.h" namespace SysTuning { namespace TraceStreamer { -BytraceHiSysEventParser::BytraceHiSysEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) +PtreaderHiSysEventParser::PtreaderHiSysEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters) : EventParserBase(dataCache, filters) { } -BytraceHiSysEventParser::~BytraceHiSysEventParser() = default; -void BytraceHiSysEventParser::ParseHiSysEventDataItem(const std::string& buffer, - const uint64_t lineSeq, - bool& haveSplitSeg) +PtreaderHiSysEventParser::~PtreaderHiSysEventParser() = default; +void PtreaderHiSysEventParser::ParseHiSysEventDataItem(const std::string& buffer, + const uint64_t lineSeq, + bool& haveSplitSeg) { json jMessage; if (!jMessage.accept(buffer)) { @@ -35,7 +35,7 @@ void BytraceHiSysEventParser::ParseHiSysEventDataItem(const std::string& buffer, streamFilters_->hiSysEventMeasureFilter_->FilterAllHiSysEvent(jMessage, lineSeq, haveSplitSeg); return; } -void BytraceHiSysEventParser::Finish() +void PtreaderHiSysEventParser::Finish() { auto startTime = streamFilters_->hiSysEventMeasureFilter_->GetPluginStartTime(); if (startTime != INVALID_UINT64) { diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h similarity index 66% rename from trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h rename to trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_hisysevent_parser.h index 1018179364ffca9e86f73d5ddd50cd1bc3136c01..5cdda88ab5c0b7d99c06a4303d828b48f9546765 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_hisysevent_parser.h +++ b/trace_streamer/src/parser/ptreader_parser/hisysevent_parser/ptreader_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, @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef BYTRACE_HI_SYS_EVENT_PARSER_H -#define BYTRACE_HI_SYS_EVENT_PARSER_H +#ifndef PTREADER_HI_SYS_EVENT_PARSER_H +#define PTREADER_HI_SYS_EVENT_PARSER_H #include "common_types.h" #include "string_help.h" @@ -22,18 +22,18 @@ #include "parser_base.h" #include "event_parser_base.h" #include "trace_data_cache.h" -#include "hi_sysevent_measure_filter.h" +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" namespace SysTuning { namespace TraceStreamer { -class BytraceHiSysEventParser : public EventParserBase { +class PtreaderHiSysEventParser : public EventParserBase { public: - BytraceHiSysEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); - ~BytraceHiSysEventParser(); + PtreaderHiSysEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters); + ~PtreaderHiSysEventParser(); void ParseHiSysEventDataItem(const std::string& buffer, const uint64_t lineSeq, bool& haveSplitSeg); void Finish(); }; } // namespace TraceStreamer } // namespace SysTuning -#endif // BYTRACE_HI_SYS_EVENT_PARSER_H +#endif // PTREADER_HI_SYS_EVENT_PARSER_H diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp similarity index 80% rename from trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp rename to trace_streamer/src/parser/ptreader_parser/ptreader_parser.cpp index d23bf8f572ec489c5fd47f945843563cb011f1dd..b1adc4d0c7f1bba0d88b6e733c37430463e1f640 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.cpp +++ b/trace_streamer/src/parser/ptreader_parser/ptreader_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, @@ -13,26 +13,34 @@ * limitations under the License. */ -#include "bytrace_parser.h" +#include "ptreader_parser.h" #include #include #include #include "app_start_filter.h" #include "binder_filter.h" #include "cpu_filter.h" -#include "hi_sysevent_measure_filter.h" +#ifdef ENABLE_HISYSEVENT +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#endif #include "parting_string.h" #include "stat_filter.h" #include "system_event_measure_filter.h" namespace SysTuning { namespace TraceStreamer { -BytraceParser::BytraceParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters, TraceFileType fileType) +PtreaderParser::PtreaderParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters, TraceFileType fileType) : ParserBase(filters), - fileType_(fileType), traceDataCache_(dataCache), - eventParser_(std::make_unique(dataCache, filters)), - hilogParser_(std::make_unique(dataCache, filters)), - hiSysEventParser_(std::make_unique(dataCache, filters)) +#ifdef ENABLE_BYTRACE + bytraceEventParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HILOG + hilogParser_(std::make_unique(dataCache, filters)), +#endif +#ifdef ENABLE_HISYSEVENT + hiSysEventParser_(std::make_unique(dataCache, filters)), +#endif + fileType_(fileType) { if (traceDataCache_->supportThread_) { dataSegArray_ = std::make_unique(maxSegArraySize); @@ -41,9 +49,9 @@ BytraceParser::BytraceParser(TraceDataCache* dataCache, const TraceStreamerFilte } } -BytraceParser::~BytraceParser() = default; +PtreaderParser::~PtreaderParser() = default; -void BytraceParser::WaitForParserEnd() +void PtreaderParser::WaitForParserEnd() { if (parseThreadStarted_ || filterThreadStarted_) { toExit_ = true; @@ -51,28 +59,34 @@ void BytraceParser::WaitForParserEnd() usleep(sleepDur_ * sleepDur_); } } - eventParser_->FilterAllEvents(); - eventParser_->Clear(); +#ifdef ENABLE_BYTRACE + bytraceEventParser_->FilterAllEvents(); + bytraceEventParser_->Clear(); +#endif +#ifdef ENABLE_HILOG hilogParser_->FilterAllHilogData(); +#endif +#ifdef ENABLE_HISYSEVENT hiSysEventParser_->Finish(); +#endif traceDataCache_->MixTraceTime(traceDataCache_->traceStartTime_, traceDataCache_->traceEndTime_); dataSegArray_.reset(); - ClearByTraceData(); + ClearPtreaderSplitData(); } -bool BytraceParser::UpdateSplitPos() +bool PtreaderParser::UpdateSplitPos() { - maxSplitPos_ = mTraceDataBytrace_.size() - 1; + maxSplitPos_ = mPtreaderSplitData_.size() - 1; TS_CHECK_TRUE_RET(minSplitPos_ == INVALID_INT32, true); - minSplitPos_ = mTraceDataBytrace_.size() - 1; + minSplitPos_ = mPtreaderSplitData_.size() - 1; TS_LOGI("minSplitPos_=%d", minSplitPos_); return true; } template -int32_t BytraceParser::WhileDetermine(Iterator& packagesLine, - Iterator& packagesBegin, - bool& isParsingOver_, - bool isFinish) +int32_t PtreaderParser::WhileDetermine(Iterator& packagesLine, + Iterator& packagesBegin, + bool& isParsingOver_, + bool isFinish) { // While loop break and continue if (packagesLine == packagesBuffer_.end()) { @@ -91,18 +105,21 @@ int32_t BytraceParser::WhileDetermine(Iterator& packagesLine, return DETERMINE_RETURN; } -int32_t BytraceParser::GotoDetermine(std::string& bufferLine, bool& haveSplitSeg) +int32_t PtreaderParser::GotoDetermine(std::string& bufferLine, bool& haveSplitSeg) { if (traceDataCache_->isSplitFile_) { - mTraceDataBytrace_.emplace_back(curFileOffset_, curDataSize_); + mPtreaderSplitData_.emplace_back(curFileOffset_, curDataSize_); } if (isFirstLine_) { isFirstLine_ = false; +#ifdef ENABLE_BYTRACE if (IsHtmlTrace(bufferLine)) { isHtmlTrace_ = true; return 1; } +#endif } +#ifdef ENABLE_BYTRACE if (isHtmlTrace_) { if (!isHtmlTraceContent_) { if (IsHtmlTraceBegin(bufferLine)) { @@ -121,27 +138,36 @@ int32_t BytraceParser::GotoDetermine(std::string& bufferLine, bool& haveSplitSeg } if (IsTraceComment(bufferLine)) { traceCommentLines_++; - mTraceDataBytrace_.clear(); + mPtreaderSplitData_.clear(); return 1; } +#endif if (bufferLine.empty()) { parsedTraceInvalidLines_++; return 1; } - if (fileType_ == TRACE_FILETYPE_HILOG) { - hilogParser_->ParseHilogDataItem(bufferLine, seq_, haveSplitSeg); - } else if (fileType_ == TRACE_FILETYPE_HI_SYSEVENT) { + if (fileType_ == TRACE_FILETYPE_HI_SYSEVENT) { +#ifdef ENABLE_HISYSEVENT hiSysEventParser_->ParseHiSysEventDataItem(bufferLine, seq_, haveSplitSeg); - } else if (isBytrace_) { +#endif + } +#ifdef ENABLE_BYTRACE + else if (isBytrace_) { if (!traceBegan_) { traceBegan_ = true; } ParseTraceDataItem(bufferLine); } +#endif +#ifdef ENABLE_HILOG + else if (fileType_ == TRACE_FILETYPE_HILOG) { + hilogParser_->ParseHilogDataItem(bufferLine, seq_, haveSplitSeg); + } +#endif return DETERMINE_RETURN; } -void BytraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish) +void PtreaderParser::ParseTraceDataSegment(std::unique_ptr bufferStr, size_t size, bool isFinish) { if (isParsingOver_) { return; @@ -188,8 +214,9 @@ void BytraceParser::ParseTraceDataSegment(std::unique_ptr bufferStr, return; } -void BytraceParser::ParseTraceDataItem(const std::string& buffer) +void PtreaderParser::ParseTraceDataItem(const std::string& buffer) { +#ifdef ENABLE_BYTRACE if (!traceDataCache_->supportThread_ || traceDataCache_->isSplitFile_) { dataSegArray_[rawDataHead_].seg = std::move(buffer); ParserData(dataSegArray_[rawDataHead_]); @@ -213,7 +240,7 @@ void BytraceParser::ParseTraceDataItem(const std::string& buffer) int32_t tmp = traceDataCache_->parserThreadNum_; while (tmp--) { parserThreadCount_++; - std::thread MatchLineThread(&BytraceParser::ParseThread, this); + std::thread MatchLineThread(&PtreaderParser::ParseThread, this); MatchLineThread.detach(); TS_LOGI("parser Thread:%d/%d start working ...\n", traceDataCache_->parserThreadNum_ - tmp, traceDataCache_->parserThreadNum_); @@ -221,12 +248,13 @@ void BytraceParser::ParseTraceDataItem(const std::string& buffer) } if (!filterThreadStarted_) { filterThreadStarted_ = true; - std::thread ParserThread(&BytraceParser::FilterThread, this); + std::thread ParserThread(&PtreaderParser::FilterThread, this); ParserThread.detach(); } - return; +#endif } -int32_t BytraceParser::GetNextSegment() +#ifdef ENABLE_BYTRACE +int32_t PtreaderParser::GetNextSegment() { int32_t head; std::lock_guard muxLockGuard(dataSegMux_); @@ -251,7 +279,7 @@ int32_t BytraceParser::GetNextSegment() return head; } -void BytraceParser::GetDataSegAttr(DataSegment& seg, const std::smatch& matcheLine) const +void PtreaderParser::GetDataSegAttr(DataSegment& seg, const std::smatch& matcheLine) const { const uint64_t S_TO_NS = 1e9; size_t index = 0; @@ -292,7 +320,7 @@ void BytraceParser::GetDataSegAttr(DataSegment& seg, const std::smatch& matcheLi seg.bufLine.eventName = eventName; seg.status = TS_PARSE_STATUS_PARSED; } -void BytraceParser::ParseThread() +void PtreaderParser::ParseThread() { while (true) { int32_t head = GetNextSegment(); @@ -310,7 +338,7 @@ void BytraceParser::ParseThread() } } -void BytraceParser::ParserData(DataSegment& seg) +void PtreaderParser::ParserData(DataSegment& seg) { std::smatch matcheLine; if (!std::regex_search(seg.seg, matcheLine, bytraceMatcher_)) { @@ -336,7 +364,7 @@ void BytraceParser::ParserData(DataSegment& seg) return; } } -void BytraceParser::FilterThread() +void PtreaderParser::FilterThread() { while (true) { DataSegment& seg = dataSegArray_[filterHead_]; @@ -345,11 +373,11 @@ void BytraceParser::FilterThread() } } } -bool BytraceParser::FilterData(DataSegment& seg) +bool PtreaderParser::FilterData(DataSegment& seg) { if (!traceDataCache_->supportThread_ || traceDataCache_->isSplitFile_) { if (seg.status.load() != TS_PARSE_STATUS_INVALID) { - eventParser_->ParseDataItem(seg.bufLine); + bytraceEventParser_->ParseDataItem(seg.bufLine); seg.status = TS_PARSE_STATUS_INIT; return true; } @@ -372,13 +400,13 @@ bool BytraceParser::FilterData(DataSegment& seg) usleep(sleepDur_); return true; } - eventParser_->ParseDataItem(seg.bufLine); + bytraceEventParser_->ParseDataItem(seg.bufLine); filterHead_ = (filterHead_ + 1) % maxSegArraySize; seg.status = TS_PARSE_STATUS_INIT; return true; } // Remove space at the beginning and end of the string -std::string BytraceParser::StrTrim(const std::string& input) const +std::string PtreaderParser::StrTrim(const std::string& input) const { std::string str = input; if (str.empty()) { @@ -388,5 +416,6 @@ std::string BytraceParser::StrTrim(const std::string& input) const str.erase(str.find_last_not_of(" ") + 1); return str; } +#endif } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h b/trace_streamer/src/parser/ptreader_parser/ptreader_parser.h similarity index 79% rename from trace_streamer/src/parser/bytrace_parser/bytrace_parser.h rename to trace_streamer/src/parser/ptreader_parser/ptreader_parser.h index 0aabfdf0faeccca2c2cbd77a7b62fc253e5665ba..502bd8a21b6614eb1d5517adae322375071fc85a 100644 --- a/trace_streamer/src/parser/bytrace_parser/bytrace_parser.h +++ b/trace_streamer/src/parser/ptreader_parser/ptreader_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, @@ -13,17 +13,24 @@ * limitations under the License. */ -#ifndef BYTRACE_PARSER_H -#define BYTRACE_PARSER_H +#ifndef PTREADER_PARSER_H +#define PTREADER_PARSER_H #include #include #include #include -#include "bytrace_event_parser.h" -#include "bytrace_hilog_parser.h" -#include "bytrace_hisysevent_parser.h" +#ifdef ENABLE_BYTRACE +#include "bytrace_parser/bytrace_event_parser.h" +#endif +#include "common_types.h" +#ifdef ENABLE_HILOG +#include "hilog_parser/ptreader_hilog_parser.h" +#endif +#ifdef ENABLE_HISYSEVENT +#include "hisysevent_parser/ptreader_hisysevent_parser.h" +#endif #include "log.h" #include "parser_base.h" #include "string_to_numerical.h" @@ -34,12 +41,12 @@ namespace SysTuning { namespace TraceStreamer { constexpr int32_t DETERMINE_CONTINUE = 2; constexpr int32_t DETERMINE_RETURN = 3; -class BytraceParser : public ParserBase { +class PtreaderParser : public ParserBase { public: - BytraceParser(TraceDataCache* dataCache, - const TraceStreamerFilters* filters, - TraceFileType fileType = TRACE_FILETYPE_BY_TRACE); - ~BytraceParser(); + PtreaderParser(TraceDataCache* dataCache, + const TraceStreamerFilters* filters, + TraceFileType fileType = TRACE_FILETYPE_BY_TRACE); + ~PtreaderParser(); template int32_t WhileDetermine(Iterator& determine, Iterator& packagesBegin, bool& isParsingOver_, bool isFinish); @@ -58,10 +65,12 @@ public: { return traceCommentLines_; } +#ifdef ENABLE_BYTRACE void EnableBytrace(bool enable) { isBytrace_ = enable; } +#endif int32_t MinSplitPos() { return minSplitPos_; @@ -70,31 +79,28 @@ public: { return maxSplitPos_; } - const auto& GetTraceDataBytrace() + const auto& GetPtreaderSplitData() { - return mTraceDataBytrace_; + return mPtreaderSplitData_; } - void ClearByTraceData() + void ClearPtreaderSplitData() { - mTraceDataBytrace_.clear(); + mPtreaderSplitData_.clear(); curFileOffset_ = 0; curDataSize_ = 0; minSplitPos_ = INVALID_INT32; maxSplitPos_ = INVALID_INT32; isParsingOver_ = false; } - auto GetHiLogParser() - { - return hilogParser_.get(); - } void WaitForParserEnd(); private: + bool UpdateSplitPos(); + void ParseTraceDataItem(const std::string& buffer) override; +#ifdef ENABLE_BYTRACE int32_t GetNextSegment(); void GetDataSegAttr(DataSegment& seg, const std::smatch& matcheLine) const; - - void FilterThread(); inline static bool IsNotSpace(char c) { return !std::isspace(c); @@ -114,23 +120,29 @@ private: { return buffer.find(R"()"; size_t parsedTraceValidLines_ = 0; size_t parsedTraceInvalidLines_ = 0; @@ -148,7 +160,6 @@ private: int32_t rawDataHead_ = 0; int32_t filterHead_ = 0; const int32_t sleepDur_ = 100; - bool isBytrace_ = true; bool traceBegan_ = false; bool isFirstLine_ = true; bool isHtmlTrace_ = false; @@ -158,8 +169,8 @@ private: uint32_t curDataSize_ = 0; int32_t minSplitPos_ = INVALID_INT32; int32_t maxSplitPos_ = INVALID_INT32; - std::deque> mTraceDataBytrace_ = {}; + std::deque> mPtreaderSplitData_ = {}; }; } // namespace TraceStreamer } // namespace SysTuning -#endif // _BYTRACE_PARSER_H_ +#endif // _ptreader_parser_H_ diff --git a/trace_streamer/src/parser/rawtrace_parser/BUILD.gn b/trace_streamer/src/parser/rawtrace_parser/BUILD.gn index 89974950dd7618619e77d199792638138ef235aa..65d4389b100566703f1c91c5c9c796f6235df384 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 @@ -43,9 +43,23 @@ config("rawtrace_parser_comm") { "${SRC}/trace_data/trace_stdtype/htrace", "${SRC}/trace_data/trace_stdtype/measure", ] + if (enable_ts_utest && !use_wasm) { + cflags = [ + "-fprofile-arcs", + "-ftest-coverage", + ] + ldflags = [ + "-fprofile-arcs", + "-ftest-coverage", + "--coverage", + ] + if (is_test) { + cflags += [ "-D IS_UT" ] + } + } } -ohos_source_set("rawtrace_parser_src") { +ohos_static_library("rawtrace_parser") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" sources = [ @@ -66,29 +80,11 @@ ohos_source_set("rawtrace_parser_src") { if (is_mingw) { cflags = [ "-includeMingW64Fix.h" ] } - if (enable_ts_utest && !use_wasm) { - cflags = [ - "-fprofile-arcs", - "-ftest-coverage", - ] - ldflags = [ - "-fprofile-arcs", - "-ftest-coverage", - "--coverage", - ] - if (is_test) { - cflags += [ "-D IS_UT" ] - } - } + public_deps = [] deps = [ "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/services:ts_all_type_cpp_standard", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/ftrace_data/${device_kernel_version}:ts_ftrace_data_cpp", - ] -} -group("rawtrace_parser") { - deps = [ - ":rawtrace_parser_src", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", ] 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..37b000358323ab02fd91a950a030eeeb6f180464 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,27 +50,35 @@ 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]); cpuRunningStatMinTime = schedSlice.TimeStampData()[i]; TS_LOGW("curCpuId=%u, cpuRunningStatMinTime=%" PRIu64 "", schedSlice.CpusData()[i], cpuRunningStatMinTime); } - traceDataCache_->UpdateTraceMinTime(cpuRunningStatMinTime); + if (cpuRunningStatMinTime != INVALID_TIME) { + traceDataCache_->UpdateTraceMinTime(cpuRunningStatMinTime); + } } bool RawTraceParser::InitRawTraceFileHeader(std::deque::iterator& packagesCurIter) { TS_CHECK_TRUE(packagesBuffer_.size() >= sizeof(RawTraceFileHeader), false, "buffer size less than rawtrace file header"); RawTraceFileHeader header; - auto ret = memcpy_s(&header, sizeof(RawTraceFileHeader), &(*packagesBuffer_.begin()), sizeof(RawTraceFileHeader)); - TS_CHECK_TRUE(ret == EOK, false, "Memcpy FAILED!Error code is %d, data size is %zu.", ret, packagesBuffer_.size()); + std::copy(packagesBuffer_.begin(), packagesBuffer_.begin() + sizeof(RawTraceFileHeader), + reinterpret_cast(&header)); 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 +86,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 +103,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 +210,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 +225,35 @@ 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_) { + 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 +275,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..9fd679aca9181fa42c0d6b759e9f2fa51f269884 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 @@ -46,4 +46,7 @@ message NativeHookConfig { uint32 sample_interval = 24; bool response_library_mode = 25; repeated int32 expand_pids = 26; + bool js_stack_report = 27; + uint32 max_js_stack_depth = 28; + string filter_napi_name = 29; } 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..2acc7cfb708693e77547746cbcec04c24979c0c9 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 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..b57c1f233fc4ed4e833d14c0c4c7faa9256a5244 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 @@ -24,23 +24,17 @@ proto_out_dir = "$root_gen_dir/cpp/" + rebase_path(".", "//") proto_rel_out_dir = rebase_path(proto_out_dir, root_build_dir) stream_data_codegen = [] -stream_data_codegen_standard = [] -stream_data_codegen_reader = [] stream_data_codegen_all = [] +stream_data_codegen_reader = [] foreach(proto, stream_data_sources) { name = get_path_info(proto, "name") stream_data_codegen += [ "$proto_out_dir/$name.pb.h", "$proto_out_dir/$name.pb.cc", ] - stream_data_codegen_standard += [ - "$proto_out_dir/${name}_standard.pb.h", - "$proto_out_dir/${name}_standard.pb.cc", - ] stream_data_codegen_reader += [ "$proto_out_dir/$name.pbreader.h" ] } stream_data_codegen_all += stream_data_codegen -stream_data_codegen_all += stream_data_codegen_standard stream_data_codegen_all += stream_data_codegen_reader config("stream_include_config") { @@ -62,7 +56,12 @@ action("stream_data_cpp_gen") { rebase_path(".", root_build_dir), ] args += rebase_path(sources, root_build_dir) - deps = [] + if (!use_wasm && !is_test && !is_fuzz) { + deps = [ + "${OHOS_PROFILER_3RDPARTY_PROTOBUF_DIR}:protoc(${host_toolchain})", + "${SRC}/proto_reader/protoc_plugin:protoreader_plugin(${host_toolchain})", + ] + } } ohos_source_set("stream_data_cpp") { @@ -78,7 +77,7 @@ ohos_source_set("stream_data_cpp") { sources = stream_data_codegen } -ohos_source_set("stream_data_encoder") { +ohos_source_set("stream_data_reader") { subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}" part_name = "${OHOS_PROFILER_PART_NAME}" deps = [ ":stream_data_cpp_gen" ] 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..f302af013f69e8f71dde2be9aec23a450117c381 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, @@ -22,11 +22,12 @@ #include #endif #include "common_types.h" -#include "bytrace_hilog_parser.h" -#include "bytrace_parser.h" -#include "htrace_parser.h" +#include "hilog_parser/ptreader_hilog_parser.h" +#include "ptreader_parser.h" +#include "pbreader_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 @@ -262,7 +266,7 @@ bool RpcServer::SendBytraceSplitFileData(SplitFileCallBack splitFileCallBack, in int32_t lastPos = ts_->GetBytraceData()->MaxSplitPos(); TS_CHECK_TRUE(firstPos != INVALID_INT32 && lastPos != INVALID_INT32 && lastPos >= firstPos, false, "firstPos(%d) or lastPos(%d) is INVALID_INT32!", firstPos, lastPos); - const auto& mTraceDataBytrace = ts_->GetBytraceData()->GetTraceDataBytrace(); + const auto& mTraceDataBytrace = ts_->GetBytraceData()->GetPtreaderSplitData(); // for 10% data int32_t tenPercentDataNum = 0.1 * (lastPos - firstPos); firstPos -= tenPercentDataNum; @@ -279,7 +283,7 @@ bool RpcServer::SendBytraceSplitFileData(SplitFileCallBack splitFileCallBack, in result += SIZE + std::to_string(mTraceDataBytrace[index].second); result += "},"; } - if (result != VALUE && !ts_->GetBytraceData()->GetTraceDataBytrace().empty()) { + if (result != VALUE && !ts_->GetBytraceData()->GetPtreaderSplitData().empty()) { result.pop_back(); result += "]}\r\n"; splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, isFinish); @@ -290,6 +294,36 @@ bool RpcServer::SendBytraceSplitFileData(SplitFileCallBack splitFileCallBack, in return true; } +#ifdef ENABLE_RAWTRACE +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; +} +#endif bool RpcServer::ParseSplitFileData(const uint8_t* data, size_t len, int32_t isFinish, @@ -307,19 +341,32 @@ bool RpcServer::ParseSplitFileData(const uint8_t* data, ts_->GetFileType() == TRACE_FILETYPE_HI_SYSEVENT)) { SendBytraceSplitFileData(splitFileCallBack, 0); splitFileCallBack(EMPTY_VALUE, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 1); - ts_->GetBytraceData()->ClearByTraceData(); + ts_->GetBytraceData()->ClearPtreaderSplitData(); + ts_->GetTraceDataCache()->isSplitFile_ = false; + return true; + } +#ifdef ENABLE_RAWTRACE + 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; } +#endif if (ts_->GetFileType() == TRACE_FILETYPE_H_TRACE) { ProcHtraceSplitResult(splitFileCallBack); } +#ifdef ENABLE_HIPERF if (ts_->GetFileType() == TRACE_FILETYPE_PERF) { ProcPerfSplitResult(splitFileCallBack, true); } +#endif splitFileCallBack(EMPTY_VALUE, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 1); - ts_->GetHtraceData()->ClearTraceDataHtrace(); + ts_->GetHtraceData()->ClearPbreaderSplitData(); +#ifdef ENABLE_ARKTS ts_->GetHtraceData()->GetJsMemoryData()->ClearArkTsSplitFileData(); +#endif ts_->GetTraceDataCache()->isSplitFile_ = false; return true; } @@ -327,8 +374,10 @@ void RpcServer::ProcHtraceSplitResult(SplitFileCallBack splitFileCallBack) { uint64_t dataSize = 0; std::string result = VALUE; +#ifdef ENABLE_NATIVE_HOOK ts_->GetHtraceData()->ClearNativehookData(); - for (const auto& itemHtrace : ts_->GetHtraceData()->GetTraceDataHtrace()) { +#endif + for (const auto& itemHtrace : ts_->GetHtraceData()->GetPbreaderSplitData()) { dataSize += itemHtrace.second; result += OFFSET + std::to_string(itemHtrace.first); result += SIZE + std::to_string(itemHtrace.second); @@ -336,32 +385,45 @@ void RpcServer::ProcHtraceSplitResult(SplitFileCallBack splitFileCallBack) } auto dataSourceType = ts_->GetHtraceData()->GetDataSourceType(); auto profilerHeader = ts_->GetHtraceData()->GetProfilerHeader(); +#ifdef ENABLE_ARKTS if (dataSourceType == DATA_SOURCE_TYPE_JSMEMORY) { dataSize += ts_->GetHtraceData()->GetArkTsConfigData().size() + ts_->GetHtraceData()->GetJsMemoryData()->GetArkTsSize(); } +#endif +#ifdef ENABLE_NATIVE_HOOK for (auto& commProto : ts_->GetTraceDataCache()->HookCommProtos()) { dataSize += (sizeof(uint32_t) + commProto->size()); } +#endif // Send Header profilerHeader.data.length = PACKET_HEADER_LENGTH + dataSize; std::string buffer(reinterpret_cast(&profilerHeader), sizeof(profilerHeader)); splitFileCallBack(buffer, (int32_t)SplitDataDataType::SPLIT_FILE_DATA, 0); // Send Datas +#ifdef ENABLE_NATIVE_HOOK ProcHookCommSplitResult(splitFileCallBack); - if (result != VALUE && !ts_->GetHtraceData()->GetTraceDataHtrace().empty()) { +#endif + if (result != VALUE && !ts_->GetHtraceData()->GetPbreaderSplitData().empty()) { result.pop_back(); result += "]}\r\n"; splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 0); } +#ifdef ENABLE_ARKTS if (dataSourceType == DATA_SOURCE_TYPE_JSMEMORY) { splitFileCallBack(ts_->GetHtraceData()->GetArkTsConfigData() + ts_->GetHtraceData()->GetJsMemoryData()->GetArkTsSplitFileData(), (int32_t)SplitDataDataType::SPLIT_FILE_DATA, 0); } +#endif +#ifdef ENABLE_HIPERF ProcPerfSplitResult(splitFileCallBack, true); +#endif +#ifdef ENABLE_EBPF ProcEbpfSplitResult(splitFileCallBack, true); +#endif } +#ifdef ENABLE_NATIVE_HOOK void RpcServer::ProcHookCommSplitResult(SplitFileCallBack splitFileCallBack) { std::string lenBuffer(sizeof(uint32_t), 0); @@ -373,6 +435,8 @@ void RpcServer::ProcHookCommSplitResult(SplitFileCallBack splitFileCallBack) } ts_->GetTraceDataCache()->ClearHookCommProtos(); } +#endif +#ifdef ENABLE_EBPF void RpcServer::ProcEbpfSplitResult(SplitFileCallBack splitFileCallBack, bool isLast) { auto ebpfSplitResult = ts_->GetHtraceData()->GetEbpfDataParser()->GetEbpfSplitResult(); @@ -399,6 +463,8 @@ void RpcServer::ProcEbpfSplitResult(SplitFileCallBack splitFileCallBack, bool is splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 0); } } +#endif +#ifdef ENABLE_HIPERF void RpcServer::ProcPerfSplitResult(SplitFileCallBack splitFileCallBack, bool isLast) { auto perfSplitResult = ts_->GetHtraceData()->GetPerfSplitResult(); @@ -426,6 +492,7 @@ void RpcServer::ProcPerfSplitResult(SplitFileCallBack splitFileCallBack, bool is splitFileCallBack(result, (int32_t)SplitDataDataType::SPLIT_FILE_JSON, 0); } } +#endif int32_t RpcServer::UpdateTraceTime(const uint8_t* data, int32_t len) { @@ -699,6 +766,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..3ba3ff051356baddcba261358ae98097e94fde8b 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, @@ -55,8 +55,12 @@ public: int32_t WasmExportDatabase(ResultCallBack resultCallBack); bool ParserConfig(std::string parserConfigJson); bool SplitFile(std::string timeSnaps); +#ifdef ENABLE_NATIVE_HOOK void ProcHookCommSplitResult(SplitFileCallBack splitFileCallBack); +#endif +#ifdef ENABLE_EBPF void ProcEbpfSplitResult(SplitFileCallBack splitFileCallBack, bool isLast); +#endif bool GetLongTraceTimeSnap(std::string dataString); bool LongTraceSplitFile(const uint8_t* data, size_t len, @@ -69,6 +73,10 @@ public: return ffrtConvertEnabled_; }; bool DetermineSystrace(const uint8_t* data, size_t len); + +#ifdef ENABLE_RAWTRACE + bool SendRawtraceSplitFileData(SplitFileCallBack splitFileCallBack, int32_t isFinish); +#endif #ifdef IS_WASM bool SaveAndParseFfrtData(const uint8_t* data, size_t len, ResultCallBack resultCallBack, bool isFinish); bool ReadAndParseData(const std::string& filePath); @@ -86,7 +94,9 @@ public: std::map g_thirdPartyConfig; private: +#ifdef ENABLE_HIPERF void ProcPerfSplitResult(SplitFileCallBack splitFileCallBack, bool isLast); +#endif void ProcHtraceSplitResult(SplitFileCallBack splitFileCallBack); bool SendBytraceSplitFileData(SplitFileCallBack splitFileCallBack, int32_t isFinish); 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..4f563ce658283917532138d5ba95e8c37734cb7f 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, @@ -44,7 +44,8 @@ public: dataCache->AppendNewTable(tableName); } std::string CreateTableSql() const; - virtual bool CanFilterId(const char op, size_t& rowCount); + bool CanFilterId(const char op, size_t& rowCount); + bool CanFilterSorted(const char op, size_t& rowCount); class Cursor : public sqlite3_vtab_cursor { public: 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..8cb6f3dbcb67836c2c77295064512b30e7ffff7c 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, @@ -16,6 +16,7 @@ #include "table_base.h" #include +#include #include #include "log.h" @@ -100,7 +101,6 @@ void TableBase::SetModuleCallbacks(sqlite3_module& module, const std::string& ta delete static_cast(vc); return SQLITE_OK; }; - module.xBestIndex = [](sqlite3_vtab* pVTab, sqlite3_index_info* idxInfo) { TS_LOGD("xBestIndex: %s %d", static_cast(pVTab)->name_.c_str(), idxInfo->nConstraint); return static_cast(pVTab)->BestIndex(idxInfo); @@ -181,7 +181,6 @@ int32_t TableBase::BestIndex(sqlite3_index_info* idxInfo) EstimatedIndexInfo estimate = {idxInfo->estimatedRows, idxInfo->estimatedCost, false}; EstimateFilterCost(filterConstraints, estimate); - idxInfo->orderByConsumed = estimate.isOrdered; idxInfo->estimatedCost = estimate.estimatedCost; idxInfo->estimatedRows = estimate.estimatedRows; @@ -247,6 +246,24 @@ bool TableBase::CanFilterId(const char op, size_t& rowCount) return true; } +bool TableBase::CanFilterSorted(const char op, size_t& rowCount) +{ + switch (op) { + case SQLITE_INDEX_CONSTRAINT_EQ: + rowCount = log2(rowCount); + break; + case SQLITE_INDEX_CONSTRAINT_GT: + case SQLITE_INDEX_CONSTRAINT_GE: + case SQLITE_INDEX_CONSTRAINT_LE: + case SQLITE_INDEX_CONSTRAINT_LT: + rowCount = (rowCount >> 1); + break; + default: + return false; + } + return true; +} + TableBase::Cursor::~Cursor() { context_ = nullptr; @@ -359,8 +376,6 @@ void TableBase::EstimateFilterCost(FilterConstraints& fc, EstimatedIndexInfo& ei ei.isOrdered = true; GetOrbyes(fc, ei); - } else { - return; } } 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..e59bfbd67a3d65bf19386eed4a9e89cccf3517c5 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, @@ -113,10 +113,10 @@ int32_t FileSystemSampleTable::Cursor::Filter(const FilterConstraints& fc, sqlit const auto& c = fileSystemSampleCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::TYPE: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), fileSystemSampleTableObj_.Types()); break; default: 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..3082d997b8fe8abb1223a3fe3a0d2f0ad6b13f22 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, @@ -52,15 +52,15 @@ int32_t AppStartupTable::Cursor::Column(int32_t appStartupCol) const case Index::ID: sqlite3_result_int64(context_, static_cast(CurrentRow())); break; + case Index::CALL_ID: + sqlite3_result_int64(context_, static_cast(appStartupObj_.CallIds()[CurrentRow()])); + break; case Index::IPID: sqlite3_result_int64(context_, static_cast(appStartupObj_.Pids()[CurrentRow()])); break; case Index::TID: sqlite3_result_int64(context_, static_cast(appStartupObj_.Tids()[CurrentRow()])); break; - case Index::CALL_ID: - sqlite3_result_int64(context_, static_cast(appStartupObj_.CallIds()[CurrentRow()])); - break; case Index::START_TIME: sqlite3_result_int64(context_, static_cast(appStartupObj_.StartTimes()[CurrentRow()])); break; diff --git a/trace_streamer/src/table/ftrace/callstack_table.cpp b/trace_streamer/src/table/ftrace/callstack_table.cpp index 4bb35b31cd3ab65d3ebefac5686743e8dd20a62e..a0eb9536f22b0821b56a76a04107c64dd8315086 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, @@ -113,16 +113,18 @@ int32_t CallStackTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_valu const auto& c = callStackTabCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::TS: - FilterTS(c.op, argv[i], slicesObj_.TimeStampData()); + FilterTS(c.op, argv[c.idxInaConstraint], slicesObj_.TimeStampData()); break; case Index::CALL_IDS: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), slicesObj_.CallIds()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + 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[c.idxInaConstraint])), + slicesObj_.Cookies()); break; default: break; @@ -148,7 +150,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 +184,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..fbc39fd7488f3e5b5fb821d5c4c289c5546b1019 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"); @@ -58,32 +57,14 @@ void CpuMeasureFilterTable::FilterByConstraint(FilterConstraints& cpufc, } } -bool CpuMeasureFilterTable::CanFilterSorted(const char op, size_t& cpuRowCount) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - cpuRowCount = cpuRowCount / log2(cpuRowCount); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - cpuRowCount = (cpuRowCount >> 1); - break; - default: - return false; - } - return true; -} - std::unique_ptr CpuMeasureFilterTable::CreateCursor() { return std::make_unique(dataCache_, this); } 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 +115,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..c1747edcfb3ad4acecebd2201052ae9409d52ac4 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, @@ -81,14 +81,15 @@ int32_t FrameMapsTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_valu const auto& c = frameMapsTabCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::SRC_ROW: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), frameMapsObj_.SrcIndexs()); break; case Index::DST_ROW: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), frameMapsObj_.DstIndexs()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + frameMapsObj_.DstIndexs()); break; default: break; @@ -114,7 +115,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..4ff2c201b85330512624f8ffbea5411529235dfb 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, @@ -81,13 +81,15 @@ int32_t GPUSliceTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value const auto& c = gpuSliceTabCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::FRAME_ROW: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), gpuSliceObj_.FrameRows()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + gpuSliceObj_.FrameRows()); break; case Index::DUR: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), gpuSliceObj_.Durs()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + gpuSliceObj_.Durs()); break; default: break; @@ -113,7 +115,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..3c770141c6c13800300a54dd32cffce26d739537 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,15 +30,13 @@ 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, double& cpufilterCost, size_t cpurowCount, uint32_t cpucurrenti) override; - // the column is sorted - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..50bafd1d0176eef5c7860e0c5b80dfee6e3dedf7 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, @@ -38,8 +38,6 @@ private: size_t instantsrowCount, uint32_t instantscurrenti) override; - bool CanFilterSorted(const char op, size_t& rowCount) const; - class Cursor : public TableBase::Cursor { public: explicit Cursor(const TraceDataCache* dataCache, TableBase* table); 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..424fe7f992c8d6b373900b439777f0b03c5f60fe 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, @@ -37,7 +37,6 @@ private: double& measurefilterCost, size_t measurerowCount, uint32_t measurecurrenti) override; - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..67fa12b0df1040a65109076d4bb7878148c48ca9 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, @@ -37,8 +37,6 @@ private: double& filterfilterCost, size_t filterrowCount, uint32_t filtercurrenti) override; - // the column is sorted - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..8bc1e87d809e4c84c78ed71abeb94aca576c50ab 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, @@ -37,8 +37,6 @@ private: double& schedfilterCost, size_t schedrowCount, uint32_t schedcurrenti) override; - // the column is sorted - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..e764640f6a6b8a6b3b0464fae45103ad2cf783d7 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, @@ -37,8 +37,6 @@ private: double& eventfilterCost, size_t eventrowCount, uint32_t eventcurrenti) override; - // the column is sorted - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..72a6662483df3fcc11531d517a46ccf60c1cf103 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, @@ -37,8 +37,6 @@ private: double& statefilterCost, size_t staterowCount, uint32_t statecurrenti) override; - // the column is sorted - bool CanFilterSorted(const char op, size_t& rowCount) const; class Cursor : public TableBase::Cursor { public: 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..00f18d147596710f37f4d9b7967eec3d45e56f39 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, @@ -69,24 +69,6 @@ void InstantsTable::FilterByConstraint(FilterConstraints& instantsfc, } } -bool InstantsTable::CanFilterSorted(const char op, size_t& instantsRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - instantsRowCnt = instantsRowCnt / log2(instantsRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - instantsRowCnt = (instantsRowCnt >> 1); - break; - default: - return false; - } - return true; -} - void InstantsTable::Cursor::SortOfIndexMap(const FilterConstraints& fc) { auto orderbys = fc.GetOrderBys(); @@ -96,15 +78,6 @@ void InstantsTable::Cursor::SortOfIndexMap(const FilterConstraints& fc) case Index::TS: indexMap_->SortBy(orderbys[i].desc); break; - case Index::NAME: - indexMap_->SortBy(orderbys[i].desc); - break; - case Index::REF: - indexMap_->SortBy(orderbys[i].desc); - break; - case Index::WAKEUP_FROM: - indexMap_->SortBy(orderbys[i].desc); - break; default: break; } @@ -125,20 +98,20 @@ int32_t InstantsTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value const auto& c = instantsTabCs[i]; switch (static_cast(c.col)) { case Index::TS: - FilterTS(c.op, argv[i], InstantsObj_.TimeStampData()); + FilterTS(c.op, argv[c.idxInaConstraint], InstantsObj_.TimeStampData()); break; case Index::NAME: indexMap_->MixRange(c.op, - dataCache_->GetConstDataIndex( - std::string(reinterpret_cast(sqlite3_value_text(argv[i])))), + dataCache_->GetConstDataIndex(std::string( + reinterpret_cast(sqlite3_value_text(argv[c.idxInaConstraint])))), InstantsObj_.NameIndexsData()); break; case Index::REF: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), InstantsObj_.InternalTidsData()); break; case Index::WAKEUP_FROM: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), InstantsObj_.WakeupFromPidsData()); break; default: @@ -191,12 +164,6 @@ void InstantsTable::GetOrbyes(FilterConstraints& instantsfc, EstimatedIndexInfo& switch (static_cast(instantsorderbys[i].iColumn)) { case Index::TS: break; - case Index::NAME: - break; - case Index::REF: - break; - case Index::WAKEUP_FROM: - break; default: // other columns can be sorted by SQLite instantsei.isOrdered = false; break; 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..9aa1d2bb6545ab81ec9354b7b0de5417b5176971 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())) { } @@ -81,24 +79,6 @@ void MeasureTable::FilterByConstraint(FilterConstraints& measurefc, } } -bool MeasureTable::CanFilterSorted(const char op, size_t& measureRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - measureRowCnt = measureRowCnt / log2(measureRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - measureRowCnt = (measureRowCnt >> 1); - break; - default: - return false; - } - return true; -} - int32_t MeasureTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value** argv) { // reset @@ -114,10 +94,11 @@ int32_t MeasureTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value* const auto& c = measureTabCs[i]; switch (static_cast(c.col)) { case Index::TS: - FilterTS(c.op, argv[i], measureObj.TimeStampData()); + FilterTS(c.op, argv[c.idxInaConstraint], measureObj.TimeStampData()); break; case Index::FILTER_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), measureObj.FilterIdData()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + measureObj.FilterIdData()); break; default: break; 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..975d91176d5faf17d0e42b42b23579f5a5c32d15 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"); @@ -56,24 +55,6 @@ void ProcessMeasureFilterTable::FilterByConstraint(FilterConstraints& filterfc, } } -bool ProcessMeasureFilterTable::CanFilterSorted(const char op, size_t& procRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - procRowCnt = procRowCnt / log2(procRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - procRowCnt = (procRowCnt >> 1); - break; - default: - return false; - } - return true; -} - std::unique_ptr ProcessMeasureFilterTable::CreateCursor() { return std::make_unique(dataCache_, this); @@ -140,9 +121,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..3786584fdce4d2200fb9ec1a29ed9df7b88bb478 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")); @@ -130,10 +128,10 @@ int32_t ProcessTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value* switch (static_cast(c.col)) { case Index::ID: case Index::IPID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::PID: - FilterIndex(c.col, c.op, argv[i]); + FilterIndex(c.col, c.op, argv[c.idxInaConstraint]); break; default: break; @@ -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..0757e143daecc3db0bc5e69b302edd7af6c671ae 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")); @@ -95,18 +94,19 @@ int32_t RawTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value** ar const auto& c = RawTableCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::NAME: - indexMap_->MixRange( - c.op, GetNameIndex(std::string(reinterpret_cast(sqlite3_value_text(argv[i])))), - rawObj_.NameData()); + indexMap_->MixRange(c.op, + GetNameIndex(std::string( + reinterpret_cast(sqlite3_value_text(argv[c.idxInaConstraint])))), + rawObj_.NameData()); break; case Index::TS: - FilterTS(c.op, argv[i], rawObj_.TimeStampData()); + FilterTS(c.op, argv[c.idxInaConstraint], rawObj_.TimeStampData()); break; case Index::INTERNAL_TID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), rawObj_.InternalTidsData()); break; default: @@ -133,10 +133,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..5652be6da684557d20740cd5085c9a5b83ffad01 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")); @@ -84,24 +71,6 @@ void SchedSliceTable::FilterByConstraint(FilterConstraints& schedfc, } } -bool SchedSliceTable::CanFilterSorted(const char op, size_t& schedRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - schedRowCnt = schedRowCnt / log2(schedRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - schedRowCnt = (schedRowCnt >> 1); - break; - default: - return false; - } - return true; -} - std::unique_ptr SchedSliceTable::CreateCursor() { return std::make_unique(dataCache_, this); @@ -131,24 +100,25 @@ int32_t SchedSliceTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_val const auto& c = schedSliceTabCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::TS: - FilterTS(c.op, argv[i], schedSliceObj_.TimeStampData()); + FilterTS(c.op, argv[c.idxInaConstraint], schedSliceObj_.TimeStampData()); break; case Index::CPU: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), schedSliceObj_.CpusData()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + schedSliceObj_.CpusData()); break; case Index::INTERNAL_TID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), schedSliceObj_.InternalTidsData()); break; case Index::INTERNAL_PID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), schedSliceObj_.InternalPidsData()); break; case Index::DUR: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), schedSliceObj_.DursData()); break; default: @@ -176,10 +146,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 +172,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..7a7ca122fc10814f75d54dfb5a37eafbd3232b1d 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, @@ -53,24 +53,6 @@ void SystemEventFilterTable::FilterByConstraint(FilterConstraints& eventfc, } } -bool SystemEventFilterTable::CanFilterSorted(const char op, size_t& sysRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - sysRowCnt = sysRowCnt / log2(sysRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - sysRowCnt = (sysRowCnt >> 1); - break; - default: - return false; - } - return true; -} - std::unique_ptr SystemEventFilterTable::CreateCursor() { return std::make_unique(dataCache_, this); 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..0755bd9cf1fed6912417764e2fce9fe61e21e7a3 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")); @@ -72,24 +71,6 @@ void ThreadStateTable::FilterByConstraint(FilterConstraints& statefc, } } -bool ThreadStateTable::CanFilterSorted(const char op, size_t& threadRowCnt) const -{ - switch (op) { - case SQLITE_INDEX_CONSTRAINT_EQ: - threadRowCnt = threadRowCnt / log2(threadRowCnt); - break; - case SQLITE_INDEX_CONSTRAINT_GT: - case SQLITE_INDEX_CONSTRAINT_GE: - case SQLITE_INDEX_CONSTRAINT_LE: - case SQLITE_INDEX_CONSTRAINT_LT: - threadRowCnt = (threadRowCnt >> 1); - break; - default: - return false; - } - return true; -} - std::unique_ptr ThreadStateTable::CreateCursor() { return std::make_unique(dataCache_, this); @@ -143,39 +124,40 @@ void ThreadStateTable::Cursor::HandleIndex(const FilterConstraints& fc, sqlite3_ const auto& c = cs[i]; switch (static_cast(c.col)) { case Index::ID: - indexMapBack->FilterId(c.op, argv[i]); + indexMapBack->FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::TS: - indexMapBack->FilterTS(c.op, argv[i], threadStateObj_.TimeStamsData()); + indexMapBack->FilterTS(c.op, argv[c.idxInaConstraint], threadStateObj_.TimeStampData()); break; case Index::INTERNAL_TID: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), threadStateObj_.ItidsData()); break; case Index::TID: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), threadStateObj_.TidsData()); break; case Index::PID: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), threadStateObj_.PidsData()); break; case Index::DUR: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), threadStateObj_.DursData()); break; case Index::CPU: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), threadStateObj_.CpusData()); break; case Index::STATE: - indexMapBack->MixRange(c.op, - static_cast(dataCache_->GetThreadStateValue( - std::string(reinterpret_cast(sqlite3_value_text(argv[i]))))), - threadStateObj_.StatesData()); + indexMapBack->MixRange( + c.op, + static_cast(dataCache_->GetThreadStateValue( + std::string(reinterpret_cast(sqlite3_value_text(argv[c.idxInaConstraint]))))), + threadStateObj_.StatesData()); break; case Index::ARGSETID: - indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMapBack->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), threadStateObj_.ArgSetsData()); break; default: @@ -188,13 +170,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..a691dd81006ab3030862aee749d20b3c3d3473a0 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")); @@ -265,12 +253,12 @@ int32_t ThreadTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_value** switch (static_cast(c.col)) { case Index::ID: case Index::ITID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::TID: case Index::INTERNAL_PID: case Index::SWITCH_COUNT: - FilterIndex(c.col, c.op, argv[i]); + FilterIndex(c.col, c.op, argv[c.idxInaConstraint]); break; default: break; @@ -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..59f5e02cc6245bd9e318e350c57e0383b7dd0bc9 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, @@ -86,18 +86,18 @@ int32_t PerfCallChainTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_ const auto& c = perfCallChainCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::CALLCHAIN_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), perfCallChainObj_.CallChainIds()); break; case Index::FILE_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), perfCallChainObj_.FileIds()); break; case Index::SYMBOL_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), perfCallChainObj_.SymbolIds()); break; default: diff --git a/trace_streamer/src/table/hiperf/perf_files_table.cpp b/trace_streamer/src/table/hiperf/perf_files_table.cpp index 2a9cd52d90c7950748de8343f059d60fa23f46e0..74e3fe253c47fc9278320554af103aa0a8b96eba 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, @@ -83,10 +83,11 @@ int32_t PerfFilesTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_valu const auto& c = perfFilesTabCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::FILE_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), perfFilesObj_.FileIds()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + perfFilesObj_.FileIds()); break; default: break; 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..cf88ddd0e1625cc4b4f3a18c13bcdc5d818fe942 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, @@ -97,21 +97,23 @@ int32_t PerfSampleTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_val const auto& c = perfSampleCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::CALLCHAIN_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), perfSampleObj_.SampleIds()); break; case Index::THREAD_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), perfSampleObj_.Tids()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + perfSampleObj_.Tids()); break; case Index::EVENT_TYPE_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), perfSampleObj_.EventTypeIds()); break; case Index::CPU_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), perfSampleObj_.CpuIds()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + perfSampleObj_.CpuIds()); break; default: break; diff --git a/trace_streamer/src/table/hiperf/perf_thread_table.cpp b/trace_streamer/src/table/hiperf/perf_thread_table.cpp index bbcc207c856cf9cba2686fcb5c52ecd6b5054bb2..eba991575d180e2920452f2f73e192dfb0c29d4d 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, @@ -80,13 +80,15 @@ int32_t PerfThreadTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_val const auto& c = perfThreadCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::THREAD_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), perfThreadObj_.Tids()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + perfThreadObj_.Tids()); break; case Index::PROCESS_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), perfThreadObj_.Pids()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), + perfThreadObj_.Pids()); break; default: break; 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..6597eaed9c9a619fb4a24196ec5970f3602f8f59 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, @@ -85,18 +85,18 @@ int32_t NativeHookFrameTable::Cursor::Filter(const FilterConstraints& fc, sqlite const auto& c = nativeHookFrameCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::CALLCHAIN_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), nativeHookFrameInfoObj_.CallChainIds()); break; case Index::SYMBOL_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), nativeHookFrameInfoObj_.SymbolNames()); break; case Index::FILE_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), nativeHookFrameInfoObj_.FilePaths()); break; default: @@ -142,11 +142,11 @@ int32_t NativeHookFrameTable::Cursor::Column(int32_t nativeHookFrameCol) const break; } case Index::OFFSET: { - sqlite3_result_int64(context_, static_cast(nativeHookFrameInfoObj_.Offsets()[CurrentRow()])); + SetTypeColumnInt64(nativeHookFrameInfoObj_.Offsets()[CurrentRow()], INVALID_UINT64); break; } case Index::SYMBOL_OFFSET: { - sqlite3_result_int64(context_, static_cast(nativeHookFrameInfoObj_.SymbolOffsets()[CurrentRow()])); + SetTypeColumnInt64(nativeHookFrameInfoObj_.SymbolOffsets()[CurrentRow()], INVALID_UINT64); break; } case Index::VADDR: { 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..7778855552c1174cb054e8bc03422b5616558040 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, @@ -103,10 +103,10 @@ int32_t NativeHookStatisticTable::Cursor::Filter(const FilterConstraints& fc, sq const auto& c = nativeHookStatisticCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::CALLCHAIN_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), nativeHookStatisticInfoObj_.CallChainIds()); break; default: 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..607e7097344870dae3586b49fdb8187fd403f272 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, @@ -109,17 +109,18 @@ int32_t NativeHookTable::Cursor::Filter(const FilterConstraints& fc, sqlite3_val const auto& c = nativeHookCs[i]; switch (static_cast(c.col)) { case Index::ID: - FilterId(c.op, argv[i]); + FilterId(c.op, argv[c.idxInaConstraint]); break; case Index::IPID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), nativeHookObj_.Ipids()); + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), + nativeHookObj_.Ipids()); break; case Index::ITID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int(argv[c.idxInaConstraint])), nativeHookObj_.InternalTidsData()); break; case Index::CALLCHAIN_ID: - indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[i])), + indexMap_->MixRange(c.op, static_cast(sqlite3_value_int64(argv[c.idxInaConstraint])), nativeHookObj_.CallChainIds()); break; default: 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..3b1f5c335f0c0f4ee8e330a942167910441a5190 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, 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..91fda08b7d330221d908c44377559f5c28f5b2e7 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, @@ -154,6 +154,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(); 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..61aa8b3fcbfdf1a5f416017ef4e5d7ceef86d1e7 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, @@ -22,10 +22,12 @@ #include "cpu_filter.h" #include "filter_filter.h" #include "frame_filter.h" -#include "hi_sysevent_measure_filter.h" +#ifdef ENABLE_HISYSEVENT +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#endif #include "irq_filter.h" #include "measure_filter.h" -#include "perf_data_filter.h" +#include "perf_filter/perf_data_filter.h" #include "process_filter.h" #include "slice_filter.h" #include "stat_filter.h" @@ -42,7 +44,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..8b8bf1ad82d7de4e0c25323642cdcb719e9f6a1c 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, @@ -31,11 +31,15 @@ class BinderFilter; class ArgsFilter; class IrqFilter; class SystemEventMeasureFilter; +#ifdef ENABLE_HISYSEVENT class HiSysEventMeasureFilter; +#endif class FrameFilter; class APPStartupFilter; class TaskPoolFilter; +#ifdef ENABLE_HIPERF class PerfDataFilter; +#endif class TraceStreamerFilters { public: TraceStreamerFilters(); @@ -62,11 +66,15 @@ public: std::unique_ptr sysEventMemMeasureFilter_; std::unique_ptr sysEventVMemMeasureFilter_; std::unique_ptr sysEventSourceFilter_; +#ifdef ENABLE_HISYSEVENT std::unique_ptr hiSysEventMeasureFilter_; +#endif std::unique_ptr frameFilter_; std::unique_ptr appStartupFilter_; std::unique_ptr taskPoolFilter_; +#ifdef ENABLE_HIPERF std::unique_ptr perfDataFilter_; +#endif }; } // namespace TraceStreamer } // namespace SysTuning diff --git a/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp b/trace_streamer/src/trace_streamer/trace_streamer_selector.cpp index 39620f0c8d7cec626aba50edc2fd0460519d5204..dc6210e58f1adec1317e95656d5db38b90d73d23 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, @@ -28,14 +28,20 @@ #include "file.h" #include "filter_filter.h" #include "frame_filter.h" -#include "hi_sysevent_measure_filter.h" +#ifdef ENABLE_HISYSEVENT +#include "hi_sysevent_filter/hi_sysevent_measure_filter.h" +#endif #include "irq_filter.h" #include "measure_filter.h" #include "task_pool_filter.h" -#include "parser/bytrace_parser/bytrace_parser.h" -#include "parser/htrace_pbreader_parser/htrace_parser.h" +#include "parser/ptreader_parser/ptreader_parser.h" +#include "parser/pbreader_parser/pbreader_parser.h" +#ifdef ENABLE_RAWTRACE #include "parser/rawtrace_parser/rawtrace_parser.h" -#include "perf_data_filter.h" +#endif +#ifdef ENABLE_HIPERF +#include "perf_filter/perf_data_filter.h" +#endif #include "process_filter.h" #include "slice_filter.h" #include "stat_filter.h" @@ -79,12 +85,14 @@ TraceFileType GuessFileType(const uint8_t* data, size_t size) if (start.find("# TRACE") != std::string::npos) { return TRACE_FILETYPE_BY_TRACE; } +#ifdef ENABLE_RAWTRACE uint16_t magicNumber = INVALID_UINT16; int ret = memcpy_s(&magicNumber, sizeof(uint16_t), data, sizeof(uint16_t)); TS_CHECK_TRUE(ret == EOK, TRACE_FILETYPE_UN_KNOW, "Memcpy FAILED!Error code is %d, data size is %zu.", ret, size); if (magicNumber == RAW_TRACE_MAGIC_NUMBER) { return TRACE_FILETYPE_RAW_TRACE; } +#endif std::string lowerStart(start); transform(start.begin(), start.end(), lowerStart.begin(), ::tolower); if ((lowerStart.compare(0, std::string("").length(), "") == 0) || @@ -97,9 +105,11 @@ TraceFileType GuessFileType(const uint8_t* data, size_t size) if (start.compare(0, std::string("OHOSPROF").length(), "OHOSPROF") == 0) { return TRACE_FILETYPE_H_TRACE; } +#ifdef ENABLE_HIPERF if (start.compare(0, std::string("PERFILE2").length(), "PERFILE2") == 0) { return TRACE_FILETYPE_PERF; } +#endif const std::regex bytraceMatcher = std::regex(R"(-(\d+)\s+\(?\s*(\d+|-+)?\)?\s?\[(\d+)\]\s*)" R"([a-zA-Z0-9.]{0,5}\s+(\d+\.\d+):\s+(\S+):)"); std::smatch matcheLine; @@ -121,7 +131,12 @@ TraceFileType GuessFileType(const uint8_t* data, size_t size) } // namespace TraceStreamerSelector::TraceStreamerSelector() - : fileType_(TRACE_FILETYPE_UN_KNOW), bytraceParser_(nullptr), htraceParser_(nullptr), rawTraceParser_(nullptr) + : ptreaderParser_(nullptr), + pbreaderParser_(nullptr), +#ifdef ENABLE_RAWTRACE + rawTraceParser_(nullptr), +#endif + fileType_(TRACE_FILETYPE_UN_KNOW) { InitFilter(); } @@ -138,7 +153,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_ = @@ -165,30 +179,38 @@ void TraceStreamerSelector::InitFilter() streamFilters_->sysEventVMemMeasureFilter_ = std::make_unique( traceDataCache_.get(), streamFilters_.get(), E_SYS_VIRTUAL_MEMORY_FILTER); streamFilters_->appStartupFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); +#ifdef ENABLE_HIPERF streamFilters_->perfDataFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); +#endif streamFilters_->sysEventSourceFilter_ = std::make_unique( traceDataCache_.get(), streamFilters_.get(), E_SYS_EVENT_SOURCE_FILTER); +#ifdef ENABLE_HISYSEVENT streamFilters_->hiSysEventMeasureFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); +#endif streamFilters_->taskPoolFilter_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); } void TraceStreamerSelector::WaitForParserEnd() { if (fileType_ == TRACE_FILETYPE_H_TRACE) { - htraceParser_->WaitForParserEnd(); + pbreaderParser_->WaitForParserEnd(); } if (fileType_ == TRACE_FILETYPE_BY_TRACE || fileType_ == TRACE_FILETYPE_HILOG || fileType_ == TRACE_FILETYPE_HI_SYSEVENT) { - bytraceParser_->WaitForParserEnd(); + ptreaderParser_->WaitForParserEnd(); } +#ifdef ENABLE_HIPERF if (fileType_ == TRACE_FILETYPE_PERF) { - htraceParser_->TraceDataSegmentEnd(false); - htraceParser_->WaitForParserEnd(); + pbreaderParser_->TraceDataSegmentEnd(false); + pbreaderParser_->WaitForParserEnd(); } +#endif +#ifdef ENABLE_RAWTRACE if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { rawTraceParser_->WaitForParserEnd(); } +#endif traceDataCache_->UpdateTraceRange(); if (traceDataCache_->AnimationTraceEnabled()) { streamFilters_->animationFilter_->UpdateFrameInfo(); @@ -205,12 +227,15 @@ void TraceStreamerSelector::SetDataType(TraceFileType type) { fileType_ = type; if (fileType_ == TRACE_FILETYPE_H_TRACE) { - htraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); + pbreaderParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); } else if (fileType_ == TRACE_FILETYPE_BY_TRACE) { - bytraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); - } else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { + ptreaderParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); + } +#ifdef ENABLE_RAWTRACE + else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { rawTraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); } +#endif } // only support parse long trace profiler_data_xxxxxxxx_xxxxxx_x.htrace bool TraceStreamerSelector::BatchParseTraceDataSegment(std::unique_ptr data, size_t size) @@ -224,9 +249,12 @@ bool TraceStreamerSelector::BatchParseTraceDataSegment(std::unique_ptr(traceDataCache_.get(), streamFilters_.get()); + pbreaderParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); +#ifdef ENABLE_HTRACE + pbreaderParser_->EnableOnlyParseFtrace(); +#endif } - htraceParser_->ParseTraceDataSegment(std::move(data), size); + pbreaderParser_->ParseTraceDataSegment(std::move(data), size); return true; } bool TraceStreamerSelector::ParseTraceDataSegment(std::unique_ptr data, @@ -240,15 +268,22 @@ bool TraceStreamerSelector::ParseTraceDataSegment(std::unique_ptr dat if (fileType_ == TRACE_FILETYPE_UN_KNOW) { fileType_ = GuessFileType(data.get(), size); if (fileType_ == TRACE_FILETYPE_H_TRACE || fileType_ == TRACE_FILETYPE_PERF) { - htraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); - htraceParser_->EnableFileSeparate(enableFileSeparate_); + pbreaderParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); +#ifdef ENABLE_ARKTS + pbreaderParser_->EnableFileSeparate(enableFileSeparate_); +#endif } else if (fileType_ == TRACE_FILETYPE_BY_TRACE || fileType_ == TRACE_FILETYPE_HI_SYSEVENT || fileType_ == TRACE_FILETYPE_HILOG) { - bytraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get(), fileType_); - bytraceParser_->EnableBytrace(fileType_ == TRACE_FILETYPE_BY_TRACE); - } else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { + ptreaderParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get(), fileType_); +#ifdef ENABLE_BYTRACE + ptreaderParser_->EnableBytrace(fileType_ == TRACE_FILETYPE_BY_TRACE); +#endif + } +#ifdef ENABLE_RAWTRACE + else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { rawTraceParser_ = std::make_unique(traceDataCache_.get(), streamFilters_.get()); } +#endif if (fileType_ == TRACE_FILETYPE_UN_KNOW) { SetAnalysisResult(TRACE_PARSER_FILE_TYPE_ERROR); TS_LOGI( @@ -262,16 +297,22 @@ bool TraceStreamerSelector::ParseTraceDataSegment(std::unique_ptr dat traceDataCache_->SetSplitFileMaxTime(maxTs_); traceDataCache_->isSplitFile_ = isSplitFile; if (fileType_ == TRACE_FILETYPE_H_TRACE) { - htraceParser_->ParseTraceDataSegment(std::move(data), size); + pbreaderParser_->ParseTraceDataSegment(std::move(data), size); } else if (fileType_ == TRACE_FILETYPE_BY_TRACE || fileType_ == TRACE_FILETYPE_HI_SYSEVENT || fileType_ == TRACE_FILETYPE_HILOG) { - bytraceParser_->ParseTraceDataSegment(std::move(data), size, isFinish); + ptreaderParser_->ParseTraceDataSegment(std::move(data), size, isFinish); return true; - } else if (fileType_ == TRACE_FILETYPE_PERF) { - htraceParser_->StoreTraceDataSegment(std::move(data), size, isFinish); - } else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { + } +#ifdef ENABLE_HIPERF + else if (fileType_ == TRACE_FILETYPE_PERF) { + pbreaderParser_->StoreTraceDataSegment(std::move(data), size, isFinish); + } +#endif +#ifdef ENABLE_RAWTRACE + else if (fileType_ == TRACE_FILETYPE_RAW_TRACE) { rawTraceParser_->ParseTraceDataSegment(std::move(data), size, isFinish); } +#endif SetAnalysisResult(TRACE_PARSER_NORMAL); return true; } @@ -335,7 +376,7 @@ bool TraceStreamerSelector::ReloadSymbolFiles(std::string& directory, std::vecto for (auto file : symbolsPaths) { TS_LOGE("files is %s", file.c_str()); } - return htraceParser_->ReparseSymbolFilesAndResymbolization(directory, symbolsPaths); + return pbreaderParser_->ReparseSymbolFilesAndResymbolization(directory, symbolsPaths); } void TraceStreamerSelector::Clear() { @@ -396,7 +437,7 @@ int32_t TraceStreamerSelector::UpdateTraceRangeTime(uint8_t* data, int32_t len) { std::string traceRangeStr; (void)memcpy_s(&traceRangeStr, len, data, len); - std::vector vTraceRangeStr = SplitStringToVec(traceRangeStr, ";"); + std::vector vTraceRangeStr = SplitStringToVec(traceRangeStr, ";"); uint64_t minTs = std::stoull(vTraceRangeStr.at(0)); uint64_t maxTs = std::stoull(vTraceRangeStr.at(1)); traceDataCache_->UpdateTraceTime(minTs); @@ -423,35 +464,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; - } - sqlString.append(buffer); - - if (EndWith(line, ";") || EndWith(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); } } - - 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..9bd575f9ba2b0af0390f54e88e9952127c6f7482 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, @@ -23,9 +23,11 @@ namespace SysTuning { namespace TraceStreamer { -class BytraceParser; -class HtraceParser; +class PtreaderParser; +class PbreaderParser; +#ifdef ENABLE_RAWTRACE class RawTraceParser; +#endif class TraceStreamerSelector { public: TraceStreamerSelector(); @@ -62,15 +64,22 @@ 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(); + return ptreaderParser_.get(); } +#ifdef ENABLE_RAWTRACE + auto GetRawtraceData() + { + return rawTraceParser_.get(); + } +#endif auto GetHtraceData() { - return htraceParser_.get(); + return pbreaderParser_.get(); } const auto GetFileType() { @@ -97,9 +106,11 @@ private: TraceFileType fileType_; std::unique_ptr streamFilters_ = {}; std::unique_ptr traceDataCache_ = {}; - std::unique_ptr bytraceParser_; - std::unique_ptr htraceParser_; + std::unique_ptr ptreaderParser_; + std::unique_ptr pbreaderParser_; +#ifdef ENABLE_RAWTRACE std::unique_ptr rawTraceParser_; +#endif bool enableFileSeparate_ = false; }; } // namespace TraceStreamer diff --git a/trace_streamer/src/version.cpp b/trace_streamer/src/version.cpp index 851dacdf154972b439e0b4853014043b6f688297..e2a69bf6ecfac1757d9d5b575b83b2c5ee73d1b7 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.5"; // version +const std::string g_traceStreamerPublishVersion = "2024/03/15"; // 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..7affc4017f0479e7e3f4ac165b176c35f642cbd7 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 @@ -13,7 +13,7 @@ # limitations under the License. #./build.sh test clean set -e -./build.sh test +./build.sh test $1 $2 rm -rf out/test/*.xml rm -rf out/test_debug/*.xml find out/test -name "*.gcda" -print0 | xargs -0 rm -rf diff --git a/trace_streamer/test/BUILD.gn b/trace_streamer/test/BUILD.gn index 27d3b37553f6bbdef74eac1fc86651d467186161..f80591b7560821108207fd0bf3fe84967b77b850 100644 --- a/trace_streamer/test/BUILD.gn +++ b/trace_streamer/test/BUILD.gn @@ -1,9 +1,9 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http:/www.apache.org/licenses/LICENSE-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,6 +20,10 @@ if (is_test) { ohos_unittest("trace_streamer_ut") { sources = [ "unittest/base/export_test.cpp", # Don't comment, for common method + "unittest/ebpf/bio_parser_test.cpp", + "unittest/ebpf/ebpf_file_system_test.cpp", + "unittest/ebpf/ebpf_parser_test.cpp", + "unittest/ebpf/paged_memory_parser_test.cpp", "unittest/filter/animation_filter_test.cpp", "unittest/filter/app_start_filter_test.cpp", "unittest/filter/binder_filter_test.cpp", @@ -32,33 +36,31 @@ if (is_test) { "unittest/filter/process_filter_test.cpp", "unittest/filter/slice_filter_test.cpp", "unittest/filter/task_pool_filter_test.cpp", - "unittest/htrace/arkts/js_cpu_profiler_test.cpp", - "unittest/htrace/arkts/js_memory_test.cpp", - "unittest/htrace/ebpf/bio_parser_test.cpp", - "unittest/htrace/ebpf/ebpf_file_system_test.cpp", - "unittest/htrace/ebpf/ebpf_parser_test.cpp", - "unittest/htrace/ebpf/paged_memory_parser_test.cpp", - "unittest/htrace/hidump_parser_test.cpp", - "unittest/htrace/hilog_parser_test.cpp", - "unittest/htrace/hisys_event_parser_test.cpp", - "unittest/htrace/htrace_binder_event_test.cpp", - "unittest/htrace/htrace_cpu_data_parser_test.cpp", - "unittest/htrace/htrace_cpu_detail_parser_test.cpp", - "unittest/htrace/htrace_diskio_parser_test.cpp", - "unittest/htrace/htrace_event_parser_test.cpp", - "unittest/htrace/htrace_irq_event_test.cpp", - "unittest/htrace/htrace_mem_parser_test.cpp", - "unittest/htrace/htrace_network_parser_test.cpp", - "unittest/htrace/htrace_process_parser_test.cpp", - "unittest/htrace/htrace_sys_mem_parser_test.cpp", - "unittest/htrace/htrace_sys_vmem_parser_test.cpp", - "unittest/htrace/native_memory/native_hook_parser_test.cpp", - "unittest/htrace/smaps_parser_test.cpp", "unittest/interface/rpc_server_test.cpp", "unittest/interface/split_file_data_test.cpp", "unittest/interface/wasm_func_test.cpp", "unittest/pbreader/parser_pbreader_test.cpp", "unittest/pbreader/proto_reader_test.cpp", + "unittest/pbreader_parser/arkts/js_cpu_profiler_test.cpp", + "unittest/pbreader_parser/arkts/js_memory_test.cpp", + "unittest/pbreader_parser/diskio_parser_test.cpp", + "unittest/pbreader_parser/hidump_parser_test.cpp", + "unittest/pbreader_parser/hilog_parser_test.cpp", + "unittest/pbreader_parser/hisys_event_parser_test.cpp", + "unittest/pbreader_parser/htrace_binder_event_test.cpp", + "unittest/pbreader_parser/htrace_cpu_detail_parser_test.cpp", + "unittest/pbreader_parser/htrace_event_parser_test.cpp", + "unittest/pbreader_parser/htrace_irq_event_test.cpp", + "unittest/pbreader_parser/native_memory/native_hook_parser_test.cpp", + "unittest/pbreader_parser/pbreader_cpu_data_parser_test.cpp", + "unittest/pbreader_parser/pbreader_mem_parser_test.cpp", + "unittest/pbreader_parser/pbreader_network_parser_test.cpp", + "unittest/pbreader_parser/pbreader_process_parser_test.cpp", + "unittest/pbreader_parser/pbreader_sys_mem_parser_test.cpp", + "unittest/pbreader_parser/pbreader_sys_vmem_parser_test.cpp", + "unittest/pbreader_parser/smaps_parser_test.cpp", + "unittest/ptreader_parser/event_parser_test.cpp", + "unittest/ptreader_parser/ptreader_parser_test.cpp", "unittest/query/query_file_test.cpp", "unittest/query/query_metrics_test.cpp", "unittest/query/span_join_test.cpp", @@ -66,8 +68,6 @@ if (is_test) { "unittest/rawtrace/ftrace_field_processor_test.cpp", "unittest/rawtrace/rawtrace_cpu_detail_parse_test.cpp", "unittest/rawtrace/rawtrace_parser_test.cpp", - "unittest/systrace/bytrace_parser_test.cpp", - "unittest/systrace/event_parser_test.cpp", "unittest/table/table_test.cpp", ] @@ -85,16 +85,25 @@ if (is_test) { "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/network_data:ts_network_data_cpp", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/process_data:ts_process_data_cpp", "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/test_data:test_data_cpp", - "${SRC}/parser/rawtrace_parser:rawtrace_parser_src", + "${SRC}/parser/rawtrace_parser:rawtrace_parser", "${THIRD_PARTY}/bounds_checking_function:libsec_static", "${THIRD_PARTY}/googletest:gtest", "${THIRD_PARTY}/googletest:gtest_main", "${THIRD_PARTY}/protobuf:protobuf_lite_static", "${THIRD_PARTY}/protobuf:protobuf_static", "../src:trace_streamer_source", - "../src/parser/htrace_pbreader_parser:htrace_pbreader_parser", + "../src/parser/pbreader_parser:pbreader_parser", "../src/proto_reader:proto_reader", ] + public_configs = [] + if (enable_stream_extend) { + sources += + [ "${EXTEND_TEST}/unittest/pbreader/pbreader_stream_parser_test.cpp" ] + public_configs += + [ "${EXTEND_SRC}/parser/pbreader_stream_parser:pbreader_stream_cfg" ] + deps += + [ "${EXTEND_SRC}/parser/pbreader_stream_parser:stream_extend_parser" ] + } include_dirs = [ "../src", "../src/trace_data", @@ -107,7 +116,7 @@ if (is_test) { "../src/metrics", "../src/include", "../src/trace_streamer", - "../src/parser/bytrace_parser", + "../src/parser/ptreader_parser", "../src/parser", "../src/cfg", "../src/metrics", @@ -117,7 +126,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", @@ -134,9 +142,8 @@ if (is_test) { "${THIRD_PARTY}/sqlite/include", "${THIRD_PARTY}/bounds_checking_function/include", "${THIRD_PARTY}/json/single_include/nlohmann", - "../src/parser/htrace_pbreader_parser", - "../src/parser/htrace_pbreader_parser/htrace_event_parser", - "../src/parser/htrace_pbreader_parser/htrace_cpu_parser", + "../src/parser/pbreader_parser", + "../src/parser/pbreader_parser/htrace_parser", "../src/proto_reader", "../src/proto_reader/include", "${SRC}/metrics", 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..add0519da4acda2d421bb1b2025f2040c6a87fbd 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 @@ -28,11 +28,23 @@ ohos_fuzztest("ts_bytrace_fuzz_test") { "../../../src/trace_streamer", "../../../src/include", "../../../src/proto_reader/include", - "../../../src/parser/bytrace_parser", + "../../../src/parser/ptreader_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 @@ -