Skip to content

Instantly share code, notes, and snippets.

@devlongs
Last active December 16, 2025 05:57
Show Gist options
  • Select an option

  • Save devlongs/2cd9c91ef4cf7f898d0c3e8c43299d74 to your computer and use it in GitHub Desktop.

Select an option

Save devlongs/2cd9c91ef4cf7f898d0c3e8c43299d74 to your computer and use it in GitHub Desktop.
Simple Manual Timing (Good for Quick Tests) Benchmarking
// A simple manual timing for benchmarking
use std::time::Instant;
fn main() {
let start = Instant::now();
// Code to benchmark
let result = expensive_function();
let duration = start.elapsed();
println!("Time elapsed: {:?}", duration);
}
fn expensive_function() -> u64 {
// Some work here
(0..1000000).sum()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment