bf_tree/circular_buffer/
metrics.rs1use std::collections::HashMap;
5
6use super::States;
7
8#[derive(serde::Serialize)]
9pub struct CircularBufferMetrics {
10 pub capacity: usize,
11 pub head_addr: usize,
12 pub tail_addr: usize,
13 pub evicting_addr: usize,
14 pub head_tail_distance: usize,
15 pub allocated_cnt: usize,
16 pub not_ready_cnt: usize,
17 pub ready_cnt: usize,
18 pub tombstone_cnt: usize,
19 pub tombstone_size: usize,
20 pub begin_tombstone_cnt: usize,
21 pub free_listed_cnt: usize,
22 pub evicted_cnt: usize,
23 pub size_cnt: HashMap<usize, usize>,
24}
25
26impl CircularBufferMetrics {
27 pub(super) fn new(cap: usize, states: &States) -> Self {
28 let head_tail_distance = states.tail_addr() - states.head_addr();
29 Self {
30 capacity: cap,
31 head_addr: states.head_addr(),
32 tail_addr: states.tail_addr(),
33 evicting_addr: states.evicting_addr,
34 head_tail_distance,
35 allocated_cnt: 0,
36 not_ready_cnt: 0,
37 ready_cnt: 0,
38 tombstone_cnt: 0,
39 tombstone_size: 0,
40 begin_tombstone_cnt: 0,
41 free_listed_cnt: 0,
42 evicted_cnt: 0,
43 size_cnt: HashMap::new(),
44 }
45 }
46}