And I forgot to run the benchmarks after rebasing
This commit is contained in:
parent
59e6a4d44c
commit
2ed1cfc912
3 changed files with 7 additions and 10 deletions
|
@ -1,6 +1,5 @@
|
||||||
// Perlin noise benchmark from https://gist.github.com/1170424
|
// Perlin noise benchmark from https://gist.github.com/1170424
|
||||||
|
|
||||||
use std::f32;
|
|
||||||
use std::float;
|
use std::float;
|
||||||
use std::int;
|
use std::int;
|
||||||
use std::rand::{Rng, RngUtil};
|
use std::rand::{Rng, RngUtil};
|
||||||
|
@ -20,8 +19,8 @@ fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) }
|
||||||
fn random_gradient<R:Rng>(r: &mut R) -> Vec2 {
|
fn random_gradient<R:Rng>(r: &mut R) -> Vec2 {
|
||||||
let v = 2.0 * float::consts::pi * r.gen();
|
let v = 2.0 * float::consts::pi * r.gen();
|
||||||
Vec2 {
|
Vec2 {
|
||||||
x: float::cos(v) as f32,
|
x: v.cos() as f32,
|
||||||
y: float::sin(v) as f32,
|
y: v.sin() as f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +65,8 @@ impl Noise2DContext {
|
||||||
origins: &mut [Vec2, ..4],
|
origins: &mut [Vec2, ..4],
|
||||||
x: f32,
|
x: f32,
|
||||||
y: f32) {
|
y: f32) {
|
||||||
let x0f = f32::floor(x);
|
let x0f = x.floor();
|
||||||
let y0f = f32::floor(y);
|
let y0f = y.floor();
|
||||||
let x0 = x0f as int;
|
let x0 = x0f as int;
|
||||||
let y0 = y0f as int;
|
let y0 = y0f as int;
|
||||||
let x1 = x0 + 1;
|
let x1 = x0 + 1;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::f64;
|
|
||||||
use std::from_str::FromStr;
|
use std::from_str::FromStr;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::uint::range;
|
use std::uint::range;
|
||||||
|
@ -90,7 +89,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: i32) {
|
||||||
d[2] = bodies[i].x[2] - bodies[j].x[2];
|
d[2] = bodies[i].x[2] - bodies[j].x[2];
|
||||||
|
|
||||||
let d2 = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
let d2 = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
||||||
let mag = dt / (d2 * f64::sqrt(d2));
|
let mag = dt / (d2 * d2.sqrt());
|
||||||
|
|
||||||
let a_mass = bodies[i].mass;
|
let a_mass = bodies[i].mass;
|
||||||
let b_mass = bodies[j].mass;
|
let b_mass = bodies[j].mass;
|
||||||
|
@ -124,7 +123,7 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
|
||||||
for range(0, 3) |k| {
|
for range(0, 3) |k| {
|
||||||
d[k] = bodies[i].x[k] - bodies[j].x[k];
|
d[k] = bodies[i].x[k] - bodies[j].x[k];
|
||||||
}
|
}
|
||||||
let dist = f64::sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
|
let dist = (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]).sqrt();
|
||||||
e -= bodies[i].mass * bodies[j].mass / dist;
|
e -= bodies[i].mass * bodies[j].mass / dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::f64;
|
|
||||||
use std::from_str::FromStr;
|
use std::from_str::FromStr;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
@ -62,5 +61,5 @@ fn main() {
|
||||||
mult_AtAv(v, u, tmp);
|
mult_AtAv(v, u, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
println(fmt!("%.9f", f64::sqrt(dot(u,v) / dot(v,v)) as float));
|
println(fmt!("%.9f", (dot(u,v) / dot(v,v)).sqrt() as float));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue