niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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_SOURCE_CPU_LINUX_H_ |
| 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_LINUX_H_ |
| 13 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 14 | #include "system_wrappers/interface/cpu_wrapper.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 18 | class CpuLinux : public CpuWrapper { |
| 19 | public: |
| 20 | CpuLinux(); |
| 21 | virtual ~CpuLinux(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 23 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 32 | virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& num_cores, |
| 33 | WebRtc_UWord32*& array); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 35 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 46 | long long old_busy_time_; |
| 47 | long long old_idle_time_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 49 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | }; |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 57 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | } // namespace webrtc |
| 59 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 60 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_LINUX_H_ |