Bright utility · Apple Silicon · GPU · CPU · memory

bgpucap

Part of Bright Utils: the b in bgpucap is for Bright (like btime, bfind, bping). Run any command like time(1) and report GPU, CPU, and unified memory utilization. Crate name gpucap; CLI command bgpucap.

# wrap a command — colored report on stderr $ bgpucap --metrics gpu,pwr,freq sleep 5 gpu avg 12.3% peak 45.6% cpu avg 8.1% peak 23.4% memory avg 52.0% peak 55.1% gpu-mhz avg 900 MHz peak 1200 MHz gpu-pwr avg 23 W peak 45 W dram-pwravg 21 W peak 25 W real 5.012345 s # JSON on stdout — pipe-friendly; human report stays on stderr $ bgpucap -f json --metrics basic sleep 1 > before.json $ bgpucap compare before.json after.json gpu 10.0 30.0 +20.0
Install → Format spec Bright Utils crates.io GitHub

Wrap any command.

bgpucap forks and execs your command, polls metrics every 100 ms (configurable with --interval), then prints a summary to stderr. Exit status matches the child process.

bgpucap sleep 1
bgpucap --metrics basic sleep 1          # lightweight: skip extended IOReport
bgpucap --metrics gpu,pwr,freq sleep 5
bgpucap --list-metrics
bgpucap --columns --separator=' / ' sleep 1
bgpucap --pid 1234 --metrics cmd-gpu sleep 5
bgpucap --no-track-gpu sleep 1           # skip per-process GPU tracking
bgpucap --color=bright -- ffmpeg -i in.mp4 out.mp4
bgpucap --interval 50 make -j8

Metric filtering

--metrics=LIST selects human or JSON output (default: all). Names and groups: basic, power, freq, thermal, mem-detail, cmd-gpu, … Run bgpucap --list-metrics for the full list. Env: BGPUCAP_METRICS.

Requirements

macOS on Apple Silicon (M1/M2/M3/M4+), arm64 only. Reads AGX GPU metrics and unified memory statistics unavailable on Intel Macs or non-macOS platforms.

Color output

--color[=WHEN]auto, always, never, plain, ansi, truecolor. --color-schemedefault or bright. Env: BGPUCAP_COLOR, BGPUCAP_COLOR_SCHEME (GPUCAP_* still accepted), plus NO_COLOR / CLICOLOR.

Graceful degradation

Core gpu, cpu, and memory always work. Extended metrics (power, freq, thermal, …) are best-effort on untested chips; omitted from output when unavailable. Validated on Apple M4 Max; chip family in JSON (chip.family: m1m4).

Format vs. color: When -f / --format (or BGPUCAP_FORMAT; GPUCAP_FORMAT still accepted) is set, output is always plain text — even with --color=always. This matches BrightDate ecosystem conventions: human reports colorize on TTY; machine format strings stay script-safe.

watch · compare · gpuexercise

Continuous watch

Sample system metrics until Ctrl+C or --count N. Default interval: 1000 ms (override with --interval).

bgpucap watch                          # live lines on stderr
bgpucap watch -n 10 --interval 500     # 10 samples every 500 ms
bgpucap watch -f json                  # NDJSON on stdout + summary JSON on exit
bgpucap watch --metrics basic --pid 1234

Compare JSON reports

Diff two -f json captures. Compares the common subset of metrics present in both files; one-sided metrics are skipped (noted on stderr).

bgpucap -f json --metrics basic sleep 5 > before.json
# … run workload …
bgpucap -f json --metrics basic sleep 5 > after.json
bgpucap compare before.json after.json

GPU exerciser

gpuexercise drives sustained GPU load via a Metal compute shader (subcommand, not a separate binary):

bgpucap gpuexercise --percent 50 --seconds 10
bgpucap gpuexercise -p 75 -s 5 -f json
bgpucap gpuexercise --mode sample -s 5      # ambient only
bgpucap gpuexercise --mode load -p 80 -s 5  # always generate load
ModeBehavior
best-effort (default)Skip load if target ≤ ambient; suggests reachable --percent
loadAlways generate Metal load to chase target
sampleNo load; measure ambient GPU for the duration
# watch — colored live samples on stderr $ bgpucap watch -n 3 --interval 1000 [1] gpu 14.2% cpu 6.1% mem 51.3% [2] gpu 18.7% cpu 7.4% mem 51.5% [3] gpu 12.1% cpu 5.9% mem 51.2% gpu avg 15.0% peak 18.7% cpu avg 6.5% peak 7.4%

-f / --format

Custom format strings follow BrightDate FORMAT-SPEC where applicable, plus gpucap-specific utilization specifiers. Set via -f or environment variable BGPUCAP_FORMAT (GPUCAP_FORMAT still accepted).

bgpucap -f '%gA,%gP,%uA,%uP,%hA,%hP,%e,%Ws,%Wt' sleep 1
bgpucap -f json --metrics basic sleep 1 > report.json
bgpucap -f 'cmd=%C x=%x gpu_peak=%gP start=%Ws' cargo build

-f json: Structured JSON on stdout (human reports on stderr). Respects --metrics. Use with bgpucap compare for before/after diffs.

gpucap

Utilization specifiers

All percentages output one decimal place, no % suffix.

Specifier Meaning
%gA / %gPGPU average / peak %
%gI / %gJGPU memory in use (bytes) avg / peak
%gM / %gOGPU memory allocated (bytes) avg / peak
%gR / %gSRenderer utilization % avg / peak
%gL / %gYTiler utilization % avg / peak
%gF / %gVGPU frequency MHz avg / peak
%gU / %gWGPU temperature °C avg / peak
%gTThermal throttle (% of samples)
%uA / %uPCPU average / peak % (system-wide)
%uF / %uVCPU frequency MHz avg / peak (blended E/P)
%gB / %gKGPU power (W) avg / peak
%gC / %gDCommand process GPU % avg / peak
%gN / %gQGPU SRAM power (W) avg / peak
%uE / %uQE-core CPU frequency MHz avg / peak
%uH / %uZP-core CPU frequency MHz avg / peak
%uB / %uKCPU package power (W) avg / peak
%uG / %uRE-core power (W) avg / peak
%uI / %uSP-core power (W) avg / peak
%aB / %aKANE power (W) avg / peak
%hG / %hJDRAM power (W) avg / peak
%hA / %hPUnified memory average / peak %
%hW / %hXWired memory bytes avg / peak
%hC / %hDCompressed memory bytes avg / peak
%hS / %hOSwap used bytes avg / peak
%hK / %hLMemory pressure level avg / peak (0–2)
%tGExercise target GPU % (gpuexercise only)
BrightDate

Timing & timestamps

Shared with btime -f — see FORMAT-SPEC tiers A–C.

Specifier Meaning Output
%Ws / %NCommand start wall time{:.9} BrightDate days
%Wt / %nCommand end wall time{:.9} BrightDate days
%eElapsed secondssec.centis (GNU style)
%EElapsed wall timem:ss.cc or h:mm:ss
%BElapsed wall time{:.9} BrightDate days
%bElapsed millidays{:.6} (no suffix)
%dEElapsed millidays{:.6} md
%CCommand lineargv joined with spaces
%xExit statuschild exit code
%%Literal %
\t, \nTab / newline

Default machine format: %gA,%gP,%uA,%uP,%hA,%hP,%e,%Ws,%Wt\n

What gets measured.

Metric Source Notes
GPU % IOKit Device Utilization % IOReport GPUPH fallback
GPU memory IOKit PerformanceStatistics In use / allocated unified memory bytes
GPU frequency IOReport + pmgr voltage-states9 Weighted MHz from P-state residency
GPU thermal IOReport GPU_CLTM, Tg*a Max Throttle % and die temperature
GPU / CPU / DRAM power IOReport Energy Model GPU Energy (nJ), CPU Energy / DRAM (mJ) → watts
ANE power IOReport Energy Model ANE total or ANE0 shard counters
E-core / P-core power IOReport Energy Model EACC_CPU / ECPU, sum of PACC*_CPU
CPU Mach host_processor_info System-wide; E/P MHz and blended freq from IOReport PCPU/ECPU
Memory host_statistics64, vm.swapusage Unified RAM %, wired, compressed, swap, pressure

Extended metrics are validated on Apple M4 Max. On other Apple Silicon chips, bgpucap prints a footnote and reports best-effort values. Samples are taken every --interval ms (default 100) while the child runs. Average and peak are computed over all samples.

Install.

1

Cargo

cargo install gpucap
bgpucap sleep 1
2

Homebrew

brew tap digital-defiance/tap
brew install digital-defiance/tap/gpucap
bgpucap sleep 1
# Homebrew also symlinks gpucap → bgpucap
3

Verify

bgpucap --version
bgpucap --help
man bgpucap
bgpucap -f '%gA,%uA,%e' sleep 0.1

Man page

man/bgpucap.1 ships with the crate. Homebrew installs it as man bgpucap. Documents options, format specifiers, environment variables, and the gpuexercise, watch, and compare subcommands.

man bgpucap          # after brew install
man bgpucap | grep -A2 FORMAT   # format specifiers

Crate name remains gpucap; command is bgpucap. Homebrew symlinks gpucapbgpucap.