Skip to content

Commit a62e2d2

Browse files
authored
[red-knot] preparse builtins in without_parse benchmark (#12395)
1 parent d617470 commit a62e2d2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crates/ruff_benchmark/benches/red_knot.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use red_knot::workspace::WorkspaceMetadata;
55
use ruff_benchmark::criterion::{
66
criterion_group, criterion_main, BatchSize, Criterion, Throughput,
77
};
8-
use ruff_db::files::{system_path_to_file, File};
8+
use ruff_db::files::{system_path_to_file, vendored_path_to_file, File};
99
use ruff_db::parsed::parsed_module;
1010
use ruff_db::program::{ProgramSettings, SearchPathSettings, TargetVersion};
1111
use ruff_db::system::{MemoryFileSystem, SystemPath, TestSystem};
12+
use ruff_db::vendored::VendoredPath;
1213
use ruff_db::Upcast;
1314

1415
static FOO_CODE: &str = r#"
@@ -48,6 +49,7 @@ struct Case {
4849
foo: File,
4950
bar: File,
5051
typing: File,
52+
builtins: File,
5153
}
5254

5355
fn setup_case() -> Case {
@@ -56,6 +58,7 @@ fn setup_case() -> Case {
5658
let foo_path = SystemPath::new("/src/foo.py");
5759
let bar_path = SystemPath::new("/src/bar.py");
5860
let typing_path = SystemPath::new("/src/typing.pyi");
61+
let builtins_path = VendoredPath::new("stdlib/builtins.pyi");
5962
fs.write_files([
6063
(foo_path, FOO_CODE),
6164
(bar_path, BAR_CODE),
@@ -82,13 +85,15 @@ fn setup_case() -> Case {
8285

8386
let bar = system_path_to_file(&db, bar_path).unwrap();
8487
let typing = system_path_to_file(&db, typing_path).unwrap();
88+
let builtins = vendored_path_to_file(&db, builtins_path).unwrap();
8589

8690
Case {
8791
db,
8892
fs,
8993
foo,
9094
bar,
9195
typing,
96+
builtins,
9297
}
9398
}
9499

@@ -104,6 +109,7 @@ fn benchmark_without_parse(criterion: &mut Criterion) {
104109
parsed_module(case.db.upcast(), case.foo);
105110
parsed_module(case.db.upcast(), case.bar);
106111
parsed_module(case.db.upcast(), case.typing);
112+
parsed_module(case.db.upcast(), case.builtins);
107113
case
108114
},
109115
|case| {
@@ -172,7 +178,7 @@ fn benchmark_cold(criterion: &mut Criterion) {
172178
group.finish();
173179
}
174180

175-
criterion_group!(cold, benchmark_without_parse);
176-
criterion_group!(without_parse, benchmark_cold);
181+
criterion_group!(cold, benchmark_cold);
182+
criterion_group!(without_parse, benchmark_without_parse);
177183
criterion_group!(incremental, benchmark_incremental);
178184
criterion_main!(without_parse, cold, incremental);

0 commit comments

Comments
 (0)