Skip to content

Instantly share code, notes, and snippets.

@palladin
Created June 21, 2016 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save palladin/9c582ef1b05efd1e69b5beca8234f800 to your computer and use it in GitHub Desktop.
Save palladin/9c582ef1b05efd1e69b5beca8234f800 to your computer and use it in GitHub Desktop.
Rust perf test
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