MCPcopy Create free account
hub / github.com/5ocworkshop/bgraph / update_cpu

Method update_cpu

examples/demo/cls_simulation.rs:163–177  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

161 }
162
163 fn update_cpu(&mut self) {
164 for i in 0..4 {
165 let spike = if self.tick % (80 + i as u64 * 25) == 0 {
166 random_range(25.0, 45.0)
167 } else {
168 0.0
169 };
170 let jitter = random_range(-2.0, 2.0);
171 let decay = (45.0 + (i as f32 * 8.0) - self.cpu_values[i]) * 0.008;
172
173 self.cpu_values[i] = (self.cpu_values[i] + jitter + decay + spike).clamp(8.0, 95.0);
174 self.cpu.push(i, self.cpu_values[i]);
175 self.cpu_cores[i].push(self.cpu_values[i]);
176 }
177 }
178
179 fn update_network(&mut self) {
180 // RX: faster oscillation with occasional spikes

Callers 1

updateMethod · 0.80

Calls 2

random_rangeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected