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(unsafe_destructor)]
14 use std::thread::Thread;
15 use std::time::Duration;
19 Nil, Cons(T, Box<List<T>>)
23 ULNil, ULCons(Box<UniqueList>)
27 let (repeat, depth) = if os::getenv("RUST_BENCH").is_some() {
36 fn run(repeat: int, depth: int) {
37 for _ in range(0, repeat) {
38 let dur = Duration::span(|| {
39 let _ = Thread::spawn(move|| {
40 recurse_or_panic(depth, None)
43 println!("iter: {}", dur);
47 type nillist = List<()>;
49 // Filled with things that have to be unwound
53 vec: Vec<Box<nillist>>,
66 fn r(l: Box<nillist>) -> r {
72 fn recurse_or_panic(depth: int, st: Option<State>) {
76 let depth = depth - 1;
81 unique: box List::Nil,
82 vec: vec!(box List::Nil),
87 let mut v = st.vec.clone();
88 v.push_all(&[box List::Cons((), st.vec.last().unwrap().clone())]);
90 unique: box List::Cons((), box *st.unique),
92 res: r(box List::Cons((), st.res._l.clone())),
97 recurse_or_panic(depth, Some(st));