1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #[feature(managed_boxes)];
13 extern crate collections;
16 use collections::list::{List, Cons, Nil};
17 use time::precise_time_s;
22 ULNil, ULCons(~UniqueList)
26 let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
35 fn run(repeat: int, depth: int) {
36 for _ in range(0, repeat) {
37 println!("starting {:.4f}", precise_time_s());
39 recurse_or_fail(depth, None)
41 println!("stopping {:.4f}", precise_time_s());
45 type nillist = List<()>;
47 // Filled with things that have to be unwound
52 tuple: (@nillist, ~nillist),
66 fn r(l: @nillist) -> r {
72 fn recurse_or_fail(depth: int, st: Option<State>) {
74 println!("unwinding {:.4f}", precise_time_s());
77 let depth = depth - 1;
91 managed: @Cons((), st.managed),
92 unique: ~Cons((), @*st.unique),
93 tuple: (@Cons((), st.tuple.ref0().clone()),
94 ~Cons((), @*st.tuple.ref1().clone())),
95 vec: st.vec + &[@Cons((), *st.vec.last().unwrap())],
96 res: r(@Cons((), st.res._l))
101 recurse_or_fail(depth, Some(st));