Skip to content

Commit

Permalink
bench: fix broken benchmark
Browse files Browse the repository at this point in the history
I'm not sure how this ever worked? Apparently, a mutable ref to `corpus`
was being taken and thus emptied out after the first use. We fix it by
re-assigning for each run.

Ref #179
  • Loading branch information
BurntSushi committed Feb 22, 2024
1 parent d4aeee2 commit cc13102
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bench/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ fn sentences(c: &mut Criterion) {
fn byte_lines(c: &mut Criterion) {
use bstr::io::BufReadExt;

let mut corpus = SUBTITLE_EN_HUGE;
let corpus = SUBTITLE_EN_HUGE;
define(c, "bstr/for_byte_line", "ascii", corpus, move |b| {
b.iter(|| {
let mut corpus = corpus;
let mut count = 0;
corpus
.for_byte_line(|line| {
Expand Down

0 comments on commit cc13102

Please sign in to comment.