Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 13 additions & 8 deletions benches/arraystring.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

extern crate arrayvec;
#[macro_use] extern crate bencher;
#[macro_use]
extern crate bencher;

use arrayvec::ArrayString;

Expand All @@ -10,8 +10,7 @@ fn try_push_c(b: &mut Bencher) {
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('c').is_ok() {
}
while v.try_push('c').is_ok() {}
v.len()
});
b.bytes = v.capacity() as u64;
Expand All @@ -21,8 +20,7 @@ fn try_push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('α').is_ok() {
}
while v.try_push('α').is_ok() {}
v.len()
});
b.bytes = v.capacity() as u64;
Expand Down Expand Up @@ -85,6 +83,13 @@ fn push_string(b: &mut Bencher) {
b.bytes = v.capacity() as u64;
}

benchmark_group!(benches, try_push_c, try_push_alpha, try_push_string, push_c,
push_alpha, push_string);
benchmark_group!(
benches,
try_push_c,
try_push_alpha,
try_push_string,
push_c,
push_alpha,
push_string
);
benchmark_main!(benches);
19 changes: 10 additions & 9 deletions benches/extend.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

extern crate arrayvec;
#[macro_use] extern crate bencher;
#[macro_use]
extern crate bencher;

use std::io::Write;

use arrayvec::ArrayVec;

use bencher::Bencher;
use bencher::black_box;
use bencher::Bencher;

fn extend_with_constant(b: &mut Bencher) {
let mut v = ArrayVec::<u8, 512>::new();
Expand Down Expand Up @@ -67,12 +67,13 @@ fn extend_from_slice(b: &mut Bencher) {
b.bytes = v.capacity() as u64;
}

benchmark_group!(benches,
extend_with_constant,
extend_with_range,
extend_with_slice,
extend_with_write,
extend_from_slice
benchmark_group!(
benches,
extend_with_constant,
extend_with_range,
extend_with_slice,
extend_with_write,
extend_from_slice
);

benchmark_main!(benches);