-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpustats.h
More file actions
55 lines (43 loc) · 1.03 KB
/
cpustats.h
File metadata and controls
55 lines (43 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CPUSTATS_H
#define CPUSTATS_H
#include <chrono>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
class CPUStats
{
public:
static std::vector<std::pair<std::string,float>> get_cpus_activity();
static std::vector<float> get_cpus_activity_vector(); ///<jsut returns the activiy wihtout nametags, 0 elemten tis always the whole CPU stat
static size_t get_cpu_count();
private:
CPUStats() = default;
static constexpr int NUM_CPU_STATES = 10;
enum CPUStates
{
S_USER = 0,
S_NICE,
S_SYSTEM,
S_IDLE,
S_IOWAIT,
S_IRQ,
S_SOFTIRQ,
S_STEAL,
S_GUEST,
S_GUEST_NICE
};
struct CPUData
{
std::string cpu;
size_t times[NUM_CPU_STATES];
};
static void ReadStatsCPU(std::vector<CPUData> & entries);
static size_t GetIdleTime(const CPUData & e);
static size_t GetActiveTime(const CPUData & e);
static std::vector<CPUData> m_CurrentEntries;
static std::vector<CPUData> m_PreviousEntries;
};
#endif // CPUSTATS_H