Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bench: Add hard mode to benchmarks. Activate with RUST_BENCH.

RUST_BENCH is on automatically when running `make perf`
  • Loading branch information...
commit 4fec4cd8f5ad45e8caea324df7434a82e560ca38 1 parent 2f3cff2
Brian Anderson brson authored
8 mk/tests.mk
View
@@ -58,6 +58,14 @@ else
CFG_RUN_CTEST=$(call CFG_RUN,$(TLIB$(1)_T_$(3)_H_$(3)),$(2))
endif
+# If we're running perf then set this environment variable
+# to put the benchmarks into 'hard mode'
+ifeq ($(MAKECMDGOALS),perf)
+ RUST_BENCH=1
+ export RUST_BENCH
+endif
+
+
######################################################################
# Main test targets
######################################################################
8 src/test/bench/core-vec-append.rs
View
@@ -21,7 +21,13 @@ fn collect_dvec(num: uint) -> [mut uint] {
}
fn main(args: [str]) {
- let args = if vec::len(args) <= 1u {["", "100000"]} else {args};
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "10000000"]
+ } else if args.len() <= 1u {
+ ["", "100000"]
+ } else {
+ args
+ };
let max = uint::from_str(args[1]).get();
let start = std::time::precise_time_s();
let raw_v = collect_raw(max);
14 src/test/bench/graph500-bfs.rs
View
@@ -404,9 +404,17 @@ fn validate(edges: [(node_id, node_id)],
true
}
-fn main() {
- let scale = 10u;
- let num_keys = 16u;
+fn main(args: [str]) {
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "12", "48"]
+ } else if args.len() <= 1u {
+ ["", "10", "16"]
+ } else {
+ args
+ };
+
+ let scale = uint::from_str(args[1]).get();
+ let num_keys = uint::from_str(args[2]).get();
let do_validate = false;
let do_sequential = true;
13 src/test/bench/msgsend.rs
View
@@ -59,8 +59,15 @@ fn run(args: [str]) {
}
fn main(args: [str]) {
- let args1 = if vec::len(args) <= 1u { ["", "10000", "4"] } else { args };
- #debug("%?", args1);
- run(args1);
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "1000000", "10000"]
+ } else if args.len() <= 1u {
+ ["", "10000", "4"]
+ } else {
+ args
+ };
+
+ #debug("%?", args);
+ run(args);
}
9 src/test/bench/shootout-ackermann.rs
View
@@ -13,10 +13,13 @@ fn ack(m: int, n: int) -> int {
}
fn main(args: [str]) {
- let n = if vec::len(args) == 2u {
- option::get(int::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "12"]
+ } else if args.len() <= 1u {
+ ["", "8"]
} else {
- 8
+ args
};
+ let n = int::from_str(args[1]).get();
io::println(#fmt("Ack(3,%d): %d\n", n, ack(3, n)));
}
10 src/test/bench/shootout-binarytrees.rs
View
@@ -23,11 +23,15 @@ fn bottom_up_tree(arena: &a.arena::arena, item: int, depth: int) -> &a.tree {
}
fn main(args: [str]) {
- let n = if vec::len(args) == 2u {
- option::get(int::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "15"]
+ } else if args.len() <= 1u {
+ ["", "8"]
} else {
- 8
+ args
};
+
+ let n = int::from_str(args[1]).get();
let min_depth = 4;
let mut max_depth;
if min_depth + 2 > n {
10 src/test/bench/shootout-fannkuchredux.rs
View
@@ -59,10 +59,14 @@ fn fannkuch(n: int) -> int {
}
fn main(args: [str]) {
- let n = if vec::len(args) == 2u {
- option::get(int::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "10"]
+ } else if args.len() <= 1u {
+ ["", "8"]
} else {
- 8
+ args
};
+
+ let n = int::from_str(args[1]).get();
io::println(#fmt("Pfannkuchen(%d) = %d", n, fannkuch(n)));
}
13 src/test/bench/shootout-fasta.rs
View
@@ -73,7 +73,17 @@ fn make_repeat_fasta(id: str, desc: str, s: str, n: int) unsafe {
fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; }
-fn main() {
+fn main(args: [str]) {
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "300000"]
+ } else if args.len() <= 1u {
+ ["", "1000"]
+ } else {
+ args
+ };
+
+ let n = int::from_str(args[1]).get();
+
let iub: [aminoacids] =
make_cumulative([acid('a', 27u32), acid('c', 12u32), acid('g', 12u32),
acid('t', 27u32), acid('B', 2u32), acid('D', 2u32),
@@ -91,7 +101,6 @@ fn main() {
"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
- let n: int = 512;
make_repeat_fasta("ONE", "Homo sapiens alu", alu, n * 2);
make_random_fasta("TWO", "IUB ambiguity codes", iub, n * 3);
make_random_fasta("THREE", "Homo sapiens frequency", homosapiens, n * 5);
9 src/test/bench/shootout-fibo.rs
View
@@ -9,10 +9,13 @@ fn fib(n: int) -> int {
}
fn main(args: [str]) {
- let n = if vec::len(args) == 2u {
- option::get(int::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "40"]
+ } else if args.len() <= 1u {
+ ["", "30"]
} else {
- 30
+ args
};
+ let n = int::from_str(args[1]).get();
io::println(#fmt("%d\n", fib(n)));
}
22 src/test/bench/shootout-mandelbrot.rs
View
@@ -140,13 +140,21 @@ fn writer(path: str, writech: comm::chan<comm::chan<line>>, size: uint)
}
}
-fn main(argv: [str]) {
- let size = if vec::len(argv) < 2_u { 80u }
- else { option::get(uint::from_str(argv[1])) };
- let yieldevery = if vec::len(argv) < 3_u { 10_u }
- else { option::get(uint::from_str(argv[2])) };
- let path = if vec::len(argv) < 4_u { "" }
- else { argv[3] };
+fn main(args: [str]) {
+ let path = if vec::len(args) < 4_u { "" }
+ else { args[3] };
+
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "4000", "10"]
+ } else if args.len() <= 1u {
+ ["", "80", "10"]
+ } else {
+ args
+ };
+
+ let size = uint::from_str(args[1]).get();
+ let yieldevery = uint::from_str(args[2]).get();
+
let writep = comm::port();
let writech = comm::chan(writep);
task::spawn {||
9 src/test/bench/shootout-nbody.rs
View
@@ -14,11 +14,14 @@ native mod libc {
}
fn main(args: [str]) {
- let n = if vec::len(args) == 2u {
- option::get(int::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "4000000"]
+ } else if args.len() <= 1u {
+ ["", "100000"]
} else {
- 100000
+ args
};
+ let n = int::from_str(args[1]).get();
let bodies: [Body::props] = NBodySystem::MakeNBodySystem();
io::println(#fmt("%f", NBodySystem::energy(bodies)));
let mut i: int = 0;
45 src/test/bench/shootout-pfib.rs
View
@@ -78,36 +78,37 @@ fn stress(num_tasks: int) {
for results.each {|r| future::get(r); }
}
-fn main(argv: [str]) {
- if vec::len(argv) == 1u {
- assert (fib(8) == 21);
- log(debug, fib(8));
+fn main(args: [str]) {
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "20"]
+ } else if args.len() <= 1u {
+ ["", "8"]
} else {
- // Interactive mode! Wooo!!!!
- let opts = parse_opts(argv);
+ args
+ };
+ let opts = parse_opts(args);
- if opts.stress {
- stress(2);
- } else {
- let max = option::get(uint::parse_buf(str::bytes(argv[1]),
- 10u)) as int;
+ if opts.stress {
+ stress(2);
+ } else {
+ let max = option::get(uint::parse_buf(str::bytes(args[1]),
+ 10u)) as int;
- let num_trials = 10;
+ let num_trials = 10;
- let out = io::stdout();
+ let out = io::stdout();
- range(1, max + 1) {|n|
- range(0, num_trials) {|i|
- let start = time::precise_time_ns();
- let fibn = fib(n);
- let stop = time::precise_time_ns();
+ range(1, max + 1) {|n|
+ range(0, num_trials) {|i|
+ let start = time::precise_time_ns();
+ let fibn = fib(n);
+ let stop = time::precise_time_ns();
- let elapsed = stop - start;
+ let elapsed = stop - start;
- out.write_line(#fmt["%d\t%d\t%s", n, fibn,
- u64::str(elapsed)]);
- }
+ out.write_line(#fmt["%d\t%d\t%s", n, fibn,
+ u64::str(elapsed)]);
}
}
}
11 src/test/bench/shootout-spectralnorm.rs
View
@@ -41,13 +41,16 @@ fn eval_AtA_times_u(u: [const float], AtAu: [mut float]) {
}
fn main(args: [str]) {
-
- let N = if vec::len(args) == 2u {
- option::get(uint::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "2000"]
+ } else if args.len() <= 1u {
+ ["", "1000"]
} else {
- 1000u
+ args
};
+ let N = uint::from_str(args[1]).get();
+
let u = vec::to_mut(vec::from_elem(N, 1.0));
let v = vec::to_mut(vec::from_elem(N, 0.0));
let mut i = 0u;
11 src/test/bench/shootout-threadring.rs
View
@@ -38,8 +38,15 @@ fn roundtrip(id: int, p: comm::port<int>, ch: comm::chan<int>) {
}
fn main(args: [str]) {
- let token = if vec::len(args) < 2u { 1000 }
- else { option::get(int::from_str(args[1])) };
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "100000"]
+ } else if args.len() <= 1u {
+ ["", "1000"]
+ } else {
+ args
+ };
+
+ let token = int::from_str(args[1]).get();
start(token);
}
8 src/test/bench/std-smallintmap.rs
View
@@ -18,7 +18,13 @@ fn check_sequential(min: uint, max: uint, map: smallintmap<uint>) {
}
fn main(args: [str]) {
- let args = if vec::len(args) <= 1u {["", "10000", "50"]} else {args};
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "100000", "50"]
+ } else if args.len() <= 1u {
+ ["", "10000", "50"]
+ } else {
+ args
+ };
let max = uint::from_str(args[1]).get();
let rep = uint::from_str(args[2]).get();
10 src/test/bench/task-perf-one-million.rs
View
@@ -46,11 +46,15 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
}
fn main(args: [str]) {
- let children = if vec::len(args) == 2u {
- option::get(uint::from_str(args[1]))
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "100000"]
+ } else if args.len() <= 1u {
+ ["", "100"]
} else {
- 100u
+ args
};
+
+ let children = uint::from_str(args[1]).get();
let port = comm::port();
let chan = comm::chan(port);
task::spawn {||
12 src/test/bench/task-perf-spawnalot.rs
View
@@ -9,10 +9,14 @@ fn f(&&n: uint) {
fn g() { }
fn main(args: [str]) {
- let n =
- if vec::len(args) < 2u {
- 10u
- } else { option::get(uint::parse_buf(str::bytes(args[1]), 10u)) };
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "400"]
+ } else if args.len() <= 1u {
+ ["", "10"]
+ } else {
+ args
+ };
+ let n = uint::from_str(args[1]).get();
let mut i = 0u;
while i < n { task::spawn {|| f(n); }; i += 1u; }
}
10 src/test/bench/task-perf-vector-party.rs
View
@@ -11,7 +11,13 @@ fn f(&&n: uint) {
}
fn main(args: [str]) {
- let n = if vec::len(args) < 2u { 100u }
- else { option::get(uint::from_str(args[1])) };
+ let args = if os::getenv("RUST_BENCH").is_some() {
+ ["", "50000"]
+ } else if args.len() <= 1u {
+ ["", "100"]
+ } else {
+ args
+ };
+ let n = uint::from_str(args[1]).get();
uint::range(0u, 100u) {|i| task::spawn {|| f(n); };}
}
Please sign in to comment.
Something went wrong with that request. Please try again.