• 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 */
15import { CPU } from '../item/CPU'
16import { GPU } from '../item/GPU'
17import { FPS } from '../item/FPS'
18import { Power } from '../item/Power'
19import { RAM } from '../item/RAM'
20import { Thermal } from '../item/Thermal'
21import { DDR } from '../item/DDR'
22import { NetWork } from '../item/NetWork';
23import { CollectorType } from './ProfilerConstant'
24import { BaseProfiler } from './BaseProfiler'
25import SPLogger from '../../../common/utils/SPLogger'
26
27export class ProfilerFactory {
28  static getProfilerByConfig(moduleName: string): BaseProfiler{
29    if (moduleName == CollectorType.TYPE_FPS) {
30
31      return FPS.getInstance()
32    } else if (moduleName == CollectorType.TYPE_CPU) {
33
34      return CPU.getInstance()
35    } else if (moduleName == CollectorType.TYPE_GPU) {
36
37      return GPU.getInstance()
38    } else if (moduleName == CollectorType.TYPE_POWER) {
39
40      return Power.getInstance()
41    } else if (moduleName == CollectorType.TYPE_RAM) {
42
43      return RAM.getInstance()
44    } else if (moduleName == CollectorType.TYPE_TEMPERATURE) {
45
46      return Thermal.getInstance()
47    } else if (moduleName == CollectorType.TYPE_DDR) {
48
49      return DDR.getInstance()
50    }else if (moduleName == CollectorType.TYPE_NET) {
51
52      return NetWork.getInstance()
53    }
54    return null
55  }
56}