pub struct ConcurrentWorkerResult {
pub operations: u64,
pub counters: Vec<CounterValue>,
}Fields§
§operations: u64§counters: Vec<CounterValue>Implementations§
Source§impl ConcurrentWorkerResult
impl ConcurrentWorkerResult
Sourcepub fn operations(operations: u64) -> Self
pub fn operations(operations: u64) -> Self
Examples found in repository?
examples/concurrent_scenario.rs (line 47)
33fn optimistic_reader(
34 ctx: &CounterLatch,
35 control: &ConcurrentBenchControl,
36) -> ConcurrentWorkerResult {
37 let mut operations = 0_u64;
38 let mut read_misses = 0_u64;
39 while !control.should_stop() {
40 if let Ok(guard) = ctx.value.try_read() {
41 black_box(*guard ^ control.thread_index() as u64 ^ control.role_thread_index() as u64);
42 operations = operations.wrapping_add(1);
43 } else {
44 read_misses = read_misses.wrapping_add(1);
45 }
46 }
47 ConcurrentWorkerResult::operations(operations).with_counter("read_misses", read_misses)
48}
49
50fn exclusive_writer(
51 ctx: &CounterLatch,
52 control: &ConcurrentBenchControl,
53) -> ConcurrentWorkerResult {
54 let mut operations = 0_u64;
55 while !control.should_stop() {
56 let mut guard = ctx.value.write().expect("rwlock poisoned");
57 *guard = guard.wrapping_add(control.thread_index() as u64 + 1);
58 black_box(*guard);
59 operations = operations.wrapping_add(1);
60 }
61 ConcurrentWorkerResult::operations(operations)
62}More examples
examples/concurrent_counters.rs (line 35)
19fn optimistic_reader(
20 ctx: &CounterLatch,
21 control: &ConcurrentBenchControl,
22) -> ConcurrentWorkerResult {
23 let mut operations = 0_u64;
24 let mut read_misses = 0_u64;
25
26 while !control.should_stop() {
27 if let Ok(guard) = ctx.value.try_read() {
28 black_box(*guard ^ control.thread_index() as u64 ^ control.role_thread_index() as u64);
29 operations = operations.wrapping_add(1);
30 } else {
31 read_misses = read_misses.wrapping_add(1);
32 }
33 }
34
35 ConcurrentWorkerResult::operations(operations).with_counter("read_misses", read_misses)
36}
37
38fn exclusive_writer(
39 ctx: &CounterLatch,
40 control: &ConcurrentBenchControl,
41) -> ConcurrentWorkerResult {
42 let mut operations = 0_u64;
43
44 while !control.should_stop() {
45 let mut guard = ctx.value.write().expect("rwlock poisoned");
46 *guard = guard.wrapping_add(control.thread_index() as u64 + 1);
47 black_box(*guard);
48 operations = operations.wrapping_add(1);
49 }
50
51 ConcurrentWorkerResult::operations(operations)
52}Sourcepub fn with_counter(self, name: &'static str, value: u64) -> Self
pub fn with_counter(self, name: &'static str, value: u64) -> Self
Examples found in repository?
examples/concurrent_scenario.rs (line 47)
33fn optimistic_reader(
34 ctx: &CounterLatch,
35 control: &ConcurrentBenchControl,
36) -> ConcurrentWorkerResult {
37 let mut operations = 0_u64;
38 let mut read_misses = 0_u64;
39 while !control.should_stop() {
40 if let Ok(guard) = ctx.value.try_read() {
41 black_box(*guard ^ control.thread_index() as u64 ^ control.role_thread_index() as u64);
42 operations = operations.wrapping_add(1);
43 } else {
44 read_misses = read_misses.wrapping_add(1);
45 }
46 }
47 ConcurrentWorkerResult::operations(operations).with_counter("read_misses", read_misses)
48}More examples
examples/concurrent_counters.rs (line 35)
19fn optimistic_reader(
20 ctx: &CounterLatch,
21 control: &ConcurrentBenchControl,
22) -> ConcurrentWorkerResult {
23 let mut operations = 0_u64;
24 let mut read_misses = 0_u64;
25
26 while !control.should_stop() {
27 if let Ok(guard) = ctx.value.try_read() {
28 black_box(*guard ^ control.thread_index() as u64 ^ control.role_thread_index() as u64);
29 operations = operations.wrapping_add(1);
30 } else {
31 read_misses = read_misses.wrapping_add(1);
32 }
33 }
34
35 ConcurrentWorkerResult::operations(operations).with_counter("read_misses", read_misses)
36}Trait Implementations§
Source§impl Clone for ConcurrentWorkerResult
impl Clone for ConcurrentWorkerResult
Source§fn clone(&self) -> ConcurrentWorkerResult
fn clone(&self) -> ConcurrentWorkerResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConcurrentWorkerResult
impl Debug for ConcurrentWorkerResult
Source§impl Default for ConcurrentWorkerResult
impl Default for ConcurrentWorkerResult
Source§fn default() -> ConcurrentWorkerResult
fn default() -> ConcurrentWorkerResult
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConcurrentWorkerResult
impl RefUnwindSafe for ConcurrentWorkerResult
impl Send for ConcurrentWorkerResult
impl Sync for ConcurrentWorkerResult
impl Unpin for ConcurrentWorkerResult
impl UnsafeUnpin for ConcurrentWorkerResult
impl UnwindSafe for ConcurrentWorkerResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more