diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:55 +0000 |
commit | 2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch) | |
tree | 033cc839730fda84ff08db877037977be94e5e3a /vendor/winnow/examples/http/bench.rs | |
parent | Initial commit. (diff) | |
download | cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip |
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/winnow/examples/http/bench.rs')
-rw-r--r-- | vendor/winnow/examples/http/bench.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/winnow/examples/http/bench.rs b/vendor/winnow/examples/http/bench.rs new file mode 100644 index 0000000..a27a119 --- /dev/null +++ b/vendor/winnow/examples/http/bench.rs @@ -0,0 +1,36 @@ +mod parser; +mod parser_streaming; + +fn one_test(c: &mut criterion::Criterion) { + let data = &b"GET / HTTP/1.1 +Host: www.reddit.com +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1 +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Language: en-us,en;q=0.5 +Accept-Encoding: gzip, deflate +Connection: keep-alive + +"[..]; + + let mut http_group = c.benchmark_group("http"); + http_group.throughput(criterion::Throughput::Bytes(data.len() as u64)); + http_group.bench_with_input( + criterion::BenchmarkId::new("complete", data.len()), + data, + |b, data| { + b.iter(|| parser::parse(data).unwrap()); + }, + ); + http_group.bench_with_input( + criterion::BenchmarkId::new("streaming", data.len()), + data, + |b, data| { + b.iter(|| parser_streaming::parse(data).unwrap()); + }, + ); + + http_group.finish(); +} + +criterion::criterion_group!(http, one_test); +criterion::criterion_main!(http); |