| 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 | |
| 14 | #include "cpu_wrapper.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | class CpuLinux : public CpuWrapper { |
| 18 | public: |
| 19 | CpuLinux(); |
| 20 | virtual ~CpuLinux(); |
| 21 | |
| 22 | int32_t CpuUsage() override; |
| 23 | int32_t CpuUsage(int8_t* pProcessName, uint32_t length) override { return 0; } |
| 24 | int32_t CpuUsage(uint32_t dwProcessID) override { return 0; } |
| 25 | |
| 26 | int32_t CpuUsageMultiCore(uint32_t& numCores, uint32_t*& array) override; |
| 27 | |
| 28 | void Reset() override { return; } |
| 29 | void Stop() override { return; } |
| 30 | |
| 31 | int GetNumCores() override; |
| 32 | |
| 33 | private: |
| 34 | int GetData(long long& busy, |
| 35 | long long& idle, |
| 36 | long long*& busyArray, |
| 37 | long long*& idleArray); |
| 38 | |
| 39 | |
| 40 | long long m_oldBusyTime; |
| 41 | long long m_oldIdleTime; |
| 42 | |
| 43 | long long* m_oldBusyTimeMulti; |
| 44 | long long* m_oldIdleTimeMulti; |
| 45 | |
| 46 | long long* m_idleArray; |
| 47 | long long* m_busyArray; |
| 48 | uint32_t* m_resultArray; |
| 49 | uint32_t m_numCores; |
| 50 | }; |
| 51 | } // namespace webrtc |
| 52 | |
| 53 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_LINUX_H_ |