2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2011-10-20 20:34:04 -07:00
|
|
|
fn f(&&n: uint) {
|
2012-03-22 08:39:41 -07:00
|
|
|
let mut i = 0u;
|
2011-08-20 13:02:26 -07:00
|
|
|
while i < n {
|
2012-06-30 16:19:07 -07:00
|
|
|
task::try(|| g() );
|
2011-09-02 15:34:58 -07:00
|
|
|
i += 1u;
|
|
|
|
}
|
2011-07-29 22:09:25 -07:00
|
|
|
}
|
|
|
|
|
2012-01-06 22:02:05 -08:00
|
|
|
fn g() { }
|
2011-07-29 22:09:25 -07:00
|
|
|
|
2012-10-03 19:16:27 -07:00
|
|
|
fn main() {
|
|
|
|
let args = os::args();
|
2012-07-13 22:57:48 -07:00
|
|
|
let args = if os::getenv(~"RUST_BENCH").is_some() {
|
|
|
|
~[~"", ~"400"]
|
2012-05-23 22:53:50 -07:00
|
|
|
} else if args.len() <= 1u {
|
2012-07-13 22:57:48 -07:00
|
|
|
~[~"", ~"10"]
|
2012-05-23 22:53:50 -07:00
|
|
|
} else {
|
|
|
|
args
|
|
|
|
};
|
|
|
|
let n = uint::from_str(args[1]).get();
|
2012-03-22 08:39:41 -07:00
|
|
|
let mut i = 0u;
|
2012-06-30 16:19:07 -07:00
|
|
|
while i < n { task::spawn(|| f(n) ); i += 1u; }
|
2011-08-15 11:34:12 -07:00
|
|
|
}
|