MCPcopy Create free account
hub / github.com/JakkuSakura/plotters-gpui / try_sample

Method try_sample

examples/animation-cpu.rs:70–81  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

68 elapsed.as_secs_f32() > 0.1
69 }
70 fn try_sample(&mut self) {
71 if !self.should_sample() {
72 return;
73 }
74 self.system.refresh_processes(ProcessesToUpdate::All, false);
75 let process = self.system.process(self.pid).unwrap();
76 self.points
77 .push_back((SystemTime::now(), process.cpu_usage()));
78 if self.points.len() > 100 {
79 self.points.pop_front();
80 }
81 }
82 fn get_line(&mut self) -> Vec<(f32, f32)> {
83 let mut line = Vec::new();
84 let time = self.points.front().unwrap().0;

Callers 1

plotMethod · 0.80

Calls 1

should_sampleMethod · 0.80

Tested by

no test coverage detected