mint_cli/commands/
stats.rs1use std::time::Duration;
2
3#[derive(Debug, Clone)]
4pub struct BlockStat {
5 pub name: String,
6 pub start_address: u32,
7 pub allocated_size: u32,
8 pub used_size: u32,
9 pub crc_value: Option<u32>,
10}
11
12#[derive(Debug)]
13pub struct BuildStats {
14 pub blocks_processed: usize,
15 pub total_allocated: usize,
16 pub total_used: usize,
17 pub total_duration: Duration,
18 pub block_stats: Vec<BlockStat>,
19}
20
21impl Default for BuildStats {
22 fn default() -> Self {
23 Self::new()
24 }
25}
26
27impl BuildStats {
28 pub fn new() -> Self {
29 Self {
30 blocks_processed: 0,
31 total_allocated: 0,
32 total_used: 0,
33 total_duration: Duration::from_secs(0),
34 block_stats: Vec::new(),
35 }
36 }
37
38 pub fn add_block(&mut self, stat: BlockStat) {
39 self.blocks_processed += 1;
40 self.total_allocated += stat.allocated_size as usize;
41 self.total_used += stat.used_size as usize;
42 self.block_stats.push(stat);
43 }
44
45 pub fn space_efficiency(&self) -> f64 {
46 if self.total_allocated == 0 {
47 0.0
48 } else {
49 (self.total_used as f64 / self.total_allocated as f64) * 100.0
50 }
51 }
52}