• 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      return FPS.getInstance();
31    } else if (moduleName == CollectorType.TYPE_CPU) {
32      return CPU.getInstance();
33    } else if (moduleName == CollectorType.TYPE_GPU) {
34      return GPU.getInstance();
35    } else if (moduleName == CollectorType.TYPE_POWER) {
36      return Power.getInstance();
37    } else if (moduleName == CollectorType.TYPE_RAM) {
38      return RAM.getInstance();
39    } else if (moduleName == CollectorType.TYPE_TEMPERATURE) {
40      return Thermal.getInstance();
41    } else if (moduleName == CollectorType.TYPE_DDR) {
42      return DDR.getInstance();
43    } else if (moduleName == CollectorType.TYPE_NET) {
44      return NetWork.getInstance();
45    }
46    return null;
47  }
48}
49