summaryrefslogtreecommitdiffstats
path: root/third_party/rust/httpdate/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/rust/httpdate/benches
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/httpdate/benches')
-rw-r--r--third_party/rust/httpdate/benches/benchmarks.rs57
1 files changed, 57 insertions, 0 deletions
diff --git a/third_party/rust/httpdate/benches/benchmarks.rs b/third_party/rust/httpdate/benches/benchmarks.rs
new file mode 100644
index 0000000000..4f82467bdb
--- /dev/null
+++ b/third_party/rust/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);