test: Fix benchmarks. rs=rustbot

This commit is contained in:
Patrick Walton 2012-12-28 19:57:18 -08:00
parent 5bd8692e9d
commit 5245aceba9
5 changed files with 47 additions and 52 deletions

View file

@ -16,9 +16,9 @@
extern mod std;
use std::map;
use mutable::Mut;
use send_map::linear::*;
use io::WriterUtil;
use core::mutable::Mut;
use core::send_map::linear::*;
use core::io::WriterUtil;
struct Results {
sequential_ints: float,
@ -185,4 +185,4 @@ fn main() {
rng, num_keys, &mut results);
write_results("libstd::map::hashmap", &results);
}
}
}

View file

@ -25,9 +25,9 @@ use std::map::HashMap;
use std::deque;
use std::deque::Deque;
use std::par;
use io::WriterUtil;
use oldcomm::*;
use int::abs;
use core::io::WriterUtil;
use core::oldcomm::*;
use core::int::abs;
type node_id = i64;
type graph = ~[~[node_id]];

View file

@ -14,7 +14,8 @@
// that things will look really good once we get that lock out of the
// message path.
use oldcomm::*;
use core::oldcomm::*;
use core::oldcomm;
extern mod std;
use std::time;

View file

@ -13,6 +13,8 @@
extern mod std;
use core::os;
// Using sqrt from the standard library is way slower than using libc
// directly even though std just calls libc, I guess it must be
// because the the indirection through another dynamic linker
@ -45,9 +47,9 @@ fn main() {
}
mod NBodySystem {
#[legacy_exports];
use Body;
fn make() -> ~[Body::props] {
pub fn make() -> ~[Body::props] {
let mut bodies: ~[Body::props] =
~[Body::sun(),
Body::jupiter(),
@ -74,8 +76,7 @@ mod NBodySystem {
return bodies;
}
fn advance(bodies: &mut [Body::props], dt: float) {
pub fn advance(bodies: &mut [Body::props], dt: float) {
let mut i = 0;
while i < 5 {
let mut j = i + 1;
@ -95,16 +96,16 @@ mod NBodySystem {
}
}
fn advance_one(bi: &mut Body::props,
bj: &mut Body::props,
dt: float) unsafe {
pub fn advance_one(bi: &mut Body::props,
bj: &mut Body::props,
dt: float) unsafe {
let dx = bi.x - bj.x;
let dy = bi.y - bj.y;
let dz = bi.z - bj.z;
let dSquared = dx * dx + dy * dy + dz * dz;
let distance = libc::sqrt(dSquared);
let distance = ::libc::sqrt(dSquared);
let mag = dt / (dSquared * distance);
bi.vx -= dx * bj.mass * mag;
@ -116,13 +117,13 @@ mod NBodySystem {
bj.vz += dz * bi.mass * mag;
}
fn move_(b: &mut Body::props, dt: float) {
pub fn move_(b: &mut Body::props, dt: float) {
b.x += dt * b.vx;
b.y += dt * b.vy;
b.z += dt * b.vz;
}
fn energy(bodies: &[Body::props]) -> float unsafe {
pub fn energy(bodies: &[Body::props]) -> float unsafe {
let mut dx;
let mut dy;
let mut dz;
@ -142,7 +143,7 @@ mod NBodySystem {
dy = bodies[i].y - bodies[j].y;
dz = bodies[i].z - bodies[j].z;
distance = libc::sqrt(dx * dx + dy * dy + dz * dz);
distance = ::libc::sqrt(dx * dx + dy * dy + dz * dz);
e -= bodies[i].mass * bodies[j].mass / distance;
j += 1;
@ -156,14 +157,14 @@ mod NBodySystem {
}
mod Body {
#[legacy_exports];
use Body;
const PI: float = 3.141592653589793;
const SOLAR_MASS: float = 39.478417604357432;
pub const PI: float = 3.141592653589793;
pub const SOLAR_MASS: float = 39.478417604357432;
// was 4 * PI * PI originally
const DAYS_PER_YEAR: float = 365.24;
pub const DAYS_PER_YEAR: float = 365.24;
type props =
pub type props =
{mut x: float,
mut y: float,
mut z: float,
@ -172,7 +173,7 @@ mod Body {
mut vz: float,
mass: float};
fn jupiter() -> Body::props {
pub fn jupiter() -> Body::props {
return {mut x: 4.84143144246472090e+00,
mut y: -1.16032004402742839e+00,
mut z: -1.03622044471123109e-01,
@ -182,7 +183,7 @@ mod Body {
mass: 9.54791938424326609e-04 * SOLAR_MASS};
}
fn saturn() -> Body::props {
pub fn saturn() -> Body::props {
return {mut x: 8.34336671824457987e+00,
mut y: 4.12479856412430479e+00,
mut z: -4.03523417114321381e-01,
@ -192,7 +193,7 @@ mod Body {
mass: 2.85885980666130812e-04 * SOLAR_MASS};
}
fn uranus() -> Body::props {
pub fn uranus() -> Body::props {
return {mut x: 1.28943695621391310e+01,
mut y: -1.51111514016986312e+01,
mut z: -2.23307578892655734e-01,
@ -202,7 +203,7 @@ mod Body {
mass: 4.36624404335156298e-05 * SOLAR_MASS};
}
fn neptune() -> Body::props {
pub fn neptune() -> Body::props {
return {mut x: 1.53796971148509165e+01,
mut y: -2.59193146099879641e+01,
mut z: 1.79258772950371181e-01,
@ -212,7 +213,7 @@ mod Body {
mass: 5.15138902046611451e-05 * SOLAR_MASS};
}
fn sun() -> Body::props {
pub fn sun() -> Body::props {
return {mut x: 0.0,
mut y: 0.0,
mut z: 0.0,
@ -222,7 +223,7 @@ mod Body {
mass: SOLAR_MASS};
}
fn offset_momentum(props: &mut Body::props,
pub fn offset_momentum(props: &mut Body::props,
px: float, py: float, pz: float) {
props.vx = -px / SOLAR_MASS;
props.vy = -py / SOLAR_MASS;

View file

@ -22,22 +22,20 @@
extern mod std;
use option = option;
use option::Some;
use option::None;
use core::option;
use std::map;
use std::map::HashMap;
use hash::Hash;
use io::{ReaderUtil, WriterUtil};
use core::hash::Hash;
use core::io::{ReaderUtil, WriterUtil};
use std::time;
use oldcomm::Chan;
use oldcomm::Port;
use oldcomm::recv;
use oldcomm::send;
use cmp::Eq;
use to_bytes::IterBytes;
use core::oldcomm::Chan;
use core::oldcomm::Port;
use core::oldcomm::recv;
use core::oldcomm::send;
use core::cmp::Eq;
use core::to_bytes::IterBytes;
macro_rules! move_out (
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
@ -117,20 +115,15 @@ fn box<T>(+x: T) -> box<T> {
}
mod map_reduce {
#[legacy_exports];
export putter;
export getter;
export mapper;
export reducer;
export map_reduce;
use std::map;
type putter<K: Owned, V: Owned> = fn(&K, V);
pub type putter<K: Owned, V: Owned> = fn(&K, V);
type mapper<K1: Owned, K2: Owned, V: Owned> = fn~(K1, putter<K2, V>);
pub type mapper<K1: Owned, K2: Owned, V: Owned> = fn~(K1, putter<K2, V>);
type getter<V: Owned> = fn() -> Option<V>;
pub type getter<V: Owned> = fn() -> Option<V>;
type reducer<K: Copy Owned, V: Copy Owned> = fn~(&K, getter<V>);
pub type reducer<K: Copy Owned, V: Copy Owned> = fn~(&K, getter<V>);
enum ctrl_proto<K: Copy Owned, V: Copy Owned> {
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
@ -245,7 +238,7 @@ mod map_reduce {
(*reduce)(&key, || get(p, &mut ref_count, &mut is_done) );
}
fn map_reduce<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
pub fn map_reduce<K1: Copy Owned, K2: Hash IterBytes Eq Const Copy Owned, V: Copy Owned>(
map: mapper<K1, K2, V>,
reduce: reducer<K2, V>,
inputs: ~[K1])