mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Use named function in incremental red knot benchmark (#14033)
Some checks are pending
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
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