MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / time_blocking

Function time_blocking

examples/tauri-sqlx-vanilla/src-tauri/src/bench.rs:371–390  ·  view source on GitHub ↗
(
    timings: &mut Vec<PhaseTiming>,
    name: impl Into<String>,
    op: F,
)

Source from the content-addressed store, hash-verified

369}
370
371async fn time_blocking<T, F>(
372 timings: &mut Vec<PhaseTiming>,
373 name: impl Into<String>,
374 op: F,
375) -> Result<T>
376where
377 T: Send + 'static,
378 F: FnOnce() -> Result<T> + Send + 'static,
379{
380 let name = name.into();
381 let started = Instant::now();
382 let result = tokio::task::spawn_blocking(op)
383 .await
384 .context("join blocking profile phase")?;
385 timings.push(PhaseTiming {
386 name,
387 ms: elapsed_ms(started),
388 });
389 result
390}
391
392async fn time_async<T, Fut>(
393 timings: &mut Vec<PhaseTiming>,

Callers 1

startMethod · 0.85

Calls 2

elapsed_msFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected