Skip to content

Commit 33ee433

Browse files
committed
Fixed xfail for nbody shootout benchmark by correcting command line parse.
Cleaned up unneeded imports and type changes to resolve compiler warnings.
1 parent 3b0d486 commit 33ee433

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src/test/bench/shootout-ackermann.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
extern mod extra;
1212

13-
use std::int;
1413
use std::os;
1514

1615
fn ack(m: int, n: int) -> int {

src/test/bench/shootout-chameneos-redux.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::comm::{stream, SharedChan};
1717
use std::option;
1818
use std::os;
1919
use std::task;
20-
use std::uint;
2120

2221
fn print_complements() {
2322
let all = [Blue, Red, Yellow];

src/test/bench/shootout-fibo.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
extern mod extra;
1212

13-
use std::int;
1413
use std::os;
1514

1615
fn fib(n: int) -> int {

src/test/bench/shootout-nbody.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// xfail-test reading from os::args()[1] - bogus!
2-
3-
use std::from_str::FromStr;
41
use std::os;
52

63
static PI: f64 = 3.141592653589793;
@@ -139,13 +136,23 @@ fn offset_momentum(bodies: &mut [Planet, ..N_BODIES]) {
139136
}
140137

141138
fn main() {
142-
let n: i32 = FromStr::from_str(os::args()[1]).unwrap();
139+
let args = os::args();
140+
let args = if os::getenv("RUST_BENCH").is_some() {
141+
~[~"", ~"1000"]
142+
} else if args.len() <= 1u {
143+
~[~"", ~"1000"]
144+
} else {
145+
args
146+
};
147+
148+
let n: i32 = from_str::<i32>(args[1]).unwrap();
143149
let mut bodies = BODIES;
144150

145151
offset_momentum(&mut bodies);
146-
println!("{:.9f}", energy(&bodies) as float);
152+
println!("{:.9f}", energy(&bodies) as f64);
147153

148154
advance(&mut bodies, 0.01, n);
149155

150-
println!("{:.9f}", energy(&bodies) as float);
156+
println!("{:.9f}", energy(&bodies) as f64);
151157
}
158+

0 commit comments

Comments
 (0)