summaryrefslogtreecommitdiffstats
path: root/vendor/iana-time-zone/examples
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/iana-time-zone/examples
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/iana-time-zone/examples')
-rw-r--r--vendor/iana-time-zone/examples/get_timezone.rs6
-rw-r--r--vendor/iana-time-zone/examples/stress-test.rs25
2 files changed, 31 insertions, 0 deletions
diff --git a/vendor/iana-time-zone/examples/get_timezone.rs b/vendor/iana-time-zone/examples/get_timezone.rs
new file mode 100644
index 000000000..0f5119f56
--- /dev/null
+++ b/vendor/iana-time-zone/examples/get_timezone.rs
@@ -0,0 +1,6 @@
+use iana_time_zone::{get_timezone, GetTimezoneError};
+
+fn main() -> Result<(), GetTimezoneError> {
+ println!("{}", get_timezone()?);
+ Ok(())
+}
diff --git a/vendor/iana-time-zone/examples/stress-test.rs b/vendor/iana-time-zone/examples/stress-test.rs
new file mode 100644
index 000000000..73df86f51
--- /dev/null
+++ b/vendor/iana-time-zone/examples/stress-test.rs
@@ -0,0 +1,25 @@
+use std::sync::atomic::{AtomicUsize, Ordering};
+use std::thread::spawn;
+
+use iana_time_zone::get_timezone;
+
+const THREADS: usize = 10;
+const ITERATIONS: usize = 100_000;
+
+static COUNT: AtomicUsize = AtomicUsize::new(0);
+
+fn main() {
+ let mut threads = Vec::with_capacity(THREADS);
+ for _ in 0..THREADS {
+ threads.push(spawn(|| {
+ for _ in 0..ITERATIONS {
+ get_timezone().unwrap();
+ COUNT.fetch_add(1, Ordering::Relaxed);
+ }
+ }));
+ }
+ for thread in threads {
+ thread.join().unwrap();
+ }
+ assert_eq!(COUNT.load(Ordering::SeqCst), THREADS * ITERATIONS);
+}