mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
## Summary Add a benchmark for the problematic case in https://github.com/astral-sh/ty/issues/711, which will potentially be solved in https://github.com/astral-sh/ruff/pull/18955
This commit is contained in:
parent
e5e3d998c5
commit
3c18d85c7d
1 changed files with 49 additions and 3 deletions
|
@ -348,10 +348,10 @@ fn benchmark_many_tuple_assignments(criterion: &mut Criterion) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn benchmark_many_attribute_assignments(criterion: &mut Criterion) {
|
fn benchmark_complex_constrained_attributes_1(criterion: &mut Criterion) {
|
||||||
setup_rayon();
|
setup_rayon();
|
||||||
|
|
||||||
criterion.bench_function("ty_micro[many_attribute_assignments]", |b| {
|
criterion.bench_function("ty_micro[complex_constrained_attributes_1]", |b| {
|
||||||
b.iter_batched_ref(
|
b.iter_batched_ref(
|
||||||
|| {
|
|| {
|
||||||
// This is a regression benchmark for https://github.com/astral-sh/ty/issues/627.
|
// This is a regression benchmark for https://github.com/astral-sh/ty/issues/627.
|
||||||
|
@ -400,6 +400,51 @@ fn benchmark_many_attribute_assignments(criterion: &mut Criterion) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn benchmark_complex_constrained_attributes_2(criterion: &mut Criterion) {
|
||||||
|
setup_rayon();
|
||||||
|
|
||||||
|
criterion.bench_function("ty_micro[complex_constrained_attributes_2]", |b| {
|
||||||
|
b.iter_batched_ref(
|
||||||
|
|| {
|
||||||
|
// This is is similar to the case above, but now the attributes are actually defined.
|
||||||
|
// https://github.com/astral-sh/ty/issues/711
|
||||||
|
setup_micro_case(
|
||||||
|
r#"
|
||||||
|
class C:
|
||||||
|
def f(self: "C"):
|
||||||
|
self.a = ""
|
||||||
|
self.b = ""
|
||||||
|
|
||||||
|
if isinstance(self.a, str):
|
||||||
|
return
|
||||||
|
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
if isinstance(self.b, str):
|
||||||
|
return
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|case| {
|
||||||
|
let Case { db, .. } = case;
|
||||||
|
let result = db.check();
|
||||||
|
assert_eq!(result.len(), 0);
|
||||||
|
},
|
||||||
|
BatchSize::SmallInput,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
struct ProjectBenchmark<'a> {
|
struct ProjectBenchmark<'a> {
|
||||||
project: InstalledProject<'a>,
|
project: InstalledProject<'a>,
|
||||||
fs: MemoryFileSystem,
|
fs: MemoryFileSystem,
|
||||||
|
@ -534,7 +579,8 @@ criterion_group!(
|
||||||
micro,
|
micro,
|
||||||
benchmark_many_string_assignments,
|
benchmark_many_string_assignments,
|
||||||
benchmark_many_tuple_assignments,
|
benchmark_many_tuple_assignments,
|
||||||
benchmark_many_attribute_assignments,
|
benchmark_complex_constrained_attributes_1,
|
||||||
|
benchmark_complex_constrained_attributes_2,
|
||||||
);
|
);
|
||||||
criterion_group!(project, anyio, attrs, hydra);
|
criterion_group!(project, anyio, attrs, hydra);
|
||||||
criterion_main!(check_file, micro, project);
|
criterion_main!(check_file, micro, project);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue