Add cargo dev repeat for profiling (#5144)

## Summary

This adds a new subcommand that can be used as

```shell
cargo build --bin ruff_dev --profile=release-debug
perf record -g -F 999 target/release-debug/ruff_dev repeat --repeat 30 --exit-zero --no-cache path/to/cpython > /dev/null
flamegraph --perfdata perf.data
```

## Test Plan

This is a ruff internal script. I successfully used it to profile
cpython with the instructions above
This commit is contained in:
konstin 2023-06-19 11:40:09 +02:00 committed by GitHub
parent be11cae619
commit 361d45f2b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View file

@ -68,7 +68,7 @@ pub enum Command {
},
}
#[derive(Debug, clap::Args)]
#[derive(Clone, Debug, clap::Args)]
#[allow(clippy::struct_excessive_bools, clippy::module_name_repetitions)]
pub struct CheckArgs {
/// List of files or directories to check.

View file

@ -159,7 +159,7 @@ fn format(files: &[PathBuf]) -> Result<ExitStatus> {
Ok(ExitStatus::Success)
}
fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
pub fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
let (cli, overrides) = args.partition();
// Construct the "default" settings. These are used when no `pyproject.toml`