#profiling #xcode #macos #instruments

app cargo-instruments

Generate Xcode Instruments trace files for binary targets

8 releases

0.3.2 Sep 21, 2020
0.3.1 Feb 24, 2020
0.2.1 Apr 4, 2019
0.2.0 Mar 20, 2019
0.1.2 Mar 17, 2019

#32 in Cargo plugins

Download history 19/week @ 2020-07-02 17/week @ 2020-07-09 13/week @ 2020-07-16 10/week @ 2020-07-23 9/week @ 2020-07-30 14/week @ 2020-08-06 19/week @ 2020-08-13 18/week @ 2020-08-20 22/week @ 2020-08-27 22/week @ 2020-09-03 12/week @ 2020-09-10 28/week @ 2020-09-17 14/week @ 2020-09-24 18/week @ 2020-10-01 13/week @ 2020-10-08 13/week @ 2020-10-15

71 downloads per month

MIT license

399 lines


Easily generate Instruments traces for your rust crate.

cargo-instruments is the glue between cargo and Xcode's bundled profiling suite. It allows you to easily profile any binary in your crate, generating files that can be viewed in the Instruments app.

Instruments Time Profiler Instruments System Trace



brew install cargo-instruments

Building from Source

First, ensure that you are running macOS, with Cargo, Xcode, and the Xcode Command Line Tools installed; then install with

cargo install cargo-instruments


basic usage

cargo-instruments requires a binary target to run. By default, it will try to build the current crate's main.rs. You can specify an alternative binary by using the --bin or --example flags, or a benchmark target with the --bench flag.

Generate a new trace file (by default saved in /target/instruments)

$ cargo instruments [-t template] [--bin foo | --example bar] [--out out_file]

Open the file in Instruments.app (or pass --open to open automatically)

$ open target/instruments/my_bin_YYYY-MM-DD-THH:MM:SS.trace

Profiling application in release mode

When profiling the application in release mode the compiler doesn't provide debugging symbols in the default configuration.

To let the compiler generate the debugging symbols even in release mode you can append the following section in your Cargo.toml.

debug = true


Instruments has the concept of 'templates', which describe sets of dtrace probes that can be enabled. cargo-instruments will use the "Time Profiler", which collects CPU core and thread use.


# View all args and options
$ cargo instruments --help
# profile the main binary with the Allocations template
$ cargo instruments -t alloc
# profile examples/my_example.rs, with the default template,
# for 10 seconds, and open the trace when finished
$ cargo instruments --example my_example --limit 10000 --open


Instruments Help

WWDC videos

The best source of information about Instruments is likely the various WWDC sessions over the years:


~813K SLoC