• 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// @ts-ignore
17import {CpuUsage, Freq} from "../../../dist/trace/bean/CpuUsage.js"
18
19describe('CpuUsage Test', ()=>{
20    let cpuUsage = new CpuUsage();
21    let freq = new Freq();
22
23    it('CpuUsageTest01', function () {
24        cpuUsage = {
25            cpu: 0,
26            usage: 0,
27            usageStr: "",
28            top1: 0,
29            top2: 0,
30            top3: 0,
31            top1Percent: 0,
32            top1PercentStr: "",
33            top2Percent: 0,
34            top2PercentStr: "",
35            top3Percent: 0,
36            top3PercentStr: "",
37        }
38        expect(cpuUsage).not.toBeUndefined()
39        expect(cpuUsage).toMatchInlineSnapshot({
40  cpu: expect.any(Number),
41  usage: expect.any(Number),
42  usageStr: expect.any(String),
43  top1: expect.any(Number),
44  top2: expect.any(Number),
45  top3: expect.any(Number),
46  top1Percent: expect.any(Number),
47  top1PercentStr: expect.any(String),
48  top2Percent: expect.any(Number),
49  top2PercentStr: expect.any(String),
50  top3Percent: expect.any(Number),
51  top3PercentStr: expect.any(String) }, `
52Object {
53  "cpu": Any<Number>,
54  "top1": Any<Number>,
55  "top1Percent": Any<Number>,
56  "top1PercentStr": Any<String>,
57  "top2": Any<Number>,
58  "top2Percent": Any<Number>,
59  "top2PercentStr": Any<String>,
60  "top3": Any<Number>,
61  "top3Percent": Any<Number>,
62  "top3PercentStr": Any<String>,
63  "usage": Any<Number>,
64  "usageStr": Any<String>,
65}
66`);
67    });
68
69    it('CpuUsageTest02', function () {
70        cpuUsage = {
71            cpu: 0,
72            value: 0,
73            startNs: 0,
74            dur: 0,
75        }
76        expect(freq).not.toBeUndefined()
77        expect(cpuUsage).toMatchInlineSnapshot({
78  cpu: expect.any(Number),
79  value: expect.any(Number),
80  startNs: expect.any(Number),
81  dur: expect.any(Number) }, `
82Object {
83  "cpu": Any<Number>,
84  "dur": Any<Number>,
85  "startNs": Any<Number>,
86  "value": Any<Number>,
87}
88`);
89    });
90})
91