1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use clap::Parser;
#[derive(Parser)]
#[command(
name = "megafine",
version,
about = "A multithreaded command-line benchmarking tool."
)]
pub struct Cli {
/// The command(s) to benchmark, or `-` to read them from stdin (one per line).
#[arg(required = true, num_args = 1.., value_name = "command")]
pub commands: Vec<String>,
/// Run JOBS command invocations simultaneously (no value: use all cores).
#[arg(short = 'j', long, value_name = "JOBS", num_args = 0..=1, default_missing_value = "0")]
pub jobs: Option<usize>,
/// Perform NUM warmup runs before the actual benchmark.
#[arg(short, long, value_name = "NUM", default_value_t = 0)]
pub warmup: u64,
/// Perform exactly NUM runs. If omitted, run until interrupted with Ctrl-C.
#[arg(short, long, value_name = "NUM")]
pub runs: Option<u64>,
/// Run commands through the current shell instead of direct execution.
#[arg(short = 'S', long)]
pub shell: bool,
/// Execute CMD once before the timing runs of each command.
#[arg(short = 's', long, value_name = "CMD")]
pub setup: Option<String>,
/// Execute CMD before each timing run.
#[arg(short = 'p', long, value_name = "CMD")]
pub prepare: Option<String>,
/// Execute CMD after all timing runs of each command.
#[arg(short = 'c', long, value_name = "CMD")]
pub cleanup: Option<String>,
/// Display names for the commands, in order (one per command), should be last argument.
#[arg(short = 'n', long = "command-name", value_name = "NAME", num_args = 1..)]
pub command_name: Vec<String>,
/// Display time unit: us, ms or s.
#[arg(short = 'u', long, value_name = "UNIT")]
pub time_unit: Option<String>,
/// Measure only the region the command brackets with megafine_start() and
/// megafine_stop() (see instrument/megafine.[h|rs]).
#[arg(short = 'R', long)]
pub region: bool,
/// Skip the /bin/true calibration that establishes the measurement floor.
#[arg(long)]
pub no_calibrate: bool,
/// Do not pin each concurrent job to its own CPU core(s). By default the
/// allowed CPUs are partitioned across the jobs so they cannot contend.
#[arg(long)]
pub no_pin: bool,
}