summaryrefslogtreecommitdiffstats
path: root/vendor/utf-8/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/utf-8/benches
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/utf-8/benches')
-rw-r--r--vendor/utf-8/benches/from_utf8_lossy.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/utf-8/benches/from_utf8_lossy.rs b/vendor/utf-8/benches/from_utf8_lossy.rs
new file mode 100644
index 000000000..95d9edf39
--- /dev/null
+++ b/vendor/utf-8/benches/from_utf8_lossy.rs
@@ -0,0 +1,30 @@
+#![feature(test)]
+
+extern crate test;
+extern crate utf8;
+
+#[path = "../tests/shared/data.rs"]
+mod data;
+
+#[path = "../tests/shared/string_from_utf8_lossy.rs"]
+mod string_from_utf8_lossy;
+
+#[bench]
+fn bench_our_string_from_utf8_lossy(bencher: &mut test::Bencher) {
+ bencher.bytes = data::DECODED_LOSSY.iter().map(|&(input, _expected)| input.len() as u64).sum();
+ bencher.iter(|| {
+ for &(input, _expected) in data::DECODED_LOSSY {
+ test::black_box(string_from_utf8_lossy::string_from_utf8_lossy(input));
+ }
+ })
+}
+
+#[bench]
+fn bench_std_string_from_utf8_lossy(bencher: &mut test::Bencher) {
+ bencher.bytes = data::DECODED_LOSSY.iter().map(|&(input, _expected)| input.len() as u64).sum();
+ bencher.iter(|| {
+ for &(input, _expected) in data::DECODED_LOSSY {
+ test::black_box(String::from_utf8_lossy(input));
+ }
+ })
+}