use std::ops::AddAssign;
use std::time::Duration;
#[derive(Clone, Debug, Default)]
pub struct TxStats {
pub page_count: usize,
pub page_alloc: usize,
pub cursor_count: usize,
pub node_count: usize,
pub node_deref: usize,
pub rebalance: usize,
pub rebalance_time: Duration,
pub split: usize,
pub spill: usize,
pub spill_time: Duration,
pub write: usize,
pub write_time: Duration,
}
impl TxStats {
pub fn sub(&self, other: &TxStats) -> TxStats {
TxStats {
page_count: self.page_count - other.page_count,
page_alloc: self.page_alloc - other.page_alloc,
cursor_count: self.cursor_count - other.cursor_count,
node_count: self.node_count - other.node_count,
node_deref: self.node_deref - other.node_deref,
rebalance: self.rebalance - other.rebalance,
rebalance_time: self.rebalance_time - other.rebalance_time,
split: self.split - other.split,
spill: self.spill - other.spill,
spill_time: self.spill_time - other.spill_time,
write: self.write - other.write,
write_time: self.write_time - other.write_time,
}
}
}
impl AddAssign for TxStats {
fn add_assign(&mut self, other: TxStats) {
self.page_count += other.page_count;
self.page_alloc += other.page_alloc;
self.cursor_count += other.cursor_count;
self.node_count += other.node_count;
self.node_deref += other.node_deref;
self.rebalance += other.rebalance;
self.rebalance_time += other.rebalance_time;
self.split += other.split;
self.spill += other.spill;
self.spill_time += other.spill_time;
self.write += other.write;
self.write_time += other.write_time;
}
}