]>
git.proxmox.com Git - rustc.git/blob - src/test/bench/task-perf-alloc-unwind.rs
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(box_syntax, duration, duration_span, collections)]
15 use std
::time
::Duration
;
19 Nil
, Cons(T
, Box
<List
<T
>>)
23 let (repeat
, depth
) = if env
::var_os("RUST_BENCH").is_some() {
32 fn run(repeat
: isize, depth
: isize) {
34 let dur
= Duration
::span(|| {
35 let _
= thread
::spawn(move|| {
36 recurse_or_panic(depth
, None
)
39 println
!("iter: {}", dur
);
43 type nillist
= List
<()>;
45 // Filled with things that have to be unwound
49 vec
: Vec
<Box
<nillist
>>,
61 fn r(l
: Box
<nillist
>) -> r
{
67 fn recurse_or_panic(depth
: isize, st
: Option
<State
>) {
71 let depth
= depth
- 1;
76 unique
: box List
::Nil
,
77 vec
: vec
!(box List
::Nil
),
82 let mut v
= st
.vec
.clone();
83 v
.push_all(&[box List
::Cons((), st
.vec
.last().unwrap().clone())]);
85 unique
: box List
::Cons((), box *st
.unique
),
87 res
: r(box List
::Cons((), st
.res
._l
.clone())),
92 recurse_or_panic(depth
, Some(st
));