by cmyr

A cargo plugin to generate Xcode Instruments trace files

244 Stars 6 Forks Last release: 9 months ago (v0.3.0) MIT License 34 Commits 7 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Easily generate Instruments traces for your rust crate.

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

requires a binary target to run. By default, it will try to build the current crate's
. You can specify an alternative binary by using the
flags, or a benchmark target with the

Generate a new trace file (by default saved in

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

Open the file in (or pass

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

debug = true


Instruments has the concept of 'templates', which describe sets of dtrace probes that can be enabled.

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/, 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:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.