cargo bench用于package基准测试

cargo bench用于在代码中以#{bench]标识(代码目录下有benches文件夹),类似于测试用例#[test]标识(代码目录下有tests文件夹)

支持的子命令如下:

# cargo bench --help
cargo-bench
Execute all benchmarks of a local package

USAGE:
    cargo bench [OPTIONS] [BENCHNAME] [-- <args>...]

OPTIONS:
    -q, --quiet                     No output printed to stdout
        --lib                       Benchmark only this package's library
        --bin <NAME>...             Benchmark only the specified binary
        --bins                      Benchmark all binaries
        --example <NAME>...         Benchmark only the specified example
        --examples                  Benchmark all examples
        --test <NAME>...            Benchmark only the specified test target
        --tests                     Benchmark all tests
        --bench <NAME>...           Benchmark only the specified bench target
        --benches                   Benchmark all benches
        --all-targets               Benchmark all targets
        --no-run                    Compile, but don't run benchmarks
    -p, --package <SPEC>...         Package to run benchmarks for
        --all                       Benchmark all packages in the workspace
        --exclude <SPEC>...         Exclude packages from the benchmark
    -j, --jobs <N>                  Number of parallel jobs, defaults to # of CPUs
        --features <FEATURES>       Space-separated list of features to activate
        --all-features              Activate all available features
        --no-default-features       Do not activate the `default` feature
        --target <TRIPLE>           Build for the target triple
        --target-dir <DIRECTORY>    Directory for all generated artifacts
        --manifest-path <PATH>      Path to Cargo.toml
        --message-format <FMT>      Error format [default: human]  [possible values: human, json, short]
        --no-fail-fast              Run all benchmarks regardless of failure
    -v, --verbose                   Use verbose output (-vv very verbose/build.rs output)
        --color <WHEN>              Coloring: auto, always, never
        --frozen                    Require Cargo.lock and cache are up to date
        --locked                    Require Cargo.lock is up to date
    -Z <FLAG>...                    Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
    -h, --help                      Prints help information

ARGS:
    <BENCHNAME>    If specified, only run benches containing this string in their names
    <args>...      Arguments for the bench binary

The benchmark filtering argument BENCHNAME and all the arguments following the
two dashes (`--`) are passed to the benchmark binaries and thus to libtest
(rustc's built in unit-test and micro-benchmarking framework). If you're
passing arguments to both Cargo and the binary, the ones after `--` go to the
binary, the ones before go to Cargo. For details about libtest's arguments see
the output of `cargo bench -- --help`.

If the `--package` argument is given, then SPEC is a package ID specification
which indicates which package should be benchmarked. If it is not given, then
the current package is benchmarked. For more information on SPEC and its format,
see the `cargo help pkgid` command.

All packages in the workspace are benchmarked if the `--all` flag is supplied. The
`--all` flag is automatically assumed for a virtual manifest.
Note that `--exclude` has to be specified in conjunction with the `--all` flag.

The `--jobs` argument affects the building of the benchmark executable but does
not affect how many jobs are used when running the benchmarks.

Compilation can be customized with the `bench` profile in the manifest.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值