Skip to content

Commit c973732

Browse files
committed
Enabling pingpong benchmark.
1 parent 517ad98 commit c973732

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/test/bench/pingpong.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Compare bounded and unbounded protocol performance.
22

3-
// xfail-test
43
// xfail-pretty
54

65
use std;
@@ -33,31 +32,35 @@ proto! pingpong_unbounded {
3332
}
3433

3534
// This stuff should go in libcore::pipes
36-
macro_rules! move {
37-
{ $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
35+
macro_rules! move_it {
36+
{ $x:expr } => { let t <- *ptr::addr_of($x); t }
3837
}
3938

4039
macro_rules! follow {
4140
{
4241
$($message:path($($x: ident),+) -> $next:ident $e:expr)+
4342
} => (
44-
|m| alt move(m) {
45-
$(some($message($($x,)* next)) {
46-
let $next = move!{next};
47-
$e })+
48-
_ { fail }
43+
|m| alt move m {
44+
$(some($message($($x,)* next)) => {
45+
// FIXME (#2329) use regular move here once move out of
46+
// enums is supported.
47+
let $next = unsafe { move_it!(next) };
48+
$e })+
49+
_ => { fail }
4950
}
5051
);
5152

5253
{
5354
$($message:path -> $next:ident $e:expr)+
5455
} => (
55-
|m| alt move(m) {
56-
$(some($message(next)) {
57-
let $next = move!{next};
56+
|m| alt move m {
57+
$(some($message(next)) => {
58+
// FIXME (#2329) use regular move here once move out of
59+
// enums is supported.
60+
let $next = unsafe { move_it!(next) };
5861
$e })+
59-
_ { fail }
60-
}
62+
_ => { fail }
63+
}
6164
)
6265
}
6366

@@ -66,8 +69,6 @@ fn switch<T: send, Tb: send, U>(+endp: pipes::recv_packet_buffered<T, Tb>,
6669
f(pipes::try_recv(endp))
6770
}
6871

69-
fn move<T>(-x: T) -> T { x }
70-
7172
// Here's the benchmark
7273

7374
fn bounded(count: uint) {
@@ -132,7 +133,11 @@ fn timeit(f: fn()) -> float {
132133
}
133134

134135
fn main() {
135-
let count = 1000000;
136+
let count = if os::getenv(~"RUST_BENCH").is_some() {
137+
250000
138+
} else {
139+
100
140+
};
136141
let bounded = do timeit { bounded(count) };
137142
let unbounded = do timeit { unbounded(count) };
138143

0 commit comments

Comments
 (0)