diff options
| author | Martin <mhaug@live.de> | 2021-08-18 18:12:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-18 18:12:26 +0200 |
| commit | c44ecbfbd2706bf8e09728f2c85135aa2299d542 (patch) | |
| tree | 1a7fe1b7f1627ed63817030468476ef4a5dc2b9e /bench/src/parsing.rs | |
| parent | 011865ab5c8943abcb64c7b545e265d1a65db32a (diff) | |
Move to exclusively oneshot benchmarks with Iai fork (#41)
Diffstat (limited to 'bench/src/parsing.rs')
| -rw-r--r-- | bench/src/parsing.rs | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/bench/src/parsing.rs b/bench/src/parsing.rs deleted file mode 100644 index f95dfe75..00000000 --- a/bench/src/parsing.rs +++ /dev/null @@ -1,38 +0,0 @@ -use iai::{black_box, main}; - -use typst::diag::TypResult; -use typst::parse::{parse, Scanner, TokenMode, Tokens}; -use typst::source::SourceFile; -use typst::syntax::SyntaxTree; - -const SRC: &str = include_str!("../../tests/typ/coma.typ"); - -fn bench_decode() -> usize { - // We don't use chars().count() because that has a special - // superfast implementation. - let mut count = 0; - let mut chars = black_box(SRC).chars(); - while let Some(_) = chars.next() { - count += 1; - } - count -} - -fn bench_scan() -> usize { - let mut count = 0; - let mut scanner = Scanner::new(black_box(SRC)); - while let Some(_) = scanner.eat() { - count += 1; - } - count -} - -fn bench_tokenize() -> usize { - Tokens::new(black_box(SRC), black_box(TokenMode::Markup)).count() -} - -fn bench_parse() -> TypResult<SyntaxTree> { - parse(&SourceFile::detached(black_box(SRC))) -} - -main!(bench_decode, bench_scan, bench_tokenize, bench_parse); |
