Browse files

Convert pfib to pipes. This is a useful stress test.

  • Loading branch information...
1 parent 1d04b0e commit f76a46242b6a34ac09643ddf4050be9d1ad11573 @eholk eholk committed Aug 1, 2012
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/test/bench/shootout-pfib.rs
View
24 src/test/bench/shootout-pfib.rs
@@ -15,33 +15,33 @@ use std;
import std::{time, getopts};
import io::writer_util;
import int::range;
-import comm::port;
-import comm::chan;
-import comm::send;
-import comm::recv;
+import pipes::port;
+import pipes::chan;
+import pipes::send;
+import pipes::recv;
import core::result;
import result::{ok, err};
fn fib(n: int) -> int {
fn pfib(c: chan<int>, n: int) {
if n == 0 {
- send(c, 0);
+ c.send(0);
} else if n <= 2 {
- send(c, 1);
+ c.send(1);
} else {
- let p = port();
- let ch = chan(p);
+ let p = pipes::port_set();
+ let ch = p.chan();
task::spawn(|| pfib(ch, n - 1) );
+ let ch = p.chan();
task::spawn(|| pfib(ch, n - 2) );
- send(c, recv(p) + recv(p));
+ c.send(p.recv() + p.recv());
}
}
- let p = port();
- let ch = chan(p);
+ let (ch, p) = pipes::stream();
let t = task::spawn(|| pfib(ch, n) );
- return recv(p);
+ p.recv()
}
type config = {stress: bool};

0 comments on commit f76a462

Please sign in to comment.