File tree 1 file changed +32
-0
lines changed 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Test performance of a task "spawn ladder", in which children task have many
2
+ // many ancestor taskgroups, but with only a few such groups alive at a time.
3
+ // Each child task has to enlist as a descendant in each of its ancestor
4
+ // groups, but that shouldn't have to happen for already-dead groups.
5
+ //
6
+ // The filename is a reference; google it in quotes.
7
+
8
+ fn child_generation ( gens_left : uint ) {
9
+ // This used to be O(n^2) in the number of generations that ever existed.
10
+ // With this code, only as many generations are alive at a time as tasks
11
+ // alive at a time,
12
+ do task:: spawn_supervised {
13
+ if gens_left & 1 == 1 {
14
+ task:: yield ( ) ; // shake things up a bit
15
+ }
16
+ if gens_left > 0 {
17
+ child_generation ( gens_left - 1 ) ; // recurse
18
+ }
19
+ }
20
+ }
21
+
22
+ fn main ( args : ~[ ~str ] ) {
23
+ let args = if os:: getenv ( ~"RUST_BENCH ") . is_some ( ) {
24
+ ~[ ~"", ~"100000 "]
25
+ } else if args. len ( ) <= 1 u {
26
+ ~[ ~"", ~"100 "]
27
+ } else {
28
+ copy args
29
+ } ;
30
+
31
+ child_generation ( uint:: from_str ( args[ 1 ] ) . get ( ) ) ;
32
+ }
You can’t perform that action at this time.
0 commit comments