Skip to content

Bench harness #4515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod errors;
use std::getopts;
use std::test;

use core::result;
use core::{result, either};
use result::{Ok, Err};

use common::config;
Expand Down Expand Up @@ -158,7 +158,11 @@ pub fn test_opts(config: config) -> test::TestOpts {
test::TestOpts {
filter: config.filter,
run_ignored: config.run_ignored,
logfile: config.logfile.map(|s| s.to_str()),
logfile: copy config.logfile,
run_tests: true,
run_benchmarks: false,
save_results: option::None,
compare_results: option::None
}
}

Expand Down Expand Up @@ -210,13 +214,15 @@ pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn {
}
}

pub fn make_test_name(config: config, testfile: &Path) -> ~str {
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
pub fn make_test_name(config: config, testfile: &Path) -> test::TestName {
test::DynTestName(fmt!("[%s] %s",
mode_str(config.mode),
testfile.to_str()))
}

pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str();
fn~() { runtest::run(config, testfile) }
test::DynTestFn(fn~() { runtest::run(config, testfile) })
}

// Local Variables:
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,12 @@ pub pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
(*v1).gt(v2)
}

#[inline(always)]
pub pure fn min<T: Ord>(v1: T, v2: T) -> T {
if v1 < v2 { v1 } else { v2 }
}

#[inline(always)]
pub pure fn max<T: Ord>(v1: T, v2: T) -> T {
if v1 > v2 { v1 } else { v2 }
}
2 changes: 1 addition & 1 deletion src/libcore/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
}
}

impl<T, U> Either<T, U> {
pub impl<T, U> Either<T, U> {
#[inline(always)]
fn either<V>(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V {
either(f_left, f_right, self)
Expand Down
1 change: 1 addition & 0 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use to_str;
use from_str;

pub use cmath::c_double_targ_consts::*;
pub use cmp::{min, max};

macro_rules! delegate(
(
Expand Down
6 changes: 1 addition & 5 deletions src/libcore/num/int-template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ use vec;
use i8;
use i16;
use i32;
pub use cmp::{min, max};

pub const bits : uint = inst::bits;
pub const bytes : uint = (inst::bits / 8);

pub const min_value: T = (-1 as T) << (bits - 1);
pub const max_value: T = min_value - 1 as T;

#[inline(always)]
pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } }
#[inline(always)]
pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } }

#[inline(always)]
pub pure fn add(x: T, y: T) -> T { x + y }
#[inline(always)]
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/num/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub trait One {
static pure fn one() -> Self;
}

pub pure fn abs<T: Ord Num Zero>(v: T) -> T {
if v < Zero::zero() { v.neg() } else { v }
}

pub trait Round {
pure fn round(&self, mode: RoundMode) -> Self;

Expand Down
7 changes: 2 additions & 5 deletions src/libcore/num/uint-template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ use u8;
use u16;
use u32;

pub use cmp::{min, max};

pub const bits : uint = inst::bits;
pub const bytes : uint = (inst::bits / 8);

pub const min_value: T = 0 as T;
pub const max_value: T = 0 as T - 1 as T;

#[inline(always)]
pub pure fn min(x: T, y: T) -> T { if x < y { x } else { y } }
#[inline(always)]
pub pure fn max(x: T, y: T) -> T { if x > y { x } else { y } }

#[inline(always)]
pub pure fn add(x: T, y: T) -> T { x + y }
#[inline(always)]
Expand Down
Loading