Last active
December 3, 2019 12:45
-
-
Save trimoq/8336aa8ffb5e41b4ce9e6404c445d66e to your computer and use it in GitHub Desktop.
First benchmark for a baseline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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