Skip to main content

CountingDevice

Struct CountingDevice 

Source
pub struct CountingDevice { /* private fields */ }
Expand description

Wraps a device and counts the reads passing through it.

The counters are atomic and the type is Sync, so a driver reading from several threads is measured correctly rather than approximately.

Implementations§

Source§

impl CountingDevice

Source

pub fn new(inner: Arc<dyn BlockRead>) -> Self

Wrap inner, counting from zero.

Source

pub fn reads(&self) -> u64

How many times the driver called read_at.

Source

pub fn bytes(&self) -> u64

How many bytes those calls asked for.

Source

pub fn reset(&self)

Start counting again from zero.

A mount reads a superblock and headers before the work being measured begins, and counting that in makes a small operation look like a large one. Reset after mounting, measure the operation, read the counters.

Trait Implementations§

Source§

impl BlockRead for CountingDevice

Source§

fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<()>

Read exactly buf.len() bytes starting at offset (bytes from the start of the device).
Source§

fn size_bytes(&self) -> u64

Total device size in bytes. Used for bounds checks.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.