diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 92bf4c6b7..c64abac20 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -563,6 +563,17 @@ pub fn start_vmm_thread( }) } +/// Measures the time of the callback, in case it returns `Ok`. +fn measure_ok(f: F) -> result::Result<(T, Duration), E> +where + F: FnOnce() -> result::Result, +{ + let begin = Instant::now(); + let value = f()?; + let duration = begin.elapsed(); + Ok((value, duration)) +} + #[derive(Clone, Deserialize, Serialize)] struct VmMigrationConfig { vm_config: Arc>,