diff --git a/ide/server/main.go b/ide/server/main.go
index 63db8b8ef3216ed7c0f66be9eb4cb6ab767ece10..25bf7ce822d00c5fdfc4ff489a6d8558fc190f8d 100644
--- a/ide/server/main.go
+++ b/ide/server/main.go
@@ -128,8 +128,8 @@ func main() {
mime.AddExtensionType(".js", "application/javascript")
log.Println(mime.TypeByExtension(".js"))
mux.HandleFunc("/logger", consoleHandler)
- mux.Handle("/application/upload/", http.StripPrefix("/upload/", http.FileServer(http.Dir(filepath.FromSlash(exPath+"/upload")))))
- mux.HandleFunc("/application//download-file", downloadHandler)
+ mux.Handle("/application/upload/", http.StripPrefix("/application/upload/", http.FileServer(http.Dir(filepath.FromSlash(exPath+"/upload")))))
+ mux.HandleFunc("/application/download-file", downloadHandler)
mux.HandleFunc("/application/serverInfo", serverInfo)
fs := http.FileServer(http.Dir(exPath + "/"))
mux.Handle("/application/", http.StripPrefix("/application/", cors(fs, version)))
@@ -273,7 +273,7 @@ func get(url string) (*http.Response, error) {
}
func clearOverdueFile() {
- MkDir(filepath.FromSlash(fmt.Sprintf("./upload/")))
+ MkDir(filepath.FromSlash(fmt.Sprintf("./application/upload/")))
now := time.Now()
loc, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
@@ -291,7 +291,7 @@ func clearOverdueFile() {
}
return false
}
- slash := filepath.FromSlash(fmt.Sprintf("./upload/"))
+ slash := filepath.FromSlash(fmt.Sprintf("./application/upload/"))
filepath.WalkDir(slash, func(path string, d fs.DirEntry, err error) error {
if checkDue(d.Name()) {
fmt.Println(now, "delete->", path, d.Name(), err)
@@ -344,7 +344,7 @@ func downloadHandler(w http.ResponseWriter, r *http.Request) {
resp(&w)(false, -1, err.Error(), nil)
return
}
- pth := filepath.FromSlash(fmt.Sprintf("/upload/%s%s", time.Now().Format("20060102150405000"), getSuffixByUrl(url).suffix))
+ pth := filepath.FromSlash(fmt.Sprintf("/application/upload/%s%s", time.Now().Format("20060102150405000"), getSuffixByUrl(url).suffix))
MkDir("." + pth)
create, err := os.Create("." + pth)
if err != nil {
@@ -357,7 +357,7 @@ func downloadHandler(w http.ResponseWriter, r *http.Request) {
return
}
fmt.Println(url, written)
- pth = "/application" + pth
+ pth = "/application/" + pth
resp(&w)(true, 0, "success", map[string]interface{}{
"url": pth,
"size": written,
diff --git a/ide/src/base-ui/select/LitAllocationSelect.ts b/ide/src/base-ui/select/LitAllocationSelect.ts
index 39587dc56a8663e57bc180dc5a5fbb4514af972e..d39a5099bade11575e17126d240e33c00082ead0 100644
--- a/ide/src/base-ui/select/LitAllocationSelect.ts
+++ b/ide/src/base-ui/select/LitAllocationSelect.ts
@@ -216,7 +216,14 @@ export class LitAllocationSelect extends BaseElement {
`;
}
- connectedCallback() {}
+ connectedCallback() {
+ this.selectAllocationInputEl!.onkeydown = (ev): void => {
+ // @ts-ignore
+ if (ev.key === '0' && ev.target.value.length === 1 && ev.target.value === '0') {
+ ev.preventDefault();
+ }
+ };
+ }
initData() {
this.selectAllocationInputEl = this.shadowRoot!.querySelector('input');
diff --git a/ide/src/base-ui/select/LitSelect.ts b/ide/src/base-ui/select/LitSelect.ts
index 28d1dded6c73574fe769a0d79efafc5356f86aab..ad6e60f1d2fa64490a1667f119310a393ed5cdee 100644
--- a/ide/src/base-ui/select/LitSelect.ts
+++ b/ide/src/base-ui/select/LitSelect.ts
@@ -439,6 +439,8 @@ export class LitSelect extends BaseElement {
);
}
}
+ } else if (ev.key === '0' && ev.target.value.length === 1 && ev.target.value === '0') {
+ ev.preventDefault();
}
};
}
diff --git a/ide/src/base-ui/select/LitSelectV.ts b/ide/src/base-ui/select/LitSelectV.ts
index dc032a0738a2adaa9c8a64647a771c34a5d92529..32b2c054fe0c4ba05c4588d472762464746594bc 100644
--- a/ide/src/base-ui/select/LitSelectV.ts
+++ b/ide/src/base-ui/select/LitSelectV.ts
@@ -158,6 +158,18 @@ export class LitSelectV extends BaseElement {
this.selectVBody = this.shadowRoot!.querySelector('.body') as HTMLDivElement;
this.selectVOptions = this.shadowRoot!.querySelector('.body-opt') as HTMLDivElement;
this.selectVIconEl = this.shadowRoot!.querySelector('.icon');
+ this.selectVInputEl!.onkeydown = (ev: KeyboardEvent) => {
+ // @ts-ignore
+ if (ev.key === '0' && ev.target.value.length === 1 && ev.target.value === '0') {
+ ev.preventDefault();
+ }
+ };
+ this.selectVSearchInputEl!.onkeydown = (ev: KeyboardEvent) => {
+ // @ts-ignore
+ if (ev.key === '0' && ev.target.value.length === 1 && ev.target.value === '0') {
+ ev.preventDefault();
+ }
+ };
this.onclick = (ev: any) => {
if (this.focused === false) {
this.focused = true;
diff --git a/ide/src/base-ui/slider/LitSlider.ts b/ide/src/base-ui/slider/LitSlider.ts
index 060e6812b87832aa102e07a084f4874a5fa936f4..eeb8b4287de3361a48ceebe3d43bedd126c057db 100644
--- a/ide/src/base-ui/slider/LitSlider.ts
+++ b/ide/src/base-ui/slider/LitSlider.ts
@@ -268,9 +268,17 @@ export class LitSlider extends BaseElement {
// Add a slider for input event listeners
this.litSlider?.addEventListener('input', this.inputChangeEvent);
this.litSlider?.addEventListener('change', this.inputChangeEvent);
+ this.litSlider?.addEventListener('keydown', this.inputKeyDownEvent);
this.litSliderStyle = this.sliderStyle;
}
+ // @ts-ignore
+ inputKeyDownEvent = (ev) => {
+ if (ev.key === '0' && ev.target.value.length === 1 && ev.target.value === '0') {
+ ev.preventDefault();
+ }
+ };
+
inputChangeEvent = (event: any) => {
if (this.litSlider) {
this.currentValue = parseInt(this.litSlider?.value);
@@ -293,6 +301,7 @@ export class LitSlider extends BaseElement {
disconnectedCallback() {
this.litSlider?.removeEventListener('input', this.inputChangeEvent);
this.litSlider?.removeEventListener('change', this.inputChangeEvent);
+ this.litSlider?.removeEventListener('change', this.inputKeyDownEvent);
}
adoptedCallback() {}
diff --git a/ide/src/base-ui/table/LitPageTable.ts b/ide/src/base-ui/table/LitPageTable.ts
index dc147693c2ab1ed9b27ffdc733ef62a2a205eff4..93876573cc6af2c544e6bbd3c219b0b691cee4e8 100644
--- a/ide/src/base-ui/table/LitPageTable.ts
+++ b/ide/src/base-ui/table/LitPageTable.ts
@@ -424,6 +424,10 @@ export class LitPageTable extends BaseElement {
:host([hideDownload]) .export{
display: none;
}
+ .td::-webkit-scrollbar {
+ width: 0;
+ background-color: transparent;
+ }
@@ -1274,7 +1278,7 @@ export class LitPageTable extends BaseElement {
let td: any;
td = document.createElement('div');
td.classList.add('td');
- td.style.overflow = 'hidden';
+ td.style.overflow = 'scroll hidden';
td.style.textOverflow = 'ellipsis';
td.style.whiteSpace = 'nowrap';
td.dataIndex = dataIndex;
diff --git a/ide/src/index.html b/ide/src/index.html
index fc79a7f22c5efe2c8a15c6d428fabe31f2b3b1ab..370f725d06731899f00321a5acb48f6c87ca0039 100644
--- a/ide/src/index.html
+++ b/ide/src/index.html
@@ -1,6 +1,6 @@
-
+
Trace Example
@@ -121,7 +144,7 @@ export class TabPaneHiLogSummary extends BaseElement {
-
+
@@ -129,20 +152,21 @@ export class TabPaneHiLogSummary extends BaseElement {
`;
}
- connectedCallback() {
+ connectedCallback(): void {
super.connectedCallback();
- new ResizeObserver(() => {
+ new ResizeObserver((): void => {
+ this.parentElement!.style.overflow = 'hidden';
this.refreshRowNodeTable();
}).observe(this.parentElement!);
this.expansionDiv?.addEventListener('click', this.expansionClickEvent);
}
- disconnectedCallback() {
+ disconnectedCallback(): void {
super.disconnectedCallback();
this.expansionDiv?.removeEventListener('click', this.expansionClickEvent);
}
- expansionClickEvent = () => {
+ expansionClickEvent = (): void => {
this.expandedNodeList.clear();
if (this.expansionUpIcon?.name === 'down') {
this.selectTreeDepth = 0;
@@ -157,8 +181,8 @@ export class TabPaneHiLogSummary extends BaseElement {
this.refreshRowNodeTable(true);
};
- private refreshSelectDepth(logTreeNodes: LogTreeNode[]) {
- logTreeNodes.forEach((item) => {
+ private refreshSelectDepth(logTreeNodes: LogTreeNode[]): void {
+ logTreeNodes.forEach((item): void => {
if (item.depth < this.selectTreeDepth) {
this.expandedNodeList.add(item.id);
if (item.children.length > 0) {
@@ -168,25 +192,24 @@ export class TabPaneHiLogSummary extends BaseElement {
});
}
- initTabSheetEl(parentTabEl: HTMLElement) {
- this.parentTabEl = parentTabEl;
- }
-
- private createRowNodeTableEL(rowNodeList: LogTreeNode[], rowColor: string = ''): DocumentFragment {
+ private createRowNodeTableEL(rowNodeList: LogTreeNode[], tableTreeEl: HTMLDivElement, tableCountEl: HTMLDivElement, rowColor: string = ''): void {
let unitPadding: number = 20;
let leftPadding: number = 5;
- let tableFragmentEl: DocumentFragment = document.createDocumentFragment();
- rowNodeList.forEach((rowNode) => {
- let tableRowEl: HTMLElement = document.createElement('tr');
- tableRowEl.className = 'tree-row-tr';
+ rowNodeList.forEach((rowNode): void => {
+ let tableTreeRowEl: HTMLElement = document.createElement('tr');
+ tableTreeRowEl.className = 'tree-row-tr';
+ tableTreeRowEl.title = rowNode.logName + '';
let leftSpacingEl: HTMLElement = document.createElement('td');
leftSpacingEl.style.paddingLeft = `${rowNode.depth * unitPadding + leftPadding}px`;
- tableRowEl.appendChild(leftSpacingEl);
- this.addToggleIconEl(rowNode, tableRowEl);
+ tableTreeRowEl.appendChild(leftSpacingEl);
+ this.addToggleIconEl(rowNode, tableTreeRowEl);
let rowNodeTextEL: HTMLElement = document.createElement('td');
- rowNodeTextEL.textContent = rowNode.logName!;
+ rowNodeTextEL.textContent = rowNode.logName + '';
rowNodeTextEL.className = 'row-name-td';
- tableRowEl.appendChild(rowNodeTextEL);
+ tableTreeRowEl.appendChild(rowNodeTextEL);
+ tableTreeEl.appendChild(tableTreeRowEl);
+ let tableCountRowEl: HTMLElement = document.createElement('tr');
+ tableCountRowEl.title = rowNode.count.toString();
let countEL: HTMLElement = document.createElement('td');
countEL.textContent = rowNode.count.toString();
countEL.className = 'count-column-td';
@@ -197,14 +220,12 @@ export class TabPaneHiLogSummary extends BaseElement {
rowNodeTextEL.style.color = rowColor;
countEL.style.color = rowColor;
}
- tableRowEl.appendChild(countEL);
- tableFragmentEl.appendChild(tableRowEl);
+ tableCountRowEl.appendChild(countEL);
+ tableCountEl.appendChild(tableCountRowEl);
if (rowNode.children && this.expandedNodeList.has(rowNode.id)) {
- let documentFragment = this.createRowNodeTableEL(rowNode.children, countEL.style.color);
- tableFragmentEl.appendChild(documentFragment);
+ this.createRowNodeTableEL(rowNode.children, tableTreeEl, tableCountEl, countEL.style.color);
}
});
- return tableFragmentEl;
}
private addToggleIconEl(rowNode: LogTreeNode, tableRowEl: HTMLElement): void {
@@ -216,7 +237,7 @@ export class TabPaneHiLogSummary extends BaseElement {
// @ts-ignore
expandIcon.name = this.expandedNodeList.has(rowNode.id) ? 'minus-square' : 'plus-square';
toggleIconEl.classList.add('expand-icon');
- toggleIconEl.addEventListener('click', () => {
+ toggleIconEl.addEventListener('click', (): void => {
let scrollTop = this.logSummaryTable?.scrollTop ?? 0;
this.changeNode(rowNode.id);
this.logSummaryTable!.scrollTop = scrollTop;
@@ -236,8 +257,8 @@ export class TabPaneHiLogSummary extends BaseElement {
private refreshRowNodeTable(useCacheRefresh: boolean = false): void {
this.logSummaryTable!.innerHTML = '';
- if (this.logSummaryTable && this.parentTabEl) {
- this.logSummaryTable.style.height = `${this.parentTabEl!.clientHeight - 30}px`;
+ if (this.logSummaryTable && this.parentElement) {
+ this.logSummaryTable.style.height = `${this.parentElement!.clientHeight - 30}px`;
}
if (!useCacheRefresh) {
this.logTreeNodes = this.buildTreeTblNodes(this.systemLogSource);
@@ -247,8 +268,17 @@ export class TabPaneHiLogSummary extends BaseElement {
this.summaryDownLoadTbl!.recycleDataSource = [];
}
}
- let fragment = this.createRowNodeTableEL(this.logTreeNodes);
- this.logSummaryTable!.appendChild(fragment);
+ let tableFragmentEl: DocumentFragment = document.createDocumentFragment();
+ let tableTreeEl: HTMLDivElement = document.createElement('div');
+ tableTreeEl.className = 'log-tree-table';
+ let tableCountEl: HTMLDivElement = document.createElement('div');
+ if (this.parentElement) {
+ tableTreeEl.style.height = `${this.parentElement!.clientHeight - 40}px`;
+ }
+ this.createRowNodeTableEL(this.logTreeNodes, tableTreeEl, tableCountEl, '');
+ tableFragmentEl.appendChild(tableTreeEl);
+ tableFragmentEl.appendChild(tableCountEl);
+ this.logSummaryTable!.appendChild(tableFragmentEl);
}
private buildTreeTblNodes(logTreeNodes: LogStruct[]): LogTreeNode[] {
diff --git a/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts b/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts
index 7ed87405ffbed34984bc5ac3f8eee84da004f8ac..9d235f3c9cce0f1a04b5ba142d88ce63730c9826 100644
--- a/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts
+++ b/ide/src/trace/component/trace/sheet/hilog/TabPaneHiLogs.ts
@@ -71,7 +71,7 @@ export class TabPaneHiLogs extends BaseElement {
this.hiLogsTbl!.itemTextHandleMap.set('startTs', (startTs) => {
return ns2Timestamp(startTs);
});
- this.hiLogsTbl!.addEventListener('row-hover', (e)=>{
+ this.hiLogsTbl!.addEventListener('row-hover', (e): void=>{
// @ts-ignore
let data = e.detail.data;
if (data) {
@@ -85,22 +85,36 @@ export class TabPaneHiLogs extends BaseElement {
this.traceSheetEl!.systemLogFlag = new Flag(Math.floor(pointX), 0, 0, 0, data.startTs!, '#999999', true, '');
this.spSystemTrace?.refreshCanvas(false);
}
- })
+ });
let tbl = this.hiLogsTbl?.shadowRoot?.querySelector('.table');
tbl!.addEventListener('scroll', ()=>{
this.tableTitleTimeHandle?.();
- })
+ });
+ this.tagFilterDiv!.onclick = (ev): void => {
+ // @ts-ignore
+ let parentNode = ev.target.parentNode;
+ if (parentNode && this.tagFilterDiv!.contains(parentNode)) {
+ this.tagFilterDiv!.removeChild(parentNode);
+ this.allowTag['delete'](parentNode.textContent.trim().toLowerCase());
+ }
+ this.tableTimeHandle?.();
+ };
+ this.searchFilterInput!.oninput = (): void => {
+ this.tableTimeHandle?.();
+ };
+ this.processFilter!.oninput = (): void => {
+ this.tableTimeHandle?.();
+ };
+ this.levelFilterInput!.onchange = (): void => {
+ this.tableTimeHandle?.();
+ };
}
connectedCallback(): void {
super.connectedCallback();
- this.tagFilterInput?.addEventListener('input', this.tagFilterInputEvent);
this.tagFilterInput?.addEventListener('keydown', this.tagFilterKeyEvent);
- this.tagFilterDiv?.addEventListener('click', this.tagFilterDivClickEvent);
- this.searchFilterInput?.addEventListener('input', this.searchFilterInputEvent);
- this.processFilter?.addEventListener('input', this.processFilterEvent);
- this.levelFilterInput?.addEventListener('change', this.levelFilterInputEvent);
- new ResizeObserver(() => {
+ new ResizeObserver((): void => {
+ this.parentElement!.style.overflow = 'hidden';
// @ts-ignore
this.hiLogsTbl?.shadowRoot?.querySelector('.table').style.height = this.parentElement.clientHeight - 20 - 45 + 'px';
this.tableTimeHandle?.();
@@ -110,12 +124,7 @@ export class TabPaneHiLogs extends BaseElement {
disconnectedCallback(): void {
super.disconnectedCallback();
- this.tagFilterInput?.removeEventListener('input', this.tagFilterInputEvent);
this.tagFilterInput?.removeEventListener('keydown', this.tagFilterKeyEvent);
- this.tagFilterDiv?.removeEventListener('click', this.tagFilterDivClickEvent);
- this.searchFilterInput?.removeEventListener('input', this.searchFilterInputEvent);
- this.processFilter?.removeEventListener('input', this.processFilterEvent);
- this.levelFilterInput?.removeEventListener('change', this.levelFilterInputEvent);
}
initHtml(): string {
@@ -176,7 +185,7 @@ export class TabPaneHiLogs extends BaseElement {
allTdEl[0].style.color = '#3D88C7';
allTdEl[0].style.textDecoration = 'underline';
allTdEl[0].style.textDecorationColor = '#3D88C7';
- trEl.addEventListener('mouseout', () => {
+ trEl.addEventListener('mouseout', (): void => {
this.traceSheetEl!.systemLogFlag = undefined;
this.spSystemTrace?.refreshCanvas(false);
})
@@ -190,7 +199,7 @@ export class TabPaneHiLogs extends BaseElement {
}
let tableHeight = Number(tbl!.style.height.replace('px', '')) - tableHeadHeight;
while (height < tableHeight) {
- if (height + firstRowHeight > tableHeight) {
+ if (firstRowHeight <= 0 || height + firstRowHeight > tableHeight) {
break;
}
height += firstRowHeight;
@@ -215,25 +224,12 @@ export class TabPaneHiLogs extends BaseElement {
this.traceSheetEl = traceSheet;
this.levelFilterInput!.selectedIndex = 0;
this.tagFilterInput!.value = '';
- this.tagFilterInput!.placeholder = 'Filter by tag...';
this.tagFilterDiv!.innerHTML = '';
this.allowTag.clear();
this.processFilter!.value = '';
- this.processFilter!.placeholder = 'Search process name...';
this.searchFilterInput!.value = '';
- this.searchFilterInput!.placeholder = 'Search message...';
}
- tagFilterInputEvent = (): void => {
- if (this.tagFilterInput) {
- if (this.tagFilterInput.value === '') {
- this.tagFilterInput.placeholder = 'Filter by tag...';
- } else {
- this.tagFilterInput.placeholder = '';
- }
- }
- };
-
tagFilterKeyEvent = (e: KeyboardEvent): void => {
let inputValue = this.tagFilterInput!.value.trim();
if (e.code === 'Enter') {
@@ -265,42 +261,6 @@ export class TabPaneHiLogs extends BaseElement {
this.tableTimeHandle?.();
};
- tagFilterDivClickEvent = (ev: Event): void => {
- // @ts-ignore
- let parentNode = ev.target.parentNode;
- if (parentNode && this.tagFilterDiv!.contains(parentNode)) {
- this.tagFilterDiv!.removeChild(parentNode);
- this.allowTag['delete'](parentNode.textContent.trim().toLowerCase());
- }
- this.tableTimeHandle?.();
- };
-
- searchFilterInputEvent = (): void => {
- if (this.searchFilterInput) {
- if (this.searchFilterInput.value === '') {
- this.searchFilterInput.placeholder = 'Search message...';
- } else {
- this.searchFilterInput.placeholder = '';
- }
- }
- this.tableTimeHandle?.();
- };
-
- processFilterEvent = (): void => {
- if (this.processFilter) {
- if (this.processFilter.value === '') {
- this.processFilter.placeholder = 'Search process name...';
- } else {
- this.processFilter.placeholder = '';
- }
- }
- this.tableTimeHandle?.();
- };
-
- levelFilterInputEvent = (): void => {
- this.tableTimeHandle?.();
- };
-
private updateFilterData(): void {
if (this.systemLogSource?.length > 0) {
this.filterData = this.systemLogSource.filter((data) => this.isFilterLog(data));
diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPerfBinaryTree.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPerfBinaryTree.ts
deleted file mode 100644
index 78c8b033bb8c8b42808d66ac2ff69327a706a498..0000000000000000000000000000000000000000
--- a/ide/src/trace/component/trace/sheet/hiperf/TabPerfBinaryTree.ts
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { BaseElement, element } from '../../../../../base-ui/BaseElement.js';
-import { SelectionParam } from '../../../../bean/BoxSelection.js';
-import { procedurePool } from '../../../../database/Procedure.js';
-
-@element('tabpane-perf-svg')
-export class TabpanePerfBinaryTree extends BaseElement {
- private svgElement: SVGSVGElement | undefined;
- private binaryTreeDate: any;
- private nodeWidth: number = 100;
- private nodeHeight: number = 50;
- private nodeGap: number | undefined;
- private pathOffset: number = 30;
- private arrowSize: number = 6;
- private searchValue: string = '';
- private currentSelection: SelectionParam | undefined;
-
- set data(perfProfilerSelection: SelectionParam | any) {
- if (perfProfilerSelection === this.currentSelection) {
- return;
- }
- this.searchValue = '';
- this.currentSelection = perfProfilerSelection;
- this.nodeGap = 100;
- this.getDataByWorker(
- [
- {
- funcName: 'setSearchValue',
- funcArgs: [''],
- },
- {
- funcName: 'getCurrentDataFromDb',
- funcArgs: [perfProfilerSelection],
- },
- ],
- (results: any[]) => {
- // console.log(results,'111');
- this.binaryTreeDate = results;
- this.draw();
- }
- );
- }
-
- initElements(): void {
- this.svgElement = this.shadowRoot?.querySelector('#binaryTreeSvg') as SVGSVGElement;
-
- }
-
- getDataByWorker(args: any[], handler: Function) {
- procedurePool.submitWithName('logic0', 'perf-action', args, undefined, (results: any) => {
- handler(results);
-
- });
- }
-
- private draw(): void {
- if (!this.binaryTreeDate) return;
- //清空SVG
- while (this.svgElement?.firstChild) {
- this.svgElement.firstChild.remove();
- }
-
- //计算树的高度和每层节点数量
- const treeWidth = this.getTreeWidth(this.binaryTreeDate);
- const treeHeight = this.getTreeHeight(this.binaryTreeDate);
-
- //计算根节点的位置
- const rootX = (this.svgElement!.clientWidth - this.nodeWidth) / 2;
- // console.log(this.svgElement!.clientWidth,'svg可视宽度');
-
- const rootY = this.nodeGap!;
-
- //绘制根节点
- const rootNode = this.createNode(rootX, rootY, this.binaryTreeDate);
- this.svgElement!.appendChild(rootNode);
-
- //绘制子节点和连线
- this.drawChildren(this.binaryTreeDate, rootX, rootY, treeWidth, treeHeight, 0, 0);
- }
-
- private drawChildren(
- nodeData: any,
- parentX: number,
- parentY: number,
- treeWidth: number,
- treeHeight: number,
- level: number,
- index: number
- ): void {
- if (nodeData.length === 0) return;
-
- //计算子节点的位置
- const startX = parentX - (treeWidth / 2) + (this.nodeWidth + this.nodeGap!) * index;
- const startY = parentY + this.nodeHeight + this.nodeGap!;
-
- //循环遍历子节点
- for (let i = 0; i < nodeData.length; i++) {
- //计算子节点的x坐标
- const childX = startX + (this.nodeWidth + this.nodeGap!) * i;
- const childNode = this.createNode(childX, startY, nodeData[i]);
- this.svgElement!.appendChild(childNode);
-
- //绘制连线
- const pathStartX = parentX + this.nodeWidth / 2;
- const pathStartY = parentY + this.nodeHeight;
- const pathEndX = childX + this.nodeWidth / 2;
- const pathEndY = startY;
- const pathControlX = (pathStartX + pathEndX) / 2;
- const pathControlY = pathStartY + this.pathOffset;
- const path = this.createPath(pathStartX, pathStartY, pathControlX, pathControlY, pathEndX, pathEndY);
- this.svgElement!.appendChild(path);
-
- //绘制箭头
- const arrow = this.createArrow(pathEndX, pathEndY);
- this.svgElement!.appendChild(arrow);
-
- // 递归绘制子节点的子节点
- this.drawChildren(nodeData[i].children, childX, startY, treeWidth, treeHeight, level + 1, i);
- }
- }
-
- private createNode(x: number, y: number, data: any): SVGElement {
- const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
-
- const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
- rect.setAttribute("x", x.toString());
- rect.setAttribute("y", y.toString());
- rect.setAttribute("width", this.nodeWidth.toString());
- rect.setAttribute("height", this.nodeHeight.toString());
- rect.setAttribute("fill", "#f5c78e");
- rect.setAttribute("stroke", "#000000");
- group.appendChild(rect);
-
- const foreignObject = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
- foreignObject.setAttribute("x", (x + 5).toString());
- foreignObject.setAttribute("y", (y + 5).toString());
- foreignObject.setAttribute("width", (this.nodeWidth - 10).toString());
- foreignObject.setAttribute("height", (this.nodeHeight - 10).toString());
-
- const div = document.createElement("div");
- div.style.width = "100%";
- div.style.height = "100%";
- div.style.whiteSpace = "nowrap";
- div.style.textOverflow = "ellipsis";
- div.style.overflow = "hidden";
- div.textContent = `${data.symbol}`;
- foreignObject.appendChild(div);
-
- group.appendChild(foreignObject);
-
- return group;
- }
-
-
- private createPath(x1: number, y1: number, cx: number, cy: number, x2: number, y2: number): SVGElement {
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
- path.setAttribute("d", `M ${x1},${y1} Q ${cx},${cy} ${x2},${y2 - this.arrowSize}`);
- path.setAttribute("fill", "none");
- path.setAttribute("stroke", "#000000");
-
- return path;
- }
-
- private createArrow(x: number, y: number): SVGElement {
- const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path");
- arrow.setAttribute(
- "d",
- `M ${x - this.arrowSize / 2},${y - this.arrowSize} L ${x + this.arrowSize / 2},${y - this.arrowSize} L ${x},${y + this.arrowSize / 2} Z`
- );
- arrow.setAttribute("fill", "#000000");
-
- return arrow;
- }
-
-
- private getTreeWidth(nodeData: any): number {
- if (nodeData.length === 0) return this.nodeWidth;
-
- const childrenCount = nodeData.length;
- return childrenCount * (this.nodeWidth + this.nodeGap!) - this.nodeGap!;
- }
-
- private getTreeHeight(nodeData: any): number {
- if (nodeData.length === 0) return this.nodeHeight;
-
- let maxHeight = 0;
- const childrenCount = nodeData.length;
-
- for (let i = 0; i < childrenCount; i++) {
- //递归计算所有子节点高度
- const childHeight = this.getTreeHeight(nodeData[i]);
- if (childHeight > maxHeight) {
- maxHeight = childHeight;
-
- }
- }
-
- return this.nodeHeight + this.nodeGap! + maxHeight;
- }
-
- initHtml(): string {
- return `
-
-
-
`;
- }
-}
diff --git a/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts b/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts
index 98a48f761bd9ba910b209aa805e921ddc239f65d..b14aebbc8ceb20c13165cb388af07cf73e79c40f 100644
--- a/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts
+++ b/ide/src/trace/component/trace/sheet/hiperf/TabPerfProfile.ts
@@ -67,21 +67,20 @@ export class TabpanePerfProfile extends BaseElement {
this.perfProfilerFilter!.style.display = 'none';
}
this.perfProfilerFilter!.disabledTransfer(false, 'perf');
- this.perfProfilerFilter!.getTransferList();
this.perfProfilerFilter!.initializeFilterTree(true, true, true);
this.perfProfilerFilter!.filterValue = '';
+ this.perfProfilerFilter!.refreshTreeTransfer();
this.perfProfileProgressEL!.loading = true;
this.perfProfileLoadingPage.style.visibility = 'visible';
this.getDataByWorkAndUpDateCanvas(perfProfilerSelection);
}
- getDataByWorkAndUpDateCanvas(perfProfilerSelection: SelectionParam) {
+ getDataByWorkAndUpDateCanvas(perfProfilerSelection: SelectionParam):void {
const initWidth = this.clientWidth;
this.initGetData(perfProfilerSelection, initWidth);
-
-
this.perfProfilerFilter!.getCallTransferData((data: any) => {
- this.initGetData(perfProfilerSelection, initWidth, data.eventTypeId);
+ const eventTypeId = data.value !== 'count' ? data.value : undefined;
+ this.initGetData(perfProfilerSelection, initWidth, eventTypeId);
});
}
@@ -91,7 +90,7 @@ export class TabpanePerfProfile extends BaseElement {
perfProfileArgs.push({
funcName: 'setEventTypeId',
funcArgs: [eventTypeId !== 'count' ? eventTypeId : undefined],
- })
+ });
}
perfProfileArgs.push(
{
@@ -101,7 +100,8 @@ export class TabpanePerfProfile extends BaseElement {
{
funcName: 'getCurrentDataFromDb',
funcArgs: [perfProfilerSelection],
- })
+ }
+ );
this.getDataByWorker(perfProfileArgs, (results: any[]) => {
this.setPerfProfilerLeftTableData(results);
@@ -116,8 +116,7 @@ export class TabpanePerfProfile extends BaseElement {
this.perfProfileFrameChart!.data = this.perfProfilerDataSource;
this.switchFlameChart();
this.perfProfilerFilter!.icon = 'block';
- })
-
+ });
}
getParentTree(
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 2ab7e98f70669b809487d4ca681b5126ebc971d8..490b8ec68419534b9cb2fb4f44a860b335b22117 100644
--- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts
+++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree.ts
@@ -26,14 +26,12 @@ import { FileMerageBean } from '../../../../database/logic-worker/ProcedureLogic
import { queryNativeHookSubType, queryNativeHookStatisticSubType } from '../../../../database/SqlLite.js';
import { ParseExpression } from '../SheetUtils.js';
import { NativeMemoryExpression } from '../../../../bean/NativeHook.js';
-import { findSearchNode } from '../../../../database/ui-worker/ProcedureWorkerCommon.js';
@element('tabpane-nm-calltree')
export class TabpaneNMCalltree extends BaseElement {
private nmCallTreeTbl: LitTable | null | undefined;
private filesystemTbr: LitTable | null | undefined;
private nmCallTreeProgressEL: LitProgressBar | null | undefined;
- private rightSource: Array = [];
private nmCallTreeFilter: any;
private nmCallTreeSource: any[] = [];
private native_type: Array = ['All Heap & Anonymous VM', 'All Heap', 'All Anonymous VM'];
@@ -59,7 +57,6 @@ export class TabpaneNMCalltree extends BaseElement {
private lastIsExpression = false;
private currentNMCallTreeFilter: TabPaneFilter | undefined | null;
private expressionStruct: NativeMemoryExpression | null = null;
- private currentNmCallTreeSource: Array = [];
set data(nmCallTreeParam: SelectionParam | any) {
if (nmCallTreeParam == this.currentSelection) {
@@ -119,7 +116,6 @@ export class TabpaneNMCalltree extends BaseElement {
this.nmCallTreeFrameChart!.mode = ChartMode.Byte;
this.nmCallTreeFrameChart?.updateCanvas(true, initWidth);
this.nmCallTreeFrameChart!.data = this.nmCallTreeSource;
- this.currentNmCallTreeSource = this.nmCallTreeSource;
this.switchFlameChart();
this.nmCallTreeFilter.icon = 'block';
}
@@ -188,7 +184,6 @@ export class TabpaneNMCalltree extends BaseElement {
data.libName.endsWith('.so.1') || data.libName.endsWith('.dll') || data.libName.endsWith('.so') ? 0 : 1;
}
let resultLength = resultValue.length;
- this.rightSource = resultValue;
this.filesystemTbr!.dataSource = resultLength == 0 ? [] : resultValue;
}
@@ -237,50 +232,34 @@ export class TabpaneNMCalltree extends BaseElement {
addSubType(subTypeList);
}
- if (this.currentSelection!.nativeMemory.length > 0) {
- procedurePool.submitWithName('logic1', 'native-memory-get-responseType', {}, undefined, (res: any) => {
- this.responseTypes = res;
- let nullIndex = this.responseTypes.findIndex((item) => {
- return item.key == 0;
- });
- if (nullIndex != -1) {
- this.responseTypes.splice(nullIndex, 1);
- }
- this.currentNMCallTreeFilter!.setSelectList(
- null,
- secondFilterList,
- 'Allocation Lifespan',
- 'Allocation Type',
- this.responseTypes.map((item: any) => {
- return item.value;
- })
- );
- this.currentNMCallTreeFilter!.setFilterModuleSelect('#first-select', 'width', '150px');
- this.currentNMCallTreeFilter!.setFilterModuleSelect('#second-select', 'width', '150px');
- this.currentNMCallTreeFilter!.setFilterModuleSelect('#third-select', 'width', '150px');
- this.currentNMCallTreeFilter!.firstSelect = '0';
- this.currentNMCallTreeFilter!.secondSelect = '0';
- this.currentNMCallTreeFilter!.thirdSelect = '0';
- this.filterAllocationType = '0';
- this.filterNativeType = '0';
- this.filterResponseSelect = '0';
- this.filterResponseType = -1;
+ procedurePool.submitWithName('logic1', 'native-memory-get-responseType', {}, undefined, (res: any) => {
+ this.responseTypes = res;
+ let nullIndex = this.responseTypes.findIndex((item) => {
+ return item.key == 0;
});
- } else {
+ if (nullIndex != -1) {
+ this.responseTypes.splice(nullIndex, 1);
+ }
this.currentNMCallTreeFilter!.setSelectList(
null,
secondFilterList,
'Allocation Lifespan',
'Allocation Type',
- undefined
+ this.responseTypes.map((item: any) => {
+ return item.value;
+ })
);
this.currentNMCallTreeFilter!.setFilterModuleSelect('#first-select', 'width', '150px');
this.currentNMCallTreeFilter!.setFilterModuleSelect('#second-select', 'width', '150px');
+ this.currentNMCallTreeFilter!.setFilterModuleSelect('#third-select', 'width', '150px');
this.currentNMCallTreeFilter!.firstSelect = '0';
this.currentNMCallTreeFilter!.secondSelect = '0';
+ this.currentNMCallTreeFilter!.thirdSelect = '0';
this.filterAllocationType = '0';
this.filterNativeType = '0';
- }
+ this.filterResponseSelect = '0';
+ this.filterResponseType = -1;
+ });
}
initElements(): void {
@@ -648,7 +627,7 @@ export class TabpaneNMCalltree extends BaseElement {
if (this.expressionStruct) {
groupArgs.set('filterExpression', this.expressionStruct);
groupArgs.set('filterResponseType', -1);
- this.currentNMCallTreeFilter!.thirdSelect = this.currentSelection!.nativeMemoryStatistic.length > 0 ? '' : '0';
+ this.currentNMCallTreeFilter!.thirdSelect = '0';
} else {
groupArgs.set('filterResponseType', this.filterResponseType);
}
@@ -834,6 +813,7 @@ export class TabpaneNMCalltree extends BaseElement {
z-index: 999999;
}
+
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 f25d7df9f64372abe729e71470681d4b86a451fb..6f9b782a8bf4ded8cd0e6f1488ae15b19bcc45e7 100644
--- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts
+++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatisticAnalysis.ts
@@ -122,6 +122,9 @@ export class TabPaneNMStatisticAnalysis extends BaseElement {
this.eventTypeData.shift(this.typeStatisticsData);
return;
}
+ if (statisticAnalysisParam.nativeMemoryStatistic.length > 0) {
+ Utils.getInstance().initResponseTypeList(statisticAnalysisParam);
+ }
// @ts-ignore
this.tableType?.shadowRoot?.querySelector('.table').style.height = this.parentElement.clientHeight - 30 + 'px';
// @ts-ignore
diff --git a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts
index 1a47327a1f9ed342bf1440bdc121af936f3236a1..35577c37faf8000a7b81f05b90ab9259b5051ace 100644
--- a/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts
+++ b/ide/src/trace/component/trace/sheet/native-memory/TabPaneNMStatstics.ts
@@ -17,7 +17,6 @@ import { BaseElement, element } from '../../../../../base-ui/BaseElement.js';
import { LitTable } from '../../../../../base-ui/table/lit-table.js';
import { SelectionParam } from '../../../../bean/BoxSelection.js';
import {
- queryNativeHookResponseTypes,
queryNativeHookStatistics,
queryNativeHookStatisticsMalloc,
queryNativeHookStatisticsSubType,
@@ -51,7 +50,9 @@ export class TabPaneNMStatstics extends BaseElement {
SpNativeMemoryChart.EVENT_HEAP.map((heap) => {
this.allMax += heap.sumHeapSize;
});
- this.initResponseTypeList(nativeStatisticsParam);
+ if (nativeStatisticsParam.nativeMemory.length > 0) {
+ Utils.getInstance().initResponseTypeList(nativeStatisticsParam);
+ }
// @ts-ignore
this.nativeStatisticsTbl?.shadowRoot.querySelector('.table').style.height =
this.parentElement!.clientHeight - 25 + 'px';
@@ -138,24 +139,6 @@ export class TabPaneNMStatstics extends BaseElement {
});
}
- initResponseTypeList(val: SelectionParam | any) {
- let types: Array = [];
- if (val.nativeMemory.indexOf('All Heap & Anonymous VM') != -1) {
- types.push("'AllocEvent'");
- types.push("'MmapEvent'");
- } else {
- if (val.nativeMemory.indexOf('All Heap') != -1) {
- types.push("'AllocEvent'");
- }
- if (val.nativeMemory.indexOf('All Anonymous VM') != -1) {
- types.push("'MmapEvent'");
- }
- }
- queryNativeHookResponseTypes(val.leftNs, val.rightNs, types).then((res) => {
- procedurePool.submitWithName('logic1', 'native-memory-init-responseType', res, undefined, () => {});
- });
- }
-
setMemoryTypeData(val: SelectionParam, result: Array, arr: Array) {
let all: NativeHookStatisticsTableData | null = null;
let heap: NativeHookStatisticsTableData | null = null;
diff --git a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts
index c050252ad7eb675d51b44c0911e18d449a2697f0..7b9bb689dc4eabc8dfef9e4c3b2378e677c71b99 100644
--- a/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts
+++ b/ide/src/trace/component/trace/sheet/task/TabPaneTaskFrames.ts
@@ -281,24 +281,11 @@ export class TabPaneTaskFrames extends BaseElement {
}
static getExecuteId(funName: string): string {
- let strArray = funName.split(',');
- let executeStr = '';
- let executeId = '';
- let endStr = '';
- if (strArray.length >= 2) {
- executeStr = strArray[1];
- if (funName.indexOf(ALLOCATION_TASK) >= 0 || funName.indexOf(PERFORM_TASK) >= 0) {
- executeId = executeStr.split(':')[1].trim();
- } else if (funName.indexOf(END_TASK) >= 0) {
- endStr = executeStr.split(':')[1].trim();
- if (endStr.indexOf('[') >= 0) {
- executeId = endStr.substring(0, endStr.indexOf('['));
- } else {
- executeId = endStr;
- }
- }
+ const executeIdMatch = funName.match(/executeId\s*:\s*(\d+)/i);
+ if (executeIdMatch && executeIdMatch.length > 1) {
+ return executeIdMatch[1];
}
- return executeId;
+ return '';
}
static getPriorityId(funName: string): number {
diff --git a/ide/src/trace/database/SqlLite.ts b/ide/src/trace/database/SqlLite.ts
index c0852e003f09cda89922795a81430cf8f2e3b328..6ee980f1d694d5cd4ac2304989923ce6d14aeb43 100644
--- a/ide/src/trace/database/SqlLite.ts
+++ b/ide/src/trace/database/SqlLite.ts
@@ -296,8 +296,8 @@ export class DbPool {
}
}
};
- thread!.onmessageerror = (e) => { };
- thread!.onerror = (e) => { };
+ thread!.onmessageerror = (e) => {};
+ thread!.onerror = (e) => {};
thread!.id = i;
thread!.busy = false;
this.works?.push(thread!);
@@ -1271,7 +1271,8 @@ export const queryVirtualMemory = (): Promise> =>
export const queryVirtualMemoryData = (filterId: number): Promise> =>
query(
'queryVirtualMemoryData',
- `select ts-${(window as any).recordStartNS
+ `select ts-${
+ (window as any).recordStartNS
} as startTime,value,filter_id as filterID from sys_mem_measure where filter_id=$filter_id`,
{ $filter_id: filterId }
);
@@ -1690,23 +1691,28 @@ export const queryAllHookData = (rightNs: number): Promise
-): Promise> =>
- query(
+ types: Array,
+ isStatistic: boolean
+): Promise> => {
+ const table = isStatistic ? 'native_hook_statistic' : 'native_hook';
+ const tsKey = isStatistic ? 'ts' : 'start_ts';
+ const type = isStatistic ? 'type' : 'event_type';
+ return query(
'queryNativeHookResponseTypes',
`
- select
- distinct last_lib_id as lastLibId,
- data_dict.data as value
- from
- native_hook A ,trace_range B
- left join data_dict on A.last_lib_id = data_dict.id
- where
- A.start_ts - B.start_ts
- between ${leftNs} and ${rightNs} and A.event_type in (${types.join(',')});
- `,
+ select
+ distinct last_lib_id as lastLibId,
+ data_dict.data as value
+ from
+ ${table} A ,trace_range B
+ left join data_dict on A.last_lib_id = data_dict.id
+ where
+ A.${tsKey} - B.start_ts
+ between ${leftNs} and ${rightNs} and A.${type} in (${types.join(',')});
+ `,
{ $leftNs: leftNs, $rightNs: rightNs, $types: types }
);
+};
/**
* HiPerf
*/
@@ -3838,9 +3844,11 @@ export const queryEbpfSamplesCount = (startTime: number, endTime: number, ipids:
select
fsCount,
vmCount from
-(select count(1) as fsCount from file_system_sample s,trace_range t where s.end_ts between $startTime + t.start_ts and $endTime + t.start_ts ${ipids.length > 0 ? `and s.ipid in (${ipids.join(',')})` : ''
+(select count(1) as fsCount from file_system_sample s,trace_range t where s.end_ts between $startTime + t.start_ts and $endTime + t.start_ts ${
+ ipids.length > 0 ? `and s.ipid in (${ipids.join(',')})` : ''
})
-,(select count(1) as vmCount from paged_memory_sample s,trace_range t where s.end_ts between $startTime + t.start_ts and $endTime + t.start_ts ${ipids.length > 0 ? `and s.ipid in (${ipids.join(',')})` : ''
+,(select count(1) as vmCount from paged_memory_sample s,trace_range t where s.end_ts between $startTime + t.start_ts and $endTime + t.start_ts ${
+ ipids.length > 0 ? `and s.ipid in (${ipids.join(',')})` : ''
});
`,
{ $startTime: startTime, $endTime: endTime }
@@ -5492,7 +5500,7 @@ export const queryTraceType = (): Promise<
export const queryTransferList = (): Promise> =>
query('queryTransferList', `select id, report_value as cmdStr from perf_report where report_type = 'config_name'`);
-export const getTabRunningPercent = (tIds: Array, leftNS: number, rightNS: number): Promise> =>
+ export const getTabRunningPercent = (tIds: Array, leftNS: number, rightNS: number): Promise> =>
query(
'getTabRunningPercent',
`
@@ -5513,7 +5521,7 @@ export const getTabRunningPercent = (tIds: Array, leftNS: number, rightN
{ $leftNS: leftNS, $rightNS: rightNS }
);
-export const querySearchFuncData = (funcName: string, tIds: number, leftNS: number, rightNS: number): Promise> =>
+export const querySearchFuncData = (funcName: string, tIds: Array, leftNS: number, rightNS: number): Promise> =>
query(
'querySearchFuncData',
`
@@ -5580,4 +5588,4 @@ export const queryCpuFreqFilterId = (): Promise> =>
or
name='cpu_frequency'
`
- );
\ No newline at end of file
+ );
diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
index 285735beeea55582f91c611e3e4f06c91d770827..578e4fee2ee156c7f779e84387af37f523192b7f 100644
--- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
+++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
@@ -37,25 +37,6 @@ export class Msg {
data: Array = [];
}
-export class hiperfSymbol {
- id: number = 0;
- startTime: number = 0;
- endTime: number = 0;
- cpu_id: number = 0;
- depth: number = 0;
- children?: Array;
- callchain_id: number = 0;
- thread_id:number = 0;
- name:string='';
-
- public clone(): hiperfSymbol {
- const cloneSymbol = new hiperfSymbol();
- cloneSymbol.children = new Array();
- cloneSymbol.depth = this.depth;
- return cloneSymbol;
- }
-}
-
export class MerageBean extends ChartStruct {
#parentNode: MerageBean | undefined = undefined;
#total = 0;
@@ -615,9 +596,6 @@ export class DataCache {
public perfCallChainMap: Map = new Map();
public jsCallChain: Array | undefined;
public jsSymbolMap = new Map();
- public perfCallFireMap = new Map();
- public perfCallChain: Array | undefined;
- public perfSymbolMap = new Map()
public static getInstance(): DataCache {
if (!this.instance) {
diff --git a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
index c4b66c101e19fdf644a845d5f9568d89b2887fb5..75146687810bae95e8e786e72b25cd4ebcd9abbe 100644
--- a/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
+++ b/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
@@ -13,9 +13,8 @@
* limitations under the License.
*/
-import { LogicHandler, ChartStruct, convertJSON, DataCache, PerfCall,hiperfSymbol } from './ProcedureLogicWorkerCommon.js';
+import { LogicHandler, ChartStruct, convertJSON, DataCache, PerfCall } from './ProcedureLogicWorkerCommon.js';
import { PerfBottomUpStruct } from '../../bean/PerfBottomUpStruct.js';
-import { hiPerfchartFrame } from '../../bean/perfStruct.js';
const systemRuleName = '/system/';
const numRuleName = '/max/min/';
@@ -37,11 +36,9 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
currentEventId: string = '';
isAnalysis: boolean = false;
isPerfBottomUp: boolean = false;
- perfCallData: any[] = [];
- eventTypeId: string = '';
+ eventTypeId?: string = '';
private dataCache = DataCache.getInstance();
- private samplesCpu = Array();
handle(data: any): void {
this.currentEventId = data.id;
@@ -51,28 +48,6 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
this.dataCache.perfCountToMs = data.params.fValue;
this.initPerfFiles();
break;
- case 'perf-fire':
- this.perfCallData = data.params
- this.initPerfFire();
- break;
- case 'perf-call-chain':
- if (!this.dataCache.perfCallChain || this.dataCache.perfCallChain.length === 0) {
- this.dataCache.perfCallChain = convertJSON(data.params.list) || [];
- this.createCallChain();
- }
- this.queryCallData(this.perfCallData);
- break;
- // 查perf_sample表并处理
- case 'perf-sample-cpu':
- // 拿到的sample的数据
- this.samplesCpu = convertJSON(data.params.list) || [];
- // 处理sample数据
- self.postMessage({
- id: data.id,
- action: data.action,
- results: this.combinePerfSampleBycallChainId(this.samplesCpu)
- });
- break;
case 'perf-queryPerfFiles':
let files = convertJSON(data.params.list) || [];
files.forEach((file: any) => {
@@ -169,29 +144,6 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
);
}
- initPerfFire() {
- this.clearAll();
- this.queryData(
- this.currentEventId,
- 'perf-call-chain',
- `select name,
- depth,
- callchain_id from perf_callchain`,
- {}
- )
- }
-
- queryCallData(data: any) {
- const sql = `SELECT id,
- callchain_id,
- timestamp_trace - start_ts AS timeTip,
- thread_id,
- cpu_id
- FROM
- perf_sample,trace_range where ${data[0] == 0 ? 'cpu_id=' : 'thread_id='}${data[1]}`;
- this.queryData(this.currentEventId!, 'perf-sample-cpu', sql, {});
- }
-
initPerfThreads() {
this.queryData(
this.currentEventId,
@@ -230,12 +182,11 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
);
}
- getCurrentDataFromDb(selectionParam: any):void {
+ getCurrentDataFromDb(selectionParam: any): void {
const cpus = selectionParam.perfAll ? [] : selectionParam.perfCpus;
const processes = selectionParam.perfAll ? [] : selectionParam.perfProcess;
const threads = selectionParam.perfAll ? [] : selectionParam.perfThread;
let filterSql = '';
- let eventTypeFilter = '';
if (cpus.length != 0 || processes.length != 0 || threads.length != 0) {
const cpuFilter = cpus.length > 0 ? `or s.cpu_id in (${cpus.join(',')}) ` : '';
const processFilter = processes.length > 0 ? `or thread.process_id in (${processes.join(',')}) ` : '';
@@ -243,7 +194,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
let arg = `${cpuFilter}${processFilter}${threadFilter}`.substring(3);
filterSql = ` and (${arg})`;
}
- eventTypeFilter = this.eventTypeId ? ` and s.event_type_id = ${this.eventTypeId}` : '';
+ const eventTypeFilter = this.eventTypeId ? ` and s.event_type_id = ${this.eventTypeId}` : '';
filterSql += eventTypeFilter;
this.queryData(
this.currentEventId,
@@ -275,125 +226,6 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
);
}
- // 将perf_sample表的数据根据callchain_id分组并赋值startTime,endTime等等
- combinePerfSampleBycallChainId(sampleList: Array) {
- let arr: any = new Array();
- let num = undefined;
- for (let i = 0; i < sampleList.length; i++) {
- // 若不是相同的callchain_id,赋值
- if (sampleList[i].callchain_id != num) {
- arr.push(new hiPrefSample());
- arr[arr.length - 1].children = new Array();
- arr[arr.length - 1].children[0] = new hiperfSymbol();
- arr[arr.length - 1].depth = -1;
- arr[arr.length - 1].name = 'name';
- arr[arr.length - 1].callchain_id = sampleList[i].callchain_id;
- arr[arr.length - 1].thread_id = sampleList[i].thread_id;
- arr[arr.length - 1].id = sampleList[i].id;
- if (i !== 0 && i !== sampleList.length - 1 && sampleList[i].callchain_id !== sampleList[i - 1].callchain_id && sampleList[i].callchain_id !== sampleList[i + 1].callchain_id) {
- arr[arr.length - 1].startTime = sampleList[i - 1].timeTip;
- } else {
- arr[arr.length - 1].startTime = sampleList[i].timeTip
- }
- }
- arr[arr.length - 1].endTime = sampleList[i].timeTip
- arr[arr.length - 1].totalTime = arr[arr.length - 1].endTime - arr[arr.length - 1].startTime
- num = sampleList[i].callchain_id
- }
- return this.combineChartData(arr);
- // return arr;
- }
- /**
- * 建立callChain每个函数的联系,设置depth跟children
- */
- private createCallChain(): void {
- const jsSymbolMap = this.dataCache.perfCallFireMap;
- for (const item of this.dataCache.perfCallChain!) {
- jsSymbolMap.set(item.callchain_id.toString() + item.depth, item);
- let parentSymbol = jsSymbolMap.get(item.callchain_id.toString() + (item.depth - 1));
- if (parentSymbol) {
- switch (parentSymbol.callchain_id) {
- case item.callchain_id:
- switch (parentSymbol.depth) {
- case item.depth - 1:
- parentSymbol.children = new Array();
- parentSymbol.children?.push(item)
- break;
- }
- break;
- }
- }
- }
- }
-
- combineChartData(samples: any): Array {
- let combineSample: any = [];
- // 遍历sample表查到的数据,并且为其匹配相应的callchain数据
- for (let sample of samples) {
- let stackTopSymbol = JSON.parse(JSON.stringify(this.dataCache.perfCallFireMap.get(sample.callchain_id.toString() + '0'))) || new hiperfSymbol();
- stackTopSymbol.startTime = sample.startTime;
- stackTopSymbol.endTime = sample.endTime;
- stackTopSymbol.totalTime = sample.totalTime;
- stackTopSymbol.thread_id = sample.thread_id;
- stackTopSymbol.cpu_id = sample.thread_id;
- this.setDur(stackTopSymbol)
- sample.children = new Array();
- sample.children.push(stackTopSymbol)
- // 每一项都和combineSample对比
- if (combineSample.length === 0) {
- combineSample.push(sample)
- } else {
- if (this.perfCallData[0] === 0) {
- if (combineSample[combineSample.length - 1].thread_id === sample.thread_id) {
- this.combinePerfCallData(combineSample[combineSample.length - 1], sample)
- } else { combineSample.push(sample) };
- } else {
- if (combineSample[combineSample.length - 1].cpu_id === sample.cpu_id) {
- this.combinePerfCallData(combineSample[combineSample.length - 1], sample)
- } else { combineSample.push(sample) };
- }
- }
- }
- return combineSample;
- }
-
- // 递归设置dur,startTime,endTime
- setDur(data: any) {
- if (data.children && data.children.length > 0) {
- data.children[0].totalTime = data.totalTime;
- data.children[0].startTime = data.startTime;
- data.children[0].endTime = data.endTime;
- data.children[0].thread_id = data.thread_id;
- data.children[0].cpu_id = data.cpu_id;
- this.setDur(data.children[0])
- } else {
- return
- }
- }
-
- // hiperf火焰图合并逻辑
- combinePerfCallData(data1: any, data2: any) {
- if (data1.depth === data2.depth && data1.name === data2.name) {
- data1.endTime = data2.endTime;
- data1.totalTime = data1.endTime - data1.startTime;
- if (data1.children && data1.children.length > 0 && data2.children && data2.children.length > 0) {
- if (data1.children[data1.children.length - 1].depth === data2.children[0].depth && data1.children[data1.children.length - 1].name !== data2.children[0].name) {
- data1.children.push(data2.children[0])
- } else {
- this.combinePerfCallData(data1.children[data1.children.length - 1], data2.children[0]);
- }
- } else if (data2.children && data2.children.length > 0 && (!data1.children || data1.children.length === 0)) {
- data1.endTime = data2.endTime;
- data1.totalTime = data1.endTime - data1.endTime;
- data1.children = new Array();
- data1.children.push(data2.children[0]);
- } else {
- }
- }
- else { }
- return
- }
-
clearAll() {
this.filesData = {};
this.samplesData = {};
@@ -406,6 +238,7 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
this.dataSource = [];
this.allProcess = [];
this.dataCache.clearPerf();
+ this.eventTypeId = undefined;
}
initPerfCallChainBottomUp(callChains: PerfCallChain[]) {
@@ -920,12 +753,12 @@ export class ProcedureLogicWorkerPerf extends LogicHandler {
case 'splitTree':
this.splitPerfTree(this.allProcess, item.funcArgs[0], item.funcArgs[1], item.funcArgs[2]);
break;
- case 'setEventTypeId':
- this.eventTypeId = item.funcArgs[0];
- break;
case 'setSearchValue':
this.searchValue = item.funcArgs[0];
break;
+ case 'setEventTypeId':
+ this.eventTypeId = item.funcArgs[0];
+ break;
case 'setCombineCallChain':
this.isAnalysis = true;
break;
@@ -1357,18 +1190,3 @@ export function timeMsFormat2p(ns: number) {
}
return perfResult;
}
-
-
-class hiPrefSample {
- name: string = "";
- depth: number = 0;
- callchain_id: number = 0;
- totalTime: number = 0;
- thread_id: number = 0;
- id: number = 0;
- startTime: number = 0;
- endTime: number = 0;
- timeTip: number = 0;
- cpu_id: number = 0;
- stack?: Array;
-}
\ No newline at end of file
diff --git a/ide/src/trace/database/ui-worker/ProcedureWorker.ts b/ide/src/trace/database/ui-worker/ProcedureWorker.ts
index 7ae2190c07e5c0fc5b23d65052d5555c7d5afb5f..bfeef7d29c5227d57ad61572dfb30c8b86b15ad9 100644
--- a/ide/src/trace/database/ui-worker/ProcedureWorker.ts
+++ b/ide/src/trace/database/ui-worker/ProcedureWorker.ts
@@ -56,7 +56,6 @@ import { FrameSpacingRender } from './ProcedureWorkerFrameSpacing.js';
import { JsCpuProfilerRender } from './ProcedureWorkerCpuProfiler.js';
import { SnapshotRender } from './ProcedureWorkerSnapshot.js';
import { LogRender } from './ProcedureWorkerLog.js';
-import { HiperfCallChartRender } from './ProcedureWorkerHiPerfCallChart.js';
let dataList: any = {};
let dataList2: any = {};
@@ -87,7 +86,6 @@ export let renders: any = {
'HiPerf-Group': new EmptyRender(),
monitorGroup: new EmptyRender(),
'HiPerf-Cpu': new HiperfCpuRender(),
- 'Hiperf-callchart':new HiperfCallChartRender(),
'HiPerf-Process': new HiperfProcessRender(),
'HiPerf-Thread': new HiperfThreadRender(),
'HiPerf-Report-Event': new HiperfEventRender(),
diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerCPU.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerCPU.ts
index 8884cf98d8b7c7db1b405abdeb5f4e6824350b09..7bb0d61b57bd7cfc57e19623f136ea53faaeed86 100644
--- a/ide/src/trace/database/ui-worker/ProcedureWorkerCPU.ts
+++ b/ide/src/trace/database/ui-worker/ProcedureWorkerCPU.ts
@@ -373,9 +373,7 @@ export class CpuStruct extends BaseStruct {
}
}
if (data.nofinish && width > 4) {
- ctx.fillStyle = ColorUtils.funcTextColor(
- ColorUtils.colorForTid((data.processId || 0) > 0 ? data.processId || 0 : data.tid || 0)
- );
+ ctx.fillStyle = '#fff';
let ruptureWidth = 4;
let ruptureNode = 8;
ctx.moveTo(data.frame.x + data.frame.width - 1, data.frame.y);
diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.ts
deleted file mode 100644
index 53e0ff6cba4135e463962b1bad8f4f444a4519f4..0000000000000000000000000000000000000000
--- a/ide/src/trace/database/ui-worker/ProcedureWorkerHiPerfCallChart.ts
+++ /dev/null
@@ -1,202 +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 { ColorUtils } from '../../component/trace/base/ColorUtils.js';
-import {
- BaseStruct,
- type Rect,
- ns2x,
- drawString,
- Render,
- isFrameContainPoint
-} from './ProcedureWorkerCommon.js';
-import { TraceRow } from '../../component/trace/base/TraceRow.js';
-import { HiPerfThreadStruct } from './ProcedureWorkerHiPerfThread.js';
-import { hiPerfchartFrame } from '../../bean/perfStruct.js';
-
-export class HiperfCallChartRender extends Render {
- renderMainThread(req: any, row: TraceRow): void {
- let list = row.dataList;
- let filter = row.dataListCache;
- hiperf(
- list,
- filter,
- TraceRow.range!.startNS,
- TraceRow.range!.endNS,
- TraceRow.range!.totalNS,
- row.frame,
- req.useCache || !TraceRow.range!.refresh
- );
- req.context.beginPath();;
- let find = false;
- let offset = 5;
- for (let re of filter) {
- HiPerfCallChartStruct.draw(req.context, re);
- if (row.isHover) {
- if (re.endTime - re.startTime === 0 ||
- re.endTime - re.startTime == null ||
- re.endTime - re.startTime === undefined) {
- if (re.frame &&
- row.hoverX >= re.frame.x - offset &&
- row.hoverX <= re.frame.x + re.frame.width + offset &&
- row.hoverY >= re.frame.y &&
- row.hoverY <= re.frame.y + re.frame.height) {
- HiPerfCallChartStruct.hoverPerfCallCutStruct = re;
- find = true;
- }
- } else {
- if (re.frame && isFrameContainPoint(re.frame, row.hoverX, row.hoverY)) {
- HiPerfCallChartStruct.hoverPerfCallCutStruct = re;
- find = true
- }
- }
- }
- if (!find && row.isHover) {
- HiPerfCallChartStruct.hoverPerfCallCutStruct = undefined
- }
- }
- req.context.closePath();
- }
-}
-
-// 火焰图数据模板
-let padding = 1;
-export class HiPerfCallChartStruct extends BaseStruct {
- static selectStruct: HiPerfCallChartStruct | undefined;
- static hoverPerfCallCutStruct: HiPerfCallChartStruct | undefined;
- id: number = 0;
- name: string = '';
- startTime: number = 0;
- endTime: number = 0;
- depth: number = 0;
- children!: Array;
- isSelect: boolean = false;
- totalTime: number = 0;
- callchain_id:number = 0;
-
- static setPerfFrame(
- hiPerfNode: any,
- startNS: number,
- endNS: number,
- totalNS: number,
- frame: Rect
- ): void {
- let x1: number, x2: number;
- if ((hiPerfNode.startTime || 0) > startNS && (hiPerfNode.startTime || 0) < endNS) {
- x1 = ns2x(hiPerfNode.startTime || 0, startNS, endNS, totalNS, frame);
- } else {
- x1 = 0;
- }
- if (
- (hiPerfNode.startTime || 0) + (hiPerfNode.totalTime || 0) > startNS &&
- (hiPerfNode.startTime || 0) + (hiPerfNode.totalTime || 0) < endNS
- ) {
- x2 = ns2x(
- (hiPerfNode.startTime || 0) + (hiPerfNode.totalTime || 0),
- startNS,
- endNS,
- totalNS,
- frame
- );
- } else {
- x2 = frame.width;
- }
- if (!hiPerfNode.frame) {
- hiPerfNode.frame = {};
- }
- let getV: number = x2 - x1 < 1 ? 1 : x2 - x1;
- hiPerfNode.frame.x = Math.floor(x1);
- hiPerfNode.frame.y = hiPerfNode.depth * 20;
- hiPerfNode.frame.width = Math.ceil(getV);
- hiPerfNode.frame.height = 20;
- }
-
- static draw(ctx: CanvasRenderingContext2D, data: HiPerfCallChartStruct): void {
- if (data.frame) {
- if (data.endTime - data.startTime === undefined || data.endTime - data.startTime === null) {
- } else {
- ctx.globalAlpha = 1;
- if (data.name === '(program)') {
- ctx.fillStyle = '#ccc';
- } else if (data.name === '(idle)') {
- ctx.fillStyle = '#f0f0f0';
- } else {
- ctx.fillStyle =
- ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.name || '', 0, ColorUtils.FUNC_COLOR.length)];
- }
- let miniHeight = 20;
- if (HiPerfCallChartStruct.hoverPerfCallCutStruct && data === HiPerfCallChartStruct.hoverPerfCallCutStruct) {
- ctx.globalAlpha = 0.7;
- }
- ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, miniHeight - padding * 2);
- if (data.frame.width > 8) {
- ctx.lineWidth = 1;
- ctx.fillStyle = '#fff';
- ctx.textBaseline = 'middle';
- drawString(ctx, `${data.name || ''}`, 4, data.frame, data);
- }
- if (data === HiPerfCallChartStruct.selectStruct) {
- ctx.strokeStyle = '#000';
- ctx.lineWidth = 2;
- ctx.strokeRect(
- data.frame.x + 1,
- data.frame.y + 1,
- data.frame.width - 2,
- miniHeight - padding * 2 - 2
- );
- }
- }
- }
- }
-}
-
-export function hiperf(
- list: Array,
- filter: Array,
- startNS: number,
- endNS: number,
- totalNS: number,
- frame: Rect,
- use: boolean
-): void {
- if (use && filter.length > 0) {
- for (let i = 0, len = filter.length; i < len; i++) {
- if ((filter[i].startTime || 0) + (filter[i].totalTime || 0) >= startNS && (filter[i].startTime || 0) <= endNS) {
- HiPerfCallChartStruct.setPerfFrame(filter[i], startNS, endNS, totalNS, frame);
- } else {
- filter[i].frame = null;
- }
- }
- return;
- }
- filter.length = 0;
- if (list) {
- let groups = list
- .filter((it) => (it.startTime ?? 0) + (it.totalTime ?? 0) >= startNS && (it.startTime ?? 0) <= endNS)
- .map((it) => {
- HiPerfCallChartStruct.setPerfFrame(it, startNS, endNS, totalNS, 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: hiPerfchartFrame, b: hiPerfchartFrame) => b.totalTime - a.totalTime);
- filter.push(arr[0]);
- });
- }
-}