ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/DynamicLeftSpineFib.java
(Generate patch)

Comparing jsr166/src/test/loops/DynamicLeftSpineFib.java (file contents):
Revision 1.1 by dl, Fri Oct 23 19:57:06 2009 UTC vs.
Revision 1.5 by jsr166, Mon Nov 2 23:42:46 2009 UTC

# Line 1 | Line 1
1 + /*
2 + * Written by Doug Lea with assistance from members of JCP JSR-166
3 + * Expert Group and released to the public domain, as explained at
4 + * http://creativecommons.org/licenses/publicdomain
5 + */
6 +
7   //import jsr166y.*;
8   import java.util.*;
9   import java.util.concurrent.*;
# Line 6 | Line 12 | public final class DynamicLeftSpineFib e
12  
13      // Performance-tuning constant:
14      static long lastStealCount;
15 <  
15 >
16      public static void main(String[] args) throws Exception {
17          int procs = 0;
18          int num = 43;
# Line 17 | Line 23 | public final class DynamicLeftSpineFib e
23                  num = Integer.parseInt(args[1]);
24          }
25          catch (Exception e) {
26 <            System.out.println("Usage: java DynamicLeftSpineFib <threads> <number> [<sequntialThreshold>]");
26 >            System.out.println("Usage: java DynamicLeftSpineFib <threads> <number> [<sequentialThreshold>]");
27              return;
28          }
29  
30 <        
30 >
31          for (int reps = 0; reps < 2; ++reps) {
32 <            ForkJoinPool g = procs == 0? new ForkJoinPool() :
32 >            ForkJoinPool g = (procs == 0) ?
33 >                new ForkJoinPool() :
34                  new ForkJoinPool(procs);
35              lastStealCount = g.getStealCount();
36              for (int i = 0; i < 10; ++i) {
# Line 57 | Line 64 | public final class DynamicLeftSpineFib e
64      int number;
65      DynamicLeftSpineFib next;
66  
67 <    DynamicLeftSpineFib(int n, DynamicLeftSpineFib nxt) {
68 <        number = n; next = nxt;
67 >    DynamicLeftSpineFib(int n, DynamicLeftSpineFib nxt) {
68 >        number = n; next = nxt;
69      }
70  
71      int getAnswer() {
# Line 85 | Line 92 | public final class DynamicLeftSpineFib e
92  
93      // Sequential version for arguments less than threshold
94      static int seqFib(int n) {
95 <        if (n <= 1)
95 >        if (n <= 1)
96              return n;
97 <        else
97 >        else
98              return seqFib(n-1) + seqFib(n-2);
99      }
93    
94 }
100  
101 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines