1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#[derive(Debug, Default)]
pub struct CostTrackerStats {
pub id: u32,
pub transaction_cost_histogram: histogram::Histogram,
pub writable_accounts_cost_histogram: histogram::Histogram,
pub transaction_count: u64,
pub block_cost: u64,
pub bank_slot: u64,
}
impl CostTrackerStats {
pub fn new(id: u32, bank_slot: u64) -> Self {
CostTrackerStats {
id,
bank_slot,
..CostTrackerStats::default()
}
}
pub fn report(&self) {
datapoint_info!(
"cost_tracker_stats",
("id", self.id as i64, i64),
(
"transaction_cost_unit_min",
self.transaction_cost_histogram.minimum().unwrap_or(0),
i64
),
(
"transaction_cost_unit_max",
self.transaction_cost_histogram.maximum().unwrap_or(0),
i64
),
(
"transaction_cost_unit_mean",
self.transaction_cost_histogram.mean().unwrap_or(0),
i64
),
(
"transaction_cost_unit_2nd_std",
self.transaction_cost_histogram
.percentile(95.0)
.unwrap_or(0),
i64
),
(
"writable_accounts_cost_min",
self.writable_accounts_cost_histogram.minimum().unwrap_or(0),
i64
),
(
"writable_accounts_cost_max",
self.writable_accounts_cost_histogram.maximum().unwrap_or(0),
i64
),
(
"writable_accounts_cost_mean",
self.writable_accounts_cost_histogram.mean().unwrap_or(0),
i64
),
(
"writable_accounts_cost_2nd_std",
self.writable_accounts_cost_histogram
.percentile(95.0)
.unwrap_or(0),
i64
),
("transaction_count", self.transaction_count as i64, i64),
("block_cost", self.block_cost as i64, i64),
("bank_slot", self.bank_slot as i64, i64),
);
}
}