Measure time

    0

    1

    Giovanny Gongora

    Codiga's Rust Recipes

    between two code executions

    use std::time::{Duration, Instant};
    
    fn main() {
      let start = Instant::now();
      expensive_function();
      let duration = start.elapsed();
      println!("Time elapsed in expensive_function() is: {:?}", duration);
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.