Skip to content

Cannot run benches in the main target, examples, or libs #84

Open
@ariofrio

Description

@ariofrio

I have a simple project with a benchmark using Rust's built-in #[bench] functionality written alongside unit tests, in the same file as the code I'm testing.

Usually I run benchmarks using:

cargo bench

Or if I only want to run some functions:

cargo bench <name_of_function>

But when I try to run cargo-instruments, I get the following error:

$ cargo instruments -t time --bench
error: The argument '--bench <NAME>' requires a value but none was supplied

USAGE:
    cargo instruments --template <TEMPLATE> <--example <NAME>|--bin <NAME>|--bench <NAME>>

For more information try --help

I don't know what I should put in as the <NAME> since the none of the following work:

cargo instruments -t time --bench <name_of_function>
cargo instruments -t time --bench <name_of_crate>
cargo instruments -t time --bench <name_of_crate>-test
cargo instruments -t time --bench <name_of_crate>-bench
cargo instruments -t time --bench crate
cargo instruments -t time --bench libtest
cargo instruments -t time --bench test
cargo instruments -t time --bench bench
cargo instruments -t time --bench benches
cargo instruments -t time --bench ''
cargo instruments -t time --bench -

I always get the following error:

Failed no bench target named `<the_name_i_tried>`.

no bench target named `<the_name_i_tried>`.

I get a similar error if I try to specify a name when with --bench using cargo bench:

$ cargo bench --bench <name_of_crate>
error: no bench target named `<name_of_crate>`.

However I can call cargo bench without arguments, or specify --bins, --bin <name_of_crate>, or --benches to run my benchmark without profiling.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions