1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_ 12 #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_ 13 14 #include "typedefs.h" 15 16 namespace webrtc { 17 class CpuWrapper 18 { 19 public: 20 static WebRtc_UWord32 DetectNumberOfCores(); 21 22 static CpuWrapper* CreateCpu(); 23 virtual ~CpuWrapper() {} 24 25 // Returns the average CPU usage for all processors. The CPU usage can be 26 // between and including 0 to 100 (%) 27 virtual WebRtc_Word32 CpuUsage() = 0; 28 virtual WebRtc_Word32 CpuUsage(WebRtc_Word8* processName, 29 WebRtc_UWord32 length) = 0; 30 virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32 dwProcessID) = 0; 31 32 // The CPU usage per core is returned in cpu_usage. The CPU can be between 33 // and including 0 to 100 (%) 34 // Note that the pointer passed as cpu_usage is redirected to a local member 35 // of the CPU wrapper. 36 // numCores is the number of cores in the cpu_usage array. 37 virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& numCores, 38 WebRtc_UWord32*& cpu_usage) = 0; 39 40 virtual void Reset() = 0; 41 virtual void Stop() = 0; 42 43 protected: 44 CpuWrapper() {} 45 46 private: 47 static WebRtc_UWord32 _numberOfCores; 48 49 }; 50 } // namespace webrtc 51 #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_ 52