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.
15 use extra::list::{List, Cons, Nil};
16 use extra::time::precise_time_s;
21 ULNil, ULCons(~UniqueList)
25 let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
34 fn run(repeat: int, depth: int) {
35 do (repeat as uint).times {
36 info!("starting %.4f", precise_time_s());
38 recurse_or_fail(depth, None)
40 info!("stopping %.4f", precise_time_s());
44 type nillist = List<()>;
46 // Filled with things that have to be unwound
51 fn_box: @fn() -> @nillist,
52 tuple: (@nillist, ~nillist),
66 fn r(l: @nillist) -> r {
72 fn recurse_or_fail(depth: int, st: Option<State>) {
74 info!("unwinding %.4f", precise_time_s());
77 let depth = depth - 1;
84 fn_box: || @Nil::<()>,
91 let fn_box = st.fn_box;
94 box: @Cons((), st.box),
95 unique: ~Cons((), @*st.unique),
96 fn_box: || @Cons((), fn_box()),
97 tuple: (@Cons((), st.tuple.first()),
98 ~Cons((), @*st.tuple.second())),
99 vec: st.vec + &[@Cons((), *st.vec.last())],
100 res: r(@Cons((), st.res._l))
105 recurse_or_fail(depth, Some(st));