pmonitor 1.3.6__tar.gz → 1.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pmonitor-1.3.6 → pmonitor-1.3.7}/PKG-INFO +1 -1
- pmonitor-1.3.7/monitor/mac_gpu.py +53 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/monitor_pids.py +2 -21
- {pmonitor-1.3.6 → pmonitor-1.3.7}/pmonitor.egg-info/PKG-INFO +1 -1
- {pmonitor-1.3.6 → pmonitor-1.3.7}/pmonitor.egg-info/SOURCES.txt +1 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/setup.py +2 -2
- {pmonitor-1.3.6 → pmonitor-1.3.7}/README.md +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/GpuMonitorLib.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/KernelBase.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/__init__.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/advapi32.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/bcrypt.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/kernel.appcore.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/kernel32.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/msvcirt.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/msvcp140.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/ntdll.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/pdh.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/rpcrt4.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/sechost.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/ucrtbased.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/vcruntime140.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/DLL/vcruntime140_1.dll +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/WinPidUtil.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/__init__.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/exec/GpuMonitor +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/exec/__init__.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/get_process_name.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/monitor_mac.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/monitor_win.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/run_monitor.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/monitor/sys_info.py +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/pmonitor.egg-info/dependency_links.txt +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/pmonitor.egg-info/entry_points.txt +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/pmonitor.egg-info/top_level.txt +0 -0
- {pmonitor-1.3.6 → pmonitor-1.3.7}/setup.cfg +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import objc
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
IOKit = Foundation.NSBundle.bundleWithIdentifier_("com.apple.framework.IOKit")
|
|
5
|
+
|
|
6
|
+
functions = [
|
|
7
|
+
("IOServiceGetMatchingService", b"II@"),
|
|
8
|
+
("IOServiceMatching", b"@*"),
|
|
9
|
+
("IORegistryEntryCreateCFProperties", b"IIo^@@I"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
objc.loadBundleFunctions(IOKit, globals(), functions)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def accelerator_performance_statistics() -> dict[str, int]:
|
|
16
|
+
accelerator_info = IOServiceGetMatchingService(
|
|
17
|
+
0, IOServiceMatching(b"IOAccelerator")
|
|
18
|
+
)
|
|
19
|
+
if accelerator_info == 0:
|
|
20
|
+
raise RuntimeError("IOAccelerator not found")
|
|
21
|
+
# else...
|
|
22
|
+
err, props = IORegistryEntryCreateCFProperties(accelerator_info, None, None, 0)
|
|
23
|
+
if err != 0:
|
|
24
|
+
raise RuntimeError("IOAccelerator properties not found")
|
|
25
|
+
# else...
|
|
26
|
+
return dict(props)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_gpu_memory():
|
|
30
|
+
try:
|
|
31
|
+
gpu_info = accelerator_performance_statistics()
|
|
32
|
+
use_gpu_memory = 0
|
|
33
|
+
device_usage = 0
|
|
34
|
+
print(f"gpu_info: {gpu_info['PerformanceStatistics']}")
|
|
35
|
+
for key, value in gpu_info["PerformanceStatistics"].items():
|
|
36
|
+
if key == "In use system memory":
|
|
37
|
+
use_gpu_memory = int(value) / 1024 / 1024
|
|
38
|
+
print(f"{key}: {value}")
|
|
39
|
+
elif key == "inUseSysMemoryBytes":
|
|
40
|
+
use_gpu_memory = int(value) / 1024 / 1024
|
|
41
|
+
print(f"{key}: {value}")
|
|
42
|
+
elif key == "Device Utilization %":
|
|
43
|
+
device_usage = int(value)
|
|
44
|
+
print('device usage', device_usage)
|
|
45
|
+
# use_gpu_memory = gpu_info["PerformanceStatistics"]["In use system memory"]
|
|
46
|
+
# total_gpu_memory = gpu_info["PerformanceStatistics"]["Alloc system memory"]
|
|
47
|
+
except Exception as e:
|
|
48
|
+
print(f"Mac端在arm64平台通过接口获取Gpu Memory失败:{e}")
|
|
49
|
+
use_gpu_memory = 0
|
|
50
|
+
return use_gpu_memory, device_usage
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
print(get_gpu_memory())
|
|
@@ -10,6 +10,7 @@ import os
|
|
|
10
10
|
import stat
|
|
11
11
|
import subprocess
|
|
12
12
|
import re
|
|
13
|
+
import mac_gpu
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class PidsPerf:
|
|
@@ -21,14 +22,6 @@ class PidsPerf:
|
|
|
21
22
|
|
|
22
23
|
def get_mac_perf(self):
|
|
23
24
|
current_pid = self.processUtil.find_main_process_pid(self.process_name)
|
|
24
|
-
gpu_tool = os.path.join(os.path.dirname(__file__), 'exec', 'GpuMonitor')
|
|
25
|
-
if os.path.exists(gpu_tool):
|
|
26
|
-
if not os.access(gpu_tool, os.X_OK):
|
|
27
|
-
try:
|
|
28
|
-
current_permissions = os.stat(gpu_tool).st_mode
|
|
29
|
-
os.chmod(gpu_tool, current_permissions | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
|
|
30
|
-
except Exception as e:
|
|
31
|
-
raise e
|
|
32
25
|
while True:
|
|
33
26
|
minor_cpu_sum = 0
|
|
34
27
|
minor_real_mem_sum = 0
|
|
@@ -42,19 +35,7 @@ class PidsPerf:
|
|
|
42
35
|
current_pids.add(current_pid) # 将主进程及子进程添加到list中
|
|
43
36
|
pids_process = self.processUtil.get_pids_process(current_pids) # 获取所有进程
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
for line in result.stdout.split('\n'):
|
|
47
|
-
pattern = r"GPU Name:(.*?),Device Percent:(.*?),Dedicated Usage:(\d+)"
|
|
48
|
-
matches = re.findall(pattern, line)
|
|
49
|
-
for match in matches:
|
|
50
|
-
gpu_name, device_percent, dedicated_usage = match
|
|
51
|
-
if 'driver' in gpu_name or 'Apple' in gpu_name:
|
|
52
|
-
gpu_memory_usage_0 = round(float(dedicated_usage) / 1024 / 1024, 2)
|
|
53
|
-
gpu_memory_percent_0 = round(float(device_percent), 2)
|
|
54
|
-
else:
|
|
55
|
-
gpu_memory_usage_1 = round(float(dedicated_usage) / 1024 / 1024, 2)
|
|
56
|
-
gpu_memory_percent_1 = round(float(device_percent), 2)
|
|
57
|
-
|
|
38
|
+
gpu_memory_usage_0, gpu_memory_percent_0 = mac_gpu.get_gpu_memory()
|
|
58
39
|
for process in pids_process:
|
|
59
40
|
try:
|
|
60
41
|
cpu_percent = process.cpu_percent()
|
|
@@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
|
|
|
5
5
|
long_description = f.read()
|
|
6
6
|
|
|
7
7
|
setup(name='pmonitor',
|
|
8
|
-
version='1.3.
|
|
8
|
+
version='1.3.7',
|
|
9
9
|
description='pc monitor',
|
|
10
10
|
long_description=long_description,
|
|
11
11
|
author='cfr',
|
|
@@ -14,7 +14,7 @@ setup(name='pmonitor',
|
|
|
14
14
|
license='MIT',
|
|
15
15
|
packages=find_packages(),
|
|
16
16
|
package_data={
|
|
17
|
-
'monitor': ['DLL/*'
|
|
17
|
+
'monitor': ['DLL/*'],
|
|
18
18
|
},
|
|
19
19
|
platforms=['all'],
|
|
20
20
|
classifiers=[],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|