summaryrefslogtreecommitdiffstats
path: root/third_party/rust/http/benches/header_value.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/http/benches/header_value.rs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/http/benches/header_value.rs')
-rw-r--r--third_party/rust/http/benches/header_value.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/third_party/rust/http/benches/header_value.rs b/third_party/rust/http/benches/header_value.rs
new file mode 100644
index 0000000000..2e1004e96e
--- /dev/null
+++ b/third_party/rust/http/benches/header_value.rs
@@ -0,0 +1,46 @@
+#![feature(test)]
+
+extern crate test;
+
+use bytes::Bytes;
+use http::HeaderValue;
+use test::Bencher;
+
+static SHORT: &'static [u8] = b"localhost";
+static LONG: &'static [u8] = b"Mozilla/5.0 (X11; CrOS x86_64 9592.71.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.80 Safari/537.36";
+
+#[bench]
+fn from_shared_short(b: &mut Bencher) {
+ b.bytes = SHORT.len() as u64;
+ let bytes = Bytes::from_static(SHORT);
+ b.iter(|| {
+ HeaderValue::from_maybe_shared(bytes.clone()).unwrap();
+ });
+}
+
+#[bench]
+fn from_shared_long(b: &mut Bencher) {
+ b.bytes = LONG.len() as u64;
+ let bytes = Bytes::from_static(LONG);
+ b.iter(|| {
+ HeaderValue::from_maybe_shared(bytes.clone()).unwrap();
+ });
+}
+
+#[bench]
+fn from_shared_unchecked_short(b: &mut Bencher) {
+ b.bytes = SHORT.len() as u64;
+ let bytes = Bytes::from_static(SHORT);
+ b.iter(|| unsafe {
+ HeaderValue::from_maybe_shared_unchecked(bytes.clone());
+ });
+}
+
+#[bench]
+fn from_shared_unchecked_long(b: &mut Bencher) {
+ b.bytes = LONG.len() as u64;
+ let bytes = Bytes::from_static(LONG);
+ b.iter(|| unsafe {
+ HeaderValue::from_maybe_shared_unchecked(bytes.clone());
+ });
+}