memcmp

Crates.iomemcmp
lib.rsmemcmp
version0.0.6
sourcesrc
created_at2015-01-09 01:12:40.875497
updated_at2015-12-12 23:54:49.337423
descriptionOptimized memory comparisons for integer slices. Temporary solution until rust issue 16913 is resolved.
homepagehttps://github.com/daramos/rust-memcmp
repositoryhttps://github.com/daramos/rust-memcmp
max_upload_size
id743
size6,355
Daniel Ramos (daramos)

documentation

https://github.com/daramos/rust-memcmp

README

rust-memcmp

Build status 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)
    });
}
Commit count: 16

cargo fmt