1 unstable release
0.1.1 | Jan 9, 2022 |
---|---|
0.1.0 |
|
#9 in #chips
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
- This only works on Apple M1 series chips.
- 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. - The resulting program needs to be run with
sudo
.
Development
Please run tests both as sudo and without sudo.
Inspirations | Related Work
- Lemire's blog post and accompanying code: http://lemire.me/blog/2021/03/24/counting-cycles-and-instructions-on-the-apple-m1-processor/
- Original code by dougallj: https://gist.github.com/dougallj/5bafb113492047c865c0c8cfbc930155#file-m1_robsize-c-L390
- https://bheisler.github.io/post/criterion-rs-0-3-4/ Introducing me to the world of counter-based profiling.
Dependencies
~0.3–2.8MB
~56K SLoC