mmtk/util/statistics/counter/
size_counter.rs1use super::*;
2use std::sync::Arc;
3use std::sync::Mutex;
4
5pub struct SizeCounter {
6 units: Arc<Mutex<EventCounter>>,
7 volume: Arc<Mutex<EventCounter>>,
8}
9
10impl SizeCounter {
19 pub fn new(units: Arc<Mutex<EventCounter>>, volume: Arc<Mutex<EventCounter>>) -> Self {
20 SizeCounter { units, volume }
21 }
22
23 pub fn inc(&mut self, size: u64) {
27 self.units.lock().unwrap().inc();
28 self.volume.lock().unwrap().inc_by(size);
29 }
30
31 pub fn start(&mut self) {
35 self.units.lock().unwrap().start();
36 self.volume.lock().unwrap().start();
37 }
38
39 pub fn stop(&mut self) {
43 self.units.lock().unwrap().stop();
44 self.volume.lock().unwrap().stop();
45 }
46
47 pub fn print_current_units(&self) {
51 self.units.lock().unwrap().print_current();
52 }
53
54 pub fn print_current_volume(&self) {
58 self.volume.lock().unwrap().print_current();
59 }
60
61 pub fn print_units(&self) {
65 self.units.lock().unwrap().print_total(None);
66 }
67
68 pub fn print_volume(&self) {
72 self.volume.lock().unwrap().print_total(None);
73 }
74}