Crates.io | memcmp |
lib.rs | memcmp |
version | 0.0.6 |
source | src |
created_at | 2015-01-09 01:12:40.875497 |
updated_at | 2015-12-12 23:54:49.337423 |
description | Optimized memory comparisons for integer slices. Temporary solution until rust issue 16913 is resolved. |
homepage | https://github.com/daramos/rust-memcmp |
repository | https://github.com/daramos/rust-memcmp |
max_upload_size | |
id | 743 |
size | 6,355 |
Optimized comparisons for integer slices. Use memcmp to compare integer slices efficiently.
Workaround for Rust issue 16913.
###Baseline PartialEq comparison: ####test test::u8_slice_cmp ... bench: 2201 ns/iter (+/- 113) = 454 MB/s
#[bench]
fn slice_cmp(b: &mut test::Bencher) {
let vec1 = vec![b'c';10_000];
let vec2 = vec1.clone();
b.bytes = vec1.len() as u64;
b.iter(|| {
let (s1, s2) = ( &vec1, &vec2 );
return s1==s2
});
}
###Using this crate: ###test test::u8_memcmp ... bench: 33 ns/iter (+/- 2) = 30303 MB/s
extern crate memcmp;
use memcmp::Memcmp;
#[bench]
fn memcmp_cmp(b: &mut test::Bencher) {
let vec1 = vec![b'c';10_000];
let vec2 = vec1.clone();
b.bytes = vec1.len() as u64;
b.iter(|| {
let (s1, s2) = ( &vec1, &vec2 );
return s1.memcmp(s2)
});
}