Skip to content

Commit

Permalink
bench: fix std comparison benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tommilligan committed May 5, 2021
1 parent b817aec commit a9ba6c2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pretty_assertions_bench/benches/benchmarks/macros.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
use crate::inputs::{BLOCK_0, BLOCK_1, CHAR_0, CHAR_1, STRING_0, STRING_1};
use criterion::{criterion_group, criterion_main, Criterion};
use pretty_assertions::{assert_eq, assert_ne};

/// assert_eq hot path
pub fn assert_eq_pass(c: &mut Criterion) {
let mut group = c.benchmark_group("assert_eq pass");

group.bench_with_input("character", &(CHAR_0, CHAR_0), |b, (left, right)| {
b.iter(|| assert_eq!(left, right))
b.iter(|| pretty_assertions::assert_eq!(left, right))
});

group.bench_with_input(
"64 char string",
&(STRING_0, STRING_0),
|b, (left, right)| b.iter(|| assert_eq!(left, right)),
|b, (left, right)| b.iter(|| pretty_assertions::assert_eq!(left, right)),
);

group.bench_with_input(
"64x64 char block",
&(BLOCK_0, BLOCK_0),
|b, (left, right)| b.iter(|| assert_eq!(left, right)),
|b, (left, right)| b.iter(|| pretty_assertions::assert_eq!(left, right)),
);

group.finish();
Expand All @@ -30,19 +29,19 @@ pub fn assert_ne_pass(c: &mut Criterion) {
let mut group = c.benchmark_group("assert_ne pass");

group.bench_with_input("character", &(CHAR_0, CHAR_1), |b, (left, right)| {
b.iter(|| assert_ne!(left, right))
b.iter(|| pretty_assertions::assert_ne!(left, right))
});

group.bench_with_input(
"64 char string",
&(STRING_0, STRING_1),
|b, (left, right)| b.iter(|| assert_ne!(left, right)),
|b, (left, right)| b.iter(|| pretty_assertions::assert_ne!(left, right)),
);

group.bench_with_input(
"64x64 char block",
&(BLOCK_0, BLOCK_1),
|b, (left, right)| b.iter(|| assert_ne!(left, right)),
|b, (left, right)| b.iter(|| pretty_assertions::assert_ne!(left, right)),
);

group.finish();
Expand Down

0 comments on commit a9ba6c2

Please sign in to comment.