Skip to content

Instantly share code, notes, and snippets.

@trimoq
Last active December 3, 2019 12:45
Show Gist options
  • Save trimoq/8336aa8ffb5e41b4ce9e6404c445d66e to your computer and use it in GitHub Desktop.
Save trimoq/8336aa8ffb5e41b4ce9e6404c445d66e to your computer and use it in GitHub Desktop.
First benchmark for a baseline
use std::time::SystemTime;
struct PositiveBackend;
impl PositiveBackend{
fn compute(&self, number: u64) -> u64{
number+1
}
}
fn main() {
let backend = Box::new(PositiveBackend);
let mut res= 0 as u64;
let start_time = SystemTime::now();
let total = 20_000_000 as u64;
// our main loop
for i in 0 .. total {
res += backend.compute(i);
}
println!("Result: {}",res);
println!("Elapsed_ms: {}", start_time.elapsed().unwrap().as_millis());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment