Home | History | Annotate | Download | only in interface
      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 CpuWrapper* CreateCpu();
     21     virtual ~CpuWrapper() {}
     22 
     23     // Returns the average CPU usage for all processors. The CPU usage can be
     24     // between and including 0 to 100 (%)
     25     virtual WebRtc_Word32 CpuUsage() = 0;
     26     virtual WebRtc_Word32 CpuUsage(WebRtc_Word8* processName,
     27                                    WebRtc_UWord32 length) = 0;
     28     virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32  dwProcessID) = 0;
     29 
     30     // The CPU usage per core is returned in cpu_usage. The CPU can be between
     31     // and including 0 to 100 (%)
     32     // Note that the pointer passed as cpu_usage is redirected to a local member
     33     // of the CPU wrapper.
     34     // numCores is the number of cores in the cpu_usage array.
     35     // The return value is -1 for failure or 0-100, indicating the average
     36     // CPU usage across all cores.
     37     // Note: on some OSs this class is initialized lazy. This means that it
     38     // might not yet be possible to retrieve any CPU metrics. When this happens
     39     // the return value will be zero (indicating that there is not a failure),
     40     // numCores will be 0 and cpu_usage will be set to NULL (indicating that
     41     // no metrics are available yet). Once the initialization is completed,
     42     // which can take in the order of seconds, CPU metrics can be retrieved.
     43     virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& numCores,
     44                                             WebRtc_UWord32*& cpu_usage) = 0;
     45 
     46     virtual void Reset() = 0;
     47     virtual void Stop() = 0;
     48 
     49 protected:
     50     CpuWrapper() {}
     51 };
     52 } // namespace webrtc
     53 #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_
     54