mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-25 00:00:22 +02:00
fix benches after cursor removal
This commit is contained in:
+5
-5
@@ -109,20 +109,20 @@ macro_rules! bench {
|
|||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for i in 0..8 {
|
for i in 0..8 {
|
||||||
bufs[i].reset();
|
bufs[i].reset();
|
||||||
let mut buf: &mut Buf = &mut bufs[i]; // type erasure
|
let buf: &mut Buf = &mut bufs[i]; // type erasure
|
||||||
test::black_box(buf.$method($($arg,)*));
|
test::black_box(buf.$method($($arg,)*));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
($fname:ident, cursor, $method:ident $(,$arg:expr)*) => (
|
($fname:ident, slice, $method:ident $(,$arg:expr)*) => (
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $fname(b: &mut Bencher) {
|
fn $fname(b: &mut Bencher) {
|
||||||
// buf must be long enough for one read of 8 bytes starting at pos 7
|
// buf must be long enough for one read of 8 bytes starting at pos 7
|
||||||
let mut buf = [1u8; 8+7];
|
let arr = [1u8; 8+7];
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for i in 0..8 {
|
for i in 0..8 {
|
||||||
buf.set_position(i);
|
let mut buf = &arr[i..];
|
||||||
let buf = &mut buf as &mut Buf; // type erasure
|
let buf = &mut buf as &mut Buf; // type erasure
|
||||||
test::black_box(buf.$method($($arg,)*));
|
test::black_box(buf.$method($($arg,)*));
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ macro_rules! bench {
|
|||||||
|
|
||||||
macro_rules! bench_group {
|
macro_rules! bench_group {
|
||||||
($method:ident $(,$arg:expr)*) => (
|
($method:ident $(,$arg:expr)*) => (
|
||||||
bench!(cursor, cursor, $method $(,$arg)*);
|
bench!(slice, slice, $method $(,$arg)*);
|
||||||
bench!(tbuf_1, testbuf TestBuf &[], $method $(,$arg)*);
|
bench!(tbuf_1, testbuf TestBuf &[], $method $(,$arg)*);
|
||||||
bench!(tbuf_1_costly, testbuf TestBufC &[], $method $(,$arg)*);
|
bench!(tbuf_1_costly, testbuf TestBufC &[], $method $(,$arg)*);
|
||||||
bench!(tbuf_2, testbuf TestBuf &[1], $method $(,$arg)*);
|
bench!(tbuf_2, testbuf TestBuf &[1], $method $(,$arg)*);
|
||||||
|
|||||||
Reference in New Issue
Block a user