Skip to content

Commit

Permalink
Merge pull request #100 from nvzqz/patch-1
Browse files Browse the repository at this point in the history
chore: Remove `divan::black_box` from benchmarks
  • Loading branch information
Aloso authored Nov 3, 2023
2 parents c8cef90 + 1532d3e commit 2f181a8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions benchmark/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro_rules! items {

#[divan::bench_group]
mod parse {
use divan::{black_box, counter::BytesCount, Bencher};
use divan::{counter::BytesCount, Bencher};
use pomsky::Expr;

macro_rules! group_item {
Expand All @@ -31,7 +31,7 @@ mod parse {
.with_inputs(|| super::$item)
.input_counter(|s| BytesCount::new(s.len()))
.bench_refs(|sample| {
let (expr, _warnings) = Expr::parse(black_box(sample));
let (expr, _warnings) = Expr::parse(sample);
expr.unwrap()
});
}
Expand All @@ -52,7 +52,7 @@ mod parse {

#[divan::bench_group]
mod compile {
use divan::{black_box, Bencher};
use divan::Bencher;
use pomsky::{
options::{CompileOptions, RegexFlavor},
Expr,
Expand All @@ -69,11 +69,11 @@ mod compile {
bencher
.with_inputs(|| {
let sample = super::$item;
let (expr, _warnings) = Expr::parse(black_box(sample));
let (expr, _warnings) = Expr::parse(sample);
(expr.unwrap(), sample)
})
.bench_refs(|(expr, sample)| {
let compiled = black_box(&expr).compile(black_box(sample), ruby());
let compiled = expr.compile(sample, ruby());
super::unwrap_compiled(compiled)
});
}
Expand All @@ -100,12 +100,12 @@ pub fn range<const N: usize>(bencher: divan::Bencher) {

bencher
.with_inputs(|| {
let (expr, _warnings) = Expr::parse(divan::black_box(&input));
let (expr, _warnings) = Expr::parse(&input);
expr.unwrap()
})
.bench_refs(|expr| {
let options = CompileOptions { max_range_size: 100, ..Default::default() };
let compiled = divan::black_box(&expr).compile(&input, options);
let compiled = expr.compile(&input, options);
unwrap_compiled(compiled)
})
}
Expand All @@ -119,7 +119,7 @@ fn unwrap_compiled(compiled: (Option<String>, Vec<Diagnostic>)) -> String {

#[divan::bench_group]
mod competition {
use divan::{black_box, counter::BytesCount};
use divan::counter::BytesCount;
use pomsky::Expr;

#[divan::bench(name = "pomsky (version number)")]
Expand All @@ -128,7 +128,7 @@ mod competition {
.with_inputs(|| super::VERSION_POMSKY)
.input_counter(|s| BytesCount::new(s.len()))
.bench_refs(|sample| {
let (expr, _, _) = Expr::parse_and_compile(black_box(sample), Default::default());
let (expr, _, _) = Expr::parse_and_compile(sample, Default::default());
expr.unwrap()
});
}
Expand All @@ -138,7 +138,7 @@ mod competition {
bencher
.with_inputs(|| super::VERSION_MELODY)
.input_counter(|s| BytesCount::new(s.len()))
.bench_refs(|sample| melody_compiler::compiler(black_box(sample)).unwrap());
.bench_refs(|sample| melody_compiler::compiler(sample).unwrap());
}
}

Expand Down

0 comments on commit 2f181a8

Please sign in to comment.