Skip to main content

ConcurrentWorkerResult

Struct ConcurrentWorkerResult 

Source
pub struct ConcurrentWorkerResult {
    pub operations: u64,
    pub counters: Vec<CounterValue>,
}

Fields§

§operations: u64§counters: Vec<CounterValue>

Implementations§

Source§

impl ConcurrentWorkerResult

Source

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
Hide additional 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}
Source

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
Hide additional 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

Source§

fn clone(&self) -> ConcurrentWorkerResult

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConcurrentWorkerResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConcurrentWorkerResult

Source§

fn default() -> ConcurrentWorkerResult

Returns the “default value” for a type. Read more
Source§

impl From<u64> for ConcurrentWorkerResult

Source§

fn from(operations: u64) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> EventData for T
where T: Send + Sync,