1
1
// Compare bounded and unbounded protocol performance.
2
2
3
- // xfail-test
4
3
// xfail-pretty
5
4
6
5
use std;
@@ -33,31 +32,35 @@ proto! pingpong_unbounded {
33
32
}
34
33
35
34
// 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 }
38
37
}
39
38
40
39
macro_rules! follow {
41
40
{
42
41
$( $message: path( $( $x: ident) ,+) -> $next: ident $e: expr) +
43
42
} => (
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 }
49
50
}
50
51
) ;
51
52
52
53
{
53
54
$( $message: path -> $next: ident $e: expr) +
54
55
} => (
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) } ;
58
61
$e } ) +
59
- _ { fail }
60
- }
62
+ _ => { fail }
63
+ }
61
64
)
62
65
}
63
66
@@ -66,8 +69,6 @@ fn switch<T: send, Tb: send, U>(+endp: pipes::recv_packet_buffered<T, Tb>,
66
69
f ( pipes:: try_recv ( endp) )
67
70
}
68
71
69
- fn move < T > ( -x : T ) -> T { x }
70
-
71
72
// Here's the benchmark
72
73
73
74
fn bounded ( count : uint ) {
@@ -132,7 +133,11 @@ fn timeit(f: fn()) -> float {
132
133
}
133
134
134
135
fn main ( ) {
135
- let count = 1000000 ;
136
+ let count = if os:: getenv ( ~"RUST_BENCH ") . is_some ( ) {
137
+ 250000
138
+ } else {
139
+ 100
140
+ } ;
136
141
let bounded = do timeit { bounded( count) } ;
137
142
let unbounded = do timeit { unbounded( count) } ;
138
143
0 commit comments