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 time::precise_time_s;
23 Nil, Cons(T, @List<T>)
27 ULNil, ULCons(Box<UniqueList>)
31 let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
40 fn run(repeat: int, depth: int) {
41 for _ in range(0, repeat) {
42 println!("starting {:.4f}", precise_time_s());
44 recurse_or_fail(depth, None)
46 println!("stopping {:.4f}", precise_time_s());
50 type nillist = List<()>;
52 // Filled with things that have to be unwound
57 tuple: (@nillist, Box<nillist>),
71 fn r(l: @nillist) -> r {
77 fn recurse_or_fail(depth: int, st: Option<State>) {
79 println!("unwinding {:.4f}", precise_time_s());
82 let depth = depth - 1;
89 tuple: (@Nil, box Nil),
96 managed: @Cons((), st.managed),
97 unique: box Cons((), @*st.unique),
98 tuple: (@Cons((), st.tuple.ref0().clone()),
99 box Cons((), @*st.tuple.ref1().clone())),
100 vec: st.vec.clone().append(&[@Cons((), *st.vec.last().unwrap())]),
101 res: r(@Cons((), st.res._l))
106 recurse_or_fail(depth, Some(st));