From 7c299252716b937f546ba0864805eade2dd86be3 Mon Sep 17 00:00:00 2001 From: yunan Date: Sun, 27 Apr 2025 18:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E8=84=91=E4=BF=A1=E6=81=AF-cpu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++- main.py | 24 ++++++---- 2 files changed, 146 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 99fe7ed..42fb55c 100644 --- a/README.md +++ b/README.md @@ -1 +1,131 @@ -简介 \ No newline at end of file +# 语言 | Language + + [中文](#中文) \| [English](#english) + + + + + + + +--- + +### 中文 + +# 简介 + + + +技术选型:PySide6 + +仿照对象:windows任务管理器 + +重要描述:主要目的是学习pyside6,当然目前还在追求实现功能中(小白一只,只会调库,暂不会自研),把能直接完成的尽快完成,然后重点优化排版与样式 + + + +预期功能: + +1. CPU: + - 获取cpu名称 - [✔] + - 实时cpu利用率 - [✔] + - 实时获取cpu速度 - [✘] + - 实时获取进程数 - [✔] + - 实时获取线程数 - [✔] + - 实时获取句柄数 - [✔] + - 获取系统正常运行时间 - [✘] + - 获取cpu基准速度 - [✔] + - 获取cpu插槽数 - [✘] + - 获取cpu内核数 - [✔] + - 获取cpu逻辑处理器数 - [✔] + - 获取虚拟化信息 - [✘] + - 获取L1缓存 - [✘] + - 获取L2缓存 - [✔] + - 获取L3缓存 - [✔] + +存在问题: + +目前来说,在获取 进线程数量以及句柄数量时,API的调用会造成卡顿。完全比不上任务管理器的丝滑。 + +当然还有一大堆问题亟待解决,如何利用python获取完整的硬件信息我还在寻找库中,目前psutil 和 wmi 库貌似只能提供主要数据,有些数据就无法获取。 + + + + + +目标图(Win11任务管理器): + +![image-20250427173734088](C:\Users\yunan\AppData\Roaming\Typora\typora-user-images\image-20250427173734088.png) + +实际图: + +![image-20250427173824906](C:\Users\yunan\AppData\Roaming\Typora\typora-user-images\image-20250427173824906.png) + +2. 内存: + - 实时内存使用量 - [✘] + - 实时内存组合 - [✘] + - 已提交 - [✘] + - 已缓存 - [✘] + - 分页缓冲池 - [✘] + - 非分页缓冲池 - [✘] + - 内存速度 - [✘] + - 已使用插槽数 - [✘] + - 外形规格 - [✘] + - 为硬件保留的内存 - [✘] +3. 磁盘: + - 磁盘名称 - [✘] + - 磁盘处理请求的时间百分比 - [✘] + - 磁盘传输速率 - [✘] + - 活动时间 - [✘] + - 平均响应时间 - [✘] + - 读取速度 - [✘] + - 写入速度 - [✘] + - 容量 - [✘] + - 已格式化大小 - [✘] + - 是否系统磁盘 - [✘] + - 是否页面文件 - [✘] + - 磁盘类型 - [✘] +4. WIFI: + - 网卡名称 - [✘] + - 吞吐量 - [✘] + - 发送 - [✘] + - 接收 - [✘] + - 适配器名称 - [✘] + - SSID - [✘] + - 连接类型 - [✘] + - IPV4 - [✘] + - IPV6 - [✘] + - 信号强度 - [✘] +5. GPU: + - GPU名称 - [✘] + - 3D - [✘] + - Copy - [✘] + - Video Decode - [✘] + - Video Processing - [✘] + - 共享GPU内存 - [✘] + - 实时利用率 - [✘] + - GPU内存 - [✘] + - 驱动版本 - [✘] + - 驱动日期 - [✘] + - DirectX版本 - [✘] + - 物理位置 - [✘] + + + + + + + + + + + + + +--- + +### English + + + +没有英文版,就意思意思。 \ No newline at end of file diff --git a/main.py b/main.py index 279f9fa..0fb1703 100644 --- a/main.py +++ b/main.py @@ -71,49 +71,55 @@ class MyWindow(QWidget): self.series.attachAxis(self.data_axisX) self.series.attachAxis(self.value_axisY) self.ui.graphicsView.setChart(self.chart) - + # 获取cpu分级缓存(暂无法获取L1缓存) self.ui.cpu_L2_cache_value.setText(str(self.c.Win32_Processor()[0].L2CacheSize / 1024)+' MB') self.ui.cpu_L3_cache_value.setText(str(self.c.Win32_Processor()[0].L3CacheSize / 1024)+' MB') - # print("系统名称: "+self.c.Win32_OperatingSystem()[0].Caption) cpufreq = psutil.cpu_freq() + # 获取cpu内核数 self.ui.cpu_kernel_value.setText(str(psutil.cpu_count(logical=False))) + # 获取cpu逻辑处理器数量 self.ui.cpu_logicprocessor_value.setText(str(psutil.cpu_count(logical=True))) + # 获取cpu基准速度 self.ui.cpu_basespeed_value.setText(str('%.2f'% (cpufreq.current/1000))+' GHz') + # 获取cpu名称 self.ui.cpu_name.setText(str(self.c.Win32_Processor()[0].Name)) - + # 定时 def set_timer(self): self.timer = QTimer(self) self.timer.timeout.connect(self.cpuLoad) - self.timer.start(1000) # 每隔200毫秒出一个点 + self.timer.start(1000) # 每隔1000毫秒出一个点 def cpuLoad(self): current_time = QDateTime.currentDateTime() self.data_axisX.setMin(current_time.addSecs(-self.limitminute*60)) self.data_axisX.setMax(current_time.addSecs(0)) + cpuload = psutil.cpu_percent() self.series.append(current_time.toMSecsSinceEpoch(),cpuload) + if self.series.at(0): + # 图表更新 # Returns the datetime as the number of milliseconds that have passed since 1970-01-01T00:00:00.000,Coordinated Universal Time(UTC) if self.series.at(0).x()