aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-02-09 16:29:40 +0000
committerAleksey Kladov <[email protected]>2021-02-09 17:25:39 +0000
commit4b1279d0b160d98c1429ca1a52b37aa7a0af5775 (patch)
tree8b71d80a070120904b76fca78d8db45b3000e9b3 /crates/ide/src/syntax_highlighting
parent9ea2c96ddd0ad8c8898f1c65667a57a78ba2218c (diff)
Infra for "unit" benchmarking
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-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]