Skip to content

Commit

Permalink
Merge pull request #639 from CosmWasm/CI-update-rust-stable
Browse files Browse the repository at this point in the history
Update rust version in CI to current stable (1.58.1)
  • Loading branch information
maurolacy authored Jan 30, 2022
2 parents 544bf59 + 5ec0762 commit 50dcbc7
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions packages/storage-plus/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ fn bench_signed_int_key(c: &mut Criterion) {

assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0));
assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check));
assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check));
assert_eq!(
to_cw_bytes(&k_check.wrapping_neg()),
i32::to_cw_bytes(&k_check.wrapping_neg())
);

b.iter(|| {
let k = k();
black_box(to_cw_bytes(&k));
black_box(to_cw_bytes(&-k));
black_box(to_cw_bytes(&k.wrapping_neg()));
});
});

Expand All @@ -44,12 +47,15 @@ fn bench_signed_int_key(c: &mut Criterion) {

assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0));
assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check));
assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check));
assert_eq!(
to_cw_bytes(&k_check.wrapping_neg()),
i32::to_cw_bytes(&k_check.wrapping_neg())
);

b.iter(|| {
let k = k();
black_box(to_cw_bytes(&k));
black_box(to_cw_bytes(&-k));
black_box(to_cw_bytes(&k.wrapping_neg()));
});
});

Expand All @@ -63,33 +69,39 @@ fn bench_signed_int_key(c: &mut Criterion) {

assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0));
assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check));
assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check));
assert_eq!(
to_cw_bytes(&k_check.wrapping_neg()),
i32::to_cw_bytes(&k_check.wrapping_neg())
);

b.iter(|| {
let k = k();
black_box(to_cw_bytes(&k));
black_box(to_cw_bytes(&-k));
black_box(to_cw_bytes(&k.wrapping_neg()));
});
});

group.bench_function("i32 to_cw_bytes: branching plus / minus", |b| {
#[inline]
fn to_cw_bytes(value: &i32) -> Buf {
if value >= &0i32 {
(*value as u32 - i32::MIN as u32).to_be_bytes()
((*value as u32).wrapping_sub(i32::MIN as u32)).to_be_bytes()
} else {
(*value as u32 + i32::MIN as u32).to_be_bytes()
((*value as u32).wrapping_add(i32::MIN as u32)).to_be_bytes()
}
}

assert_eq!(to_cw_bytes(&0), i32::to_cw_bytes(&0));
assert_eq!(to_cw_bytes(&k_check), i32::to_cw_bytes(&k_check));
assert_eq!(to_cw_bytes(&-k_check), i32::to_cw_bytes(&-k_check));
assert_eq!(
to_cw_bytes(&k_check.wrapping_neg()),
i32::to_cw_bytes(&k_check.wrapping_neg())
);

b.iter(|| {
let k = k();
black_box(to_cw_bytes(&k));
black_box(to_cw_bytes(&-k));
black_box(to_cw_bytes(&k.wrapping_neg()));
});
});

Expand Down

0 comments on commit 50dcbc7

Please sign in to comment.