Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 71 lines (57 sloc) 2.261 kb
f62460c Florian Hahn Change `xfail` directives in compiletests to `ignore`, closes #11363
fhahn authored
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
d1affff Graydon Hoare Reliciense makefiles and testsuite. Yup.
graydon authored
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
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.
10
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
11 // Test for concurrent tasks
12
f62460c Florian Hahn Change `xfail` directives in compiletests to `ignore`, closes #11363
fhahn authored
13 // ignore-test OOM on linux-32 without opts
303d7bf Brian Anderson test: xfail bench/task-perf-one-million. OOM on 32-bit linux w/o opts
brson authored
14
206ab89 Patrick Walton librustc: Stop reexporting the standard modules from prelude.
pcwalton authored
15 use std::os;
16 use std::task;
17 use std::uint;
ce62032 Daniel Micay rename std::vec -> std::slice
thestinger authored
18 use std::slice;
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
19
7858065 Alex Crichton std: Rename Chan/Port types and constructor
alexcrichton authored
20 fn calc(children: uint, parent_wait_chan: &Sender<Sender<Sender<int>>>) {
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
21
579eb24 Patrick Walton test: Automatically remove all `~[T]` from tests.
pcwalton authored
22 let wait_ports: Vec<Reciever<Sender<Sender<int>>>> = vec::from_fn(children, |_| {
7858065 Alex Crichton std: Rename Chan/Port types and constructor
alexcrichton authored
23 let (wait_port, wait_chan) = stream::<Sender<Sender<int>>>();
3dbc1c3 Scott Lawrence Remove do keyword from test/
bytbox authored
24 task::spawn(proc() {
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
25 calc(children / 2, &wait_chan);
3dbc1c3 Scott Lawrence Remove do keyword from test/
bytbox authored
26 });
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
27 wait_port
38efa17 Patrick Walton test: Remove all remaining non-procedure uses of `do`.
pcwalton authored
28 });
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
29
579eb24 Patrick Walton test: Automatically remove all `~[T]` from tests.
pcwalton authored
30 let child_start_chans: Vec<Sender<Sender<int>>> =
fc525ee Aaron Turon Fallout from renaming
aturon authored
31 wait_ports.into_iter().map(|port| port.recv()).collect();
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
32
7858065 Alex Crichton std: Rename Chan/Port types and constructor
alexcrichton authored
33 let (start_port, start_chan) = stream::<Sender<int>>();
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
34 parent_wait_chan.send(start_chan);
7858065 Alex Crichton std: Rename Chan/Port types and constructor
alexcrichton authored
35 let parent_result_chan: Sender<int> = start_port.recv();
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
36
579eb24 Patrick Walton test: Automatically remove all `~[T]` from tests.
pcwalton authored
37 let child_sum_ports: Vec<Reciever<int>> =
fc525ee Aaron Turon Fallout from renaming
aturon authored
38 child_start_chans.into_iter().map(|child_start_chan| {
eee6775 Huon Wilson Implement consuming iterators for ~[], remove vec::{consume, consume_rev...
huonw authored
39 let (child_sum_port, child_sum_chan) = stream::<int>();
40 child_start_chan.send(child_sum_chan);
41 child_sum_port
38efa17 Patrick Walton test: Remove all remaining non-procedure uses of `do`.
pcwalton authored
42 }).collect();
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
43
fc525ee Aaron Turon Fallout from renaming
aturon authored
44 let sum = child_sum_ports.into_iter().fold(0, |sum, sum_port| sum + sum_port.recv() );
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
45
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
46 parent_result_chan.send(sum + 1);
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
47 }
48
edc317b Brian Anderson Remove arg vectors from main functions. Stop supporting them.
brson authored
49 fn main() {
50 let args = os::args();
4bcda71 Ben Blum Fix warnings in src/test/bench tests. Nobody will ever care.
bblum authored
51 let args = if os::getenv("RUST_BENCH").is_some() {
4348e23 Richo Healey std: Remove String's to_owned
richo authored
52 vec!("".to_string(), "30".to_string())
4fec4cd Brian Anderson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
53 } else if args.len() <= 1u {
4348e23 Richo Healey std: Remove String's to_owned
richo authored
54 vec!("".to_string(), "10".to_string())
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
55 } else {
4fec4cd Brian Anderson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
56 args
0438e6e Brian Anderson bench: Add a test for task concurrency
brson authored
57 };
4fec4cd Brian Anderson bench: Add hard mode to benchmarks. Activate with RUST_BENCH.
brson authored
58
69afce6 Corey Richardson Update task-perf-one-million
cmr authored
59 let children = from_str::<uint>(args[1]).unwrap();
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
60 let (wait_port, wait_chan) = stream();
3dbc1c3 Scott Lawrence Remove do keyword from test/
bytbox authored
61 task::spawn(proc() {
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
62 calc(children, &wait_chan);
3dbc1c3 Scott Lawrence Remove do keyword from test/
bytbox authored
63 });
02e907b Brian Anderson Remove oldcomm from the test suite
brson authored
64
65 let start_chan = wait_port.recv();
66 let (sum_port, sum_chan) = stream::<int>();
67 start_chan.send(sum_chan);
68 let sum = sum_port.recv();
cc6ec8d Alex Crichton log: Introduce liblog, the old std::logging
alexcrichton authored
69 println!("How many tasks? {} tasks.", sum);
329eca6 Michael J. Sullivan Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
msullivan authored
70 }
Something went wrong with that request. Please try again.