blob: 7e580030e6ed9879072f33cda0bae8af37fe7939 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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_SOURCE_CPU_MAC_H_
12#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_
13
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000014#include "system_wrappers/interface/cpu_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000017
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000018class CpuWrapperMac : public CpuWrapper {
19 public:
20 CpuWrapperMac();
21 virtual ~CpuWrapperMac();
niklase@google.com470e71d2011-07-07 08:21:25 +000022
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000023 virtual WebRtc_Word32 CpuUsage();
24 virtual WebRtc_Word32 CpuUsage(WebRtc_Word8* process_name,
25 WebRtc_UWord32 length) {
26 return -1;
27 }
28 virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32 process_id) {
29 return -1;
30 }
niklase@google.com470e71d2011-07-07 08:21:25 +000031
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000032 // Note: this class will block the call and sleep if called too fast
33 // This function blocks the calling thread if the thread is calling it more
34 // often than every 500 ms.
35 virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& num_cores,
36 WebRtc_UWord32*& array);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000038 virtual void Reset() {}
39 virtual void Stop() {}
40
41 private:
42 WebRtc_Word32 Update(WebRtc_Word64 time_diffMS);
43
44 WebRtc_UWord32 cpu_count_;
45 WebRtc_UWord32* cpu_usage_;
46 WebRtc_Word32 total_cpu_usage_;
47 WebRtc_Word64* last_tick_count_;
48 WebRtc_Word64 last_time_;
niklase@google.com470e71d2011-07-07 08:21:25 +000049};
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000050
niklase@google.com470e71d2011-07-07 08:21:25 +000051} // namespace webrtc
52
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000053#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_