macpm 3.3.0__tar.gz → 3.3.1__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.
Files changed (95) hide show
  1. {macpm-3.3.0 → macpm-3.3.1}/CHANGELOG.md +24 -0
  2. {macpm-3.3.0/macpm.egg-info → macpm-3.3.1}/PKG-INFO +24 -9
  3. {macpm-3.3.0 → macpm-3.3.1}/README.md +23 -8
  4. {macpm-3.3.0 → macpm-3.3.1}/RELEASE.md +14 -14
  5. {macpm-3.3.0 → macpm-3.3.1}/macpm/__init__.py +1 -1
  6. {macpm-3.3.0 → macpm-3.3.1}/macpm/gpuview.py +6 -3
  7. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/sampler.py +6 -7
  8. {macpm-3.3.0 → macpm-3.3.1}/macpm/macpm.py +49 -2
  9. {macpm-3.3.0 → macpm-3.3.1}/macpm/metrics.py +40 -6
  10. {macpm-3.3.0 → macpm-3.3.1}/macpm/sampler.py +13 -16
  11. {macpm-3.3.0 → macpm-3.3.1/macpm.egg-info}/PKG-INFO +24 -9
  12. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/SOURCES.txt +1 -0
  13. {macpm-3.3.0 → macpm-3.3.1}/setup.py +1 -1
  14. {macpm-3.3.0 → macpm-3.3.1}/tests/test_gpuview.py +17 -2
  15. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_view.py +37 -0
  16. macpm-3.3.1/tests/test_power_panel.py +28 -0
  17. macpm-3.3.1/tests/test_sampler.py +78 -0
  18. macpm-3.3.0/tests/test_sampler.py +0 -35
  19. {macpm-3.3.0 → macpm-3.3.1}/LICENSE +0 -0
  20. {macpm-3.3.0 → macpm-3.3.1}/MANIFEST.in +0 -0
  21. {macpm-3.3.0 → macpm-3.3.1}/docs/linux-port.md +0 -0
  22. {macpm-3.3.0 → macpm-3.3.1}/macpm/__main__.py +0 -0
  23. {macpm-3.3.0 → macpm-3.3.1}/macpm/backend.py +0 -0
  24. {macpm-3.3.0 → macpm-3.3.1}/macpm/blessed_engine.py +0 -0
  25. {macpm-3.3.0 → macpm-3.3.1}/macpm/capabilities.py +0 -0
  26. {macpm-3.3.0 → macpm-3.3.1}/macpm/dump.py +0 -0
  27. {macpm-3.3.0 → macpm-3.3.1}/macpm/footprint.py +0 -0
  28. {macpm-3.3.0 → macpm-3.3.1}/macpm/ioreport.py +0 -0
  29. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/__init__.py +0 -0
  30. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/cpu.py +0 -0
  31. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/gpu.py +0 -0
  32. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/modelname.py +0 -0
  33. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/net.py +0 -0
  34. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/power.py +0 -0
  35. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/proc.py +0 -0
  36. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/soc.py +0 -0
  37. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/sysfs.py +0 -0
  38. {macpm-3.3.0 → macpm-3.3.1}/macpm/linux_backend/thermal.py +0 -0
  39. {macpm-3.3.0 → macpm-3.3.1}/macpm/macos_gpu.py +0 -0
  40. {macpm-3.3.0 → macpm-3.3.1}/macpm/netinfo.py +0 -0
  41. {macpm-3.3.0 → macpm-3.3.1}/macpm/netmodel.py +0 -0
  42. {macpm-3.3.0 → macpm-3.3.1}/macpm/network.py +0 -0
  43. {macpm-3.3.0 → macpm-3.3.1}/macpm/probe.py +0 -0
  44. {macpm-3.3.0 → macpm-3.3.1}/macpm/processes.py +0 -0
  45. {macpm-3.3.0 → macpm-3.3.1}/macpm/sensors.py +0 -0
  46. {macpm-3.3.0 → macpm-3.3.1}/macpm/smc.py +0 -0
  47. {macpm-3.3.0 → macpm-3.3.1}/macpm/soc.py +0 -0
  48. {macpm-3.3.0 → macpm-3.3.1}/macpm/theme.py +0 -0
  49. {macpm-3.3.0 → macpm-3.3.1}/macpm/tui.py +0 -0
  50. {macpm-3.3.0 → macpm-3.3.1}/macpm/widgets.py +0 -0
  51. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/dependency_links.txt +0 -0
  52. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/entry_points.txt +0 -0
  53. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/not-zip-safe +0 -0
  54. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/requires.txt +0 -0
  55. {macpm-3.3.0 → macpm-3.3.1}/macpm.egg-info/top_level.txt +0 -0
  56. {macpm-3.3.0 → macpm-3.3.1}/packaging/README-linux.txt +0 -0
  57. {macpm-3.3.0 → macpm-3.3.1}/packaging/README.txt +0 -0
  58. {macpm-3.3.0 → macpm-3.3.1}/packaging/build-linux.sh +0 -0
  59. {macpm-3.3.0 → macpm-3.3.1}/packaging/build.sh +0 -0
  60. {macpm-3.3.0 → macpm-3.3.1}/packaging/entry_tui.py +0 -0
  61. {macpm-3.3.0 → macpm-3.3.1}/packaging/install.sh +0 -0
  62. {macpm-3.3.0 → macpm-3.3.1}/packaging/linux/Dockerfile +0 -0
  63. {macpm-3.3.0 → macpm-3.3.1}/packaging/linux/README.txt +0 -0
  64. {macpm-3.3.0 → macpm-3.3.1}/packaging/macpm-linux.spec +0 -0
  65. {macpm-3.3.0 → macpm-3.3.1}/packaging/macpm.command +0 -0
  66. {macpm-3.3.0 → macpm-3.3.1}/pyproject.toml +0 -0
  67. {macpm-3.3.0 → macpm-3.3.1}/setup.cfg +0 -0
  68. {macpm-3.3.0 → macpm-3.3.1}/tests/__init__.py +0 -0
  69. {macpm-3.3.0 → macpm-3.3.1}/tests/linux_fixtures.py +0 -0
  70. {macpm-3.3.0 → macpm-3.3.1}/tests/test_ane.py +0 -0
  71. {macpm-3.3.0 → macpm-3.3.1}/tests/test_blessed_engine.py +0 -0
  72. {macpm-3.3.0 → macpm-3.3.1}/tests/test_calc_freq.py +0 -0
  73. {macpm-3.3.0 → macpm-3.3.1}/tests/test_cli.py +0 -0
  74. {macpm-3.3.0 → macpm-3.3.1}/tests/test_footprint.py +0 -0
  75. {macpm-3.3.0 → macpm-3.3.1}/tests/test_layout.py +0 -0
  76. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_cpu.py +0 -0
  77. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_gpu.py +0 -0
  78. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_ixsmi.py +0 -0
  79. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_modelname.py +0 -0
  80. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_net.py +0 -0
  81. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_nvidia.py +0 -0
  82. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_power.py +0 -0
  83. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_sampler.py +0 -0
  84. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_thermal.py +0 -0
  85. {macpm-3.3.0 → macpm-3.3.1}/tests/test_linux_wiring.py +0 -0
  86. {macpm-3.3.0 → macpm-3.3.1}/tests/test_macos_gpu.py +0 -0
  87. {macpm-3.3.0 → macpm-3.3.1}/tests/test_netinfo.py +0 -0
  88. {macpm-3.3.0 → macpm-3.3.1}/tests/test_network.py +0 -0
  89. {macpm-3.3.0 → macpm-3.3.1}/tests/test_probe.py +0 -0
  90. {macpm-3.3.0 → macpm-3.3.1}/tests/test_process_linux.py +0 -0
  91. {macpm-3.3.0 → macpm-3.3.1}/tests/test_processes.py +0 -0
  92. {macpm-3.3.0 → macpm-3.3.1}/tests/test_sampler_macos.py +0 -0
  93. {macpm-3.3.0 → macpm-3.3.1}/tests/test_sensors.py +0 -0
  94. {macpm-3.3.0 → macpm-3.3.1}/tests/test_theme.py +0 -0
  95. {macpm-3.3.0 → macpm-3.3.1}/tests/test_widgets.py +0 -0
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.1 — 2026-11-25
4
+
5
+ ### Fixed
6
+
7
+ - GPU view: `s` now includes the process table's GPU-memory column on
8
+ single-card hosts (macOS, single-GPU Linux), where the sort cycle skipped it;
9
+ the `GPU MEM` header was widened so its `↓`/`↑` marker is not clipped.
10
+
11
+ - macOS power panel on macOS 27: an energy counter that stops reporting — the
12
+ CPU/ANE `Energy Model` channels do this without root on newer builds — now
13
+ falls back to `n/a` once its last ten samples were silent, instead of
14
+ showing `0.00W` forever. Its stale peak, average and maximum are cleared at
15
+ the same time.
16
+ - The Power box names the half that is still reporting (`Power (GPU only)` /
17
+ `Power (CPU only)`) instead of presenting a partial sum as package power.
18
+ - A counter that has not produced a first reading yet shows `CPU: —` / `GPU: —`
19
+ for the first frames instead of a misleading `0.00W`.
20
+
21
+ ### Changed
22
+
23
+ - Documented `--no-color`: it emits no foreground colour, uses the terminal's
24
+ own foreground, and can be paired with terminal themes and keyword
25
+ highlighting; it stays outside the `←`/`→` ring.
26
+
3
27
  ## 3.3.0 — 2026-11-20
4
28
 
5
29
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: macpm
3
- Version: 3.3.0
3
+ Version: 3.3.1
4
4
  Summary: Performance monitoring CLI for Apple Silicon and Linux
5
5
  Home-page: https://github.com/visualcjy/macpm
6
6
  Author: Jinyu Chen
@@ -165,7 +165,7 @@ macpm [--interval INTERVAL] [--color COLOR] [--avg AVG] [--show_cores [BOOL]] [-
165
165
  | `--interval SECONDS` | Sampling and display interval (default `1`) |
166
166
  | `--color 1-8` | Display colour (default `2`) |
167
167
  | `--native` | Start in the built-in semantic colour theme |
168
- | `--no-color` | Use the terminal's default foreground (no accent colour) |
168
+ | `--no-color` | Emit no colour; use the terminal's default foreground (works with terminal themes and keyword highlighting) |
169
169
  | `--avg SECONDS` | Averaging window for power values (default `30`) |
170
170
  | `--show_cores [BOOL]` | Start in the per-core view |
171
171
  | `--no-public-ip` | Do not look up the public IP and location |
@@ -198,8 +198,20 @@ single-card GPU tables only the header row and the current sort column are
198
198
  bright; the other normal cells stay dim. The palette uses fixed xterm-256
199
199
  indices (16-255), so it does not follow the terminal profile.
200
200
 
201
- `--no-color` is outside the ring: it keeps the terminal's default foreground
202
- for a monochrome setup or a terminal-side keyword highlighter.
201
+ ### No colour
202
+
203
+ `--no-color` emits no foreground colour at all: frames, labels, numbers, bars
204
+ and footer hints all use the terminal's default foreground. This is the mode
205
+ to combine with the terminal's own theme and keyword highlighting (iTerm2
206
+ `Triggers → Highlight Text`, NyaTerm `内置规则`, etc.), so numbers, errors or
207
+ IP addresses can be coloured by the terminal instead of macpm. It is outside
208
+ the `←`/`→` ring: pressing an arrow returns to a colour theme, and the flag wins
209
+ over `--color`/`--native` if both are given. Bars and frames stay readable
210
+ because they are drawn with block and box glyphs, not colour.
211
+
212
+ ```sh
213
+ macpm --no-color
214
+ ```
203
215
 
204
216
  | | |
205
217
  |---|---|
@@ -367,7 +379,7 @@ shows `n/a` and the reason stays in the data
367
379
 
368
380
  A single-GPU machine keeps the older layout: card summary on top, process table
369
381
  below. Every view's footer starts with the app name and version
370
- (`macpm v3.3.0 · q quit …`).
382
+ (`macpm v3.3.1 · q quit …`).
371
383
 
372
384
  ```text
373
385
  ┌ GPU INFO ────────────────────────────────────────────────────────────────────────────────┐
@@ -381,7 +393,7 @@ below. Every view's footer starts with the app name and version
381
393
  │ └ 222 Xorg 2.0G │
382
394
  │ 2 AMD GPU (amdgpu) ▉▉▉▉▏▏ 60% 1100/1750 12.0W ▉▉▉▉▏▏▏▏▏▏ 3.0G/8.0G 46°C │
383
395
  │ 3 AMD GPU (amdgpu) ▉▉▉▉▉▏ 85% 1200/1750 12.0W ▉▉▉▉▉▏▏▏▏▏ 4.0G/8.0G 49°C │
384
- └ macpm v3.3.0 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
396
+ └ macpm v3.3.1 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
385
397
  ```
386
398
 
387
399
  | Platform | What fills each row |
@@ -677,9 +689,12 @@ Release steps are documented in [RELEASE.md](https://github.com/visualcjy/macpm/
677
689
  - **`macpm: command not found`** — add your Python user-base `bin` directory to
678
690
  `PATH`, or run `python3 -m macpm`.
679
691
  - **Power readings freeze or show `n/a` on macOS 27** — some builds restrict
680
- unprivileged `Energy Model` refreshes. CPU/GPU usage and frequency still
681
- work; a counter that never reports is shown as `n/a` instead of `0.00W`.
682
- Run `macpm-dump` to inspect the raw values.
692
+ unprivileged `Energy Model` refreshes, and the CPU/ANE channels can stop
693
+ updating while the GPU one keeps working. CPU/GPU usage and frequency still
694
+ work; a counter that has been silent for ten samples is shown as `n/a`
695
+ instead of `0.00W`, and the Power box then reads `Power (GPU only)`. The
696
+ first frames of a session show `CPU: —` until a counter reports once. Run
697
+ `macpm-dump` to inspect the raw values.
683
698
  - **M5/Ultra values look wrong** — CPU tier/channel mapping is not complete;
684
699
  see the compatibility table.
685
700
  - **The Temps & Fans box says `SMC unavailable`** — the AppleSMC user client
@@ -123,7 +123,7 @@ macpm [--interval INTERVAL] [--color COLOR] [--avg AVG] [--show_cores [BOOL]] [-
123
123
  | `--interval SECONDS` | Sampling and display interval (default `1`) |
124
124
  | `--color 1-8` | Display colour (default `2`) |
125
125
  | `--native` | Start in the built-in semantic colour theme |
126
- | `--no-color` | Use the terminal's default foreground (no accent colour) |
126
+ | `--no-color` | Emit no colour; use the terminal's default foreground (works with terminal themes and keyword highlighting) |
127
127
  | `--avg SECONDS` | Averaging window for power values (default `30`) |
128
128
  | `--show_cores [BOOL]` | Start in the per-core view |
129
129
  | `--no-public-ip` | Do not look up the public IP and location |
@@ -156,8 +156,20 @@ single-card GPU tables only the header row and the current sort column are
156
156
  bright; the other normal cells stay dim. The palette uses fixed xterm-256
157
157
  indices (16-255), so it does not follow the terminal profile.
158
158
 
159
- `--no-color` is outside the ring: it keeps the terminal's default foreground
160
- for a monochrome setup or a terminal-side keyword highlighter.
159
+ ### No colour
160
+
161
+ `--no-color` emits no foreground colour at all: frames, labels, numbers, bars
162
+ and footer hints all use the terminal's default foreground. This is the mode
163
+ to combine with the terminal's own theme and keyword highlighting (iTerm2
164
+ `Triggers → Highlight Text`, NyaTerm `内置规则`, etc.), so numbers, errors or
165
+ IP addresses can be coloured by the terminal instead of macpm. It is outside
166
+ the `←`/`→` ring: pressing an arrow returns to a colour theme, and the flag wins
167
+ over `--color`/`--native` if both are given. Bars and frames stay readable
168
+ because they are drawn with block and box glyphs, not colour.
169
+
170
+ ```sh
171
+ macpm --no-color
172
+ ```
161
173
 
162
174
  | | |
163
175
  |---|---|
@@ -325,7 +337,7 @@ shows `n/a` and the reason stays in the data
325
337
 
326
338
  A single-GPU machine keeps the older layout: card summary on top, process table
327
339
  below. Every view's footer starts with the app name and version
328
- (`macpm v3.3.0 · q quit …`).
340
+ (`macpm v3.3.1 · q quit …`).
329
341
 
330
342
  ```text
331
343
  ┌ GPU INFO ────────────────────────────────────────────────────────────────────────────────┐
@@ -339,7 +351,7 @@ below. Every view's footer starts with the app name and version
339
351
  │ └ 222 Xorg 2.0G │
340
352
  │ 2 AMD GPU (amdgpu) ▉▉▉▉▏▏ 60% 1100/1750 12.0W ▉▉▉▉▏▏▏▏▏▏ 3.0G/8.0G 46°C │
341
353
  │ 3 AMD GPU (amdgpu) ▉▉▉▉▉▏ 85% 1200/1750 12.0W ▉▉▉▉▉▏▏▏▏▏ 4.0G/8.0G 49°C │
342
- └ macpm v3.3.0 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
354
+ └ macpm v3.3.1 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
343
355
  ```
344
356
 
345
357
  | Platform | What fills each row |
@@ -635,9 +647,12 @@ Release steps are documented in [RELEASE.md](https://github.com/visualcjy/macpm/
635
647
  - **`macpm: command not found`** — add your Python user-base `bin` directory to
636
648
  `PATH`, or run `python3 -m macpm`.
637
649
  - **Power readings freeze or show `n/a` on macOS 27** — some builds restrict
638
- unprivileged `Energy Model` refreshes. CPU/GPU usage and frequency still
639
- work; a counter that never reports is shown as `n/a` instead of `0.00W`.
640
- Run `macpm-dump` to inspect the raw values.
650
+ unprivileged `Energy Model` refreshes, and the CPU/ANE channels can stop
651
+ updating while the GPU one keeps working. CPU/GPU usage and frequency still
652
+ work; a counter that has been silent for ten samples is shown as `n/a`
653
+ instead of `0.00W`, and the Power box then reads `Power (GPU only)`. The
654
+ first frames of a session show `CPU: —` until a counter reports once. Run
655
+ `macpm-dump` to inspect the raw values.
641
656
  - **M5/Ultra values look wrong** — CPU tier/channel mapping is not complete;
642
657
  see the compatibility table.
643
658
  - **The Temps & Fans box says `SMC unavailable`** — the AppleSMC user client
@@ -1,4 +1,4 @@
1
- # Releasing macpm 3.3.0
1
+ # Releasing macpm 3.3.1
2
2
 
3
3
  This checklist prepares a GitHub tag and a PyPI upload. It does not push or
4
4
  publish anything by itself.
@@ -7,11 +7,11 @@ publish anything by itself.
7
7
 
8
8
  - macOS Apple Silicon, Python 3.9+.
9
9
  - Clean working tree (`git status`), all tests passing.
10
- - Version is `3.3.0` in:
10
+ - Version is `3.3.1` in:
11
11
  - `setup.py`
12
12
  - `macpm/__init__.py` (`__version__`)
13
13
  - the banner and `--version` derive from it (`macpm/macpm.py`)
14
- - `CHANGELOG.md` has the `3.3.0` entry.
14
+ - `CHANGELOG.md` has the `3.3.1` entry.
15
15
 
16
16
  ## 2. Test from source
17
17
 
@@ -38,7 +38,7 @@ Test the wheel in a **clean** venv (this is the real "no source tree" test):
38
38
 
39
39
  ```sh
40
40
  python3 -m venv /tmp/macpm-wheel-test
41
- /tmp/macpm-wheel-test/bin/pip install dist/macpm-3.3.0-py3-none-any.whl
41
+ /tmp/macpm-wheel-test/bin/pip install dist/macpm-3.3.1-py3-none-any.whl
42
42
  /tmp/macpm-wheel-test/bin/macpm --help
43
43
  /tmp/macpm-wheel-test/bin/macpm-dump # Ctrl+C
44
44
  ```
@@ -78,13 +78,13 @@ Manual alternative (fallback, e.g. when OIDC is unavailable):
78
78
  ```sh
79
79
  # requires a PyPI API token in ~/.pypirc or TWINE_PASSWORD
80
80
  python3 -m twine upload --non-interactive \
81
- dist/macpm-3.3.0.tar.gz dist/macpm-3.3.0-py3-none-any.whl
81
+ dist/macpm-3.3.1.tar.gz dist/macpm-3.3.1-py3-none-any.whl
82
82
  ```
83
83
 
84
84
  Then verify:
85
85
 
86
86
  ```sh
87
- python3 -m pip install --upgrade macpm==3.3.0
87
+ python3 -m pip install --upgrade macpm==3.3.1
88
88
  macpm --version
89
89
  ```
90
90
 
@@ -93,10 +93,10 @@ macpm --version
93
93
  ```sh
94
94
  git add setup.py pyproject.toml MANIFEST.in README.md CHANGELOG.md RELEASE.md \
95
95
  macpm packaging tests .github bin
96
- git commit -m "Release macpm 3.3.0: built-in semantic colour theme"
97
- git tag -a v3.3.0 -m "macpm 3.3.0"
96
+ git commit -m "Release macpm 3.3.1: macOS 27 power fallback and GPU sort fixes"
97
+ git tag -a v3.3.1 -m "macpm 3.3.1"
98
98
  git push origin main
99
- git push origin v3.3.0
99
+ git push origin v3.3.1
100
100
  ```
101
101
 
102
102
  The `Release` workflow builds the sdist/wheel, checks metadata and attaches
@@ -122,7 +122,7 @@ PYTHON=python3 packaging/build.sh
122
122
  This produces:
123
123
 
124
124
  ```text
125
- dist/macpm-3.3.0-macos-arm64.tar.gz
125
+ dist/macpm-3.3.1-macos-arm64.tar.gz
126
126
  ```
127
127
 
128
128
  Attach it to the GitHub release. The binaries are ad-hoc signed, not
@@ -148,10 +148,10 @@ The first run downloads python-build-standalone (cached in
148
148
  `~/.cache/macpm-build/pbs`) and produces:
149
149
 
150
150
  ```text
151
- dist/macpm-3.3.0-linux-x86_64.tar.gz
152
- dist/macpm-3.3.0-linux-aarch64.tar.gz
153
- dist/macpm_3.3.0_amd64.deb
154
- dist/macpm_3.3.0_arm64.deb
151
+ dist/macpm-3.3.1-linux-x86_64.tar.gz
152
+ dist/macpm-3.3.1-linux-aarch64.tar.gz
153
+ dist/macpm_3.3.1_amd64.deb
154
+ dist/macpm_3.3.1_arm64.deb
155
155
  ```
156
156
 
157
157
  Both architectures keep a glibc 2.17 floor. Building x86_64 on an arm64 host
@@ -1,3 +1,3 @@
1
1
  """macpm: rootless performance monitor for Apple Silicon."""
2
2
 
3
- __version__ = "3.3.0"
3
+ __version__ = "3.3.1"
@@ -35,7 +35,7 @@ from .processes import ProcessRow, ProcessSampler
35
35
  from .theme import BOX, KEY, LABEL, OK, TITLE, Palette, footer_spans, metric_spans, paint_spans, severity, title_spans
36
36
  from .tui import RESET_FG, _border, _bottom, _center, _fit, _format_mem, _pad, _text_width, footer
37
37
 
38
- _SORTS = ["gpu", "pid", "name", "user"]
38
+ _SORTS = ["gpu", "mem", "pid", "name", "user"]
39
39
  _HEADER = {
40
40
  "pid": "PID",
41
41
  "name": "NAME",
@@ -535,7 +535,8 @@ class GpuView:
535
535
  return
536
536
  index = (_SORTS.index(self.sort) + 1) % len(_SORTS) if self.sort in _SORTS else 0
537
537
  self.sort = _SORTS[index]
538
- self.desc = self.sort == "gpu"
538
+ # Highest GPU time or GPU memory first; the rest are name/id orders.
539
+ self.desc = self.sort in ("gpu", "mem")
539
540
  self._sorted = None
540
541
  self.offset = 0
541
542
 
@@ -567,6 +568,7 @@ class GpuView:
567
568
  row.gpu_mem_mb or 0.0,
568
569
  -row.pid,
569
570
  ),
571
+ "mem": lambda row: (_gpu_memory_mb(row) or 0.0, -row.pid),
570
572
  "pid": lambda row: row.pid,
571
573
  "name": lambda row: (row.name.lower(), row.pid),
572
574
  "user": lambda row: (row.user.lower(), row.pid),
@@ -910,7 +912,8 @@ class GpuView:
910
912
  "card": 5,
911
913
  "user": 9,
912
914
  "gpu": 6,
913
- "mem": 7,
915
+ # Wide enough for "GPU MEM ↓" so the sort arrow is never clipped.
916
+ "mem": 9,
914
917
  "shared": 7,
915
918
  "model": 18,
916
919
  }
@@ -19,7 +19,7 @@ from typing import Optional
19
19
  import psutil
20
20
 
21
21
  from ..capabilities import Capabilities
22
- from ..metrics import energy_available, sane_energy
22
+ from ..metrics import energy_available, energy_warming, sane_energy
23
23
  from .cpu import CpuSampler
24
24
  from .gpu import shared_backend
25
25
  from .power import EnergySampler
@@ -196,13 +196,12 @@ class LinuxSampler:
196
196
  "cpu_energy": cpu_joules * scale,
197
197
  "gpu_energy": gpu_joules * scale,
198
198
  "combined_power": combined_joules * scale,
199
- "cpu_energy_available": energy_available(
200
- self._seen["cpu"], self._sample_count
201
- ),
202
- "gpu_energy_available": energy_available(
203
- self._seen["gpu"], self._sample_count
204
- ),
199
+ "cpu_energy_available": energy_available(self._seen["cpu"]),
200
+ "gpu_energy_available": energy_available(self._seen["gpu"]),
205
201
  "ane_energy_available": False,
202
+ "cpu_energy_warming": energy_warming(self._sample_count),
203
+ "gpu_energy_warming": energy_warming(self._sample_count),
204
+ "ane_energy_warming": False,
206
205
  "power_source": energy["cpu_source"] or energy["system_source"],
207
206
  }
208
207
 
@@ -123,7 +123,8 @@ parser.add_argument('--interval', type=int, default=1,
123
123
  parser.add_argument('--color', type=int, default=2,
124
124
  help='Choose display color (0~8)')
125
125
  parser.add_argument('--no-color', action='store_true', default=False,
126
- help="Use the terminal's default foreground (no accent colour)")
126
+ help="Emit no colour; use the terminal's default foreground "
127
+ "(pairs with terminal themes and keyword highlighting)")
127
128
  parser.add_argument('--native', action='store_true', default=False,
128
129
  help='Start in the built-in semantic colour theme')
129
130
  parser.add_argument('--avg', type=int, default=30,
@@ -249,6 +250,8 @@ def parse_cpu_metrics(powermetrics_parse):
249
250
  cpu_metric_dict["package_W"] = cpu_metrics.get("combined_power", 0) / 1000
250
251
  cpu_metric_dict["cpu_available"] = cpu_metrics.get("cpu_energy_available", True)
251
252
  cpu_metric_dict["gpu_available"] = cpu_metrics.get("gpu_energy_available", True)
253
+ cpu_metric_dict["cpu_warming"] = cpu_metrics.get("cpu_energy_warming", False)
254
+ cpu_metric_dict["gpu_warming"] = cpu_metrics.get("gpu_energy_warming", False)
252
255
  cpu_metric_dict["ane_available"] = cpu_metrics.get("ane_energy_available", True)
253
256
  cpu_metric_dict["power_source"] = cpu_metrics.get("power_source", "")
254
257
  return cpu_metric_dict
@@ -624,6 +627,12 @@ class DefaultView():
624
627
  self.avg_package_power_list = deque([], maxlen=max(1, int(args.avg / args.interval)))
625
628
  self.avg_cpu_power_list = deque([], maxlen=max(1, int(args.avg / args.interval)))
626
629
  self.avg_gpu_power_list = deque([], maxlen=max(1, int(args.avg / args.interval)))
630
+ # Peaks are reset when a counter stops reporting, so a frozen sensor
631
+ # cannot leave a stale maximum on screen.
632
+ self._cpu_max_power_default = soc_info_dict["cpu_max_power"]
633
+ self._gpu_max_power_default = soc_info_dict["gpu_max_power"]
634
+ self._cpu_power_seen = False
635
+ self._gpu_power_seen = False
627
636
 
628
637
  def _processor_width(self, width):
629
638
  if not self.show_cores:
@@ -928,6 +937,20 @@ class DefaultView():
928
937
 
929
938
  cpu_available = cpu_metrics_dict["cpu_available"]
930
939
  gpu_available = cpu_metrics_dict["gpu_available"]
940
+ cpu_warming = cpu_metrics_dict.get("cpu_warming", False)
941
+ gpu_warming = cpu_metrics_dict.get("gpu_warming", False)
942
+ # A counter that froze after reporting once keeps a stale peak;
943
+ # drop it so the panel shows n/a rather than a stale maximum.
944
+ if self._cpu_power_seen and not (cpu_available or cpu_warming):
945
+ self.cpu_peak_power = 0.0
946
+ self.cpu_max_power = self._cpu_max_power_default
947
+ self.avg_cpu_power_list.clear()
948
+ if self._gpu_power_seen and not (gpu_available or gpu_warming):
949
+ self.gpu_peak_power = 0.0
950
+ self.gpu_max_power = self._gpu_max_power_default
951
+ self.avg_gpu_power_list.clear()
952
+ self._cpu_power_seen = cpu_available
953
+ self._gpu_power_seen = gpu_available
931
954
  power_source = cpu_metrics_dict.get("power_source", "")
932
955
  power_note = " (battery)" if power_source == "battery" else ""
933
956
 
@@ -940,7 +963,11 @@ class DefaultView():
940
963
  self.avg_package_power_list.append(package_power_W)
941
964
  avg_package_power = get_avg(self.avg_package_power_list)
942
965
  self.power_charts.title = "".join([
943
- "Power: ",
966
+ # A warming counter is unknown, not missing: keep the
967
+ # plain label so the title does not flicker.
968
+ power_label(cpu_available or cpu_warming,
969
+ gpu_available or gpu_warming),
970
+ ": ",
944
971
  '{0:.2f}'.format(package_power_W),
945
972
  "W (avg: ",
946
973
  '{0:.2f}'.format(avg_package_power),
@@ -974,6 +1001,8 @@ class DefaultView():
974
1001
  "W)"
975
1002
  ])
976
1003
  self.cpu_power_chart.append(cpu_power_percent)
1004
+ elif cpu_warming:
1005
+ self.cpu_power_chart.title = "CPU: —"
977
1006
  else:
978
1007
  self.cpu_power_chart.title = "CPU: n/a"
979
1008
  self.cpu_power_chart.append(0)
@@ -999,6 +1028,8 @@ class DefaultView():
999
1028
  "W)"
1000
1029
  ])
1001
1030
  self.gpu_power_chart.append(gpu_power_percent)
1031
+ elif gpu_warming:
1032
+ self.gpu_power_chart.title = "GPU: —"
1002
1033
  else:
1003
1034
  self.gpu_power_chart.title = "GPU: n/a"
1004
1035
  self.gpu_power_chart.append(0)
@@ -1090,6 +1121,22 @@ def _ram_detail_line(ram_metrics_dict, platform):
1090
1121
  )
1091
1122
 
1092
1123
 
1124
+ def power_label(cpu_available, gpu_available):
1125
+ """Title prefix for the Power panel.
1126
+
1127
+ When one component's energy counter stops reporting (macOS 27 freezes the
1128
+ CPU channel without root), the combined figure is only the other half and
1129
+ the title must say so instead of calling it the package power.
1130
+ """
1131
+ if cpu_available and gpu_available:
1132
+ return "Power"
1133
+ if gpu_available:
1134
+ return "Power (GPU only)"
1135
+ if cpu_available:
1136
+ return "Power (CPU only)"
1137
+ return "Power"
1138
+
1139
+
1093
1140
  def get_process_summary(powermetrics_parse, capabilities=None):
1094
1141
  """Two top-style lines for the process view: CPU, GPU and RAM usage."""
1095
1142
  if not powermetrics_parse:
@@ -6,6 +6,7 @@ are re-exported from there for backwards compatibility.
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ from collections import deque
9
10
  from typing import Optional
10
11
 
11
12
  ENERGY_TO_J = {
@@ -19,6 +20,10 @@ ENERGY_TO_J = {
19
20
  }
20
21
 
21
22
  ENERGY_GRACE_SAMPLES = 3
23
+ # Availability looks at this many recent samples so a counter that stops
24
+ # updating (macOS 27 freezes the CPU/ANE Energy Model channels without root)
25
+ # falls back to ``n/a`` instead of reporting a permanent 0 W.
26
+ ENERGY_WINDOW_SAMPLES = 10
22
27
 
23
28
 
24
29
  def calc_freq(states: list, freqs: list) -> tuple[float, float]:
@@ -89,14 +94,43 @@ def energy_to_joules(value: int, unit: str) -> float:
89
94
  return max(0.0, float(value)) * ENERGY_TO_J.get((unit or "").strip().lower(), 1e-3)
90
95
 
91
96
 
92
- def energy_available(seen: bool, samples: int) -> bool:
93
- """Whether a component's energy counter is reporting anything.
97
+ def energy_available(seen: bool) -> bool:
98
+ """Whether a component's energy counter reported a non-zero delta.
94
99
 
95
- A counter that has never produced a non-zero delta after a few frames is
96
- treated as unreadable, so the UI can show ``n/a`` instead of a
97
- misleading 0 W.
100
+ A counter that has never produced a usable reading — or stopped doing so,
101
+ which is what macOS 27 does to the CPU channel without root — must be
102
+ shown as unavailable rather than as a plausible 0 W.
98
103
  """
99
- return seen or samples <= ENERGY_GRACE_SAMPLES
104
+ return bool(seen)
105
+
106
+
107
+ def energy_warming(samples: int) -> bool:
108
+ """The first frames of a session, before a counter has had a chance."""
109
+ return samples <= ENERGY_GRACE_SAMPLES
110
+
111
+
112
+ class EnergyTracker:
113
+ """Recent-sample availability for one energy counter.
114
+
115
+ ``available`` is true while the last ``ENERGY_WINDOW_SAMPLES`` deltas
116
+ contained a non-zero reading, so a counter that reports once and then
117
+ freezes stops being trusted; ``warming`` covers the first frames, before
118
+ any reading has had a chance to arrive.
119
+ """
120
+
121
+ def __init__(self, window: int = ENERGY_WINDOW_SAMPLES) -> None:
122
+ self._recent: deque = deque(maxlen=max(1, int(window)))
123
+ self.samples = 0
124
+
125
+ def add(self, joules: float) -> None:
126
+ self.samples += 1
127
+ self._recent.append(joules > 0.0)
128
+
129
+ def available(self) -> bool:
130
+ return any(self._recent)
131
+
132
+ def warming(self) -> bool:
133
+ return self.samples <= ENERGY_GRACE_SAMPLES
100
134
 
101
135
 
102
136
  def sane_energy(joules: float, elapsed: float, max_power: float) -> float:
@@ -18,7 +18,9 @@ from .macos_gpu import physical_memory, read_device_stats
18
18
  from .metrics import (
19
19
  ENERGY_GRACE_SAMPLES,
20
20
  ENERGY_TO_J,
21
+ EnergyTracker,
21
22
  ane_usage,
23
+ energy_warming,
22
24
  calc_freq,
23
25
  energy_available,
24
26
  energy_to_joules,
@@ -46,6 +48,7 @@ _ENERGY_TO_J = ENERGY_TO_J
46
48
  _ENERGY_GRACE_SAMPLES = ENERGY_GRACE_SAMPLES
47
49
  _energy_to_joules = energy_to_joules
48
50
  _energy_available = energy_available
51
+ _energy_warming = energy_warming
49
52
  _sane_energy = sane_energy
50
53
 
51
54
 
@@ -96,7 +99,7 @@ class Sampler:
96
99
  # Some macOS builds expose the Energy Model counters but never update
97
100
  # them without root. Track whether a component has ever produced a
98
101
  # usable delta so the UI can say n/a instead of a misleading 0 W.
99
- self._energy_seen = {"cpu": False, "gpu": False, "ane": False}
102
+ self._energy_trackers = {name: EnergyTracker() for name in ("cpu", "gpu", "ane")}
100
103
  self._sample_count = 0
101
104
 
102
105
  self.prev_time: Optional[float] = None
@@ -165,12 +168,9 @@ class Sampler:
165
168
  ane_percent = ane_usage(self._ane.delta() if self._ane is not None else {})
166
169
 
167
170
  self._sample_count += 1
168
- if cpu_joules > 0.0:
169
- self._energy_seen["cpu"] = True
170
- if gpu_joules > 0.0:
171
- self._energy_seen["gpu"] = True
172
- if ane_joules > 0.0:
173
- self._energy_seen["ane"] = True
171
+ self._energy_trackers["cpu"].add(cpu_joules)
172
+ self._energy_trackers["gpu"].add(gpu_joules)
173
+ self._energy_trackers["ane"].add(ane_joules)
174
174
 
175
175
  cpu_joules = _sane_energy(cpu_joules, elapsed, self._power_limits["cpu"])
176
176
  gpu_joules = _sane_energy(gpu_joules, elapsed, self._power_limits["gpu"])
@@ -200,16 +200,13 @@ class Sampler:
200
200
  "cpu_energy": cpu_mj,
201
201
  "gpu_energy": gpu_mj,
202
202
  "combined_power": total_mj,
203
- "cpu_energy_available": _energy_available(
204
- self._energy_seen["cpu"], self._sample_count
205
- ),
206
- "gpu_energy_available": _energy_available(
207
- self._energy_seen["gpu"], self._sample_count
208
- ),
203
+ "cpu_energy_available": self._energy_trackers["cpu"].available(),
204
+ "gpu_energy_available": self._energy_trackers["gpu"].available(),
209
205
  "ane_usage": ane_percent,
210
- "ane_energy_available": _energy_available(
211
- self._energy_seen["ane"], self._sample_count
212
- ),
206
+ "ane_energy_available": self._energy_trackers["ane"].available(),
207
+ "cpu_energy_warming": self._energy_trackers["cpu"].warming(),
208
+ "gpu_energy_warming": self._energy_trackers["gpu"].warming(),
209
+ "ane_energy_warming": self._energy_trackers["ane"].warming(),
213
210
  },
214
211
  "gpu": gpu_payload,
215
212
  "disk": self._disk_rates(elapsed),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: macpm
3
- Version: 3.3.0
3
+ Version: 3.3.1
4
4
  Summary: Performance monitoring CLI for Apple Silicon and Linux
5
5
  Home-page: https://github.com/visualcjy/macpm
6
6
  Author: Jinyu Chen
@@ -165,7 +165,7 @@ macpm [--interval INTERVAL] [--color COLOR] [--avg AVG] [--show_cores [BOOL]] [-
165
165
  | `--interval SECONDS` | Sampling and display interval (default `1`) |
166
166
  | `--color 1-8` | Display colour (default `2`) |
167
167
  | `--native` | Start in the built-in semantic colour theme |
168
- | `--no-color` | Use the terminal's default foreground (no accent colour) |
168
+ | `--no-color` | Emit no colour; use the terminal's default foreground (works with terminal themes and keyword highlighting) |
169
169
  | `--avg SECONDS` | Averaging window for power values (default `30`) |
170
170
  | `--show_cores [BOOL]` | Start in the per-core view |
171
171
  | `--no-public-ip` | Do not look up the public IP and location |
@@ -198,8 +198,20 @@ single-card GPU tables only the header row and the current sort column are
198
198
  bright; the other normal cells stay dim. The palette uses fixed xterm-256
199
199
  indices (16-255), so it does not follow the terminal profile.
200
200
 
201
- `--no-color` is outside the ring: it keeps the terminal's default foreground
202
- for a monochrome setup or a terminal-side keyword highlighter.
201
+ ### No colour
202
+
203
+ `--no-color` emits no foreground colour at all: frames, labels, numbers, bars
204
+ and footer hints all use the terminal's default foreground. This is the mode
205
+ to combine with the terminal's own theme and keyword highlighting (iTerm2
206
+ `Triggers → Highlight Text`, NyaTerm `内置规则`, etc.), so numbers, errors or
207
+ IP addresses can be coloured by the terminal instead of macpm. It is outside
208
+ the `←`/`→` ring: pressing an arrow returns to a colour theme, and the flag wins
209
+ over `--color`/`--native` if both are given. Bars and frames stay readable
210
+ because they are drawn with block and box glyphs, not colour.
211
+
212
+ ```sh
213
+ macpm --no-color
214
+ ```
203
215
 
204
216
  | | |
205
217
  |---|---|
@@ -367,7 +379,7 @@ shows `n/a` and the reason stays in the data
367
379
 
368
380
  A single-GPU machine keeps the older layout: card summary on top, process table
369
381
  below. Every view's footer starts with the app name and version
370
- (`macpm v3.3.0 · q quit …`).
382
+ (`macpm v3.3.1 · q quit …`).
371
383
 
372
384
  ```text
373
385
  ┌ GPU INFO ────────────────────────────────────────────────────────────────────────────────┐
@@ -381,7 +393,7 @@ below. Every view's footer starts with the app name and version
381
393
  │ └ 222 Xorg 2.0G │
382
394
  │ 2 AMD GPU (amdgpu) ▉▉▉▉▏▏ 60% 1100/1750 12.0W ▉▉▉▉▏▏▏▏▏▏ 3.0G/8.0G 46°C │
383
395
  │ 3 AMD GPU (amdgpu) ▉▉▉▉▉▏ 85% 1200/1750 12.0W ▉▉▉▉▉▏▏▏▏▏ 4.0G/8.0G 49°C │
384
- └ macpm v3.3.0 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
396
+ └ macpm v3.3.1 · q quit 1-5 view s sort ↑/↓ page Space pause ←/→ colour ────────────────┘
385
397
  ```
386
398
 
387
399
  | Platform | What fills each row |
@@ -677,9 +689,12 @@ Release steps are documented in [RELEASE.md](https://github.com/visualcjy/macpm/
677
689
  - **`macpm: command not found`** — add your Python user-base `bin` directory to
678
690
  `PATH`, or run `python3 -m macpm`.
679
691
  - **Power readings freeze or show `n/a` on macOS 27** — some builds restrict
680
- unprivileged `Energy Model` refreshes. CPU/GPU usage and frequency still
681
- work; a counter that never reports is shown as `n/a` instead of `0.00W`.
682
- Run `macpm-dump` to inspect the raw values.
692
+ unprivileged `Energy Model` refreshes, and the CPU/ANE channels can stop
693
+ updating while the GPU one keeps working. CPU/GPU usage and frequency still
694
+ work; a counter that has been silent for ten samples is shown as `n/a`
695
+ instead of `0.00W`, and the Power box then reads `Power (GPU only)`. The
696
+ first frames of a session show `CPU: —` until a counter reports once. Run
697
+ `macpm-dump` to inspect the raw values.
683
698
  - **M5/Ultra values look wrong** — CPU tier/channel mapping is not complete;
684
699
  see the compatibility table.
685
700
  - **The Temps & Fans box says `SMC unavailable`** — the AppleSMC user client
@@ -81,6 +81,7 @@ tests/test_linux_wiring.py
81
81
  tests/test_macos_gpu.py
82
82
  tests/test_netinfo.py
83
83
  tests/test_network.py
84
+ tests/test_power_panel.py
84
85
  tests/test_probe.py
85
86
  tests/test_process_linux.py
86
87
  tests/test_processes.py
@@ -7,7 +7,7 @@ README = (ROOT / "README.md").read_text(encoding="utf-8")
7
7
 
8
8
  setup(
9
9
  name="macpm",
10
- version="3.3.0",
10
+ version="3.3.1",
11
11
  author="Jinyu Chen",
12
12
  author_email="visualcjy@mail.com",
13
13
  url="https://github.com/visualcjy/macpm",
@@ -179,13 +179,28 @@ class SingleCardTests(unittest.TestCase):
179
179
  view = make_view([])
180
180
 
181
181
  seen = []
182
- for _ in range(4):
182
+ for _ in range(5):
183
183
  seen.append((view.sort, view.desc))
184
184
  view.cycle_sort()
185
185
 
186
- self.assertEqual(seen, [("gpu", True), ("pid", False),
186
+ self.assertEqual(seen, [("gpu", True), ("mem", True), ("pid", False),
187
187
  ("name", False), ("user", False)])
188
188
 
189
+ def test_processes_are_sorted_by_gpu_memory(self):
190
+ rows = [
191
+ ProcessRow(1, "tiny", "u", 0.0, 0, 0.0, gpu_card="0", gpu_mem_mb=1024.0),
192
+ ProcessRow(2, "huge", "u", 0.0, 0, 0.0, gpu_card="0", gpu_mem_mb=8192.0),
193
+ ProcessRow(3, "mid", "u", 0.0, 0, 0.0, gpu_card="0", gpu_mem_mb=2048.0),
194
+ ]
195
+ view = make_view(rows)
196
+ view.sort = "mem"
197
+ view.desc = True
198
+ view._sorted = None
199
+
200
+ self.assertEqual(
201
+ [row.name for row in view._visible_rows()], ["huge", "mid", "tiny"]
202
+ )
203
+
189
204
  def test_no_gpu_machine(self):
190
205
  caps = linux_caps(gpu_util=False, gpu_freq=False, gpu_power=False, proc_gpu=False)
191
206
  view = make_view([], caps=caps, ready=False, gpu_available=False)
@@ -119,6 +119,43 @@ class ViewRenderTests(unittest.TestCase):
119
119
  self.assertNotIn("ANE", output)
120
120
  self.assertIn("Intel Core i7-12700H", output)
121
121
 
122
+ def test_power_panel_drops_a_frozen_counter(self):
123
+ sampler = LinuxSampler(1)
124
+ sampler.prime()
125
+ args = types.SimpleNamespace(color=2, show_cores=False, interval=1, avg=30)
126
+ view = DefaultView(
127
+ sampler.soc, args, netinfo=None, capabilities=sampler.capabilities
128
+ )
129
+ sample = sampler.sample()
130
+ processor = sample["processor"]
131
+ processor.update({
132
+ "cpu_energy": 4000.0, "gpu_energy": 8000.0,
133
+ "cpu_energy_available": True, "gpu_energy_available": True,
134
+ "cpu_energy_warming": False, "gpu_energy_warming": False,
135
+ })
136
+ with contextlib.redirect_stdout(io.StringIO()):
137
+ view.display(sample, args)
138
+
139
+ self.assertIn("CPU: 4.00W", view.cpu_power_chart.title)
140
+ self.assertTrue(view.power_charts.title.startswith("Power: "))
141
+
142
+ # The counter freezes after reporting: n/a, and its stale peak is gone.
143
+ processor.update({"cpu_energy": 0.0, "cpu_energy_available": False})
144
+ with contextlib.redirect_stdout(io.StringIO()):
145
+ view.display(sample, args)
146
+
147
+ self.assertEqual(view.cpu_power_chart.title, "CPU: n/a")
148
+ self.assertEqual(view.cpu_peak_power, 0.0)
149
+ self.assertEqual(view.cpu_max_power, view._cpu_max_power_default)
150
+ self.assertTrue(view.power_charts.title.startswith("Power (GPU only):"))
151
+
152
+ # Before the first usable sample the panel shows a dash, not 0.00 W.
153
+ processor.update({"cpu_energy_available": False, "cpu_energy_warming": True})
154
+ with contextlib.redirect_stdout(io.StringIO()):
155
+ view.display(sample, args)
156
+
157
+ self.assertEqual(view.cpu_power_chart.title, "CPU: —")
158
+
122
159
  def test_view_without_gpu_power_or_e_cores(self):
123
160
  sampler = LinuxSampler(1)
124
161
  sampler.prime()
@@ -0,0 +1,28 @@
1
+ """Power panel titles: component naming, n/a and the warming dash."""
2
+
3
+ import sys
4
+ import unittest
5
+
6
+ _argv, sys.argv = sys.argv, ["macpm"]
7
+ try:
8
+ from macpm.macpm import power_label
9
+ finally:
10
+ sys.argv = _argv
11
+
12
+
13
+ class PowerLabelTests(unittest.TestCase):
14
+ def test_both_counters_report_the_plain_package_power(self):
15
+ self.assertEqual(power_label(True, True), "Power")
16
+
17
+ def test_missing_cpu_names_the_remainder(self):
18
+ self.assertEqual(power_label(False, True), "Power (GPU only)")
19
+
20
+ def test_missing_gpu_names_the_remainder(self):
21
+ self.assertEqual(power_label(True, False), "Power (CPU only)")
22
+
23
+ def test_neither_counter_falls_back_to_the_plain_name(self):
24
+ self.assertEqual(power_label(False, False), "Power")
25
+
26
+
27
+ if __name__ == "__main__":
28
+ unittest.main()
@@ -0,0 +1,78 @@
1
+ import unittest
2
+
3
+ from macpm.metrics import EnergyTracker
4
+ from macpm.sampler import _energy_available, _energy_warming, _sane_energy
5
+
6
+
7
+ class SaneEnergyTests(unittest.TestCase):
8
+ def test_normal_delta_is_kept(self):
9
+ self.assertEqual(_sane_energy(10.0, 1.0, 240.0), 10.0)
10
+
11
+ def test_spike_is_dropped(self):
12
+ self.assertEqual(_sane_energy(6208.38, 1.0, 240.0), 0.0)
13
+
14
+ def test_negative_and_missing_values_are_zeroed(self):
15
+ self.assertEqual(_sane_energy(-1.0, 1.0, 240.0), 0.0)
16
+ self.assertEqual(_sane_energy(0.0, 1.0, 240.0), 0.0)
17
+
18
+ def test_zero_elapsed_is_never_plausible(self):
19
+ self.assertEqual(_sane_energy(1.0, 0.0, 240.0), 0.0)
20
+
21
+ def test_value_at_the_limit_is_kept(self):
22
+ self.assertEqual(_sane_energy(240.0, 1.0, 240.0), 240.0)
23
+
24
+
25
+ class EnergyAvailabilityTests(unittest.TestCase):
26
+ def test_silent_counter_is_unavailable(self):
27
+ self.assertFalse(_energy_available(False))
28
+
29
+ def test_reporting_counter_is_available(self):
30
+ self.assertTrue(_energy_available(True))
31
+
32
+ def test_first_frames_are_warming(self):
33
+ self.assertTrue(_energy_warming(1))
34
+ self.assertTrue(_energy_warming(3))
35
+ self.assertFalse(_energy_warming(4))
36
+
37
+
38
+ class EnergyTrackerTests(unittest.TestCase):
39
+ """A counter that freezes must stop being trusted (macOS 27 CPU channel)."""
40
+
41
+ def test_startup_grace_is_warming_but_not_available(self):
42
+ tracker = EnergyTracker()
43
+
44
+ self.assertTrue(tracker.warming())
45
+ self.assertFalse(tracker.available())
46
+
47
+ def test_silent_counter_leaves_the_grace_period(self):
48
+ tracker = EnergyTracker()
49
+ for _ in range(4):
50
+ tracker.add(0.0)
51
+
52
+ self.assertFalse(tracker.warming())
53
+ self.assertFalse(tracker.available())
54
+
55
+ def test_frozen_counter_falls_back_after_the_window(self):
56
+ tracker = EnergyTracker(window=5)
57
+ tracker.add(1.0)
58
+ for _ in range(4):
59
+ tracker.add(0.0)
60
+ self.assertTrue(tracker.available())
61
+
62
+ tracker.add(0.0)
63
+
64
+ self.assertFalse(tracker.available())
65
+
66
+ def test_recovering_counter_is_trusted_again(self):
67
+ tracker = EnergyTracker(window=3)
68
+ for _ in range(10):
69
+ tracker.add(0.0)
70
+ self.assertFalse(tracker.available())
71
+
72
+ tracker.add(2.0)
73
+
74
+ self.assertTrue(tracker.available())
75
+
76
+
77
+ if __name__ == "__main__":
78
+ unittest.main()
@@ -1,35 +0,0 @@
1
- import unittest
2
-
3
- from macpm.sampler import _energy_available, _sane_energy
4
-
5
-
6
- class SaneEnergyTests(unittest.TestCase):
7
- def test_normal_delta_is_kept(self):
8
- self.assertEqual(_sane_energy(10.0, 1.0, 240.0), 10.0)
9
-
10
- def test_spike_is_dropped(self):
11
- self.assertEqual(_sane_energy(6208.38, 1.0, 240.0), 0.0)
12
-
13
- def test_negative_and_missing_values_are_zeroed(self):
14
- self.assertEqual(_sane_energy(-1.0, 1.0, 240.0), 0.0)
15
- self.assertEqual(_sane_energy(0.0, 1.0, 240.0), 0.0)
16
-
17
- def test_zero_elapsed_is_never_plausible(self):
18
- self.assertEqual(_sane_energy(1.0, 0.0, 240.0), 0.0)
19
-
20
- def test_value_at_the_limit_is_kept(self):
21
- self.assertEqual(_sane_energy(240.0, 1.0, 240.0), 240.0)
22
-
23
-
24
- class EnergyAvailabilityTests(unittest.TestCase):
25
- def test_counter_must_be_silent_past_the_grace_period(self):
26
- self.assertTrue(_energy_available(False, 1))
27
- self.assertTrue(_energy_available(False, 3))
28
- self.assertFalse(_energy_available(False, 4))
29
-
30
- def test_seen_counter_stays_available(self):
31
- self.assertTrue(_energy_available(True, 10))
32
-
33
-
34
- if __name__ == "__main__":
35
- unittest.main()
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
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes