blob: 804b53e27cff10a4ef768f1dbadb3d91077d49fa [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_LINUX_H_
12#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_LINUX_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 CpuLinux : public CpuWrapper {
19 public:
20 CpuLinux();
21 virtual ~CpuLinux();
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 0;
27 }
28 virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32 process_id) {
29 return 0;
30 }
niklase@google.com470e71d2011-07-07 08:21:25 +000031
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000032 virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& num_cores,
33 WebRtc_UWord32*& array);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000035 virtual void Reset() {
36 return;
37 }
38 virtual void Stop() {
39 return;
40 }
41 private:
42 int GetData(long long& busy, long long& idle, long long*& busy_array,
43 long long*& idle_array);
44 int GetNumCores();
niklase@google.com470e71d2011-07-07 08:21:25 +000045
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000046 long long old_busy_time_;
47 long long old_idle_time_;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000049 long long* old_busy_time_multi_;
50 long long* old_idle_time_multi_;
51
52 long long* idle_array_;
53 long long* busy_array_;
54 WebRtc_UWord32* result_array_;
55 WebRtc_UWord32 num_cores_;
niklase@google.com470e71d2011-07-07 08:21:25 +000056};
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000057
niklase@google.com470e71d2011-07-07 08:21:25 +000058} // namespace webrtc
59
phoglund@webrtc.orgb15d2852012-11-21 08:02:57 +000060#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_LINUX_H_