-
Notifications
You must be signed in to change notification settings - Fork 13
/
bench.rs
37 lines (29 loc) · 859 Bytes
/
bench.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![feature(test)]
extern crate htmlescape;
extern crate test;
extern crate num;
extern crate rand;
use htmlescape::*;
static BIG_STR: &'static str = include_str!("../moonstone-short.txt");
#[bench]
fn bench_encode_attribute(bh: &mut test::Bencher) {
bh.iter(|| { encode_attribute(BIG_STR) });
bh.bytes = BIG_STR.len() as u64;
}
#[bench]
fn bench_encode_minimal(bh: &mut test::Bencher) {
bh.iter(|| { encode_minimal(BIG_STR) });
bh.bytes = BIG_STR.len() as u64;
}
#[bench]
fn bench_decode_attribute(bh: &mut test::Bencher) {
let encoded = encode_attribute(BIG_STR);
bh.iter(|| { decode_html(&encoded) });
bh.bytes = encoded.len() as u64;
}
#[bench]
fn bench_decode_minimal(bh: &mut test::Bencher) {
let encoded = encode_minimal(BIG_STR);
bh.iter(|| { decode_html(&encoded) });
bh.bytes = encoded.len() as u64;
}