Created
June 21, 2016 21:51
-
-
Save palladin/9c582ef1b05efd1e69b5beca8234f800 to your computer and use it in GitHub Desktop.
Rust perf test
This file contains hidden or 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
extern crate time; | |
use std::io; | |
use time::PreciseTime; | |
fn main() { | |
let mut guess: String = String::new(); | |
io::stdin().read_line(&mut guess).expect("failed to read line"); | |
let n: i64 = guess.trim().parse().expect("Please type a number!"); | |
let start = PreciseTime::now(); | |
let sum = (1..n).fold(0, |sum, x| sum + x); | |
let end = PreciseTime::now(); | |
println!("Time {}, Sum: {}", start.to(end), sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment