#compare #slice #integer #optimized #issue #temporary #solution

memcmp

Optimized memory comparisons for integer slices. Temporary solution until rust issue 16913 is resolved.

5 releases

Uses old Rust 2015

0.0.6 Apr 22, 2015
0.0.5 Feb 13, 2015
0.0.4 Jan 10, 2015
0.0.2 Jan 9, 2015
0.0.1 Jan 9, 2015

#53 in #temporary

35 downloads per month
Used in 3 crates

MIT license

7KB
134 lines

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)
    });
}

No runtime deps

Features