| 1 |
mod parser; |
| 2 |
mod parser_streaming; |
| 3 |
|
| 4 |
fn one_test(c: &mut criterion::Criterion) { |
| 5 |
let data = &b"GET / HTTP/1.1 |
| 6 |
Host: www.reddit.com |
| 7 |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 |
| 8 |
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
| 9 |
Accept-Language: en-us,en;q=0.5 |
| 10 |
Accept-Encoding: gzip, deflate |
| 11 |
Connection: keep-alive |
| 12 |
|
| 13 |
"[..]; |
| 14 |
|
| 15 |
let mut http_group = c.benchmark_group("http"); |
| 16 |
http_group.throughput(criterion::Throughput::Bytes(data.len() as u64)); |
| 17 |
http_group.bench_with_input( |
| 18 |
criterion::BenchmarkId::new("complete", data.len()), |
| 19 |
data, |
| 20 |
|b, data| { |
| 21 |
b.iter(|| parser::parse(data).unwrap()); |
| 22 |
}, |
| 23 |
); |
| 24 |
http_group.bench_with_input( |
| 25 |
criterion::BenchmarkId::new("streaming", data.len()), |
| 26 |
data, |
| 27 |
|b, data| { |
| 28 |
b.iter(|| parser_streaming::parse(data).unwrap()); |
| 29 |
}, |
| 30 |
); |
| 31 |
|
| 32 |
http_group.finish(); |
| 33 |
} |
| 34 |
|
| 35 |
criterion::criterion_group!(http, one_test); |
| 36 |
criterion::criterion_main!(http); |