diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
commit | 4547b622d8d29df964fa2914213088b148c498fc (patch) | |
tree | 9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/uuid/benches/format_str.rs | |
parent | Releasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz rustc-4547b622d8d29df964fa2914213088b148c498fc.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/uuid/benches/format_str.rs')
-rw-r--r-- | vendor/uuid/benches/format_str.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/uuid/benches/format_str.rs b/vendor/uuid/benches/format_str.rs new file mode 100644 index 000000000..0ae576d32 --- /dev/null +++ b/vendor/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 bench_hyphen(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.to_hyphenated()).unwrap();
+ test::black_box(buffer);
+ });
+}
+
+#[bench]
+fn bench_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.to_simple()).unwrap();
+ test::black_box(buffer);
+ })
+}
+
+#[bench]
+fn bench_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.to_urn()).unwrap();
+ test::black_box(buffer);
+ })
+}
+
+#[bench]
+fn bench_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.to_hyphenated().encode_lower(&mut buffer);
+ test::black_box(buffer);
+ });
+}
+
+#[bench]
+fn bench_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.to_simple().encode_lower(&mut buffer);
+ test::black_box(buffer);
+ })
+}
+
+#[bench]
+fn bench_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.to_urn().encode_lower(&mut buffer);
+ test::black_box(buffer);
+ })
+}
|