diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-09 17:35:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-09 17:35:53 +0000 |
commit | 98b82859551555a1b0671c75307d56a17aa545b6 (patch) | |
tree | e5cfdfb84ff708901aca1a528403b70a54efdd1c /crates/ide | |
parent | 12c7b66a7c6963d42ab5f33a9ac3f0b30e351b69 (diff) | |
parent | 4b1279d0b160d98c1429ca1a52b37aa7a0af5775 (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.rs | 22 |
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 @@ | |||
1 | use std::fs; | ||
2 | |||
3 | use expect_test::{expect_file, ExpectFile}; | 1 | use expect_test::{expect_file, ExpectFile}; |
4 | use test_utils::project_dir; | 2 | use test_utils::{bench, bench_fixture, skip_slow_tests}; |
5 | 3 | ||
6 | use crate::{fixture, FileRange, TextRange}; | 4 | use crate::{fixture, FileRange, TextRange}; |
7 | 5 | ||
@@ -228,15 +226,19 @@ fn bar() { | |||
228 | } | 226 | } |
229 | 227 | ||
230 | #[test] | 228 | #[test] |
231 | fn accidentally_quadratic() { | 229 | fn 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] |