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

Comparing jsr166/src/test/extra166y/LongMapReduceDemo.java (file contents):
Revision 1.1 by dl, Sun Nov 1 22:00:35 2009 UTC vs.
Revision 1.2 by jsr166, Mon Nov 16 04:16:43 2009 UTC

# Line 17 | Line 17 | public class LongMapReduceDemo {
17      /**
18       * Sequential version, for performance comparison
19       */
20 <    static long seqMapReduce(long[] array,
20 >    static long seqMapReduce(long[] array,
21                              LongOp mapper,
22                              LongReducer reducer,
23                              long base) {
24          long n = array.length;
25          long x = base;
26 <        for (int i = 0; i < n; ++i)
26 >        for (int i = 0; i < n; ++i)
27              x = reducer.op(x, mapper.op(array[i]));
28          return x;
29      }
# Line 32 | Line 32 | public class LongMapReduceDemo {
32      static final class GetNext implements LongOp {
33          public long op(long seed) {
34              long x = seed;
35 <            x ^= x << 13;
36 <            x ^= x >>> 7;
35 >            x ^= x << 13;
36 >            x ^= x >>> 7;
37              x ^= (x << 17);
38              return x;
39          }
# Line 52 | Line 52 | public class LongMapReduceDemo {
52          int n = 1 << 18;
53          int reps = 1 << 8;
54          long[] array = new long[n];
55 <        for (int i = 0; i < n; ++i)
55 >        for (int i = 0; i < n; ++i)
56              array[i] = i + 1L;
57          ForkJoinPool fjp = new ForkJoinPool(1);
58          ParallelLongArray pa = ParallelLongArray.createUsingHandoff(array, fjp);
# Line 120 | Line 120 | public class LongMapReduceDemo {
120          for (int i = 0; i < array.length; ++i)
121              array[i] = s++;
122      }
123 <    
123 >
124   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines