From 4b6f5e5b99b9461fca2245a7639b63bb76dc4f9a Mon Sep 17 00:00:00 2001 From: liuxiong Date: Thu, 1 Aug 2024 11:49:18 +0800 Subject: [PATCH 1/2] improve startup speed: for windows, linux and macos, use specified method to get cpu brand --- general/hardware.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/general/hardware.py b/general/hardware.py index 26645c8..dcc99c9 100644 --- a/general/hardware.py +++ b/general/hardware.py @@ -1,5 +1,7 @@ import platform +import re import cpuinfo +from cpuinfo import DataSource import psutil from .gpu import CGPUInfo from .hdd import getDrivesInfo @@ -36,21 +38,47 @@ def __init__(self, switchCPU=False, switchGPU=False, switchHDD=False, switchRAM= self.switchHDD = switchHDD self.switchRAM = switchRAM - get_cpu_info = cpuinfo.get_cpu_info() - specName = 'CPU: ' + get_cpu_info.get('brand_raw', "Unknown") - specArch = 'Arch: ' + get_cpu_info.get('arch_string_raw', "Unknown") - specOs = 'OS: ' + str(platform.system()) + ' ' + str(platform.release()) - logger.info(f"{specName} - {specArch} - {specOs}") + self.print_sys_info() self.GPUInfo = CGPUInfo() self.switchGPU = switchGPU self.switchVRAM = switchVRAM + def print_sys_info(self): + brand = None + if DataSource.is_windows: # Windows + brand = DataSource.winreg_processor_brand().strip() + elif DataSource.has_proc_cpuinfo(): # Linux + return_code, output = DataSource.cat_proc_cpuinfo() + if return_code == 0 and output is not None: + for line in output.splitlines(): + r = re.search(r'model name\s*:\s*(.+)', line) + if r: + brand = r.group(1) + break + elif DataSource.has_sysctl(): # macOS + return_code, output = DataSource.sysctl_machdep_cpu_hw_cpufrequency() + if return_code == 0 and output is not None: + for line in output.splitlines(): + r = re.search(r'machdep\.cpu\.brand_string\s*:\s*(.+)', line) + if r: + brand = r.group(1) + break + + # fallback to use cpuinfo.get_cpu_info() + if not brand: + brand = cpuinfo.get_cpu_info().get('brand_raw', "Unknown") + + specName = 'CPU: ' + brand + specArch = 'Arch: ' + DataSource.arch_string_raw + specOs = 'OS: ' + str(platform.system()) + ' ' + str(platform.release()) + logger.info(f"{specName} - {specArch} - {specOs}") + def getHDDsInfo(self): - return getDrivesInfo() + return getDrivesInfo() def getGPUInfo(self): - return self.GPUInfo.getInfo() + return self.GPUInfo.getInfo() def getStatus(self): cpu = -1 From 54fb81896101ecf9683187ddd82c8e79e16ac920 Mon Sep 17 00:00:00 2001 From: Crystian Date: Thu, 1 Aug 2024 22:11:48 +0200 Subject: [PATCH 2/2] new version with speedy bootstrap --- __init__.py | 2 +- core/version.py | 2 +- pyproject.toml | 2 +- version | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 8c72bc6..4f5f79c 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ @author: Crystian @title: Crystools @nickname: Crystools -@version: 1.16.4 +@version: 1.16.5 @project: "https://github.com/crystian/ComfyUI-Crystools", @description: Plugins for multiples uses, mainly for debugging, you need them! IG: https://www.instagram.com/crystian.ia """ diff --git a/core/version.py b/core/version.py index 946a502..aa79aaa 100644 --- a/core/version.py +++ b/core/version.py @@ -1 +1 @@ -version = "1.16.4" +version = "1.16.5" diff --git a/pyproject.toml b/pyproject.toml index c2ae595..987cf03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-crystools" description = "With this suit, you can see the resources monitor, progress bar & time elapsed, metadata and compare between two images, compare between two JSONs, show any value to console/display, pipes, and more!\nThis provides better nodes to load/save images, previews, etc, and see \"hidden\" data without loading a new workflow." -version = "1.16.4" +version = "1.16.5" license = { file = "LICENSE" } dependencies = ["deepdiff", "torch", "numpy", "Pillow", "pynvml", "py-cpuinfo"] diff --git a/version b/version index a232073..0d92a10 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.16.4 +1.16.5