aboutsummaryrefslogtreecommitdiff
path: root/vendor/crossbeam-utils/benches/atomic_cell.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/crossbeam-utils/benches/atomic_cell.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/crossbeam-utils/benches/atomic_cell.rs')
-rw-r--r--vendor/crossbeam-utils/benches/atomic_cell.rs156
1 files changed, 0 insertions, 156 deletions
diff --git a/vendor/crossbeam-utils/benches/atomic_cell.rs b/vendor/crossbeam-utils/benches/atomic_cell.rs
deleted file mode 100644
index 844f7c0..0000000
--- a/vendor/crossbeam-utils/benches/atomic_cell.rs
+++ /dev/null
@@ -1,156 +0,0 @@
-#![feature(test)]
-
-extern crate test;
-
-use std::sync::Barrier;
-
-use crossbeam_utils::atomic::AtomicCell;
-use crossbeam_utils::thread;
-
-#[bench]
-fn load_u8(b: &mut test::Bencher) {
- let a = AtomicCell::new(0u8);
- let mut sum = 0;
- b.iter(|| sum += a.load());
- test::black_box(sum);
-}
-
-#[bench]
-fn store_u8(b: &mut test::Bencher) {
- let a = AtomicCell::new(0u8);
- b.iter(|| a.store(1));
-}
-
-#[bench]
-fn fetch_add_u8(b: &mut test::Bencher) {
- let a = AtomicCell::new(0u8);
- b.iter(|| a.fetch_add(1));
-}
-
-#[bench]
-fn compare_exchange_u8(b: &mut test::Bencher) {
- let a = AtomicCell::new(0u8);
- let mut i = 0;
- b.iter(|| {
- let _ = a.compare_exchange(i, i.wrapping_add(1));
- i = i.wrapping_add(1);
- });
-}
-
-#[bench]
-fn concurrent_load_u8(b: &mut test::Bencher) {
- const THREADS: usize = 2;
- const STEPS: usize = 1_000_000;
-
- let start = Barrier::new(THREADS + 1);
- let end = Barrier::new(THREADS + 1);
- let exit = AtomicCell::new(false);
-
- let a = AtomicCell::new(0u8);
-
- thread::scope(|scope| {
- for _ in 0..THREADS {
- scope.spawn(|_| loop {
- start.wait();
-
- let mut sum = 0;
- for _ in 0..STEPS {
- sum += a.load();
- }
- test::black_box(sum);
-
- end.wait();
- if exit.load() {
- break;
- }
- });
- }
-
- start.wait();
- end.wait();
-
- b.iter(|| {
- start.wait();
- end.wait();
- });
-
- start.wait();
- exit.store(true);
- end.wait();
- })
- .unwrap();
-}
-
-#[bench]
-fn load_usize(b: &mut test::Bencher) {
- let a = AtomicCell::new(0usize);
- let mut sum = 0;
- b.iter(|| sum += a.load());
- test::black_box(sum);
-}
-
-#[bench]
-fn store_usize(b: &mut test::Bencher) {
- let a = AtomicCell::new(0usize);
- b.iter(|| a.store(1));
-}
-
-#[bench]
-fn fetch_add_usize(b: &mut test::Bencher) {
- let a = AtomicCell::new(0usize);
- b.iter(|| a.fetch_add(1));
-}
-
-#[bench]
-fn compare_exchange_usize(b: &mut test::Bencher) {
- let a = AtomicCell::new(0usize);
- let mut i = 0;
- b.iter(|| {
- let _ = a.compare_exchange(i, i.wrapping_add(1));
- i = i.wrapping_add(1);
- });
-}
-
-#[bench]
-fn concurrent_load_usize(b: &mut test::Bencher) {
- const THREADS: usize = 2;
- const STEPS: usize = 1_000_000;
-
- let start = Barrier::new(THREADS + 1);
- let end = Barrier::new(THREADS + 1);
- let exit = AtomicCell::new(false);
-
- let a = AtomicCell::new(0usize);
-
- thread::scope(|scope| {
- for _ in 0..THREADS {
- scope.spawn(|_| loop {
- start.wait();
-
- let mut sum = 0;
- for _ in 0..STEPS {
- sum += a.load();
- }
- test::black_box(sum);
-
- end.wait();
- if exit.load() {
- break;
- }
- });
- }
-
- start.wait();
- end.wait();
-
- b.iter(|| {
- start.wait();
- end.wait();
- });
-
- start.wait();
- exit.store(true);
- end.wait();
- })
- .unwrap();
-}