Skip to content

Commit 07ce364

Browse files
committed
---
yaml --- r: 13208 b: refs/heads/master c: 027e97b h: refs/heads/master v: v3
1 parent f45f6be commit 07ce364

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3ab738f4afae1dce2b65f969f80cfc597d95b16e
2+
refs/heads/master: 027e97b12961be16a293aa197561d6e59fa0a1f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// xfail-win32
2+
3+
use std;
4+
5+
import tuple::{first, second};
6+
import std::list::{list, cons, nil};
7+
import std::time::precise_time_s;
8+
9+
fn main() {
10+
let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
11+
(50, 1000)
12+
} else {
13+
(10, 10)
14+
};
15+
16+
run(repeat, depth);
17+
}
18+
19+
fn run(repeat: int, depth: int) {
20+
iter::repeat(repeat as uint) { ||
21+
#debug("starting %.4f", precise_time_s());
22+
task::try { ||
23+
recurse_or_fail(depth, none)
24+
};
25+
#debug("stopping %.4f", precise_time_s());
26+
}
27+
}
28+
29+
type nillist = list<()>;
30+
31+
// Filled with things that have to be unwound
32+
enum st {
33+
st_({
34+
box: @nillist,
35+
unique: ~nillist,
36+
fn_box: fn@() -> @nillist,
37+
fn_unique: fn~() -> ~nillist,
38+
tuple: (@nillist, ~nillist),
39+
vec: [@nillist],
40+
res: r
41+
})
42+
}
43+
44+
resource r(_l: @nillist) {
45+
}
46+
47+
fn recurse_or_fail(depth: int, st: option<st>) {
48+
if depth == 0 {
49+
#debug("unwinding %.4f", precise_time_s());
50+
fail;
51+
} else {
52+
let depth = depth - 1;
53+
54+
let st = alt st {
55+
none {
56+
st_({
57+
box: @nil,
58+
unique: ~nil,
59+
fn_box: fn@() -> @nillist { @nil::<()> },
60+
fn_unique: fn~() -> ~nillist { ~nil::<()> },
61+
tuple: (@nil, ~nil),
62+
vec: [@nil],
63+
res: r(@nil)
64+
})
65+
}
66+
some(st) {
67+
let fn_box = st.fn_box;
68+
let fn_unique = st.fn_unique;
69+
70+
st_({
71+
box: @cons((), st.box),
72+
unique: ~cons((), @*st.unique),
73+
fn_box: fn@() -> @nillist { @cons((), fn_box()) },
74+
fn_unique: fn~() -> ~nillist { ~cons((), @*fn_unique()) },
75+
tuple: (@cons((), first(st.tuple)),
76+
~cons((), @*second(st.tuple))),
77+
vec: st.vec + [@cons((), st.vec.last())],
78+
res: r(@cons((), *(st.res)))
79+
})
80+
}
81+
};
82+
83+
recurse_or_fail(depth, some(st));
84+
}
85+
}

0 commit comments

Comments
 (0)