MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / run

Method run

performance-metrics/src/main.rs:284–320  ·  view source on GitHub ↗
(&self, overrides: &PerformanceTestOverrides)

Source from the content-addressed store, hash-verified

282
283impl PerformanceTest {
284 pub fn run(&self, overrides: &PerformanceTestOverrides) -> PerformanceTestResult {
285 if self.control.num_ops.is_some() && !self.name.starts_with("micro_") {
286 eprintln!(
287 "Warning: num_ops is set on '{}' but has no effect on non micro benchmarks",
288 self.name
289 );
290 }
291
292 let effective_control = {
293 let mut control = self.control.clone();
294 if let Some(test_timeout) = overrides.test_timeout {
295 control.test_timeout = test_timeout;
296 }
297 control.vm_type = overrides.vm_type;
298 control
299 };
300
301 // Run warmup iterations if configured (results discarded)
302 for _ in 0..self.control.warmup_iterations {
303 let _ = (self.func_ptr)(&effective_control);
304 }
305
306 let mut metrics = Vec::new();
307 for _ in 0..overrides
308 .test_iterations
309 .unwrap_or(self.control.test_iterations)
310 {
311 metrics.push((self.func_ptr)(&effective_control));
312 }
313
314 let mean = (self.unit_adjuster)(mean(&metrics).unwrap());
315 let std_dev = (self.unit_adjuster)(std_deviation(&metrics).unwrap());
316 let max = (self.unit_adjuster)(metrics.clone().into_iter().reduce(f64::max).unwrap());
317 let min = (self.unit_adjuster)(metrics.clone().into_iter().reduce(f64::min).unwrap());
318
319 PerformanceTestResult::passed(self.name, mean, std_dev, max, min)
320 }
321
322 // Calculate the timeout for each test
323 // Note: To cover the setup/cleanup time, 20s is added for each iteration of the test

Callers 1

run_test_with_timeoutFunction · 0.45

Calls 6

newFunction · 0.85
meanFunction · 0.85
std_deviationFunction · 0.85
reduceMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected