Add a quick benchmark

This commit is contained in:
Carl Lerche
2015-02-09 22:20:55 -08:00
parent 7276213c43
commit 17637665e9
5 changed files with 81 additions and 27 deletions
+34
View File
@@ -0,0 +1,34 @@
#![feature(test, core)]
use bytes::ByteBuf;
use bytes::traits::*;
use iobuf::{RWIobuf};
use test::Bencher;
extern crate bytes;
extern crate iobuf;
extern crate test;
const SIZE:usize = 4_096;
#[bench]
pub fn bench_byte_buf_fill_4kb(b: &mut Bencher) {
b.iter(|| {
let mut buf = ByteBuf::mut_with_capacity(SIZE);
for _ in 0..SIZE {
buf.write_slice(&[0]);
}
});
}
#[bench]
pub fn bench_rw_iobuf_fill_4kb(b: &mut Bencher) {
b.iter(|| {
let mut buf = RWIobuf::new(SIZE);
for _ in 0..SIZE {
let _ = buf.fill(&[0]);
}
});
}