Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
gswirski committed Oct 1, 2023
1 parent 1898547 commit 5a6c55a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ $ nix-shell --command 'cargo install cargo-instruments' --pure -p \

`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.
using the `--bin` or `--example` flags, a test target with the `--test` flag,
or a benchmark target with the `--bench` flag.

Assuming your crate has one binary target named `mybin`, and you want to profile
using the `Allocations` Instruments template:
Expand Down Expand Up @@ -154,6 +154,7 @@ OPTIONS:
-p, --package <NAME> Specify package for example/bin/bench
--profile <NAME> Pass --profile NAME to cargo
-t, --template <TEMPLATE> Specify the instruments template to run
--test <NAME> Test target to run
--time-limit <MILLIS> Limit recording time to the specified value (in milliseconds)
-o, --output <PATH> Output .trace file to the given path
Expand Down Expand Up @@ -219,6 +220,15 @@ $ cargo instruments -t alloc
$ cargo instruments -t Allocations --example my_example --time-limit 10000 --open
```

```shell
# Profile a single test scanario with the File Activity template
#
# You will find `your_library_name` name by running `cargo test` and checking the 'Running' line.
# e.g. Running unittests src/main.rs (target/debug/deps/your_library_name-3cabce0a041cfeed)
# Optionally, you can provide a specific test case after the -- marker
$ cargo instruments -t io --test your_library_name -- opt::tests::specific_test
```

## Resources

[Instruments Help][instruments]
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn build_target(cargo_options: &CargoOpts, workspace: &Workspace) -> Result<Path
result
.tests
.iter()
.find(|unit_output| { unit_output.unit.target.name() == test })
.find(|unit_output| unit_output.unit.target.name() == test)
.map(|unit_output| unit_output.path.clone())
.ok_or_else(|| anyhow!("no test '{}'", test))
} else {
Expand Down

0 comments on commit 5a6c55a

Please sign in to comment.