feat add profiling
This commit is contained in:
41
3party/cppuprofile/lib/util/cpumonitor.h
Normal file
41
3party/cppuprofile/lib/util/cpumonitor.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// Software Name : cppuprofile
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2022 Orange
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
//
|
||||
// This software is distributed under the BSD License;
|
||||
// see the LICENSE file for more details.
|
||||
//
|
||||
// Author: Cédric CHEDALEUX <cedric.chedaleux@orange.com> et al.
|
||||
|
||||
#ifndef CPUMONITOR_H_
|
||||
#define CPUMONITOR_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace uprofile
|
||||
{
|
||||
|
||||
class CpuMonitor
|
||||
{
|
||||
public:
|
||||
explicit CpuMonitor();
|
||||
virtual ~CpuMonitor();
|
||||
|
||||
vector<float> getUsage();
|
||||
|
||||
private:
|
||||
static size_t getNumberOfCPUCores();
|
||||
static void extractCpuTimes(const string& cpuInfo, size_t& idleTime, size_t& totalTime);
|
||||
|
||||
// Store the last idle and total time for each CPU
|
||||
vector<size_t> m_lastIdleTimes;
|
||||
vector<size_t> m_lastTotalTimes;
|
||||
|
||||
size_t m_nbCpus;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* CPUMONITOR_H_ */
|
Reference in New Issue
Block a user