aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-09 17:35:53 +0000
committerGitHub <[email protected]>2021-02-09 17:35:53 +0000
commit98b82859551555a1b0671c75307d56a17aa545b6 (patch)
treee5cfdfb84ff708901aca1a528403b70a54efdd1c /crates/ide
parent12c7b66a7c6963d42ab5f33a9ac3f0b30e351b69 (diff)
parent4b1279d0b160d98c1429ca1a52b37aa7a0af5775 (diff)
Merge #7613
7613: Benchmarking infrastructure r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 1854da914..4a1229a31 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -1,7 +1,5 @@
1use std::fs;
2
3use expect_test::{expect_file, ExpectFile}; 1use expect_test::{expect_file, ExpectFile};
4use test_utils::project_dir; 2use test_utils::{bench, bench_fixture, skip_slow_tests};
5 3
6use crate::{fixture, FileRange, TextRange}; 4use crate::{fixture, FileRange, TextRange};
7 5
@@ -228,15 +226,19 @@ fn bar() {
228} 226}
229 227
230#[test] 228#[test]
231fn accidentally_quadratic() { 229fn benchmark_syntax_highlighting() {
232 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); 230 if skip_slow_tests() {
233 let src = fs::read_to_string(file).unwrap(); 231 return;
232 }
234 233
235 let (analysis, file_id) = fixture::file(&src); 234 let fixture = bench_fixture::big_struct();
235 let (analysis, file_id) = fixture::file(&fixture);
236 236
237 // let t = std::time::Instant::now(); 237 let hash = {
238 let _ = analysis.highlight(file_id).unwrap(); 238 let _pt = bench("syntax highlighting");
239 // eprintln!("elapsed: {:?}", t.elapsed()); 239 analysis.highlight(file_id).unwrap().len()
240 };
241 assert_eq!(hash, 32009);
240} 242}
241 243
242#[test] 244#[test]