• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { BaseElement, element } from '../../../base-ui/BaseElement.js';
17import './TabThreadAnalysis.js';
18import './TabCpuAnalysis.js';
19import { TabCpuAnalysis } from './TabCpuAnalysis.js';
20import { TabThreadAnalysis } from './TabThreadAnalysis.js';
21import { LitTabs } from '../../../base-ui/tabs/lit-tabs.js';
22import { CheckCpuSetting } from './CheckCpuSetting.js';
23import { Top20FrequencyThread } from './Top20FrequencyThread.js';
24import { procedurePool } from '../../database/Procedure.js';
25
26@element('sp-scheduling-analysis')
27export class SpSchedulingAnalysis extends BaseElement {
28  static traceChange: boolean = false;
29  static cpuCount: number = 0;
30  static startTs: number = 0;
31  static endTs: number = 0;
32  static totalDur: number = 0;
33  private tabs: LitTabs | null | undefined;
34  private tabCpuAnalysis: TabCpuAnalysis | null | undefined;
35  private tabThreadAnalysis: TabThreadAnalysis | null | undefined;
36
37  initElements(): void {
38    this.tabs = this.shadowRoot?.querySelector<LitTabs>('#tabs');
39    this.tabCpuAnalysis = this.shadowRoot?.querySelector<TabCpuAnalysis>('#cpu-analysis');
40    this.tabThreadAnalysis = this.shadowRoot?.querySelector<TabThreadAnalysis>('#thread-analysis');
41  }
42
43  static resetCpu() {
44    SpSchedulingAnalysis.traceChange = true;
45    CheckCpuSetting.resetCpuSettings();
46    Top20FrequencyThread.threads = undefined;
47    procedurePool.submitWithName('logic1', 'scheduling-clearData', {}, undefined, (res: any) => {});
48  }
49
50  init() {
51    if (SpSchedulingAnalysis.traceChange) {
52      SpSchedulingAnalysis.traceChange = false;
53      this.tabs!.activekey = '1';
54      SpSchedulingAnalysis.startTs = (window as any).recordStartNS;
55      SpSchedulingAnalysis.endTs = (window as any).recordEndNS;
56      SpSchedulingAnalysis.totalDur = SpSchedulingAnalysis.endTs - SpSchedulingAnalysis.startTs;
57      SpSchedulingAnalysis.cpuCount = (window as any).cpuCount;
58      this.tabCpuAnalysis?.init();
59      this.tabThreadAnalysis?.init();
60    }
61  }
62
63  initHtml(): string {
64    return `
65        <style>
66        .content{
67            display: flex;
68            flex-direction: column;
69            background-color: var(--dark-background5,#F6F6F6);
70            position: absolute;
71            width: 100%;
72            height: 100%;
73            top: 0;
74            bottom: 0;
75            left: 0;
76            right: 0;
77        }
78        #tabs{
79            width: 100%;
80            height: calc(100% - 55px);
81            background-color: var(--dark-background,#FFFFFF);
82        }
83        :host {
84            width: 100%;
85            height: 100%;
86            background: var(--dark-background5,#F6F6F6);
87        }
88        .interval{
89            height: 55px;
90            width: 100%;
91            background-color: var(--dark-background,#FFFFFF);
92        }
93        </style>
94        <div class="content">
95            <div class="interval"></div>
96            <lit-tabs id="tabs" position="top-left" activekey="1" mode="card">
97                    <lit-tabpane key="1" tab="CPU Data">
98                        <tab-cpu-analysis id="cpu-analysis"></tab-cpu-analysis>
99                    </lit-tabpane>
100                    <lit-tabpane key="2" tab="Thread Analysis">
101                        <tab-thread-analysis id="thread-analysis"></tab-thread-analysis>
102                    </lit-tabpane>
103            </lit-tabs>
104        </div>
105        `;
106  }
107}
108