summary refs log tree commit diff
path: root/src/test/bench
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-01-31 17:12:29 -0800
committerNiko Matsakis <niko@alum.mit.edu>2013-02-07 05:53:30 -0800
commita32498d8464e0dfa4e2cb31967a66e076da40109 (patch)
tree62fc02049c4d06ccd64a704f6f9e3af53d2835e3 /src/test/bench
parent82d73963334f01b818cda767b44cd0c8f3baf4cc (diff)
downloadrust-a32498d8464e0dfa4e2cb31967a66e076da40109.tar.gz
rust-a32498d8464e0dfa4e2cb31967a66e076da40109.zip
Make ~fn non-copyable, make &fn copyable, split barefn/closure types,
correct handling of moves for struct-record update.

Part of #3678.  Fixes #2828, #3904, #4719.
Diffstat (limited to 'src/test/bench')
-rw-r--r--src/test/bench/graph500-bfs.rs44
-rw-r--r--src/test/bench/task-perf-alloc-unwind.rs9
2 files changed, 30 insertions, 23 deletions
diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs
index 5ade0c9ed25..222307bd240 100644
--- a/src/test/bench/graph500-bfs.rs
+++ b/src/test/bench/graph500-bfs.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #[legacy_modes];
+#[allow(deprecated_mode)];
 
 /*!
 
@@ -247,8 +248,13 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
         }
     }
 
+    fn is_gray_factory() -> ~fn(c: &color) -> bool {
+        let r: ~fn(c: &color) -> bool = is_gray;
+        r
+    }
+
     let mut i = 0;
-    while par::any(colors, is_gray) {
+    while par::any(colors, is_gray_factory) {
         // Do the BFS.
         log(info, fmt!("PBFS iteration %?", i));
         i += 1;
@@ -257,14 +263,13 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
         let color = arc::ARC(move colors);
 
         let color_vec = arc::get(&color); // FIXME #3387 requires this temp
-        colors = do par::mapi_factory(*color_vec) {
+        colors = do par::mapi(*color_vec) {
             let colors = arc::clone(&color);
             let graph = arc::clone(&graph);
-            fn~(move graph, move colors, +i: uint, +c: color) -> color {
-                let c : color = c;
+            fn~(+i: uint, +c: &color) -> color {
                 let colors = arc::get(&colors);
                 let graph = arc::get(&graph);
-                match c {
+                match *c {
                   white => {
                     let i = i as node_id;
 
@@ -290,11 +295,13 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
     }
 
     // Convert the results.
-    do par::map(colors) |c| {
-        match *c {
-          white => { -1i64 }
-          black(parent) => { parent }
-          _ => { die!(~"Found remaining gray nodes in BFS") }
+    do par::map(colors) {
+        fn~(c: &color) -> i64 {
+            match *c {
+                white => { -1i64 }
+                black(parent) => { parent }
+                _ => { die!(~"Found remaining gray nodes in BFS") }
+            }
         }
     }
 }
@@ -377,14 +384,15 @@ fn validate(edges: ~[(node_id, node_id)],
 
     log(info, ~"Verifying tree and graph edges...");
 
-    let edges = copy edges;
-    let status = do par::alli(tree) |u, v| {
-        let u = u as node_id;
-        if *v == -1i64 || u == root {
-            true
-        }
-        else {
-            edges.contains(&(u, *v)) || edges.contains(&(*v, u))
+    let status = do par::alli(tree) {
+        let edges = copy edges;
+        fn~(+u: uint, v: &i64) -> bool {
+            let u = u as node_id;
+            if *v == -1i64 || u == root {
+                true
+            } else {
+                edges.contains(&(u, *v)) || edges.contains(&(*v, u))
+            }
         }
     };
 
diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs
index 20dcb079597..8e5ab45bae8 100644
--- a/src/test/bench/task-perf-alloc-unwind.rs
+++ b/src/test/bench/task-perf-alloc-unwind.rs
@@ -15,6 +15,10 @@ extern mod std;
 use std::list::{List, Cons, Nil};
 use std::time::precise_time_s;
 
+enum UniqueList {
+    ULNil, ULCons(~UniqueList)
+}
+
 fn main() {
     let (repeat, depth) = if os::getenv(~"RUST_BENCH").is_some() {
         (50, 1000)
@@ -43,7 +47,6 @@ struct State {
     box: @nillist,
     unique: ~nillist,
     fn_box: fn@() -> @nillist,
-    fn_unique: fn~() -> ~nillist,
     tuple: (@nillist, ~nillist),
     vec: ~[@nillist],
     res: r
@@ -76,7 +79,6 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
                 box: @Nil,
                 unique: ~Nil,
                 fn_box: fn@() -> @nillist { @Nil::<()> },
-                fn_unique: fn~() -> ~nillist { ~Nil::<()> },
                 tuple: (@Nil, ~Nil),
                 vec: ~[@Nil],
                 res: r(@Nil)
@@ -84,14 +86,11 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
           }
           Some(st) => {
             let fn_box = st.fn_box;
-            let fn_unique = copy st.fn_unique;
 
             State {
                 box: @Cons((), st.box),
                 unique: ~Cons((), @*st.unique),
                 fn_box: fn@() -> @nillist { @Cons((), fn_box()) },
-                fn_unique: fn~(move fn_unique) -> ~nillist
-                    { ~Cons((), @*fn_unique()) },
                 tuple: (@Cons((), st.tuple.first()),
                         ~Cons((), @*st.tuple.second())),
                 vec: st.vec + ~[@Cons((), st.vec.last())],