pub struct FlashOps {
pub reads: u64,
pub read_bytes: u64,
pub writes: u64,
pub erases: u64,
}Available on crate feature
std only.Expand description
A snapshot of a MockFlash’s operation counters.
Subtracting two snapshots gives the cost of whatever happened between them, which is the portable and deterministic way to measure this crate: on real hardware an erase is 100 ms or more, a page write is microseconds, and a read is bus-bound, so the counts predict behaviour across parts in a way a desktop wall-clock number never can.
let mut db: SensorDb<MockFlash<256, 4096>, 256, 8> =
SensorDb::new(MockFlash::new(8 * 4096), 0, 8, 1)?;
db.format()?;
let before = db.driver_mut().ops();
db.append(1, 0, &[0xAB])?;
// A buffered append touches no flash at all.
assert_eq!(db.driver_mut().ops() - before, Default::default());Fields§
§reads: u64Read operations.
read_bytes: u64Bytes read. The number that matters for mount cost on a real bus.
writes: u64Page-program operations, successful or torn.
erases: u64Sector-erase operations, successful or torn. The expensive one.
Trait Implementations§
impl Copy for FlashOps
impl Eq for FlashOps
impl StructuralPartialEq for FlashOps
Auto Trait Implementations§
impl Freeze for FlashOps
impl RefUnwindSafe for FlashOps
impl Send for FlashOps
impl Sync for FlashOps
impl Unpin for FlashOps
impl UnsafeUnpin for FlashOps
impl UnwindSafe for FlashOps
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