From 1aa07a8604469548857b8e71f09ed3ea7af1adba Mon Sep 17 00:00:00 2001 From: danghongquan Date: Fri, 24 Nov 2023 15:02:05 +0800 Subject: [PATCH 1/3] allAppStartups_demo Signed-off-by: danghongquan --- ide/src/trace/SpApplication.ts | 2 +- ide/src/trace/component/SpKeyboard.ts | 6 + ide/src/trace/component/SpSystemTrace.ts | 9 ++ .../trace/component/chart/SpAllAppStartups.ts | 138 ++++++++++++++++++ .../trace/component/chart/SpChartManager.ts | 4 + .../trace/component/trace/base/TraceRow.ts | 1 + .../trace/component/trace/base/TraceSheet.ts | 3 + .../trace/sheet/TabPaneCurrentSelection.ts | 36 +++++ ide/src/trace/database/SqlLite.ts | 29 ++++ .../database/ui-worker/ProcedureWorker.ts | 2 + .../ui-worker/ProcedureWorkerAllAppStartup.ts | 110 ++++++++++++++ 11 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 ide/src/trace/component/chart/SpAllAppStartups.ts create mode 100644 ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts diff --git a/ide/src/trace/SpApplication.ts b/ide/src/trace/SpApplication.ts index 3c4e3cae..670470b2 100644 --- a/ide/src/trace/SpApplication.ts +++ b/ide/src/trace/SpApplication.ts @@ -1449,7 +1449,7 @@ export class SpApplication extends BaseElement { }, { title: 'Keyboard shortcuts', - icon: 'menu', + icon: 'smart-help', clickHandler: function (item: MenuItem) { SpStatisticsHttpUtil.addOrdinaryVisitAction({ event: 'Keyboard shortcuts', diff --git a/ide/src/trace/component/SpKeyboard.ts b/ide/src/trace/component/SpKeyboard.ts index 45a30f51..19341f17 100644 --- a/ide/src/trace/component/SpKeyboard.ts +++ b/ide/src/trace/component/SpKeyboard.ts @@ -137,6 +137,12 @@ export class SpKeyboard extends BaseElement { 展示快捷方式 + + +
v
+ + 展示/隐藏Vsync信号 + diff --git a/ide/src/trace/component/SpSystemTrace.ts b/ide/src/trace/component/SpSystemTrace.ts index 956d81aa..8bc57e81 100644 --- a/ide/src/trace/component/SpSystemTrace.ts +++ b/ide/src/trace/component/SpSystemTrace.ts @@ -87,6 +87,7 @@ import { TabPaneCurrentSelection } from './trace/sheet/TabPaneCurrentSelection.j import { SpChartList } from './trace/SpChartList.js'; import './trace/SpChartList.js'; import { AppStartupStruct } from '../database/ui-worker/ProcedureWorkerAppStartup.js'; +import { AllAppStartupStruct } from '../database/ui-worker/ProcedureWorkerAllAppStartup.js'; import { SoStruct } from '../database/ui-worker/ProcedureWorkerSoInit.js'; import { TabPaneTaskFrames } from './trace/sheet/task/TabPaneTaskFrames.js'; import { FlagsConfig } from './SpFlags.js'; @@ -2659,6 +2660,10 @@ export class SpSystemTrace extends BaseElement { TraceRow.ROW_TYPE_APP_STARTUP, () => AppStartupStruct.hoverStartupStruct !== null && AppStartupStruct.hoverStartupStruct !== undefined, ], + [ + TraceRow.ROW_TYPE_ALL_APPSTARTUPS, + () => AllAppStartupStruct.hoverStartupStruct !== null && AllAppStartupStruct.hoverStartupStruct !== undefined, + ], [TraceRow.ROW_TYPE_STATIC_INIT, () => SoStruct.hoverSoStruct !== null && SoStruct.hoverSoStruct !== undefined], [TraceRow.ROW_TYPE_JANK, () => JankStruct.hoverJankStruct !== null && JankStruct.hoverJankStruct !== undefined], [TraceRow.ROW_TYPE_HEAP, () => HeapStruct.hoverHeapStruct !== null && HeapStruct.hoverHeapStruct !== undefined], @@ -3222,6 +3227,10 @@ export class SpSystemTrace extends BaseElement { AppStartupStruct.selectStartupStruct = AppStartupStruct.hoverStartupStruct; this.traceSheetEL?.displayStartupData(AppStartupStruct.selectStartupStruct, scrollToFuncHandler); this.timerShaftEL?.modifyFlagList(undefined); + }else if(clickRowType === TraceRow.ROW_TYPE_ALL_APPSTARTUPS && AllAppStartupStruct.hoverStartupStruct){ + AllAppStartupStruct.selectStartupStruct = AllAppStartupStruct.hoverStartupStruct; + this.traceSheetEL?.displayAllStartupData(AllAppStartupStruct.selectStartupStruct!, scrollToFuncHandler) + this.timerShaftEL?.modifyFlagList(undefined); } else if (clickRowType === TraceRow.ROW_TYPE_STATIC_INIT && SoStruct.hoverSoStruct) { SoStruct.selectSoStruct = SoStruct.hoverSoStruct; this.traceSheetEL?.displayStaticInitData(SoStruct.selectSoStruct, scrollToFuncHandler); diff --git a/ide/src/trace/component/chart/SpAllAppStartups.ts b/ide/src/trace/component/chart/SpAllAppStartups.ts new file mode 100644 index 00000000..527871ae --- /dev/null +++ b/ide/src/trace/component/chart/SpAllAppStartups.ts @@ -0,0 +1,138 @@ +/* + * 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.js'; +import { TraceRow } from '../trace/base/TraceRow.js'; +import { renders } from '../../database/ui-worker/ProcedureWorker.js'; +import { CpuFreqStruct } from '../../database/ui-worker/ProcedureWorkerFreq.js'; +import { queryAppStartupProcessIds,queryProcessAllAppStartup,queryProcessStartup,querySingleAppStartupsName } from '../../database/SqlLite.js'; +import { FlagsConfig } from '../SpFlags.js'; +// import { AppStartupStruct, AppStartupRender } from '../../database/ui-worker/ProcedureWorkerAppStartup.js'; +import { AllAppStartupStruct, AllAppStartupRender } from '../../database/ui-worker/ProcedureWorkerAllAppStartup.js'; + +export class SpAllAppStartupsChart { + private readonly trace: SpSystemTrace | undefined; + static APP_STARTUP_PID_ARR: Array = []; + static jsonRow: TraceRow | undefined; + static trace: SpSystemTrace; + static AllAppStartupsNameArr :any[] = []; + static allAppStartupsAva: number[] = []; + + constructor(trace: SpSystemTrace) { + SpAllAppStartupsChart.trace = trace; + } + + + + + + async init() { + SpAllAppStartupsChart.APP_STARTUP_PID_ARR = []; + let appStartUpPids = await queryAppStartupProcessIds(); + appStartUpPids.forEach((it) => SpAllAppStartupsChart.APP_STARTUP_PID_ARR.push(it.pid)); + SpAllAppStartupsChart.AllAppStartupsNameArr = []; + SpAllAppStartupsChart.allAppStartupsAva = []; + for(let i = 0; i < SpAllAppStartupsChart.APP_STARTUP_PID_ARR.length; i++){ + let tmpAppName:any[] = await querySingleAppStartupsName(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]!); + if(tmpAppName![0].name.includes(String.fromCharCode(99,111,109,46)) && !tmpAppName![0].name.includes(String.fromCharCode(99,111,109,46,104,117,97,119,101,105,46,104,109,111,115))){ + SpAllAppStartupsChart.allAppStartupsAva.push(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]); + SpAllAppStartupsChart.AllAppStartupsNameArr.push(tmpAppName![0].name); + } + } + let loadAppStartup: boolean = FlagsConfig.getFlagsConfigEnableStatus('AppStartup'); + if (loadAppStartup && SpAllAppStartupsChart.allAppStartupsAva.length) await this.initFolder(); + } + + async initFolder() { + let row: TraceRow = TraceRow.skeleton(); + row.setAttribute('hasStartup', 'true'); + row.rowId = `all-app-start-${SpAllAppStartupsChart.APP_STARTUP_PID_ARR![0]}`; + // row.rowId = '16499'; + row.index = 0; + row.rowType = TraceRow.ROW_TYPE_ALL_APPSTARTUPS; + row.rowParentId = ''; + row.folder = false; + row.style.height = '40px'; + row.name = `All App Startups`; + row.selectChangeHandler = SpAllAppStartupsChart.trace.selectChangeHandler; + row.favoriteChangeHandler = SpAllAppStartupsChart.trace.favoriteChangeHandler; + row.supplier = async (): Promise> =>{ + let sendRes: AllAppStartupStruct[] | PromiseLike = []; + for(let i = 0; i < SpAllAppStartupsChart.allAppStartupsAva.length; i++){ + let tmpResArr = await queryProcessStartup(SpAllAppStartupsChart.allAppStartupsAva[i]); + let maxStartTs: number | undefined = tmpResArr[0].startTs; + let minStartTs: number | undefined = tmpResArr[0].startTs; + let singleDur = tmpResArr[0].dur; + let endTs :number | undefined = tmpResArr[0].startTs; + if(tmpResArr.length > 1){ + for(let j = 0;j < tmpResArr.length; j++){ + if(Number(tmpResArr[j].startTs) > Number(maxStartTs)){ + maxStartTs = tmpResArr[j].startTs; + }else if(Number(tmpResArr[j].startTs) < Number(minStartTs)){ + minStartTs = tmpResArr[j].startTs; + } + } + tmpResArr.forEach((item)=>{ + if(item.startTs == maxStartTs){ + endTs = Number(item.startTs)+Number(item.dur); + singleDur = Number(endTs)-Number(minStartTs); + } + }) + }else if(tmpResArr.length === 1){ + minStartTs = tmpResArr[0].startTs; + singleDur = tmpResArr[0].dur; + } + sendRes.push( + { + dur: singleDur, + value: undefined, + startTs: minStartTs, + pid: SpAllAppStartupsChart.allAppStartupsAva[i], + process: undefined, + itid: undefined, + endItid: undefined, + tid: SpAllAppStartupsChart.allAppStartupsAva[i], + startName: undefined, + stepName: SpAllAppStartupsChart.AllAppStartupsNameArr[i], + translateY: undefined, + frame: undefined, + isHover: false + } + ) + } + return sendRes + } + + row.onThreadHandler = (useCache): void => { + let context: CanvasRenderingContext2D; + if (row.currentContext) { + context = row.currentContext; + } else { + context = row.collect ? SpAllAppStartupsChart.trace.canvasFavoritePanelCtx! : SpAllAppStartupsChart.trace.canvasPanelCtx!; + } + row.canvasSave(context); + (renders['all-app-start-up'] as AllAppStartupRender).renderMainThread( + { + appStartupContext: context, + useCache: useCache, + type: `app-startup ${row.rowId}`, + }, + row + ); + row.canvasRestore(context); + }; + SpAllAppStartupsChart.trace.rowsEL?.appendChild(row); + } +} diff --git a/ide/src/trace/component/chart/SpChartManager.ts b/ide/src/trace/component/chart/SpChartManager.ts index ab9f3a90..62b96d1d 100644 --- a/ide/src/trace/component/chart/SpChartManager.ts +++ b/ide/src/trace/component/chart/SpChartManager.ts @@ -49,6 +49,7 @@ import { MemoryConfig } from '../../bean/MemoryConfig.js'; import { FlagsConfig } from '../SpFlags.js'; import { SpLogChart } from './SpLogChart.js'; import { SpHiSysEventChart } from './SpHiSysEventChart.js'; +import { SpAllAppStartupsChart } from './SpAllAppStartups.js'; export class SpChartManager { static APP_STARTUP_PID_ARR: Array = []; @@ -68,6 +69,7 @@ export class SpChartManager { private smapsChart: VmTrackerChart; private clockChart: SpClockChart; private irqChart: SpIrqChart; + private SpAllAppStartupsChart!: SpAllAppStartupsChart; frameTimeChart: SpFrameTimeChart; public arkTsChart: SpArkTsChart; private logChart: SpLogChart; @@ -93,6 +95,7 @@ export class SpChartManager { this.arkTsChart = new SpArkTsChart(trace); this.logChart = new SpLogChart(trace); this.spHiSysEvent = new SpHiSysEventChart(trace); + this.SpAllAppStartupsChart = new SpAllAppStartupsChart(trace) } async init(progress: Function) { @@ -164,6 +167,7 @@ export class SpChartManager { await this.arkTsChart.initFolder(); info('ark ts initialized'); await this.frameTimeChart.init(); + await this.SpAllAppStartupsChart.init(); progress('process', 92); await this.process.initAsyncFuncData(); await this.process.initDeliverInputEvent(); diff --git a/ide/src/trace/component/trace/base/TraceRow.ts b/ide/src/trace/component/trace/base/TraceRow.ts index 41cf9d28..d0460c53 100644 --- a/ide/src/trace/component/trace/base/TraceRow.ts +++ b/ide/src/trace/component/trace/base/TraceRow.ts @@ -117,6 +117,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_ALL_APPSTARTUPS = 'all-appstartups' static FRAME_WIDTH: number = 0; static range: TimeRange | undefined | null; static rangeSelectObject: RangeSelectStruct | undefined; diff --git a/ide/src/trace/component/trace/base/TraceSheet.ts b/ide/src/trace/component/trace/base/TraceSheet.ts index d1ff74b5..514a1b53 100644 --- a/ide/src/trace/component/trace/base/TraceSheet.ts +++ b/ide/src/trace/component/trace/base/TraceSheet.ts @@ -42,6 +42,7 @@ import { type TabPaneNMStatisticAnalysis } from '../sheet/native-memory/TabPaneN import { type TabPaneCurrent } from '../sheet/TabPaneCurrent.js'; import { type SlicesTime } from '../timer-shaft/SportRuler.js'; import { type AppStartupStruct } from '../../../database/ui-worker/ProcedureWorkerAppStartup.js'; +import { type AllAppStartupStruct } from '../../../database/ui-worker/ProcedureWorkerAllAppStartup.js'; import { type SoStruct } from '../../../database/ui-worker/ProcedureWorkerSoInit.js'; import { type FrameAnimationStruct } from '../../../database/ui-worker/ProcedureWorkerFrameAnimation.js'; import { type TraceRow } from './TraceRow.js'; @@ -502,6 +503,8 @@ export class TraceSheet extends BaseElement { this.displayTab('current-selection').setIrqData(data); displayStartupData = (data: AppStartupStruct, scrollCallback: Function): void => this.displayTab('current-selection').setStartupData(data, scrollCallback); + displayAllStartupData = (data: AllAppStartupStruct, scrollCallback: Function): void => + this.displayTab('current-selection').setAllStartupData(data, scrollCallback); displayStaticInitData = (data: SoStruct, scrollCallback: Function): void => this.displayTab('current-selection').setStaticInitData(data, scrollCallback); diff --git a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts index f57ea33e..13f4d311 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts @@ -49,6 +49,7 @@ import { AppStartupStruct } from '../../../database/ui-worker/ProcedureWorkerApp import { SoStruct } from '../../../database/ui-worker/ProcedureWorkerSoInit.js'; import { type SelectionParam } from '../../../bean/BoxSelection.js'; import { type FrameAnimationStruct } from '../../../database/ui-worker/ProcedureWorkerFrameAnimation.js'; +import { AllAppStartupStruct } from '../../../database/ui-worker/ProcedureWorkerAllAppStartup.js'; const INPUT_WORD = 'This is the interval from when the task became eligible to run \n(e.g.because of notifying a wait queue it was a suspended on) to\n when it started running.'; @@ -815,6 +816,41 @@ export class TabPaneCurrentSelection extends BaseElement { this.currentSelectionTbl!.dataSource = list; } } + setAllStartupData(data: AllAppStartupStruct,scrollCallback: Function): void{ + this.setTableHeight('550px'); + this.initCanvas(); + let allStartUpLeftTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#leftTitle'); + let allStartUpmiddleTitle: HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightText'); + let allStartUpRightButton:HTMLElement | null | undefined = this?.shadowRoot?.querySelector('#rightButton'); + if(allStartUpmiddleTitle) allStartUpmiddleTitle.style.visibility = 'hidden'; + if(allStartUpRightButton) allStartUpRightButton.style.visibility = 'hidden'; + if (allStartUpLeftTitle) { + allStartUpLeftTitle.innerText = 'Details'; + } + let list: any[] = []; + list.push({name: "Name", value: data.stepName!}) + list.push({ + name: "StartTime(Relative)", + value: getTimeString(data.startTs || 0) + }); + list.push({ + name: "StartTime(Absolute)", + value:((data.startTs || 0) + (window as any).recordStartNS) / 1000000000 + 's' + }); + list.push({ + name: "endTime(Relative)", + value: getTimeString((data.startTs || 0) + (data.dur || 0)) + }); + list.push({ + name: "endTime(Abslute)", + value: ((data.startTs || 0) + (data.dur || 0) + (window as any).recordStartNS) / 1000000000 + 's' + }) + list.push({ + name:"Dur", + value: getTimeString(data.dur || 0) + }) + this.currentSelectionTbl!.dataSource = list; + } setStartupData(data: AppStartupStruct, scrollCallback: Function): void { this.setTableHeight('550px'); diff --git a/ide/src/trace/database/SqlLite.ts b/ide/src/trace/database/SqlLite.ts index 75c4132d..2a581a50 100644 --- a/ide/src/trace/database/SqlLite.ts +++ b/ide/src/trace/database/SqlLite.ts @@ -1421,6 +1421,35 @@ order by start_name;`, { $pid: pid } ); + export const queryProcessAllAppStartup = (pids: Array): Promise> => + query( + 'queryProcessStartup', + ` + select + P.pid, + A.tid, + A.call_id as itid, + (case when A.start_time < B.start_ts then 0 else (A.start_time - B.start_ts) end) as startTs, + (case + when A.start_time < B.start_ts then (A.end_time - B.start_ts) + when A.end_time = -1 then 0 + else (A.end_time - A.start_time) end) as dur, + A.start_name as startName +from app_startup A,trace_range B +left join process P on A.ipid = P.ipid +where P.pid in(${pids.join(',')}) +order by start_name;`, + { $pid: pids } + ); + + export const querySingleAppStartupsName = (pid:number): Promise> => + query( + 'queryAllAppStartupsName', + `select name from process + where pid=$pid`, + { $pid: pid } + ) + export const queryProcessSoMaxDepth = (): Promise> => query( 'queryProcessSoMaxDepth', diff --git a/ide/src/trace/database/ui-worker/ProcedureWorker.ts b/ide/src/trace/database/ui-worker/ProcedureWorker.ts index 0fd1daf6..1766c0d9 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorker.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorker.ts @@ -58,6 +58,7 @@ import { SnapshotRender } from './ProcedureWorkerSnapshot.js'; import { LogRender } from './ProcedureWorkerLog.js'; import { HiPerfCallChartRender } from './ProcedureWorkerHiPerfCallChart.js'; import { HiSysEventRender } from './ProcedureWorkerHiSysEvent.js'; +import { AllAppStartupRender } from './ProcedureWorkerAllAppStartup.js'; let dataList: any = {}; let dataList2: any = {}; @@ -77,6 +78,7 @@ export let renders: any = { 'file-system-cell': new FileSystemRender(), process: new ProcessRender(), 'app-start-up': new AppStartupRender(), + 'all-app-start-up': new AllAppStartupRender(), 'app-so-init': new SoRender(), heap: new HeapRender(), 'heap-timeline': new HeapTimelineRender(), diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts new file mode 100644 index 00000000..ad422222 --- /dev/null +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts @@ -0,0 +1,110 @@ +/* + * 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, drawString } from './ProcedureWorkerCommon.js'; +import { TraceRow } from '../../component/trace/base/TraceRow.js'; +import { ColorUtils } from '../../component/trace/base/ColorUtils.js'; +import { querySingleAppStartupsName } from '../SqlLite.js'; + +export class AllAppStartupRender { + renderMainThread( + req: { + appStartupContext: CanvasRenderingContext2D; + useCache: boolean; + type: string; + }, + appStartUpRow: TraceRow + ): void { + let list = appStartUpRow.dataList; + let filter = appStartUpRow.dataListCache; + dataFilterHandler(list, filter, { + startKey: 'startTs', + durKey: 'dur', + startNS: TraceRow.range?.startNS ?? 0, + endNS: TraceRow.range?.endNS ?? 0, + totalNS: TraceRow.range?.totalNS ?? 0, + frame: appStartUpRow.frame, + paddingTop: 5, + useCache: req.useCache || !(TraceRow.range?.refresh ?? false), + }); + req.appStartupContext.globalAlpha = 0.6; + let find = false; + let offset = 3; + for (let re of filter) { + AllAppStartupStruct.draw(req.appStartupContext, re); + if (appStartUpRow.isHover) { + if ( + re.frame && + appStartUpRow.hoverX >= re.frame.x - offset && + appStartUpRow.hoverX <= re.frame.x + re.frame.width + offset + ) { + AllAppStartupStruct.hoverStartupStruct = re; + find = true; + } + } + } + if (!find && appStartUpRow.isHover) { + AllAppStartupStruct.hoverStartupStruct = undefined; + } + } +} + +const padding = 3; + +export class AllAppStartupStruct extends BaseStruct { + static hoverStartupStruct: AllAppStartupStruct | undefined; + static selectStartupStruct: AllAppStartupStruct | undefined; + dur: number | undefined; + value: string | undefined; + startTs: number | undefined; + pid: number | undefined; + process: string | undefined; + itid: number | undefined; + endItid: number | undefined; + tid: number | undefined; + startName: number | undefined; + stepName: string | undefined; + + static draw(ctx: CanvasRenderingContext2D, data: AllAppStartupStruct): void { + if (data.frame) { + ctx.globalAlpha = 1.0; + ctx.fillStyle = ColorUtils.colorForTid(data.startName!); + ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, data.frame.height); + if (data.frame.width > 7) { + ctx.textBaseline = 'middle'; + ctx.lineWidth = 1; + let draAppName: string | undefined = ''; + if(data.stepName){ + draAppName = `${data.stepName} (${(data.dur! / 1000000).toFixed(2)}ms)`; + } + let textColor = + ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.stepName || '', 0, ColorUtils.FUNC_COLOR.length)]; + ctx.fillStyle = ColorUtils.funcTextColor(textColor); + // ctx.fillStyle = '#000'; + drawString(ctx, draAppName, 2, data.frame, data); + } + if (data === AllAppStartupStruct.selectStartupStruct) { + ctx.strokeStyle = '#232c5d'; + ctx.lineWidth = 2; + ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, data.frame.height); + } + } + } + + static async getStartupName(pid: number): Promise { + let singleAppName = await querySingleAppStartupsName(pid); + return singleAppName[0].name; + } +} -- Gitee From 261df941d96a1b021544355d28fa2bfe63217ab2 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Sat, 25 Nov 2023 11:46:18 +0800 Subject: [PATCH 2/3] allAppStartups_demo Signed-off-by: danghongquan --- .../trace/component/chart/SpAllAppStartups.ts | 45 ++++++++++--------- .../trace/sheet/TabPaneCurrentSelection.ts | 4 +- .../ui-worker/ProcedureWorkerAllAppStartup.ts | 1 - 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ide/src/trace/component/chart/SpAllAppStartups.ts b/ide/src/trace/component/chart/SpAllAppStartups.ts index 527871ae..d12ed401 100644 --- a/ide/src/trace/component/chart/SpAllAppStartups.ts +++ b/ide/src/trace/component/chart/SpAllAppStartups.ts @@ -17,9 +17,12 @@ import { SpSystemTrace } from '../SpSystemTrace.js'; import { TraceRow } from '../trace/base/TraceRow.js'; import { renders } from '../../database/ui-worker/ProcedureWorker.js'; import { CpuFreqStruct } from '../../database/ui-worker/ProcedureWorkerFreq.js'; -import { queryAppStartupProcessIds,queryProcessAllAppStartup,queryProcessStartup,querySingleAppStartupsName } from '../../database/SqlLite.js'; +import { + queryAppStartupProcessIds, + queryProcessStartup, + querySingleAppStartupsName, +} from '../../database/SqlLite.js'; import { FlagsConfig } from '../SpFlags.js'; -// import { AppStartupStruct, AppStartupRender } from '../../database/ui-worker/ProcedureWorkerAppStartup.js'; import { AllAppStartupStruct, AllAppStartupRender } from '../../database/ui-worker/ProcedureWorkerAllAppStartup.js'; export class SpAllAppStartupsChart { @@ -27,7 +30,7 @@ export class SpAllAppStartupsChart { static APP_STARTUP_PID_ARR: Array = []; static jsonRow: TraceRow | undefined; static trace: SpSystemTrace; - static AllAppStartupsNameArr :any[] = []; + static AllAppStartupsNameArr: any[] = []; static allAppStartupsAva: number[] = []; constructor(trace: SpSystemTrace) { @@ -44,11 +47,12 @@ export class SpAllAppStartupsChart { appStartUpPids.forEach((it) => SpAllAppStartupsChart.APP_STARTUP_PID_ARR.push(it.pid)); SpAllAppStartupsChart.AllAppStartupsNameArr = []; SpAllAppStartupsChart.allAppStartupsAva = []; - for(let i = 0; i < SpAllAppStartupsChart.APP_STARTUP_PID_ARR.length; i++){ - let tmpAppName:any[] = await querySingleAppStartupsName(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]!); - if(tmpAppName![0].name.includes(String.fromCharCode(99,111,109,46)) && !tmpAppName![0].name.includes(String.fromCharCode(99,111,109,46,104,117,97,119,101,105,46,104,109,111,115))){ + for (let i = 0; i < SpAllAppStartupsChart.APP_STARTUP_PID_ARR.length; i++) { + let tmpSingleApp: any[] = await queryProcessStartup(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]!); + if (tmpSingleApp.length == 8) { + let avilSingleName = await querySingleAppStartupsName(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]!); SpAllAppStartupsChart.allAppStartupsAva.push(SpAllAppStartupsChart.APP_STARTUP_PID_ARR[i]); - SpAllAppStartupsChart.AllAppStartupsNameArr.push(tmpAppName![0].name); + SpAllAppStartupsChart.AllAppStartupsNameArr.push(avilSingleName![0].name); } } let loadAppStartup: boolean = FlagsConfig.getFlagsConfigEnableStatus('AppStartup'); @@ -59,7 +63,6 @@ export class SpAllAppStartupsChart { let row: TraceRow = TraceRow.skeleton(); row.setAttribute('hasStartup', 'true'); row.rowId = `all-app-start-${SpAllAppStartupsChart.APP_STARTUP_PID_ARR![0]}`; - // row.rowId = '16499'; row.index = 0; row.rowType = TraceRow.ROW_TYPE_ALL_APPSTARTUPS; row.rowParentId = ''; @@ -68,29 +71,29 @@ export class SpAllAppStartupsChart { row.name = `All App Startups`; row.selectChangeHandler = SpAllAppStartupsChart.trace.selectChangeHandler; row.favoriteChangeHandler = SpAllAppStartupsChart.trace.favoriteChangeHandler; - row.supplier = async (): Promise> =>{ + row.supplier = async (): Promise> => { let sendRes: AllAppStartupStruct[] | PromiseLike = []; - for(let i = 0; i < SpAllAppStartupsChart.allAppStartupsAva.length; i++){ + for (let i = 0; i < SpAllAppStartupsChart.allAppStartupsAva.length; i++) { let tmpResArr = await queryProcessStartup(SpAllAppStartupsChart.allAppStartupsAva[i]); let maxStartTs: number | undefined = tmpResArr[0].startTs; let minStartTs: number | undefined = tmpResArr[0].startTs; let singleDur = tmpResArr[0].dur; - let endTs :number | undefined = tmpResArr[0].startTs; - if(tmpResArr.length > 1){ - for(let j = 0;j < tmpResArr.length; j++){ - if(Number(tmpResArr[j].startTs) > Number(maxStartTs)){ + let endTs: number | undefined = tmpResArr[0].startTs; + if (tmpResArr.length > 1) { + for (let j = 0; j < tmpResArr.length; j++) { + if (Number(tmpResArr[j].startTs) > Number(maxStartTs)) { maxStartTs = tmpResArr[j].startTs; - }else if(Number(tmpResArr[j].startTs) < Number(minStartTs)){ + } else if (Number(tmpResArr[j].startTs) < Number(minStartTs)) { minStartTs = tmpResArr[j].startTs; } } - tmpResArr.forEach((item)=>{ - if(item.startTs == maxStartTs){ - endTs = Number(item.startTs)+Number(item.dur); - singleDur = Number(endTs)-Number(minStartTs); + tmpResArr.forEach((item) => { + if (item.startTs == maxStartTs) { + endTs = Number(item.startTs) + Number(item.dur); + singleDur = Number(endTs) - Number(minStartTs); } }) - }else if(tmpResArr.length === 1){ + } else if (tmpResArr.length === 1) { minStartTs = tmpResArr[0].startTs; singleDur = tmpResArr[0].dur; } @@ -114,7 +117,7 @@ export class SpAllAppStartupsChart { } return sendRes } - + row.onThreadHandler = (useCache): void => { let context: CanvasRenderingContext2D; if (row.currentContext) { diff --git a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts index 13f4d311..c0a61286 100644 --- a/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts +++ b/ide/src/trace/component/trace/sheet/TabPaneCurrentSelection.ts @@ -838,11 +838,11 @@ export class TabPaneCurrentSelection extends BaseElement { value:((data.startTs || 0) + (window as any).recordStartNS) / 1000000000 + 's' }); list.push({ - name: "endTime(Relative)", + name: "EndTime(Relative)", value: getTimeString((data.startTs || 0) + (data.dur || 0)) }); list.push({ - name: "endTime(Abslute)", + name: "EndTime(Abslute)", value: ((data.startTs || 0) + (data.dur || 0) + (window as any).recordStartNS) / 1000000000 + 's' }) list.push({ diff --git a/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts index ad422222..ede7a836 100644 --- a/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts +++ b/ide/src/trace/database/ui-worker/ProcedureWorkerAllAppStartup.ts @@ -92,7 +92,6 @@ export class AllAppStartupStruct extends BaseStruct { let textColor = ColorUtils.FUNC_COLOR[ColorUtils.hashFunc(data.stepName || '', 0, ColorUtils.FUNC_COLOR.length)]; ctx.fillStyle = ColorUtils.funcTextColor(textColor); - // ctx.fillStyle = '#000'; drawString(ctx, draAppName, 2, data.frame, data); } if (data === AllAppStartupStruct.selectStartupStruct) { -- Gitee From c5d20e0f6c87e5e388d5d08c41fb7f51a56e4774 Mon Sep 17 00:00:00 2001 From: danghongquan Date: Mon, 27 Nov 2023 14:26:27 +0800 Subject: [PATCH 3/3] modify_chartInfo Signed-off-by: danghongquan --- ide/src/trace/component/chart/SpChartManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/src/trace/component/chart/SpChartManager.ts b/ide/src/trace/component/chart/SpChartManager.ts index 62b96d1d..e58a5652 100644 --- a/ide/src/trace/component/chart/SpChartManager.ts +++ b/ide/src/trace/component/chart/SpChartManager.ts @@ -166,8 +166,8 @@ export class SpChartManager { progress('ark ts', 90); await this.arkTsChart.initFolder(); info('ark ts initialized'); - await this.frameTimeChart.init(); await this.SpAllAppStartupsChart.init(); + await this.frameTimeChart.init(); progress('process', 92); await this.process.initAsyncFuncData(); await this.process.initDeliverInputEvent(); -- Gitee