Handle fallout in bench tests

This commit is contained in:
Kevin Ballard 2014-05-05 00:29:59 -07:00
parent eab6bb2ece
commit dbbb847bf0
17 changed files with 18 additions and 5 deletions

View File

@ -90,6 +90,7 @@ fn vector<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint, dist: &[uint]) {
fn main() {
let args = os::args();
let args = args.as_slice();
let n_keys = {
if args.len() == 2 {
from_str::<uint>(args[1]).unwrap()

View File

@ -155,6 +155,7 @@ fn empty_results() -> Results {
fn main() {
let args = os::args();
let args = args.as_slice();
let num_keys = {
if args.len() == 2 {
from_str::<uint>(args[1]).unwrap()

View File

@ -24,7 +24,7 @@ use std::vec;
use std::io::File;
macro_rules! bench (
($argv:expr, $id:ident) => (maybe_run_test($argv, stringify!($id).to_owned(), $id))
($argv:expr, $id:ident) => (maybe_run_test($argv.as_slice(), stringify!($id).to_owned(), $id))
)
fn main() {

View File

@ -61,6 +61,7 @@ fn ping_pong_bench(n: uint, m: uint) {
fn main() {
let args = os::args();
let args = args.as_slice();
let n = if args.len() == 3 {
from_str::<uint>(args[1]).unwrap()
} else {

View File

@ -31,6 +31,7 @@ fn parfib(n: uint) -> uint {
fn main() {
let args = os::args();
let args = args.as_slice();
let n = if args.len() == 2 {
from_str::<uint>(args[1]).unwrap()
} else {

View File

@ -28,6 +28,7 @@ fn start(argc: int, argv: **u8) -> int {
fn main() {
let args = os::args();
let args = args.as_slice();
let n = if args.len() == 2 {
from_str::<uint>(args[1]).unwrap()
} else {

View File

@ -40,6 +40,7 @@ fn bottom_up_tree<'r>(arena: &'r TypedArena<Tree<'r>>, item: int, depth: int)
fn main() {
let args = std::os::args();
let args = args.as_slice();
let n = if std::os::getenv("RUST_BENCH").is_some() {
17
} else if args.len() <= 1u {

View File

@ -194,7 +194,7 @@ fn main() {
let nn = if std::os::getenv("RUST_BENCH").is_some() {
200000
} else {
std::os::args().get(1).and_then(|arg| from_str(*arg)).unwrap_or(600)
std::os::args().as_slice().get(1).and_then(|arg| from_str(*arg)).unwrap_or(600)
};
print_complements();

View File

@ -53,7 +53,7 @@ fn fannkuch(n: uint, i: uint) -> (int, int) {
}
fn main() {
let n = std::os::args().get(1).and_then(|arg| from_str(*arg)).unwrap_or(2u);
let n = std::os::args().as_slice().get(1).and_then(|arg| from_str(*arg)).unwrap_or(2u);
let (tx, rx) = channel();
for i in range(0, n) {

View File

@ -177,6 +177,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
fn main() {
let args = os::args();
let args = args.as_slice();
let n = if args.len() > 1 {
from_str::<uint>(args[1]).unwrap()
} else {

View File

@ -74,6 +74,7 @@ fn make_fasta<W: Writer, I: Iterator<u8>>(
fn run<W: Writer>(writer: &mut W) {
let args = os::args();
let args = args.as_slice();
let n = if os::getenv("RUST_BENCH").is_some() {
25000000
} else if args.len() <= 1u {

View File

@ -72,7 +72,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> ~str {
// given a map, search for the frequency of a pattern
fn find(mm: &HashMap<Vec<u8> , uint>, key: ~str) -> uint {
let key = key.into_ascii().to_lower().into_str();
let key = key.into_ascii().as_slice().to_lower().into_str();
match mm.find_equiv(&key.as_bytes()) {
option::None => { return 0u; }
option::Some(&num) => { return num; }

View File

@ -65,6 +65,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
fn main() {
let args = std::os::args();
let args = args.as_slice();
let res = if args.len() < 2 {
println!("Test mode: do not dump the image because it's not utf8, \
which interferes with the test runner.");

View File

@ -190,7 +190,7 @@ fn to_utf8(raw_sol: &List<u64>) -> ~str {
}
}
}
std::str::from_utf8_owned(sol.move_iter().collect()).unwrap()
std::str::from_utf8(sol.as_slice()).unwrap().to_owned()
}
// Prints a solution in ~str form.
@ -270,6 +270,7 @@ fn search(
fn main () {
let args = std::os::args();
let args = args.as_slice();
let stop_after = if args.len() <= 1 {
2098
} else {

View File

@ -88,6 +88,7 @@ fn pidigits(n: int) {
fn main() {
let args = std::os::args();
let args = args.as_slice();
let n = if args.len() < 2 {
512
} else {

View File

@ -94,6 +94,7 @@ fn mult_AtAv(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>,
fn main() {
let args = os::args();
let args = args.as_slice();
let n = if os::getenv("RUST_BENCH").is_some() {
5500
} else if args.len() < 2 {

View File

@ -35,6 +35,7 @@ fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) {
fn main() {
let args = std::os::args();
let args = args.as_slice();
let token = if std::os::getenv("RUST_BENCH").is_some() {
2000000
} else {