Skip to content

Instantly share code, notes, and snippets.

sum:
test bench_cloned ... bench: 60 ns/iter (+/- 0)
test bench_map ... bench: 60 ns/iter (+/- 1)
test bench_pat ... bench: 61 ns/iter (+/- 3)
find string:
test bench_cloned ... bench: 1,129 ns/iter (+/- 72)
test bench_map ... bench: 1,133 ns/iter (+/- 142)
@bluss
bluss / 01-bench
Created September 10, 2016 22:45
Using rustc 1.13.0-nightly (923bac459 2016-09-06) x86-64/linux
#
test clone_str ... bench: 370,601 ns/iter (+/- 14,692) = 2829 MB/s
test clone_vec_from_fn ... bench: 372,835 ns/iter (+/- 38,525) = 2812 MB/s
test clone_vec_from_incremental ... bench: 369,055 ns/iter (+/- 8,690) = 2841 MB/s
test fast_clone_vec ... bench: 374,947 ns/iter (+/- 11,168) = 2796 MB/s
/* This code is MIT/Apache-2.0 licensed or whatever you'd like if you ask me.
test shpfx ... bench: 8,433,171 ns/iter (+/- 145,316) = 5843 MB/s
test shpfx_short ... bench: 4,885 ns/iter (+/- 117) = 9852 MB/s
*/
#![feature(test)]
@bluss
bluss / 0-zipfail.rs
Last active April 21, 2016 21:13
rustc -C opt-level=3 -C "llvm-args=-x86-asm-syntax=intel" --emit=asm zipfail.rs
#![crate_type="lib"]
// bad
#[no_mangle]
pub fn copy_zip_vec(xs: &Vec<u8>, ys: &mut Vec<u8>) {
for (a, b) in ys.iter_mut().zip(xs.iter()) {
*a = *b;
}
}
{0xdc, 0xc4, 0x0f, 0x05, 0x58, 0x01, 0xac, 0xab},
{0x93, 0xca, 0x57, 0x7d, 0xf3, 0x9b, 0xf4, 0xc9},
{0x4d, 0xd4, 0xc7, 0x4d, 0x02, 0x9b, 0xcb, 0x82},
{0xfb, 0xf7, 0xdd, 0xe7, 0xb8, 0x0a, 0xf8, 0x8b},
{0x28, 0x83, 0xd3, 0x88, 0x60, 0x57, 0x75, 0xcf},
{0x67, 0x3b, 0x53, 0x49, 0x2f, 0xd5, 0xf9, 0xde},
{0xa7, 0x22, 0x9f, 0xc5, 0x50, 0x2b, 0x0d, 0xc5},
{0x40, 0x11, 0xb1, 0x9b, 0x98, 0x7d, 0x92, 0xd3},
{0x8e, 0x9a, 0x29, 0x8d, 0x11, 0x95, 0x90, 0x36},
{0xe4, 0x3d, 0x06, 0x6c, 0xb3, 0x8e, 0xa4, 0x25},