1 2/* 3 * Copyright (C) 2022 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16import { type SpSystemTrace } from '../SpSystemTrace'; 17import { TraceRow } from '../trace/base/TraceRow'; 18import { renders } from '../../database/ui-worker/ProcedureWorker'; 19import { type EmptyRender } from '../../database/ui-worker/cpu/ProcedureWorkerCPU'; 20import { type FreqExtendRender, CpuFreqExtendStruct } from '../../database/ui-worker/ProcedureWorkerFreqExtend'; 21import { type BinderRender, BinderStruct } from '../../database/ui-worker/procedureWorkerBinder'; 22import { type BaseStruct } from '../../bean/BaseStruct'; 23import { type AllStatesRender, AllstatesStruct } from '../../database/ui-worker/ProcedureWorkerAllStates'; 24import { StateGroup } from '../../bean/StateModle'; 25import { queryAllFuncNames } from '../../database/sql/Func.sql'; 26import { Utils } from '../trace/base/Utils'; 27import { TabPaneFreqUsage } from '../trace/sheet/frequsage/TabPaneFreqUsage'; 28const UNIT_HEIGHT: number = 20; 29const MS_TO_US: number = 1000000; 30const MIN_HEIGHT: number = 2; 31export class SpSegmentationChart { 32 static trace: SpSystemTrace; 33 static cpuRow: TraceRow<CpuFreqExtendStruct> | undefined; 34 static GpuRow: TraceRow<CpuFreqExtendStruct> | undefined; 35 static binderRow: TraceRow<BinderStruct> | undefined; 36 static schedRow: TraceRow<CpuFreqExtendStruct> | undefined; 37 static freqInfoMapData = new Map<number, unknown>(); 38 static hoverLine: Array<HeightLine> = []; 39 static tabHoverObj: { key: string, cycle: number }; 40 private rowFolder!: TraceRow<BaseStruct>; 41 static chartData: Array<Object> = []; 42 static statesRow: TraceRow<AllstatesStruct> | undefined; 43 // 数据切割联动 44 static setChartData(type: string, data: Array<FreqChartDataStruct>): void { 45 SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 }; 46 SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined; 47 if (type === 'CPU-FREQ') { 48 setCpuData(data); 49 } else if (type === 'GPU-FREQ') { 50 setGpuData(data); 51 } else { 52 setSchedData(data); 53 } 54 SpSegmentationChart.trace.refreshCanvas(false); 55 } 56 57 // state泳道联动 58 static setStateChartData(data: Array<StateGroup>) { 59 SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 }; 60 SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined; 61 let stateChartData = new Array(); 62 stateChartData = data.map(v => { 63 return { 64 dur: v.dur, 65 chartDur: v.chartDur, 66 pid: v.pid, 67 tid: v.tid, 68 end_ts: v.startTs! + v.chartDur!, 69 id: v.id, 70 name: 'all-state', 71 startTime: v.startTs, 72 start_ts: v.startTs, 73 state: v.state, 74 type: v.type, 75 cycle: v.cycle, 76 }; 77 }); 78 SpSegmentationChart.statesRow!.dataList = []; 79 SpSegmentationChart.statesRow!.dataListCache = []; 80 SpSegmentationChart.statesRow!.isComplete = false; 81 // @ts-ignore 82 SpSegmentationChart.statesRow!.supplier = (): Promise<Array<ThreadStruct>> => 83 new Promise<Array<AllstatesStruct>>((resolve) => resolve(stateChartData)); 84 SpSegmentationChart.trace.refreshCanvas(false); 85 }; 86 87 // binder联动调用 88 static setBinderChartData(data: Array<Array<FreqChartDataStruct>>): void { 89 SpSegmentationChart.tabHoverObj = { key: '', cycle: -1 }; 90 SpSegmentationChart.trace.traceSheetEL!.systemLogFlag = undefined; 91 BinderStruct.maxHeight = 0; 92 SpSegmentationChart.binderRow!.dataList = []; 93 SpSegmentationChart.binderRow!.dataListCache = []; 94 SpSegmentationChart.binderRow!.isComplete = false; 95 if (data.length === 0) { 96 SpSegmentationChart.binderRow!.style.height = `40px`; 97 SpSegmentationChart.binderRow!.funcMaxHeight = 40; 98 // @ts-ignore 99 SpSegmentationChart.binderRow!.supplier = (): Promise<Array<FreqChartDataStruct>> => 100 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([])); 101 } else { 102 let binderList: Array<FreqChartDataStruct> = []; 103 let chartData: Array<FreqChartDataStruct> = []; 104 setBinderData(data, binderList); 105 chartData = binderList.map((v: FreqChartDataStruct) => { 106 return { 107 cpu: 108 v.name === 'binder transaction' 109 ? 0 110 : v.name === 'binder transaction async' 111 ? 1 112 : v.name === 'binder reply' 113 ? MS_TO_US 114 : 3, 115 startNS: v.startNS, 116 dur: v.dur, 117 name: `${v.name}`, 118 value: v.value, 119 depth: v.depth, 120 cycle: v.cycle, 121 }; 122 }); 123 // @ts-ignore 124 SpSegmentationChart.binderRow!.supplier = (): Promise<Array<FreqChartDataStruct>> => 125 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(chartData)); 126 SpSegmentationChart.binderRow!.style.height = `${BinderStruct.maxHeight > MIN_HEIGHT ? BinderStruct.maxHeight * UNIT_HEIGHT + UNIT_HEIGHT : 40}px`; 127 SpSegmentationChart.binderRow!.funcMaxHeight = BinderStruct.maxHeight > MIN_HEIGHT ? BinderStruct.maxHeight * UNIT_HEIGHT + UNIT_HEIGHT : 40; 128 } 129 TraceRow.range!.refresh = true; 130 SpSegmentationChart.binderRow!.needRefresh = true; 131 SpSegmentationChart.binderRow!.draw(false); 132 if (SpSegmentationChart.binderRow!.collect) { 133 window.publish(window.SmartEvent.UI.RowHeightChange, { 134 expand: SpSegmentationChart.binderRow!.funcExpand, 135 value: SpSegmentationChart.binderRow!.funcMaxHeight - 40, 136 }); 137 } 138 SpSegmentationChart.trace.favoriteChartListEL?.scrollTo(0, 0); 139 SpSegmentationChart.trace.refreshCanvas(false); 140 } 141 // 悬浮联动 142 static tabHover(type: string, tableIsHover: boolean = false, cycle: number = -1): void { 143 if (tableIsHover) { 144 if (SpSegmentationChart.tabHoverObj.cycle === cycle && SpSegmentationChart.tabHoverObj.key === type) { 145 SpSegmentationChart.tabHoverObj = { cycle: -1, key: '' }; 146 } else { 147 SpSegmentationChart.tabHoverObj = { cycle, key: type }; 148 } 149 } else { 150 SpSegmentationChart.tabHoverObj = { cycle: -1, key: '' }; 151 } 152 153 SpSegmentationChart.trace.refreshCanvas(false); 154 } 155 constructor(trace: SpSystemTrace) { 156 SpSegmentationChart.trace = trace; 157 } 158 async init() { 159 if (Utils.getInstance().getCallStatckMap().size > 0) { 160 await this.initFolder(); 161 await this.initCpuFreq(); 162 await this.initGpuTrace(); 163 await this.initSchedTrace(); 164 await this.initBinderTrace(); 165 await this.initAllStates(); 166 } else { 167 return; 168 } 169 } 170 async initFolder() { 171 let row = TraceRow.skeleton(); 172 row.rowId = 'segmentation'; 173 row.index = 0; 174 row.rowType = TraceRow.ROW_TYPE_SPSEGNENTATION; 175 row.rowParentId = ''; 176 row.folder = true; 177 row.style.height = '40px'; 178 row.name = 'Segmentation'; 179 row.supplier = (): Promise<Array<BaseStruct>> => new Promise<Array<BaseStruct>>((resolve) => resolve([])); 180 row.onThreadHandler = (useCache): void => { 181 row.canvasSave(SpSegmentationChart.trace.canvasPanelCtx!); 182 if (row.expansion) { 183 SpSegmentationChart.trace.canvasPanelCtx?.clearRect(0, 0, row.frame.width, row.frame.height); 184 } else { 185 (renders['empty'] as EmptyRender).renderMainThread( 186 { 187 context: SpSegmentationChart.trace.canvasPanelCtx, 188 useCache: useCache, 189 type: '', 190 }, 191 row 192 ); 193 } 194 row.canvasRestore(SpSegmentationChart.trace.canvasPanelCtx!); 195 }; 196 this.rowFolder = row; 197 SpSegmentationChart.trace.rowsEL?.appendChild(row); 198 } 199 async initCpuFreq() { 200 // json文件泳道 201 SpSegmentationChart.cpuRow = TraceRow.skeleton<CpuFreqExtendStruct>(); 202 SpSegmentationChart.cpuRow.rowId = 'cpu-freq'; 203 SpSegmentationChart.cpuRow.rowType = TraceRow.ROW_TYPE_CPU_COMPUTILITY; 204 SpSegmentationChart.cpuRow.rowParentId = ''; 205 SpSegmentationChart.cpuRow.style.height = '40px'; 206 SpSegmentationChart.cpuRow.name = 'Cpu Computility'; 207 SpSegmentationChart.cpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; 208 SpSegmentationChart.cpuRow.addRowCheckFilePop(); 209 SpSegmentationChart.cpuRow.rowSetting = 'checkFile'; 210 // 拿到了用户传递的数据 211 SpSegmentationChart.cpuRow.onRowCheckFileChangeHandler = (): void => { 212 SpSegmentationChart.freqInfoMapData = new Map<number, unknown>(); 213 if (sessionStorage.getItem('freqInfoData')) { 214 // @ts-ignore 215 let chartData = JSON.parse(JSON.parse(sessionStorage.getItem('freqInfoData'))); 216 let mapData = new Map<number, number>(); 217 // @ts-ignore 218 chartData.map((v) => { 219 for (let key in v.freqInfo) { 220 mapData.set(Number(key), Number(v.freqInfo[key])); 221 } 222 SpSegmentationChart.freqInfoMapData.set(v.cpuId, {'smtRate': v.smtRate, mapData}); 223 mapData = new Map(); 224 }); 225 TabPaneFreqUsage.refresh(); 226 } 227 }; 228 SpSegmentationChart.cpuRow.focusHandler = (ev): void => { 229 SpSegmentationChart.trace?.displayTip( 230 SpSegmentationChart.cpuRow!, 231 CpuFreqExtendStruct.hoverStruct, 232 `<span>${CpuFreqExtendStruct.hoverStruct === undefined ? 0 : CpuFreqExtendStruct.hoverStruct.value! 233 }</span>` 234 ); 235 }; 236 SpSegmentationChart.cpuRow.findHoverStruct = (): void => { 237 CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.cpuRow!.getHoverStruct(); 238 }; 239 // @ts-ignore 240 SpSegmentationChart.cpuRow.supplier = (): Promise<Array<freqChartDataStruct>> => 241 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([])); 242 SpSegmentationChart.cpuRow.onThreadHandler = (useCache): void => { 243 let context: CanvasRenderingContext2D; 244 if (SpSegmentationChart.cpuRow!.currentContext) { 245 context = SpSegmentationChart.cpuRow!.currentContext; 246 } else { 247 context = SpSegmentationChart.cpuRow!.collect 248 ? SpSegmentationChart.trace.canvasFavoritePanelCtx! 249 : SpSegmentationChart.trace.canvasPanelCtx!; 250 } 251 SpSegmentationChart.cpuRow!.canvasSave(context); 252 (renders['freq-extend'] as FreqExtendRender).renderMainThread( 253 { 254 context: context, 255 useCache: useCache, 256 type: 'CPU-FREQ', 257 }, 258 SpSegmentationChart.cpuRow! 259 ); 260 SpSegmentationChart.cpuRow!.canvasRestore(context); 261 }; 262 SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.cpuRow); 263 this.rowFolder!.addChildTraceRow(SpSegmentationChart.cpuRow); 264 } 265 async initGpuTrace() { 266 SpSegmentationChart.GpuRow = TraceRow.skeleton<CpuFreqExtendStruct>(); 267 SpSegmentationChart.GpuRow.rowId = 'gpurow'; 268 SpSegmentationChart.GpuRow.rowType = TraceRow.ROW_TYPE_GPU_COMPUTILITY; 269 SpSegmentationChart.GpuRow.rowParentId = ''; 270 SpSegmentationChart.GpuRow.style.height = '40px'; 271 SpSegmentationChart.GpuRow.name = 'Gpu Computility'; 272 SpSegmentationChart.GpuRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; 273 SpSegmentationChart.GpuRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; 274 // @ts-ignore 275 SpSegmentationChart.GpuRow.supplier = (): Promise<Array<freqChartDataStruct>> => 276 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([])); 277 SpSegmentationChart.GpuRow.focusHandler = (ev): void => { 278 SpSegmentationChart.trace?.displayTip( 279 SpSegmentationChart.GpuRow!, 280 CpuFreqExtendStruct.hoverStruct, 281 `<span>${CpuFreqExtendStruct.hoverStruct === undefined ? 0 : CpuFreqExtendStruct.hoverStruct.value! 282 }</span>` 283 ); 284 }; 285 SpSegmentationChart.GpuRow.findHoverStruct = (): void => { 286 CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.GpuRow!.getHoverStruct(); 287 }; 288 SpSegmentationChart.GpuRow.onThreadHandler = (useCache): void => { 289 let context: CanvasRenderingContext2D; 290 if (SpSegmentationChart.GpuRow!.currentContext) { 291 context = SpSegmentationChart.GpuRow!.currentContext; 292 } else { 293 context = SpSegmentationChart.GpuRow!.collect 294 ? SpSegmentationChart.trace.canvasFavoritePanelCtx! 295 : SpSegmentationChart.trace.canvasPanelCtx!; 296 } 297 SpSegmentationChart.GpuRow!.canvasSave(context); 298 (renders['freq-extend'] as FreqExtendRender).renderMainThread( 299 { 300 context: context, 301 useCache: useCache, 302 type: 'GPU-FREQ', 303 }, 304 SpSegmentationChart.GpuRow! 305 ); 306 SpSegmentationChart.GpuRow!.canvasRestore(context); 307 }; 308 SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.GpuRow); 309 this.rowFolder!.addChildTraceRow(SpSegmentationChart.GpuRow); 310 } 311 async initSchedTrace() { 312 SpSegmentationChart.schedRow = TraceRow.skeleton<CpuFreqExtendStruct>(); 313 SpSegmentationChart.schedRow.rowId = 'sched_switch Count'; 314 SpSegmentationChart.schedRow.rowType = TraceRow.ROW_TYPE_SCHED_SWITCH; 315 SpSegmentationChart.schedRow.rowParentId = ''; 316 SpSegmentationChart.schedRow.style.height = '40px'; 317 SpSegmentationChart.schedRow.name = 'Sched_switch Count'; 318 SpSegmentationChart.schedRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; 319 SpSegmentationChart.schedRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; 320 SpSegmentationChart.schedRow.focusHandler = (ev): void => { 321 SpSegmentationChart.trace?.displayTip( 322 SpSegmentationChart.schedRow!, 323 CpuFreqExtendStruct.hoverStruct, 324 `<span>${CpuFreqExtendStruct.hoverStruct?.value!}</span>` 325 ); 326 }; 327 SpSegmentationChart.schedRow.findHoverStruct = (): void => { 328 CpuFreqExtendStruct.hoverStruct = SpSegmentationChart.schedRow!.getHoverStruct(); 329 }; 330 // @ts-ignore 331 SpSegmentationChart.schedRow.supplier = (): Promise<Array<freqChartDataStruct>> => 332 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([])); 333 SpSegmentationChart.schedRow.onThreadHandler = (useCache): void => { 334 let context: CanvasRenderingContext2D; 335 if (SpSegmentationChart.schedRow!.currentContext) { 336 context = SpSegmentationChart.schedRow!.currentContext; 337 } else { 338 context = SpSegmentationChart.schedRow!.collect 339 ? SpSegmentationChart.trace.canvasFavoritePanelCtx! 340 : SpSegmentationChart.trace.canvasPanelCtx!; 341 } 342 SpSegmentationChart.schedRow!.canvasSave(context); 343 (renders['freq-extend'] as FreqExtendRender).renderMainThread( 344 { 345 context: context, 346 useCache: useCache, 347 type: 'SCHED-SWITCH', 348 }, 349 SpSegmentationChart.schedRow! 350 ); 351 SpSegmentationChart.schedRow!.canvasRestore(context); 352 }; 353 SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.schedRow); 354 this.rowFolder!.addChildTraceRow(SpSegmentationChart.schedRow); 355 } 356 357 async initAllStates() { 358 SpSegmentationChart.statesRow = TraceRow.skeleton<AllstatesStruct>(); 359 SpSegmentationChart.statesRow.rowId = `statesrow`; 360 SpSegmentationChart.statesRow.rowType = TraceRow.ROW_TYPE_THREAD; 361 SpSegmentationChart.statesRow.rowParentId = ''; 362 SpSegmentationChart.statesRow.style.height = '30px'; 363 SpSegmentationChart.statesRow.name = `All States`; 364 SpSegmentationChart.statesRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; 365 SpSegmentationChart.statesRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; 366 // @ts-ignore 367 SpSegmentationChart.statesRow.supplier = (): Promise<Array<freqChartDataStruct>> => 368 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve([])); 369 SpSegmentationChart.statesRow.onThreadHandler = (useCache) => { 370 let context: CanvasRenderingContext2D; 371 if (SpSegmentationChart.statesRow!.currentContext) { 372 context = SpSegmentationChart.statesRow!.currentContext; 373 } else { 374 context = SpSegmentationChart.statesRow!.collect ? SpSegmentationChart.trace.canvasFavoritePanelCtx! : SpSegmentationChart.trace.canvasPanelCtx!; 375 } 376 SpSegmentationChart.statesRow!.canvasSave(context); 377 (renders.stateCut as AllStatesRender).renderMainThread( 378 { 379 context: context, 380 useCache: useCache, 381 type: ``, 382 translateY: SpSegmentationChart.statesRow!.translateY, 383 }, 384 SpSegmentationChart.statesRow! 385 ); 386 SpSegmentationChart.statesRow!.canvasRestore(context); 387 }; 388 SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.statesRow); 389 this.rowFolder!.addChildTraceRow(SpSegmentationChart.statesRow); 390 } 391 392 async initBinderTrace() { 393 SpSegmentationChart.binderRow = TraceRow.skeleton<BinderStruct>(); 394 SpSegmentationChart.binderRow.rowId = 'binderrow'; 395 SpSegmentationChart.binderRow.rowType = TraceRow.ROW_TYPE_BINDER_COUNT; 396 SpSegmentationChart.binderRow.enableCollapseChart(40, SpSegmentationChart.trace); 397 SpSegmentationChart.binderRow.rowParentId = ''; 398 SpSegmentationChart.binderRow.name = 'Binder Count'; 399 SpSegmentationChart.binderRow.style.height = '40px'; 400 SpSegmentationChart.binderRow.favoriteChangeHandler = SpSegmentationChart.trace.favoriteChangeHandler; 401 SpSegmentationChart.binderRow.selectChangeHandler = SpSegmentationChart.trace.selectChangeHandler; 402 SpSegmentationChart.binderRow.findHoverStruct = () => { 403 BinderStruct.hoverCpuFreqStruct = SpSegmentationChart.binderRow!.dataListCache.find((v: BinderStruct) => { 404 if (SpSegmentationChart.binderRow!.isHover) { 405 if (v.frame!.x < SpSegmentationChart.binderRow!.hoverX + 1 && 406 v.frame!.x + v.frame!.width > SpSegmentationChart.binderRow!.hoverX - 1 && 407 (BinderStruct.maxHeight * 20 - v.depth * 20 + 20) < SpSegmentationChart.binderRow!.hoverY && 408 BinderStruct.maxHeight * 20 - v.depth * 20 + v.value * 20 + 20 > SpSegmentationChart.binderRow!.hoverY) { 409 return v; 410 } 411 } 412 }) 413 }; 414 SpSegmentationChart.binderRow.focusHandler = (ev): void => { 415 SpSegmentationChart.trace!.displayTip( 416 SpSegmentationChart.binderRow!, 417 BinderStruct.hoverCpuFreqStruct, 418 `<span style='font-weight: bold;'>Cycle: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.cycle : 0 419 }</span><br> 420 <span style='font-weight: bold;'>Name: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.name : '' 421 }</span><br> 422 <span style='font-weight: bold;'>Count: ${BinderStruct.hoverCpuFreqStruct ? BinderStruct.hoverCpuFreqStruct.value : 0 423 }</span>` 424 ); 425 }; 426 427 SpSegmentationChart.binderRow.supplier = (): Promise<Array<BinderStruct>> => 428 new Promise<Array<BinderStruct>>((resolve) => resolve([])); 429 SpSegmentationChart.binderRow.onThreadHandler = (useCache): void => { 430 let context: CanvasRenderingContext2D; 431 if (SpSegmentationChart.binderRow!.currentContext) { 432 context = SpSegmentationChart.binderRow!.currentContext; 433 } else { 434 context = SpSegmentationChart.binderRow!.collect 435 ? SpSegmentationChart.trace.canvasFavoritePanelCtx! 436 : SpSegmentationChart.trace.canvasPanelCtx!; 437 } 438 SpSegmentationChart.binderRow!.canvasSave(context); 439 (renders.binder as BinderRender).renderMainThread( 440 { 441 context: context, 442 useCache: useCache, 443 type: 'BINDER', 444 }, 445 SpSegmentationChart.binderRow! 446 ); 447 SpSegmentationChart.binderRow!.canvasRestore(context); 448 }; 449 SpSegmentationChart.trace.rowsEL?.appendChild(SpSegmentationChart.binderRow); 450 this.rowFolder!.addChildTraceRow(SpSegmentationChart.binderRow); 451 } 452} 453class FreqChartDataStruct { 454 colorIndex?: number = 0; 455 dur: number = 0; 456 value: number = 0; 457 startNS: number = 0; 458 cycle: number = 0; 459 depth?: number = 1; 460 name?: string = ''; 461} 462 463function setCpuData(data: Array<FreqChartDataStruct>) { 464 let currentMaxValue = 0; 465 data.map((v: FreqChartDataStruct) => { 466 if (v.value > currentMaxValue) { 467 currentMaxValue = v.value; 468 } 469 }); 470 CpuFreqExtendStruct.hoverType = 'CPU-FREQ'; 471 CpuFreqExtendStruct.cpuMaxValue = currentMaxValue; 472 SpSegmentationChart.cpuRow!.dataList = []; 473 SpSegmentationChart.cpuRow!.dataListCache = []; 474 SpSegmentationChart.cpuRow!.isComplete = false; 475 // @ts-ignore 476 SpSegmentationChart.cpuRow!.supplier = (): Promise<Array<FreqChartDataStruct>> => 477 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data)); 478} 479function setGpuData(data: Array<FreqChartDataStruct>): void { 480 let currentMaxValue = 0; 481 data.map((v: FreqChartDataStruct) => { 482 if (v.value && v.value > currentMaxValue!) { 483 currentMaxValue = v.value; 484 } 485 }); 486 CpuFreqExtendStruct.hoverType = 'GPU-FREQ'; 487 CpuFreqExtendStruct.gpuMaxValue = currentMaxValue; 488 SpSegmentationChart.GpuRow!.dataList = []; 489 SpSegmentationChart.GpuRow!.dataListCache = []; 490 SpSegmentationChart.GpuRow!.isComplete = false; 491 // @ts-ignore 492 SpSegmentationChart.GpuRow!.supplier = (): Promise<Array<FreqChartDataStruct>> => 493 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data)); 494} 495function setSchedData(data: Array<FreqChartDataStruct>): void { 496 let currentMaxValue = 0; 497 data.map((v: FreqChartDataStruct) => { 498 if (v.value && v.value > currentMaxValue!) { 499 currentMaxValue = v.value; 500 } 501 }); 502 CpuFreqExtendStruct.hoverType = 'SCHED-SWITCH'; 503 CpuFreqExtendStruct.schedMaxValue = currentMaxValue!; 504 SpSegmentationChart.schedRow!.dataList = []; 505 SpSegmentationChart.schedRow!.dataListCache = []; 506 SpSegmentationChart.schedRow!.isComplete = false; 507 // @ts-ignore 508 SpSegmentationChart.schedRow!.supplier = (): Promise<Array<FreqChartDataStruct>> => 509 new Promise<Array<FreqChartDataStruct>>((resolve) => resolve(data)); 510} 511function setBinderData(data: Array<Array<FreqChartDataStruct>>, binderList: Array<FreqChartDataStruct>): void { 512 data.map((v: Array<FreqChartDataStruct>) => { 513 // 统计每一竖列的最大count 514 let listCount = 0; 515 v.map((t: FreqChartDataStruct) => { 516 listCount += t.value; 517 if (t.name === 'binder transaction') { 518 t.depth = t.value; 519 } 520 if (t.name === 'binder transaction async') { 521 t.depth = 522 t.value + 523 (v.filter((i: FreqChartDataStruct) => { 524 return i.name === 'binder transaction'; 525 }).length > 0 526 ? v.filter((i: FreqChartDataStruct) => { 527 return i.name === 'binder transaction'; 528 })[0].value 529 : 0); 530 } 531 if (t.name === 'binder reply') { 532 t.depth = 533 t.value + 534 (v.filter((i: FreqChartDataStruct) => { 535 return i.name === 'binder transaction'; 536 }).length > 0 537 ? v.filter((i: FreqChartDataStruct) => { 538 return i.name === 'binder transaction'; 539 })[0].value 540 : 0) + 541 (v.filter((i: FreqChartDataStruct) => { 542 return i.name === 'binder transaction async'; 543 }).length > 0 544 ? v.filter((i: FreqChartDataStruct) => { 545 return i.name === 'binder transaction async'; 546 })[0].value 547 : 0); 548 } 549 if (t.name === 'binder async rcv') { 550 t.depth = 551 t.value + 552 (v.filter((i: FreqChartDataStruct) => { 553 return i.name === 'binder transaction'; 554 }).length > 0 555 ? v.filter((i: FreqChartDataStruct) => { 556 return i.name === 'binder transaction'; 557 })[0].value 558 : 0) + 559 (v.filter((i: FreqChartDataStruct) => { 560 return i.name === 'binder transaction async'; 561 }).length > 0 562 ? v.filter((i: FreqChartDataStruct) => { 563 return i.name === 'binder transaction async'; 564 })[0].value 565 : 0) + 566 (v.filter((i: FreqChartDataStruct) => { 567 return i.name === 'binder reply'; 568 }).length > 0 569 ? v.filter((i: FreqChartDataStruct) => { 570 return i.name === 'binder reply'; 571 })[0].value 572 : 0); 573 } 574 binderList.push(t); 575 }); 576 BinderStruct.maxHeight = 577 BinderStruct.maxHeight > listCount ? BinderStruct.maxHeight : JSON.parse(JSON.stringify(listCount)); 578 listCount = 0; 579 }); 580} 581 582class HeightLine { 583 key: string = ''; 584 cycle: number = -1; 585} 586