Skip to content

Commit dbdf639

Browse files
committed
Add a benchmark for tokenization of a large stylesheet.
1 parent 664111f commit dbdf639

File tree

2 files changed

+8541
-0
lines changed

2 files changed

+8541
-0
lines changed

src/big-stylesheet.css

Lines changed: 8523 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,24 @@ fn unquoted_url(b: &mut Bencher) {
601601
})
602602
}
603603

604+
#[cfg(feature = "bench")]
605+
const BIG_STYLESHEET: &'static str = include_str!("big-stylesheet.css");
606+
607+
#[cfg(feature = "bench")]
608+
#[bench]
609+
fn big_stylesheet(b: &mut Bencher) {
610+
b.iter(|| {
611+
let mut input = Parser::new(BIG_STYLESHEET);
612+
input.look_for_var_functions();
613+
614+
let mut last_token = None;
615+
while let Ok(tok) = input.next() {
616+
last_token = Some(test::black_box(tok));
617+
}
618+
last_token
619+
})
620+
}
621+
604622
struct JsonParser;
605623

606624
#[test]

0 commit comments

Comments
 (0)