Skip to content

Commit

Permalink
refactor(bench): rename string to buf
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 6, 2025
1 parent 617b574 commit b211677
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ fn map_benchmark(c: &mut Criterion) {
}

fn level_benchmark(c: &mut Criterion) {
let mut string = String::new();
let mut buf = String::new();
for entry in fs::read_dir("assets/").unwrap() {
let path = entry.unwrap().path();
string += &(fs::read_to_string(path).unwrap() + "\n\n");
buf += &(fs::read_to_string(path).unwrap() + "\n\n");
}

c.bench_function("load levels", |b| {
b.iter(|| black_box(Level::load_from_str(black_box(&string)).collect::<Vec<_>>()))
c.bench_function("load levels from str", |b| {
b.iter(|| black_box(Level::load_from_str(black_box(&buf)).count()))
});
c.bench_function("load the nth level", |b| {
b.iter(|| black_box(Level::load_nth_from_str(black_box(&string), black_box(3371)).unwrap()))
c.bench_function("load the nth level from str", |b| {
b.iter(|| black_box(Level::load_nth_from_str(black_box(&buf), black_box(3371)).unwrap()))
});
}

Expand Down

0 comments on commit b211677

Please sign in to comment.