1use crate::tx::TxStats;
2use std::ops::{AddAssign, Sub};
3
4#[derive(Clone, Debug, Default)]
6pub struct Stats {
7 pub free_page_n: usize,
10 pub pending_page_n: usize,
12 pub free_alloc: usize,
14 pub freelist_in_use: usize,
16
17 pub tx_n: usize,
20 pub open_tx_n: usize,
22
23 pub tx_stats: TxStats,
25}
26
27impl Sub for Stats {
28 type Output = Stats;
29
30 fn sub(self, other: Stats) -> Stats {
31 Stats {
32 free_page_n: self.free_page_n,
33 pending_page_n: self.pending_page_n,
34 free_alloc: self.free_alloc,
35 freelist_in_use: self.freelist_in_use,
36 tx_n: self.tx_n - other.tx_n,
37 open_tx_n: self.open_tx_n - other.open_tx_n,
38 tx_stats: self.tx_stats.sub(&other.tx_stats),
39 }
40 }
41}
42
43impl AddAssign for Stats {
44 fn add_assign(&mut self, other: Stats) {
45 self.tx_stats += other.tx_stats;
46 }
47}