Created
August 25, 2016 20:11
-
-
Save jackmott/b30403cb61de826789a4975406b0b605 to your computer and use it in GitHub Desktop.
rusttest
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
extern crate time; | |
//use std::io; | |
//use std::cmp::Ordering; | |
//use rand::Rng; | |
use time::{Duration,PreciseTime}; | |
fn add_array() -> f64 | |
{ | |
let v = vec![2.0;32000000]; | |
let start = PreciseTime::now(); | |
let mut sum = 0.0; | |
for x in v { | |
let v = x*x; | |
sum += v; | |
} | |
let end = PreciseTime::now(); | |
println!("Time:{}", start.to(end).num_milliseconds()); | |
sum | |
} | |
fn main() { | |
println!("Sum:{}",add_array()); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment