ImSQL
C++ 기반 SQL 자동화 및 라이선스 관리 엔진
Loading...
Searching...
No Matches
system_info_cpu.hpp
1
12#pragma once
13
14#include <mutex>
15#include <atomic>
16#include <fstream>
17#include <string>
18#include <thread>
19#include <chrono>
20#include <cstdint>
21
22namespace utils::system_info {
23
27struct CPU {
31 struct Stat {
32 uint64_t idleTotal;
33 uint64_t total;
34 };
35
48 struct TimeStat {
49 uint64_t user, nice, system, idle, io_wait, irq, soft_irq, steal;
50
55 [[nodiscard]] uint64_t getIdleTotal() const noexcept {
56 return idle + io_wait;
57 }
58
63 [[nodiscard]] uint64_t getTotal() const noexcept {
64 return user + nice + system + idle + io_wait + irq + soft_irq + steal;
65 }
66 };
67
71 struct Usage {
72 uint64_t idle;
73 uint64_t total;
74 };
75
81 static Stat read();
82
89 static float calculate(const Usage& prev, const Usage& curr);
90};
91
97void updateCPUUsage();
98
102void startSystemUsageUpdater();
103
109std::string getCpuModel();
110
116float getLatestCpuUsage();
117
118} // namespace utils::system_info // end of SystemUsage
CPU의 기본 상태를 나타내는 구조체.
Definition system_info_cpu.hpp:31
uint64_t idleTotal
유휴 시간 + IO 대기 시간
Definition system_info_cpu.hpp:32
uint64_t total
전체 CPU 시간
Definition system_info_cpu.hpp:33
CPU 시간 관련 세부 통계.
Definition system_info_cpu.hpp:48
uint64_t getIdleTotal() const noexcept
idle + io_wait 합을 계산합니다.
Definition system_info_cpu.hpp:55
uint64_t getTotal() const noexcept
모든 CPU 시간 총합을 계산합니다.
Definition system_info_cpu.hpp:63
CPU 사용량을 계산하기 위한 간단한 구조체.
Definition system_info_cpu.hpp:71
uint64_t idle
유휴 시간
Definition system_info_cpu.hpp:72
uint64_t total
전체 시간
Definition system_info_cpu.hpp:73
CPU 상태 및 사용량 정보를 관리하는 구조체 및 함수 모음.
Definition system_info_cpu.hpp:27
static float calculate(const Usage &prev, const Usage &curr)
이전 사용량과 현재 사용량을 비교하여 CPU 사용률을 계산합니다.
Definition system_info_cpu.cpp:60
static Stat read()
현재 CPU 사용 상태를 읽어옵니다.
Definition system_info_cpu.cpp:45