fn baseline_hashmap(b: &mut Bencher, n: usize, cap: usize) {
	let words: Vec<usize> = memchr_iter(b'\n', WORDS)
		.collect(); // can't clone Memchr iterator itself, hence this
	let starts = vec![0].into_iter()
		.chain(words.clone().into_iter().map(|n| n+1)); // one past delimiter
	let ends = words.into_iter()
		.chain(vec![WORDS.len()].into_iter());
	let lines: Vec<_> = starts.zip(ends)
		.map(|(start, end)| &WORDS[start..end])
		.collect();

	b.iter(|| {
		let mut map = map(cap);
		for &line in lines.iter() {
			let p = prefix(&line, n);
			insert(&mut map, p);
		}
	})
}
/*
this benchmark is solely about measuring code
that populates HashMap with occasional copies of references to slices of WORDS,
hence collection of such slices outside the bench loop
*/
this benchmark is solely about measuring code
that populates HashMap with occasional copies of references to slices of WORDS,
hence collection of such slices outside the bench loop
this benchmark is solely about measuring code that populates HashMap with occasional copies of references to slices of WORDS hence collection of such slices outside the bench loop
fn baseline_hashmap(b: &mut Bencher, n: usize, cap: usize) {
	let words: Vec<usize> = memchr_iter(b'\n', WORDS)
		.collect(); // can't clone Memchr iterator itself, hence this
	let starts = vec![0].into_iter()
		.chain(words.clone().into_iter().map(|n| n+1)); // one past delimiter
	let ends = words.into_iter()
		.chain(vec![WORDS.len()].into_iter());
	let lines: Vec<_> = starts.zip(ends)
		.map(|(start, end)| &WORDS[start..end])
		.collect();
	b.iter(|| {
		let mut map = map(cap);
		for &line in lines.iter() {
			let p = prefix(&line, n);
			insert(&mut map, p);
		}
	})
}
fn baseline_hashmap ( b : & mut Bencher , n : usize , cap : usize ) { let words : Vec < usize > = memchr_iter ( b'\n' , WORDS ) . collect ( ) ; // can't clone Memchr iterator itself, hence this let starts = vec ! [ 0 ] . into_iter ( ) . chain ( words . clone ( ) . into_iter ( ) . map ( | n | n + 1 ) ) ; // one past delimiter let ends = words . into_iter ( ) . chain ( vec ! [ WORDS len ( ) ] . into_iter ( ) ) ; let lines : Vec < _ > = starts . zip ( ends ) . map ( | ( start , end ) | & WORDS [ start .. end ] ) . collect ( ) ; b . iter ( | | { let mut map = map ( cap ) ; for & line in lines . iter ( ) { let p = prefix ( & line , n ) ; insert ( & mut map , p ) ; } } ) }
this benchmark is solely about measuring code
that populates HashMap with occasional copies of references to slices of WORDS,
hence collection of such slices outside the bench loop
this benchmark is solely about measuring code that populates HashMap with occasional copies of references to slices of WORDS hence collection of such slices outside the bench loop
b
&mut Bencher
n
usize
cap
usize
b
&mut Bencher
n
usize
cap
usize