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