Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Measure execution time

Rust

#![allow(unused)]
fn main() {
use std::time::Instant;

let start = Instant::now();
// ...
let duration = start.elapsed();
}

Python

import time

start = time.time()
# ...
duration = time.time() - start