macpm 0.15__tar.gz → 0.23__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.
- macpm-0.23/PKG-INFO +117 -0
- {macpm-0.15 → macpm-0.23}/README.md +4 -2
- {macpm-0.15 → macpm-0.23}/macpm/macpm.py +71 -34
- macpm-0.23/macpm.egg-info/PKG-INFO +117 -0
- {macpm-0.15 → macpm-0.23}/setup.py +2 -2
- macpm-0.15/PKG-INFO +0 -19
- macpm-0.15/macpm.egg-info/PKG-INFO +0 -19
- {macpm-0.15 → macpm-0.23}/LICENSE +0 -0
- {macpm-0.15 → macpm-0.23}/macpm/__init__.py +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/SOURCES.txt +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/dependency_links.txt +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/entry_points.txt +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/not-zip-safe +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/requires.txt +0 -0
- {macpm-0.15 → macpm-0.23}/macpm.egg-info/top_level.txt +0 -0
- {macpm-0.15 → macpm-0.23}/setup.cfg +0 -0
macpm-0.23/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: macpm
|
|
3
|
+
Version: 0.23
|
|
4
|
+
Summary: Performance monitoring CLI tool for Apple Silicon
|
|
5
|
+
Home-page: https://github.com/visualcjy/macpm
|
|
6
|
+
Author: Jinyu Chen
|
|
7
|
+
Author-email: visualcjy@mail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: macpm
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: dashing
|
|
16
|
+
Requires-Dist: psutil
|
|
17
|
+
Requires-Dist: humanize
|
|
18
|
+
|
|
19
|
+
# macpm
|
|
20
|
+
|
|
21
|
+
PyPI - Downloads (https://pypi.org/project/macpm/#files)
|
|
22
|
+
or: pip install macpm
|
|
23
|
+
|
|
24
|
+
enhanced MAC Performance monitoring CLI tool for Apple Silicon
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
```shell
|
|
29
|
+
pip install macpm
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What is `macpm`
|
|
33
|
+
|
|
34
|
+
forked form https://github.com/tlkh/asitop
|
|
35
|
+
1. fixed the problem that "E-CPU Usage" and "P-CPU Usage" always 100%
|
|
36
|
+
2. add "Disk IO" and "Network IO" info
|
|
37
|
+
3. adjust the hard coded max power in CPU/GPU/ANE
|
|
38
|
+
4. change the way to call powermetrics, no temp files in /tmp
|
|
39
|
+
5. press ESC or q to quit
|
|
40
|
+
6. press LEFT or RIGHT to switch color, press 1 : default view, 2 : show_core view
|
|
41
|
+
7. fix M1 has no "down_ratio" tag problem, fix p-core cpu usage
|
|
42
|
+
|
|
43
|
+
A Python-based `nvtop`-inspired command line tool for Apple Silicon (aka M1) Macs.
|
|
44
|
+
|
|
45
|
+
* Utilization info:
|
|
46
|
+
* CPU (E-cluster and P-cluster), GPU
|
|
47
|
+
* Frequency and utilization
|
|
48
|
+
* ANE utilization (measured by power)
|
|
49
|
+
* Memory info:
|
|
50
|
+
* RAM and swap, size and usage
|
|
51
|
+
* (Apple removed memory bandwidth from `powermetrics`)
|
|
52
|
+
* Power info:
|
|
53
|
+
* CPU power, GPU power (Apple removed package power from `powermetrics`)
|
|
54
|
+
* Chart for CPU/GPU power
|
|
55
|
+
* Peak power, rolling average display
|
|
56
|
+
|
|
57
|
+
`macpm` uses the built-in [`powermetrics`](https://www.unix.com/man-page/osx/1/powermetrics/) utility on macOS, which allows access to a variety of hardware performance counters. Note that it requires `sudo` to run due to `powermetrics` needing root access to run. `macpm` is lightweight and has minimal performance impact.
|
|
58
|
+
|
|
59
|
+
**`macpm` only works on Apple Silicon Macs on macOS Monterey!**
|
|
60
|
+
|
|
61
|
+
## Installation and Usage
|
|
62
|
+
|
|
63
|
+
`macpm` is a Python-based command line tool. You need `pip` to download and install `macpm`. macOS already comes with Python, to install `pip`, you can follow an [online guide](https://phoenixnap.com/kb/install-pip-mac). After you install `macpm` via `pip`, you can use it via the Terminal.
|
|
64
|
+
|
|
65
|
+
```shell
|
|
66
|
+
# to enter password before start
|
|
67
|
+
# this mode is recommended!
|
|
68
|
+
sudo macpm
|
|
69
|
+
|
|
70
|
+
# it will prompt password on start
|
|
71
|
+
macpm
|
|
72
|
+
|
|
73
|
+
# advanced options
|
|
74
|
+
macpm [-h] [--interval INTERVAL] [--color COLOR] [--avg AVG]
|
|
75
|
+
optional arguments:
|
|
76
|
+
-h, --help show this help message and exit
|
|
77
|
+
--interval INTERVAL Display interval and sampling interval for powermetrics (seconds)
|
|
78
|
+
--color COLOR Choose display color (0~8)
|
|
79
|
+
--avg AVG Interval for averaged values (seconds)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
`powermetrics` is used to measure the following:
|
|
85
|
+
|
|
86
|
+
* CPU/GPU utilization via active residency
|
|
87
|
+
* CPU/GPU frequency
|
|
88
|
+
* Package/CPU/GPU/ANE energy consumption
|
|
89
|
+
* CPU/GPU/Media Total memory bandwidth via the DCS (DRAM Command Scheduler)
|
|
90
|
+
|
|
91
|
+
[`psutil`](https://github.com/giampaolo/psutil) is used to measure the following:
|
|
92
|
+
|
|
93
|
+
* memory and swap usage
|
|
94
|
+
|
|
95
|
+
[`sysctl`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysctl.3.html) is used to measure the following:
|
|
96
|
+
|
|
97
|
+
* CPU name
|
|
98
|
+
* CPU core counts
|
|
99
|
+
|
|
100
|
+
[`system_profiler`](https://ss64.com/osx/system_profiler.html) is used to measure the following:
|
|
101
|
+
|
|
102
|
+
* GPU core count
|
|
103
|
+
|
|
104
|
+
Some information is guesstimate and hardcoded as there doesn't seem to be a official source for it on the system:
|
|
105
|
+
|
|
106
|
+
* CPU/GPU TDP
|
|
107
|
+
* CPU/GPU maximum memory bandwidth
|
|
108
|
+
* ANE max power
|
|
109
|
+
* Media engine max bandwidth
|
|
110
|
+
|
|
111
|
+
## Why
|
|
112
|
+
|
|
113
|
+
Because I didn't find something like this online. Also, just curious about stuff.
|
|
114
|
+
|
|
115
|
+
## Disclaimers
|
|
116
|
+
|
|
117
|
+
I did this randomly don't blame me if it fried your new MacBook or something.
|
|
@@ -5,8 +5,8 @@ or: pip install macpm
|
|
|
5
5
|
|
|
6
6
|
enhanced MAC Performance monitoring CLI tool for Apple Silicon
|
|
7
7
|
|
|
8
|
-

|
|
9
|
+

|
|
10
10
|
```shell
|
|
11
11
|
pip install macpm
|
|
12
12
|
```
|
|
@@ -19,6 +19,8 @@ forked form https://github.com/tlkh/asitop
|
|
|
19
19
|
3. adjust the hard coded max power in CPU/GPU/ANE
|
|
20
20
|
4. change the way to call powermetrics, no temp files in /tmp
|
|
21
21
|
5. press ESC or q to quit
|
|
22
|
+
6. press LEFT or RIGHT to switch color, press 1 : default view, 2 : show_core view
|
|
23
|
+
7. fix M1 has no "down_ratio" tag problem, fix p-core cpu usage
|
|
22
24
|
|
|
23
25
|
A Python-based `nvtop`-inspired command line tool for Apple Silicon (aka M1) Macs.
|
|
24
26
|
|
|
@@ -9,7 +9,7 @@ import psutil
|
|
|
9
9
|
import plistlib
|
|
10
10
|
import curses
|
|
11
11
|
|
|
12
|
-
version = 'macpm v0.
|
|
12
|
+
version = 'macpm v0.23'
|
|
13
13
|
parser = argparse.ArgumentParser(
|
|
14
14
|
description=f'{version}: Performance monitoring CLI tool for Apple Silicon')
|
|
15
15
|
parser.add_argument('--interval', type=int, default=1,
|
|
@@ -253,12 +253,17 @@ def parse_cpu_metrics(powermetrics_parse):
|
|
|
253
253
|
core = e_core if name[0] == 'E' else p_core
|
|
254
254
|
core.append(cpu["cpu"])
|
|
255
255
|
cpu_metric_dict[name + str(cpu["cpu"]) + "_freq_Mhz"] = int(cpu["freq_hz"] / (1e6))
|
|
256
|
-
|
|
256
|
+
#there is no down_ratio in M1
|
|
257
|
+
if cluster.get("down_ratio") is None:
|
|
258
|
+
idle_ratio = cpu["idle_ratio"]
|
|
259
|
+
else:
|
|
260
|
+
idle_ratio = cluster["down_ratio"] + (1 - cluster["down_ratio"]) * (cpu["idle_ratio"] + cpu["down_ratio"])
|
|
261
|
+
cpu_metric_dict[name + str(cpu["cpu"]) + "_active"] = int((1 - idle_ratio) * 100)
|
|
257
262
|
if name[0] == 'E':
|
|
258
|
-
e_total_idle_ratio +=
|
|
263
|
+
e_total_idle_ratio += idle_ratio
|
|
259
264
|
e_core_count += 1
|
|
260
265
|
else:
|
|
261
|
-
p_total_idle_ratio +=
|
|
266
|
+
p_total_idle_ratio += idle_ratio
|
|
262
267
|
p_core_count += 1
|
|
263
268
|
|
|
264
269
|
cpu_metric_dict["E-Cluster_active"] = int((1 - e_total_idle_ratio/e_core_count)*100)
|
|
@@ -340,6 +345,7 @@ class DefaultView():
|
|
|
340
345
|
self.disk_write_bps_peak = 0
|
|
341
346
|
self.network_in_bps_peak = 0
|
|
342
347
|
self.network_out_bps_peak = 0
|
|
348
|
+
self.default_cpu_perline = 8
|
|
343
349
|
self.construct(soc_info_dict,args)
|
|
344
350
|
|
|
345
351
|
def construct(self,soc_info_dict,args):
|
|
@@ -351,15 +357,34 @@ class DefaultView():
|
|
|
351
357
|
self.e_core_count = soc_info_dict["e_core_count"]
|
|
352
358
|
self.e_core_gauges = [VGauge(val=0, color=args.color, border_color=args.color) for _ in range(self.e_core_count)]
|
|
353
359
|
self.p_core_count = soc_info_dict["p_core_count"]
|
|
354
|
-
self.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
+
self.max_cpu_perline = self.default_cpu_perline
|
|
361
|
+
for i in range(int(self.default_cpu_perline/2),self.default_cpu_perline):
|
|
362
|
+
if self.p_core_count % i == 0:
|
|
363
|
+
self.max_cpu_perline = i
|
|
364
|
+
break
|
|
365
|
+
import math
|
|
366
|
+
p_core_lines = math.ceil(self.p_core_count / self.max_cpu_perline)
|
|
367
|
+
self.p_core_gauges = []
|
|
368
|
+
self.p_core_split = []
|
|
369
|
+
for i in range(p_core_lines):
|
|
370
|
+
self.p_core_gauges.append([])
|
|
371
|
+
self.p_core_gauges[i].extend([VGauge(val=0, color=args.color, border_color=args.color) for _ in range(self.max_cpu_perline if i < p_core_lines - 1 else self.p_core_count - i * self.max_cpu_perline)])
|
|
360
372
|
self.p_core_split.append(HSplit(
|
|
361
|
-
*self.
|
|
373
|
+
*self.p_core_gauges[i],
|
|
362
374
|
))
|
|
375
|
+
if args.show_cores:
|
|
376
|
+
self.processor_gauges = [self.cpu1_gauge,
|
|
377
|
+
HSplit(*self.e_core_gauges),
|
|
378
|
+
self.cpu2_gauge,]
|
|
379
|
+
#for i in range(len(self.p_core_split)):
|
|
380
|
+
self.processor_gauges.extend(self.p_core_split)
|
|
381
|
+
self.processor_gauges.extend(self.gpu_ane_gauges)
|
|
382
|
+
else:
|
|
383
|
+
self.processor_gauges = [
|
|
384
|
+
HSplit(self.cpu1_gauge, self.cpu2_gauge),
|
|
385
|
+
HSplit(*self.gpu_ane_gauges)
|
|
386
|
+
]
|
|
387
|
+
"""
|
|
363
388
|
self.processor_gauges = [self.cpu1_gauge,
|
|
364
389
|
HSplit(*self.e_core_gauges),
|
|
365
390
|
self.cpu2_gauge,
|
|
@@ -369,6 +394,7 @@ class DefaultView():
|
|
|
369
394
|
HSplit(self.cpu1_gauge, self.cpu2_gauge),
|
|
370
395
|
HSplit(*self.gpu_ane_gauges)
|
|
371
396
|
]
|
|
397
|
+
"""
|
|
372
398
|
self.processor_split = VSplit(
|
|
373
399
|
*self.processor_gauges,
|
|
374
400
|
title="Processor Utilization",
|
|
@@ -515,12 +541,14 @@ class DefaultView():
|
|
|
515
541
|
self.e_core_gauges[i].color = args.color
|
|
516
542
|
self.e_core_gauges[i].border_color = args.color
|
|
517
543
|
for i in range(len(self.p_core_gauges)):
|
|
518
|
-
self.p_core_gauges[i]
|
|
519
|
-
|
|
544
|
+
for j in range(len(self.p_core_gauges[i])):
|
|
545
|
+
self.p_core_gauges[i][j].color = args.color
|
|
546
|
+
self.p_core_gauges[i][j].border_color = args.color
|
|
547
|
+
"""
|
|
520
548
|
for i in range(len(self.p_core_gauges_ext)):
|
|
521
549
|
self.p_core_gauges_ext[i].color = args.color
|
|
522
550
|
self.p_core_gauges_ext[i].border_color = args.color
|
|
523
|
-
|
|
551
|
+
"""
|
|
524
552
|
thermal_pressure = parse_thermal_pressure(powermetrics_parse)
|
|
525
553
|
cpu_metrics_dict = parse_cpu_metrics(powermetrics_parse)
|
|
526
554
|
gpu_metrics_dict = parse_gpu_metrics(powermetrics_parse)
|
|
@@ -577,13 +605,14 @@ class DefaultView():
|
|
|
577
605
|
core_count += 1
|
|
578
606
|
core_count = 0
|
|
579
607
|
for i in cpu_metrics_dict["p_core"]:
|
|
580
|
-
core_gauges =self.p_core_gauges if core_count < 8 else self.p_core_gauges_ext
|
|
581
|
-
core_gauges
|
|
608
|
+
#core_gauges =self.p_core_gauges if core_count < 8 else self.p_core_gauges_ext
|
|
609
|
+
core_gauges = self.p_core_gauges[int(core_count / self.max_cpu_perline)]
|
|
610
|
+
core_gauges[core_count % self.max_cpu_perline].title = "".join([
|
|
582
611
|
("Core-" if self.p_core_count < 6 else 'C-') + str(i + 1) + " ",
|
|
583
612
|
str(cpu_metrics_dict["P-Cluster" + str(i) + "_active"]),
|
|
584
613
|
"%",
|
|
585
614
|
])
|
|
586
|
-
core_gauges[core_count %
|
|
615
|
+
core_gauges[core_count % self.max_cpu_perline].value = cpu_metrics_dict["P-Cluster" + str(i) + "_active"]
|
|
587
616
|
core_count += 1
|
|
588
617
|
|
|
589
618
|
self.gpu_gauge.title = "".join([
|
|
@@ -766,7 +795,7 @@ class DefaultView():
|
|
|
766
795
|
disk_read_iops = disk_metrics_dict["read_iops"]
|
|
767
796
|
if disk_read_iops > self.disk_read_iops_peak:
|
|
768
797
|
self.disk_read_iops_peak = disk_read_iops
|
|
769
|
-
self.disk_read_iops_charts.title = "Read iops: "+ f'{disk_read_iops}
|
|
798
|
+
self.disk_read_iops_charts.title = "Read iops: "+ f'{disk_read_iops}'
|
|
770
799
|
if self.disk_read_iops_charts.datapoints:
|
|
771
800
|
disk_read_iops_rate = int(disk_read_iops / self.disk_read_iops_peak * 100) if self.disk_read_iops_peak > 0 else 0
|
|
772
801
|
else:
|
|
@@ -776,7 +805,7 @@ class DefaultView():
|
|
|
776
805
|
disk_write_iops = disk_metrics_dict["write_iops"]
|
|
777
806
|
if disk_write_iops > self.disk_write_iops_peak:
|
|
778
807
|
self.disk_write_iops_peak = disk_write_iops
|
|
779
|
-
self.disk_write_iops_charts.title = "Write iops: "+ f'{disk_write_iops}
|
|
808
|
+
self.disk_write_iops_charts.title = "Write iops: "+ f'{disk_write_iops}'
|
|
780
809
|
if self.disk_write_iops_charts.datapoints:
|
|
781
810
|
disk_write_iops_rate = int(disk_read_iops / self.disk_write_iops_peak * 100) if self.disk_write_iops_peak > 0 else 0
|
|
782
811
|
else:
|
|
@@ -786,7 +815,7 @@ class DefaultView():
|
|
|
786
815
|
disk_read_bps = disk_metrics_dict["read_Bps"]
|
|
787
816
|
if disk_read_bps > self.disk_read_bps_peak:
|
|
788
817
|
self.disk_read_bps_peak = disk_read_bps
|
|
789
|
-
self.disk_read_bps_charts.title = "Read : "+ f'{format_number(disk_read_bps)}/s
|
|
818
|
+
self.disk_read_bps_charts.title = "Read : "+ f'{format_number(disk_read_bps)}/s'
|
|
790
819
|
if self.disk_read_bps_charts.datapoints:
|
|
791
820
|
disk_read_bps_rate = int(disk_read_bps / self.disk_read_bps_peak * 100) if self.disk_read_bps_peak > 0 else 0
|
|
792
821
|
else:
|
|
@@ -796,7 +825,7 @@ class DefaultView():
|
|
|
796
825
|
disk_write_bps = disk_metrics_dict["write_Bps"]
|
|
797
826
|
if disk_write_bps > self.disk_write_bps_peak:
|
|
798
827
|
self.disk_write_bps_peak = disk_write_bps
|
|
799
|
-
self.disk_write_bps_charts.title = "Write : "+ f'{format_number(disk_write_bps)}/s
|
|
828
|
+
self.disk_write_bps_charts.title = "Write : "+ f'{format_number(disk_write_bps)}/s'
|
|
800
829
|
if self.disk_write_bps_charts.datapoints:
|
|
801
830
|
disk_write_bps_rate = int(disk_write_bps / self.disk_write_bps_peak * 100) if self.disk_write_bps_peak > 0 else 0
|
|
802
831
|
else:
|
|
@@ -806,7 +835,7 @@ class DefaultView():
|
|
|
806
835
|
network_in_bps = network_metrics_dict["in_Bps"]
|
|
807
836
|
if network_in_bps > self.network_in_bps_peak:
|
|
808
837
|
self.network_in_bps_peak = network_in_bps
|
|
809
|
-
self.network_in_bps_charts.title = "in : "+ f'{format_number(network_in_bps)}/s
|
|
838
|
+
self.network_in_bps_charts.title = "in : "+ f'{format_number(network_in_bps)}/s'
|
|
810
839
|
if self.network_in_bps_charts.datapoints:
|
|
811
840
|
network_in_bps_rate = int(network_in_bps / self.network_in_bps_peak * 100) if self.network_in_bps_peak > 0 else 0
|
|
812
841
|
else:
|
|
@@ -816,23 +845,26 @@ class DefaultView():
|
|
|
816
845
|
network_out_bps = network_metrics_dict["out_Bps"]
|
|
817
846
|
if network_out_bps > self.network_out_bps_peak:
|
|
818
847
|
self.network_out_bps_peak = network_out_bps
|
|
819
|
-
self.network_out_bps_charts.title = "out : "+ f'{format_number(network_out_bps)}/s
|
|
848
|
+
self.network_out_bps_charts.title = "out : "+ f'{format_number(network_out_bps)}/s'
|
|
820
849
|
if self.network_out_bps_charts.datapoints:
|
|
821
850
|
network_out_bps_rate = int(network_out_bps / self.network_out_bps_peak * 100) if self.network_out_bps_peak > 0 else 0
|
|
822
851
|
else:
|
|
823
852
|
network_out_bps_rate = 100
|
|
824
853
|
self.network_out_bps_charts.append(network_out_bps_rate)
|
|
825
854
|
|
|
855
|
+
self.disk_io_charts.title = ''.join([f"Disk IO (peak R:{self.disk_read_iops_peak} W:{self.disk_write_iops_peak}",
|
|
856
|
+
f" | R:{format_number(self.disk_read_bps_peak)}/s W:{format_number(self.disk_write_bps_peak)}/s)"
|
|
857
|
+
])
|
|
858
|
+
self.network_io_charts.title = f"Network IO (peak in:{format_number(self.network_in_bps_peak)}/s out:{format_number(self.network_out_bps_peak)}/s)"
|
|
826
859
|
self.ui.display()
|
|
827
860
|
|
|
828
861
|
def get_avg(inlist):
|
|
829
862
|
avg = sum(inlist) / len(inlist)
|
|
830
863
|
return avg
|
|
831
864
|
|
|
832
|
-
def
|
|
865
|
+
def begin(stdscr):
|
|
833
866
|
soc_info_dict = get_soc_info()
|
|
834
|
-
view1 =
|
|
835
|
-
clear_console()
|
|
867
|
+
view1 = None
|
|
836
868
|
stdscr.nodelay(True)
|
|
837
869
|
view = 1
|
|
838
870
|
try:
|
|
@@ -844,6 +876,9 @@ def main(stdscr):
|
|
|
844
876
|
data = data + output
|
|
845
877
|
str_output = output.decode()
|
|
846
878
|
if str_output.startswith('</plist>'):
|
|
879
|
+
if view1 is None:
|
|
880
|
+
view1 = DefaultView(soc_info_dict=soc_info_dict,args=args)
|
|
881
|
+
clear_console()
|
|
847
882
|
data = data.replace(b'\x00',b'')
|
|
848
883
|
powermetrics_parse = plistlib.loads(data)
|
|
849
884
|
key = stdscr.getch()
|
|
@@ -882,18 +917,15 @@ def main(stdscr):
|
|
|
882
917
|
|
|
883
918
|
return
|
|
884
919
|
|
|
885
|
-
|
|
886
|
-
|
|
920
|
+
def main():
|
|
921
|
+
global powermetrics_process
|
|
887
922
|
print(f"\n{version} - enhanced MAC Performance monitoring CLI tool for Apple Silicon")
|
|
888
923
|
print("You can update macpm by running `pip install macpm --upgrade`")
|
|
889
924
|
print("Get help at `https://github.com/visualcjy/macpm`")
|
|
890
925
|
print("P.S. You are recommended to run macpm with `sudo macpm`\n")
|
|
891
926
|
print("\n[1/3] Loading macpm\n")
|
|
892
|
-
print("\033[?25l")
|
|
893
|
-
#global powermetrics_process
|
|
894
|
-
|
|
895
927
|
print("\n[2/3] Starting powermetrics process\n")
|
|
896
|
-
|
|
928
|
+
pause = os.popen("sudo echo").read()
|
|
897
929
|
command = " ".join([
|
|
898
930
|
"sudo nice -n",
|
|
899
931
|
str(10),
|
|
@@ -906,9 +938,14 @@ if __name__ == "__main__":
|
|
|
906
938
|
powermetrics_process = subprocess.Popen(command.split(" "), stdin=PIPE, stdout=PIPE)
|
|
907
939
|
|
|
908
940
|
print("\n[3/3] Waiting for first reading...\n")
|
|
909
|
-
|
|
910
|
-
curses.wrapper(
|
|
941
|
+
print("\033[?25l")
|
|
942
|
+
curses.wrapper(begin)
|
|
911
943
|
print("\033[?25h")
|
|
944
|
+
|
|
945
|
+
if __name__ == "__main__":
|
|
946
|
+
|
|
947
|
+
main()
|
|
948
|
+
|
|
912
949
|
try:
|
|
913
950
|
powermetrics_process.terminate()
|
|
914
951
|
print("Successfully terminated powermetrics process")
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: macpm
|
|
3
|
+
Version: 0.23
|
|
4
|
+
Summary: Performance monitoring CLI tool for Apple Silicon
|
|
5
|
+
Home-page: https://github.com/visualcjy/macpm
|
|
6
|
+
Author: Jinyu Chen
|
|
7
|
+
Author-email: visualcjy@mail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: macpm
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: dashing
|
|
16
|
+
Requires-Dist: psutil
|
|
17
|
+
Requires-Dist: humanize
|
|
18
|
+
|
|
19
|
+
# macpm
|
|
20
|
+
|
|
21
|
+
PyPI - Downloads (https://pypi.org/project/macpm/#files)
|
|
22
|
+
or: pip install macpm
|
|
23
|
+
|
|
24
|
+
enhanced MAC Performance monitoring CLI tool for Apple Silicon
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
```shell
|
|
29
|
+
pip install macpm
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What is `macpm`
|
|
33
|
+
|
|
34
|
+
forked form https://github.com/tlkh/asitop
|
|
35
|
+
1. fixed the problem that "E-CPU Usage" and "P-CPU Usage" always 100%
|
|
36
|
+
2. add "Disk IO" and "Network IO" info
|
|
37
|
+
3. adjust the hard coded max power in CPU/GPU/ANE
|
|
38
|
+
4. change the way to call powermetrics, no temp files in /tmp
|
|
39
|
+
5. press ESC or q to quit
|
|
40
|
+
6. press LEFT or RIGHT to switch color, press 1 : default view, 2 : show_core view
|
|
41
|
+
7. fix M1 has no "down_ratio" tag problem, fix p-core cpu usage
|
|
42
|
+
|
|
43
|
+
A Python-based `nvtop`-inspired command line tool for Apple Silicon (aka M1) Macs.
|
|
44
|
+
|
|
45
|
+
* Utilization info:
|
|
46
|
+
* CPU (E-cluster and P-cluster), GPU
|
|
47
|
+
* Frequency and utilization
|
|
48
|
+
* ANE utilization (measured by power)
|
|
49
|
+
* Memory info:
|
|
50
|
+
* RAM and swap, size and usage
|
|
51
|
+
* (Apple removed memory bandwidth from `powermetrics`)
|
|
52
|
+
* Power info:
|
|
53
|
+
* CPU power, GPU power (Apple removed package power from `powermetrics`)
|
|
54
|
+
* Chart for CPU/GPU power
|
|
55
|
+
* Peak power, rolling average display
|
|
56
|
+
|
|
57
|
+
`macpm` uses the built-in [`powermetrics`](https://www.unix.com/man-page/osx/1/powermetrics/) utility on macOS, which allows access to a variety of hardware performance counters. Note that it requires `sudo` to run due to `powermetrics` needing root access to run. `macpm` is lightweight and has minimal performance impact.
|
|
58
|
+
|
|
59
|
+
**`macpm` only works on Apple Silicon Macs on macOS Monterey!**
|
|
60
|
+
|
|
61
|
+
## Installation and Usage
|
|
62
|
+
|
|
63
|
+
`macpm` is a Python-based command line tool. You need `pip` to download and install `macpm`. macOS already comes with Python, to install `pip`, you can follow an [online guide](https://phoenixnap.com/kb/install-pip-mac). After you install `macpm` via `pip`, you can use it via the Terminal.
|
|
64
|
+
|
|
65
|
+
```shell
|
|
66
|
+
# to enter password before start
|
|
67
|
+
# this mode is recommended!
|
|
68
|
+
sudo macpm
|
|
69
|
+
|
|
70
|
+
# it will prompt password on start
|
|
71
|
+
macpm
|
|
72
|
+
|
|
73
|
+
# advanced options
|
|
74
|
+
macpm [-h] [--interval INTERVAL] [--color COLOR] [--avg AVG]
|
|
75
|
+
optional arguments:
|
|
76
|
+
-h, --help show this help message and exit
|
|
77
|
+
--interval INTERVAL Display interval and sampling interval for powermetrics (seconds)
|
|
78
|
+
--color COLOR Choose display color (0~8)
|
|
79
|
+
--avg AVG Interval for averaged values (seconds)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
`powermetrics` is used to measure the following:
|
|
85
|
+
|
|
86
|
+
* CPU/GPU utilization via active residency
|
|
87
|
+
* CPU/GPU frequency
|
|
88
|
+
* Package/CPU/GPU/ANE energy consumption
|
|
89
|
+
* CPU/GPU/Media Total memory bandwidth via the DCS (DRAM Command Scheduler)
|
|
90
|
+
|
|
91
|
+
[`psutil`](https://github.com/giampaolo/psutil) is used to measure the following:
|
|
92
|
+
|
|
93
|
+
* memory and swap usage
|
|
94
|
+
|
|
95
|
+
[`sysctl`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/sysctl.3.html) is used to measure the following:
|
|
96
|
+
|
|
97
|
+
* CPU name
|
|
98
|
+
* CPU core counts
|
|
99
|
+
|
|
100
|
+
[`system_profiler`](https://ss64.com/osx/system_profiler.html) is used to measure the following:
|
|
101
|
+
|
|
102
|
+
* GPU core count
|
|
103
|
+
|
|
104
|
+
Some information is guesstimate and hardcoded as there doesn't seem to be a official source for it on the system:
|
|
105
|
+
|
|
106
|
+
* CPU/GPU TDP
|
|
107
|
+
* CPU/GPU maximum memory bandwidth
|
|
108
|
+
* ANE max power
|
|
109
|
+
* Media engine max bandwidth
|
|
110
|
+
|
|
111
|
+
## Why
|
|
112
|
+
|
|
113
|
+
Because I didn't find something like this online. Also, just curious about stuff.
|
|
114
|
+
|
|
115
|
+
## Disclaimers
|
|
116
|
+
|
|
117
|
+
I did this randomly don't blame me if it fried your new MacBook or something.
|
|
@@ -4,12 +4,12 @@ long_description = 'Performance monitoring CLI tool for Apple Silicon'
|
|
|
4
4
|
|
|
5
5
|
setup(
|
|
6
6
|
name='macpm',
|
|
7
|
-
version='0.
|
|
7
|
+
version='0.23',
|
|
8
8
|
author='Jinyu Chen',
|
|
9
9
|
author_email='visualcjy@mail.com',
|
|
10
10
|
url='https://github.com/visualcjy/macpm',
|
|
11
11
|
description='Performance monitoring CLI tool for Apple Silicon',
|
|
12
|
-
long_description=
|
|
12
|
+
long_description=open('README.md').read(),
|
|
13
13
|
long_description_content_type="text/markdown",
|
|
14
14
|
license='MIT',
|
|
15
15
|
packages=find_packages(),
|
macpm-0.15/PKG-INFO
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: macpm
|
|
3
|
-
Version: 0.15
|
|
4
|
-
Summary: Performance monitoring CLI tool for Apple Silicon
|
|
5
|
-
Home-page: https://github.com/visualcjy/macpm
|
|
6
|
-
Author: Jinyu Chen
|
|
7
|
-
Author-email: visualcjy@mail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Keywords: macpm
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: MacOS
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: dashing
|
|
16
|
-
Requires-Dist: psutil
|
|
17
|
-
Requires-Dist: humanize
|
|
18
|
-
|
|
19
|
-
Performance monitoring CLI tool for Apple Silicon
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: macpm
|
|
3
|
-
Version: 0.15
|
|
4
|
-
Summary: Performance monitoring CLI tool for Apple Silicon
|
|
5
|
-
Home-page: https://github.com/visualcjy/macpm
|
|
6
|
-
Author: Jinyu Chen
|
|
7
|
-
Author-email: visualcjy@mail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Keywords: macpm
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: MacOS
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: dashing
|
|
16
|
-
Requires-Dist: psutil
|
|
17
|
-
Requires-Dist: humanize
|
|
18
|
-
|
|
19
|
-
Performance monitoring CLI tool for Apple Silicon
|
|
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
|