• 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
16@Component
17export default struct DebugInfo {
18  @Prop debugWindow: boolean
19  private pssMemory: number
20  private sharedMemory: number
21  private privateMemory: number
22
23  build() {
24    Stack({ alignContent: Alignment.Top }) {
25      Text($r('app.string.navigation_information'))
26        .fontSize(25)
27        .width('80%')
28        .lineHeight(40)
29        .margin({ top: '20%' })
30        .fontWeight(FontWeight.Bold)
31
32      if (this.debugWindow) {
33        Column() {
34          this.showDebug($r('app.string.pss'), this.pssMemory)
35          this.showDebug($r('app.string.sharedDirty'), this.sharedMemory)
36          this.showDebug($r('app.string.privateDirty'), this.privateMemory)
37        }
38        .width('85%')
39        .height('25%')
40        .margin({ top: '40%' })
41        .padding({ bottom: '5%', top: '5%' })
42        .backgroundColor(Color.White)
43        .border({ width: 2, radius: 10 })
44      }
45    }
46    .width('100%')
47    .height('100%')
48  }
49
50  @Builder
51  // Debug显示信息复用组件
52  showDebug(title: Resource, data: number) {
53    Row() {
54      Text(title)
55        .fontSize(20)
56        .width('60%')
57        .margin({ left: 6 })
58        .textAlign(TextAlign.End)
59
60      Text(`${data}KB`)
61        .fontSize(20)
62    }
63    .width('100%')
64    .margin({ top: 10 })
65  }
66}