Skip to content

Commit 44f2f77

Browse files
authored
[ty] Add a DateType benchmark (#19148)
## Summary The [`DateType`](https://github.com/glyph/DateType) library has some very large protocols in it. Currently we type-check it quite quickly, but the current version of #18659 makes our execution time on this library pathologically slow. That PR doesn't seem to have a big impact on any of our current benchmarks, however, so it seems we have some missing coverage in this area; I therefore propose that we add `DateType` as a benchmark. Currently the benchmark runs pretty quickly (about half the runtime of attrs, which is our fastest real-world benchmark currently), and the library has 0 third-party dependencies, so the benchmark is quick to setup. ## Test Plan `cargo bench -p ruff_benchmark --bench=ty`
1 parent 1c710c2 commit 44f2f77

File tree

1 file changed

+20
-6
lines changed
  • crates/ruff_benchmark/benches

1 file changed

+20
-6
lines changed

crates/ruff_benchmark/benches/ty.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,8 @@ fn bench_project(benchmark: &ProjectBenchmark, criterion: &mut Criterion) {
498498
let diagnostics = result.len();
499499

500500
assert!(
501-
diagnostics > 1 && diagnostics <= max_diagnostics,
502-
"Expected between {} and {} diagnostics but got {}",
503-
1,
504-
max_diagnostics,
505-
diagnostics
501+
diagnostics <= max_diagnostics,
502+
"Expected <={max_diagnostics} diagnostics but got {diagnostics}"
506503
);
507504
}
508505

@@ -570,6 +567,23 @@ fn anyio(criterion: &mut Criterion) {
570567
bench_project(&benchmark, criterion);
571568
}
572569

570+
fn datetype(criterion: &mut Criterion) {
571+
let benchmark = ProjectBenchmark::new(
572+
RealWorldProject {
573+
name: "DateType",
574+
repository: "https://github.com/glyph/DateType",
575+
commit: "57c9c93cf2468069f72945fc04bf27b64100dad8",
576+
paths: vec![SystemPath::new("src")],
577+
dependencies: vec![],
578+
max_dep_date: "2025-07-04",
579+
python_version: PythonVersion::PY313,
580+
},
581+
0,
582+
);
583+
584+
bench_project(&benchmark, criterion);
585+
}
586+
573587
criterion_group!(check_file, benchmark_cold, benchmark_incremental);
574588
criterion_group!(
575589
micro,
@@ -578,5 +592,5 @@ criterion_group!(
578592
benchmark_complex_constrained_attributes_1,
579593
benchmark_complex_constrained_attributes_2,
580594
);
581-
criterion_group!(project, anyio, attrs, hydra);
595+
criterion_group!(project, anyio, attrs, hydra, datetype);
582596
criterion_main!(check_file, micro, project);

0 commit comments

Comments
 (0)