DtkDevice
DTK library for device.
dcpudevice.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4#ifndef DCPUDEVICE_H
5#define DCPUDEVICE_H
6
7#include "dtkdevice_global.h"
8
9#include <QObject>
10
11DDEVICE_BEGIN_NAMESPACE
12
13class DCpuDevicePrivate;
14class LIBDTKDEVICESHARED_EXPORT DCpuDevice : public QObject
15{
16public:
17 struct DCpuStat {
18 quint64 user {0}; // user time
19 quint64 nice {0}; // user time with low priority
20 quint64 sys {0}; // system time
21 quint64 idle {0}; // idle time
22 quint64 iowait {0}; // io wait time
23 quint64 hardirq {0}; // interrupt time
24 quint64 softirq {0}; // soft interrupt time
25 quint64 steal {0}; // stolen time
26 quint64 guest {0}; // guest time
27 quint64 guestNice {0}; // guest time (niced)
28 };
29
30 struct DCpuUsage {
31 quint64 total {0};
32 quint64 idle {0};
33 };
34
35 explicit DCpuDevice(QObject *parent = nullptr);
37
39 int coreCount(int physicalID);
40 int threadCount(int physicalID, int coreID);
41 int physicalID(int processorID);
42 int coreID(int processorID);
43 QString architecture(int physicalID);
44 QString vendor(int physicalID);
45 QString model(int physicalID);
46 QString minFreq(int processorID);
47 QString maxFreq(int processorID);
48 QString cache(int processorID, QString type);
49 QString flags(int processorID);
50 QString stepping(int processorID);
51 QString family(int processorID);
52 QString bogoMIPS(int processorID);
53
54 QString temperature(int physicalID);
55 QString currentFreq(int processorID);
58 DCpuStat stat(int processorID);
59 DCpuUsage usage(int processorID);
60
61private:
62 QScopedPointer<DCpuDevicePrivate> d_ptr;
63 Q_DECLARE_PRIVATE(DCpuDevice)
64};
65
66DDEVICE_END_NAMESPACE
67
68#endif // DCPUDEVICE_H
CPU设备信息.
Definition: dcpudevice.h:15
DCpuStat stat(int processorID)
获取指定线程ID的状态.
QString flags(int processorID)
获取指定线程ID的特性.
QString stepping(int processorID)
获取指定线程ID的步进.
int coreID(int processorID)
获取指定线程ID的物理核ID.
QString model(int physicalID)
获取指定CPU的型号.
DCpuUsage usage(int processorID)
获取指定线程ID的资源占用信息.
DCpuUsage usage()
获取所有CPU的资源占用信息.
int physicalID(int processorID)
获取指定线程ID的CPU的ID.
QString minFreq(int processorID)
获取指定线程ID的最小频率(kHz、MHz、GHz).
int physicalCount()
获取所有物理CPU个数.
QString maxFreq(int processorID)
获取指定线程ID的最大频率(kHz、MHz、GHz).
int threadCount(int physicalID, int coreID)
获取指定CPU和物理核的线程个数.
QString currentFreq(int processorID)
获取指定线程ID的当前频率(kHz、MHz、GHz).
QString temperature(int physicalID)
获取指定CPU的温度.
QString bogoMIPS(int processorID)
获取指定线程ID的运算速度.
QString family(int processorID)
获取指定线程ID的家族.
QString architecture(int physicalID)
获取指定CPU的架构.
QString vendor(int physicalID)
获取指定CPU的厂商.
int coreCount(int physicalID)
获取指定CPU的核心个数.
DCpuStat stat()
获取所有CPU的状态.
QString cache(int processorID, QString type)
获取指定线程ID和缓存类型的缓存大小.
CPU的状态信息
Definition: dcpudevice.h:17
CPU的利用率信息
Definition: dcpudevice.h:30