Skip to content

Instantly share code, notes, and snippets.

@jackmott
Created August 25, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackmott/b30403cb61de826789a4975406b0b605 to your computer and use it in GitHub Desktop.
Save jackmott/b30403cb61de826789a4975406b0b605 to your computer and use it in GitHub Desktop.
rusttest
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