diff --git a/benches/initialization.rs b/benches/initialization.rs index 7df7f6d..8f183d6 100644 --- a/benches/initialization.rs +++ b/benches/initialization.rs @@ -6,7 +6,7 @@ const EMPTY_SOURCE: &str = ""; fn criterion_benchmark(c: &mut Criterion) { c.bench_function("initialization", |b| { - b.iter(|| Tokenizer::new(black_box(EMPTY_SOURCE), &DUOS_RUST)) + b.iter(|| black_box(Tokenizer::new(EMPTY_SOURCE, &DUOS_RUST))) }); } diff --git a/benches/tokenize.rs b/benches/tokenize.rs index acf36ce..d630114 100644 --- a/benches/tokenize.rs +++ b/benches/tokenize.rs @@ -23,28 +23,24 @@ fn criterion_benchmark(c: &mut Criterion) { } } - let mut total = 0; - c.bench_function( "Tokenize Yuumi vulkan game engine", |b: &mut criterion::Bencher<'_>| { b.iter(|| { - total = 0; - for (_, source) in files.iter() { - let mut tokenizer = Tokenizer::new(black_box(source), black_box(&DUOS_RUST)); - - let subtotal_tokens = match tokenizer.tokenize_all() { - Ok(tokens) => tokens.len(), - Err(err) => panic!("{}", err), - }; - - total += subtotal_tokens; + let mut tokenizer = Tokenizer::new(source, &DUOS_RUST); + let tokens = tokenizer.tokenize_all().unwrap(); + black_box(tokens); } }) }, ); + let mut total = 0; + for (_, source) in files.iter() { + let mut tokenizer = Tokenizer::new(source, &DUOS_RUST); + total += tokenizer.tokenize_all().unwrap().len(); + } println!("Amount of tokens created : {}", total); }