#performance #counter #macos #apple #perf #series #chips

macos-perf

Measure the performance of Rust code on Apple's M1 series chips using performance counters

1 unstable release

0.1.1 Jan 9, 2022
0.1.0 Jan 9, 2022

#10 in #chips

MIT license

16KB
327 lines

About

Measure the performance of Rust code on Apple's M1 series chips using performance counters. The resulting measurements will be much more stable than simply timing the execution. However, we still need to model the expected execution time based off the reported metrics.

Example

// See also examples/main.rs
use rust_macos_perf::{init, timeit_loops};

init().unwrap();
let pc = timeit_loops! {10, {
    // Your function here.
}}
.unwrap();
println!("{:?}", pc);

Warning

This is an extremely unstable API. Also the the underlying Apple functions may change anytime.

Requirements

  1. This only works on Apple M1 series chips.
  2. For this to work, the Apple Developer SDK needs to be installed. This can be installed via xcode-select --install. If anything else is missing, please file a ticket here on GitHub.
  3. The resulting program needs to be run with sudo.

Development

Please run tests both as sudo and without sudo.

Inspirations | Related Work

Dependencies

~0.3–3MB
~61K SLoC