forked from mirrors/jj
cli: copy color output option to Criterion
This commit is contained in:
parent
9f1dc8f67c
commit
8a796cd98c
1 changed files with 7 additions and 3 deletions
|
@ -73,12 +73,16 @@ pub struct BenchResolvePrefixArgs {
|
||||||
prefix: String,
|
prefix: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_criterion(ui: &Ui) -> Criterion {
|
||||||
|
Criterion::default().with_output_color(ui.color())
|
||||||
|
}
|
||||||
|
|
||||||
fn run_bench<R, O>(ui: &mut Ui, id: &str, mut routine: R) -> io::Result<()>
|
fn run_bench<R, O>(ui: &mut Ui, id: &str, mut routine: R) -> io::Result<()>
|
||||||
where
|
where
|
||||||
R: (FnMut() -> O) + Copy,
|
R: (FnMut() -> O) + Copy,
|
||||||
O: Debug,
|
O: Debug,
|
||||||
{
|
{
|
||||||
let mut criterion = Criterion::default();
|
let mut criterion = new_criterion(ui);
|
||||||
let before = Instant::now();
|
let before = Instant::now();
|
||||||
let result = routine();
|
let result = routine();
|
||||||
let after = Instant::now();
|
let after = Instant::now();
|
||||||
|
@ -142,7 +146,7 @@ pub(crate) fn cmd_bench(
|
||||||
}
|
}
|
||||||
BenchCommands::Revset(command_matches) => {
|
BenchCommands::Revset(command_matches) => {
|
||||||
let workspace_command = command.workspace_helper(ui)?;
|
let workspace_command = command.workspace_helper(ui)?;
|
||||||
let mut criterion = Criterion::default();
|
let mut criterion = new_criterion(ui);
|
||||||
let mut group = criterion.benchmark_group("revsets");
|
let mut group = criterion.benchmark_group("revsets");
|
||||||
bench_revset(
|
bench_revset(
|
||||||
ui,
|
ui,
|
||||||
|
@ -159,7 +163,7 @@ pub(crate) fn cmd_bench(
|
||||||
let workspace_command = command.workspace_helper(ui)?;
|
let workspace_command = command.workspace_helper(ui)?;
|
||||||
let file_path = command.cwd().join(&command_matches.file);
|
let file_path = command.cwd().join(&command_matches.file);
|
||||||
let revsets = std::fs::read_to_string(&file_path)?;
|
let revsets = std::fs::read_to_string(&file_path)?;
|
||||||
let mut criterion = Criterion::default();
|
let mut criterion = new_criterion(ui);
|
||||||
let mut group = criterion.benchmark_group("revsets");
|
let mut group = criterion.benchmark_group("revsets");
|
||||||
for revset in revsets.lines() {
|
for revset in revsets.lines() {
|
||||||
let revset = revset.trim();
|
let revset = revset.trim();
|
||||||
|
|
Loading…
Reference in a new issue