aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-09 18:53:27 +0000
committerGitHub <[email protected]>2021-02-09 18:53:27 +0000
commit4f9a5287bfea124b76571424ce3eb4a91aec337a (patch)
treecfe365b8382bfae9f8d0bfc9ebc9c35cc6e58307 /crates/ide
parent96a9ab725093b5f6501ed086973906ebb77805ff (diff)
parent61f15b72ac52c23148038b3867198597b345e2f6 (diff)
Merge #7615
7615: Add parsing benchmark r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs37
1 files changed, 32 insertions, 5 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 4a1229a31..9d0cd1af5 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -1,7 +1,8 @@
1use expect_test::{expect_file, ExpectFile}; 1use expect_test::{expect_file, ExpectFile};
2use ide_db::SymbolKind;
2use test_utils::{bench, bench_fixture, skip_slow_tests}; 3use test_utils::{bench, bench_fixture, skip_slow_tests};
3 4
4use crate::{fixture, FileRange, TextRange}; 5use crate::{fixture, FileRange, HlTag, TextRange};
5 6
6#[test] 7#[test]
7fn test_highlighting() { 8fn test_highlighting() {
@@ -226,7 +227,7 @@ fn bar() {
226} 227}
227 228
228#[test] 229#[test]
229fn benchmark_syntax_highlighting() { 230fn benchmark_syntax_highlighting_long_struct() {
230 if skip_slow_tests() { 231 if skip_slow_tests() {
231 return; 232 return;
232 } 233 }
@@ -235,10 +236,36 @@ fn benchmark_syntax_highlighting() {
235 let (analysis, file_id) = fixture::file(&fixture); 236 let (analysis, file_id) = fixture::file(&fixture);
236 237
237 let hash = { 238 let hash = {
238 let _pt = bench("syntax highlighting"); 239 let _pt = bench("syntax highlighting long struct");
239 analysis.highlight(file_id).unwrap().len() 240 analysis
241 .highlight(file_id)
242 .unwrap()
243 .iter()
244 .filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Struct))
245 .count()
240 }; 246 };
241 assert_eq!(hash, 32009); 247 assert_eq!(hash, 2001);
248}
249
250#[test]
251fn benchmark_syntax_highlighting_parser() {
252 if skip_slow_tests() {
253 return;
254 }
255
256 let fixture = bench_fixture::glorious_old_parser();
257 let (analysis, file_id) = fixture::file(&fixture);
258
259 let hash = {
260 let _pt = bench("syntax highlighting parser");
261 analysis
262 .highlight(file_id)
263 .unwrap()
264 .iter()
265 .filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Function))
266 .count()
267 };
268 assert_eq!(hash, 1629);
242} 269}
243 270
244#[test] 271#[test]