Skip to content

Commit

Permalink
libhtml: Add a few more benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyball committed May 19, 2014
1 parent 6e19183 commit 24b73d7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libhtml/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,22 @@ mod tests {
let s = "<script src="evil.domain?foo&" type='baz'>";
b.iter(|| unescape(s));
}

#[bench]
fn bench_longest_entity(b: &mut test::Bencher) {
let s = "&CounterClockwiseContourIntegral;";
b.iter(|| assert_eq!(unescape(s).as_slice(), "\u2233"));
}

#[bench]
fn bench_longest_non_entity(b: &mut test::Bencher) {
let s = "&CounterClockwiseContourIntegraX;";
b.iter(|| assert_eq!(unescape(s).as_slice(), "&CounterClockwiseContourIntegraX;"));
}

#[bench]
fn bench_short_entity_long_tail(b: &mut test::Bencher) {
let s = "&ampnterClockwiseContourIntegral";
b.iter(|| assert_eq!(unescape(s).as_slice(), "&nterClockwiseContourIntegral"));
}
}

0 comments on commit 24b73d7

Please sign in to comment.