Closed
Description
I compared the performance of three equivalent functions:
pub fn chars_zip(x:&str, y:&str) -> usize {
x.chars()
.zip(y.chars())
.filter(|&(xc, yc)| xc != yc)
.count()
}
pub fn bytes_zip(x:&str, y:&str) -> usize {
x.bytes()
.zip(y.bytes())
.filter(|&(xc, yc)| xc != yc)
.count()
}
pub fn slice_zip(x:&str, y:&str) -> usize {
let x = x.as_bytes();
let y = y.as_bytes();
x.iter()
.zip(y)
.filter(|&(xc, yc)| xc != yc)
.count()
}
This is results (release mode):
chars_zip 0.1450s
bytes_zip 0.2599s
slice_zip 0.0643s