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

Comparing jsr166/src/test/loops/MapLoops.java (file contents):
Revision 1.5 by jsr166, Mon Nov 2 23:42:46 2009 UTC vs.
Revision 1.11 by jsr166, Thu Dec 18 18:43:22 2014 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
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   import java.util.*;
# Line 20 | Line 20 | public class MapLoops {
20  
21      public static void main(String[] args) throws Exception {
22  
23 <        Class mapClass = null;
23 >        Class<?> mapClass = null;
24          if (args.length > 0) {
25              try {
26                  mapClass = Class.forName(args[0]);
# Line 58 | Line 58 | public class MapLoops {
58          System.out.print(" ops: " + nops);
59          System.out.println();
60  
61        int k = 1;
61          int warmups = 2;
62 <        for (int i = 1; i <= maxThreads;) {
62 >        for (int k = 1, i = 1; i <= maxThreads;) {
63              Thread.sleep(100);
64              test(i, nkeys, mapClass);
65              if (warmups > 0)
# Line 97 | Line 96 | public class MapLoops {
96          }
97      }
98  
99 <    static void test(int i, int nkeys, Class mapClass) throws Exception {
99 >    static void test(int i, int nkeys, Class<?> mapClass) throws Exception {
100          System.out.print("Threads: " + i + "\t:");
101          Map<Integer, Integer> map = (Map<Integer,Integer>)mapClass.newInstance();
102          Integer[] key = makeKeys(nkeys);
# Line 112 | Line 111 | public class MapLoops {
111          barrier.await();
112          barrier.await();
113          long time = timer.getTime();
114 <        long tpo = time / (i * (long)nops);
114 >        long tpo = time / (i * (long) nops);
115          System.out.print(LoopHelpers.rightJustify(tpo) + " ns per op");
116 <        double secs = (double)(time) / 1000000000.0;
116 >        double secs = (double) time / 1000000000.0;
117          System.out.println("\t " + secs + "s run time");
118          map.clear();
119      }
# Line 127 | Line 126 | public class MapLoops {
126          int position;
127          int total;
128  
129 <        Runner(int id, Map<Integer,Integer> map, Integer[] key,  CyclicBarrier barrier) {
129 >        Runner(int id, Map<Integer,Integer> map, Integer[] key, CyclicBarrier barrier) {
130              this.map = map;
131              this.key = key;
132              this.barrier = barrier;
# Line 137 | Line 136 | public class MapLoops {
136          }
137  
138          int step() {
139 <            // random-walk around key positions,  bunching accesses
139 >            // random-walk around key positions, bunching accesses
140              int r = rng.next();
141              position += (r & 7) - 3;
142              while (position >= key.length) position -= key.length;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines