mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
Use named function in incremental red knot benchmark (#14033)
This commit is contained in:
parent
cf0f5e1318
commit
48fa839c80
1 changed files with 33 additions and 31 deletions
|
@ -120,40 +120,42 @@ fn setup_rayon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn benchmark_incremental(criterion: &mut Criterion) {
|
fn benchmark_incremental(criterion: &mut Criterion) {
|
||||||
|
fn setup() -> Case {
|
||||||
|
let case = setup_case();
|
||||||
|
let result = case.db.check().unwrap();
|
||||||
|
|
||||||
|
assert_eq!(result, EXPECTED_DIAGNOSTICS);
|
||||||
|
|
||||||
|
case.fs
|
||||||
|
.write_file(
|
||||||
|
&case.re_path,
|
||||||
|
format!("{}\n# A comment\n", source_text(&case.db, case.re).as_str()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
case
|
||||||
|
}
|
||||||
|
|
||||||
|
fn incremental(case: &mut Case) {
|
||||||
|
let Case { db, .. } = case;
|
||||||
|
|
||||||
|
db.apply_changes(
|
||||||
|
vec![ChangeEvent::Changed {
|
||||||
|
path: case.re_path.clone(),
|
||||||
|
kind: ChangedKind::FileContent,
|
||||||
|
}],
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
|
let result = db.check().unwrap();
|
||||||
|
|
||||||
|
assert_eq!(result, EXPECTED_DIAGNOSTICS);
|
||||||
|
}
|
||||||
|
|
||||||
setup_rayon();
|
setup_rayon();
|
||||||
|
|
||||||
criterion.bench_function("red_knot_check_file[incremental]", |b| {
|
criterion.bench_function("red_knot_check_file[incremental]", |b| {
|
||||||
b.iter_batched_ref(
|
b.iter_batched_ref(setup, incremental, BatchSize::SmallInput);
|
||||||
|| {
|
|
||||||
let case = setup_case();
|
|
||||||
case.db.check().unwrap();
|
|
||||||
|
|
||||||
case.fs
|
|
||||||
.write_file(
|
|
||||||
&case.re_path,
|
|
||||||
format!("{}\n# A comment\n", source_text(&case.db, case.re).as_str()),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
case
|
|
||||||
},
|
|
||||||
|case| {
|
|
||||||
let Case { db, .. } = case;
|
|
||||||
|
|
||||||
db.apply_changes(
|
|
||||||
vec![ChangeEvent::Changed {
|
|
||||||
path: case.re_path.clone(),
|
|
||||||
kind: ChangedKind::FileContent,
|
|
||||||
}],
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
let result = db.check().unwrap();
|
|
||||||
|
|
||||||
assert_eq!(result, EXPECTED_DIAGNOSTICS);
|
|
||||||
},
|
|
||||||
BatchSize::SmallInput,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue