Skip to content

Commit

Permalink
Fix mutating benchmark benching more than just mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jan 4, 2025
1 parent 016094c commit 99568ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions benches/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ fn mutating_inputs(c: &mut Criterion) {

let string = base_string.clone().repeat(*n);
let new_len = string.len();
(db, base_string, base_len, string, new_len)
},
|&mut (ref mut db, ref base_string, base_len, ref string, new_len)| {
let input = Input::new(db, base_string.clone());
let actual_len = length(db, input);

let input = Input::new(&db, base_string.clone());
let actual_len = length(&db, input);
assert_eq!(base_len, actual_len);

(db, input, string, new_len)
},
|&mut (ref mut db, input, ref string, new_len)| {
input.set_text(db).to(string.clone());
let actual_len = length(db, input);
assert_eq!(new_len, actual_len);
Expand Down

0 comments on commit 99568ba

Please sign in to comment.