Skip to content

bench: return the target and the bytes to avoid compiler optimize away the code for integer-encoding #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions benches/varint_bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|| rng.gen::<u8>(),
|num| {
let mut target = [0u8; 16];
u8::encode_var(num, &mut target)
let bytes = u8::encode_var(num, &mut target);

(target, bytes)
},
BatchSize::SmallInput,
)
Expand Down Expand Up @@ -437,7 +439,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|| rng.gen::<u16>(),
|num| {
let mut target = [0u8; 16];
u16::encode_var(num, &mut target)
let bytes = u16::encode_var(num, &mut target);

(target, bytes)
},
BatchSize::SmallInput,
)
Expand Down Expand Up @@ -530,7 +534,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|| rng.gen::<u32>(),
|num| {
let mut target = [0u8; 16];
u32::encode_var(num, &mut target)
let bytes = u32::encode_var(num, &mut target);

(target, bytes)
},
BatchSize::SmallInput,
)
Expand Down Expand Up @@ -624,7 +630,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|| rng.gen::<u64>(),
|num| {
let mut target = [0u8; 16];
u64::encode_var(num, &mut target)
let bytes = u64::encode_var(num, &mut target);

(target, bytes)
},
BatchSize::SmallInput,
)
Expand Down