diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/uuid/benches | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/uuid/benches')
-rw-r--r-- | third_party/rust/uuid/benches/format_str.rs | 66 | ||||
-rw-r--r-- | third_party/rust/uuid/benches/parse_str.rs | 50 | ||||
-rw-r--r-- | third_party/rust/uuid/benches/v4.rs | 11 |
3 files changed, 127 insertions, 0 deletions
diff --git a/third_party/rust/uuid/benches/format_str.rs b/third_party/rust/uuid/benches/format_str.rs new file mode 100644 index 0000000000..fab89297bf --- /dev/null +++ b/third_party/rust/uuid/benches/format_str.rs @@ -0,0 +1,66 @@ +#![feature(test)] +extern crate test; + +use std::io::Write; +use test::Bencher; +use uuid::Uuid; + +#[bench] +fn hyphenated(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 36]; + write!(&mut buffer as &mut [_], "{:x}", uuid.hyphenated()).unwrap(); + buffer + }); +} + +#[bench] +fn simple(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 32]; + write!(&mut buffer as &mut [_], "{:x}", uuid.simple()).unwrap(); + buffer + }) +} + +#[bench] +fn urn(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 36 + 9]; + write!(&mut buffer as &mut [_], "{:x}", uuid.urn()).unwrap(); + buffer + }) +} + +#[bench] +fn encode_hyphen(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 36]; + uuid.hyphenated().encode_lower(&mut buffer); + buffer + }); +} + +#[bench] +fn encode_simple(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 32]; + uuid.simple().encode_lower(&mut buffer); + buffer + }) +} + +#[bench] +fn encode_urn(b: &mut Bencher) { + let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap(); + b.iter(|| { + let mut buffer = [0_u8; 36 + 9]; + uuid.urn().encode_lower(&mut buffer); + buffer + }) +} diff --git a/third_party/rust/uuid/benches/parse_str.rs b/third_party/rust/uuid/benches/parse_str.rs new file mode 100644 index 0000000000..e53ba242d3 --- /dev/null +++ b/third_party/rust/uuid/benches/parse_str.rs @@ -0,0 +1,50 @@ +#![feature(test)] +extern crate test; + +use test::Bencher; +use uuid::Uuid; + +#[bench] +fn parse_nil(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("00000000000000000000000000000000")); +} + +#[bench] +fn parse_nil_hyphenated(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("00000000-0000-0000-0000-000000000000")); +} + +#[bench] +fn parse_random(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8")); +} + +#[bench] +fn parse_random_hyphenated(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8")); +} + +#[bench] +fn parse_urn(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8")); +} + +#[bench] +fn parse_invalid_len(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4")) +} + +#[bench] +fn parse_invalid_character(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4")) +} + +#[bench] +fn parse_invalid_group_len(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("01020304-1112-2122-3132-41424344")); +} + +#[bench] +fn parse_invalid_groups(b: &mut Bencher) { + b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4")); +} diff --git a/third_party/rust/uuid/benches/v4.rs b/third_party/rust/uuid/benches/v4.rs new file mode 100644 index 0000000000..61c3246b95 --- /dev/null +++ b/third_party/rust/uuid/benches/v4.rs @@ -0,0 +1,11 @@ +#![cfg(feature = "v4")] +#![feature(test)] +extern crate test; + +use test::Bencher; +use uuid::Uuid; + +#[bench] +fn new_v4(b: &mut Bencher) { + b.iter(|| Uuid::new_v4()); +} |