std::str: Add bench tests for StrVector::connect() and for str::push_str
This commit is contained in:
parent
8fce135326
commit
e34e2032e8
1 changed files with 19 additions and 0 deletions
|
|
@ -3897,4 +3897,23 @@ mod bench {
|
|||
with_capacity(100);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_push_str(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
do bh.iter {
|
||||
let mut r = ~"";
|
||||
r.push_str(s);
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_connect(bh: &mut BenchHarness) {
|
||||
let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
|
||||
let sep = "→";
|
||||
let v = [s, s, s, s, s, s, s, s, s, s];
|
||||
do bh.iter {
|
||||
assert_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue