From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/httpdate/benches/benchmarks.rs | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 vendor/httpdate/benches/benchmarks.rs (limited to 'vendor/httpdate/benches') diff --git a/vendor/httpdate/benches/benchmarks.rs b/vendor/httpdate/benches/benchmarks.rs new file mode 100644 index 000000000..4f82467bd --- /dev/null +++ b/vendor/httpdate/benches/benchmarks.rs @@ -0,0 +1,57 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +pub fn parse_imf_fixdate(c: &mut Criterion) { + c.bench_function("parse_imf_fixdate", |b| { + b.iter(|| { + let d = black_box("Sun, 06 Nov 1994 08:49:37 GMT"); + black_box(httpdate::parse_http_date(d)).unwrap(); + }) + }); +} + +pub fn parse_rfc850_date(c: &mut Criterion) { + c.bench_function("parse_rfc850_date", |b| { + b.iter(|| { + let d = black_box("Sunday, 06-Nov-94 08:49:37 GMT"); + black_box(httpdate::parse_http_date(d)).unwrap(); + }) + }); +} + +pub fn parse_asctime(c: &mut Criterion) { + c.bench_function("parse_asctime", |b| { + b.iter(|| { + let d = black_box("Sun Nov 6 08:49:37 1994"); + black_box(httpdate::parse_http_date(d)).unwrap(); + }) + }); +} + +struct BlackBoxWrite; + +impl std::fmt::Write for BlackBoxWrite { + fn write_str(&mut self, s: &str) -> Result<(), std::fmt::Error> { + black_box(s); + Ok(()) + } +} + +pub fn encode_date(c: &mut Criterion) { + c.bench_function("encode_date", |b| { + let d = "Wed, 21 Oct 2015 07:28:00 GMT"; + black_box(httpdate::parse_http_date(d)).unwrap(); + b.iter(|| { + use std::fmt::Write; + let _ = write!(BlackBoxWrite, "{}", d); + }) + }); +} + +criterion_group!( + benches, + parse_imf_fixdate, + parse_rfc850_date, + parse_asctime, + encode_date +); +criterion_main!(benches); -- cgit v1.2.3