• 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
17// @ts-ignore
18import {getDataNo,
19  getFormatData,
20  getInitializeTime
21  // @ts-ignore
22} from "../../../../../dist/trace/component/schedulingAnalysis/utils/Utils.js";
23
24describe('schedulingAnalysis utils  Test', () => {
25  it('schedulingAnalysisUtilsTest01', () => {
26    expect(getFormatData([{
27      avg:5,
28      max:10,
29      min:1,
30      sum:16
31    }])).toStrictEqual([
32      {
33        "avg": "5ns ",
34        "index": 1,
35        "max": "10ns ",
36        "min": "1ns ",
37        "sum": "16ns "
38      }
39    ]);
40  });
41  it('schedulingAnalysisUtilsTest02', () => {
42    expect(getDataNo([{
43      avg:5,
44      max:10,
45      min:1,
46      sum:16
47    }])).toStrictEqual([
48      {
49        "avg": 5,
50        "index": 1,
51        "max": 10,
52        "min": 1,
53        "sum": 16
54      }
55    ]);
56  });
57  // 23m46s12ms32μs
58  it('schedulingAnalysisUtilsTest03', () => {
59    expect(getInitializeTime('1h')).toBe('3600000000000');
60  });
61  it('schedulingAnalysisUtilsTest04', () => {
62    expect(getInitializeTime(' 23m')).toBe('1380000000000');
63  });
64  it('schedulingAnalysisUtilsTest05', () => {
65    expect(getInitializeTime('46s')).toBe('46000000000');
66  });
67})
68