about summary refs log tree commit diff
path: root/src/test/bench
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-09 13:34:50 -0700
committerbors <bors@rust-lang.org>2013-07-09 13:34:50 -0700
commite388a80c234d628c4d1fab77dc3e3f2c04cbefc5 (patch)
tree694f659ded49c002e1aee01146eed625ab50c1bc /src/test/bench
parent5aa0ca9b2eb28166d9ab2e86557a5b1f84230b46 (diff)
parent20a2fbd05557b21b7e3f38d17250388a350d3484 (diff)
downloadrust-e388a80c234d628c4d1fab77dc3e3f2c04cbefc5.tar.gz
rust-e388a80c234d628c4d1fab77dc3e3f2c04cbefc5.zip
auto merge of #7117 : jensnockert/rust/freestanding, r=cmr
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

This means that instead of having to know everywhere what the type is, like

~~~
f64::sin(x)
~~~

You can simply write code that uses the type-generic versions in num instead, this works for all types that implement the corresponding trait in num.

~~~
num::sin(x)
~~~

Note 1: If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note 2: If you were using a function that corresponds to an operator, use the
operator instead.

Note 3: This is just https://github.com/mozilla/rust/pull/7090 reopened against master.
Diffstat (limited to 'src/test/bench')
-rw-r--r--src/test/bench/graph500-bfs.rs2
-rw-r--r--src/test/bench/noise.rs9
-rw-r--r--src/test/bench/shootout-nbody.rs5
-rw-r--r--src/test/bench/shootout-spectralnorm.rs3
4 files changed, 8 insertions, 11 deletions
diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs
index 47de9334be1..dbb8da1ebd7 100644
--- a/src/test/bench/graph500-bfs.rs
+++ b/src/test/bench/graph500-bfs.rs
@@ -22,7 +22,7 @@ use extra::time;
 use extra::deque::Deque;
 use extra::par;
 use std::hashmap::HashSet;
-use std::int::abs;
+use std::num::abs;
 use std::io;
 use std::os;
 use std::rand::RngUtil;
diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs
index b65a6429f2c..a8742b3073f 100644
--- a/src/test/bench/noise.rs
+++ b/src/test/bench/noise.rs
@@ -1,6 +1,5 @@
 // Perlin noise benchmark from https://gist.github.com/1170424
 
-use std::f32;
 use std::float;
 use std::int;
 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 {
     let v = 2.0 * float::consts::pi * r.gen();
     Vec2 {
-        x: float::cos(v) as f32,
-        y: float::sin(v) as f32,
+        x: v.cos() as f32,
+        y: v.sin() as f32,
     }
 }
 
@@ -66,8 +65,8 @@ impl Noise2DContext {
                          origins: &mut [Vec2, ..4],
                          x: f32,
                          y: f32) {
-        let x0f = f32::floor(x);
-        let y0f = f32::floor(y);
+        let x0f = x.floor();
+        let y0f = y.floor();
         let x0 = x0f as int;
         let y0 = y0f as int;
         let x1 = x0 + 1;
diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs
index 7940b5a13c1..a56d1f44fa2 100644
--- a/src/test/bench/shootout-nbody.rs
+++ b/src/test/bench/shootout-nbody.rs
@@ -1,4 +1,3 @@
-use std::f64;
 use std::from_str::FromStr;
 use std::os;
 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];
 
                 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 b_mass = bodies[j].mass;
@@ -124,7 +123,7 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
             for range(0, 3) |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;
         }
     }
diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs
index 35a37e55332..3e3df53eaad 100644
--- a/src/test/bench/shootout-spectralnorm.rs
+++ b/src/test/bench/shootout-spectralnorm.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::f64;
 use std::from_str::FromStr;
 use std::os;
 use std::vec;
@@ -62,5 +61,5 @@ fn main() {
         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));
 }