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

Comparing jsr166/src/test/loops/MapMicroBenchmark.java (file contents):
Revision 1.10 by jsr166, Tue Mar 15 19:47:05 2011 UTC vs.
Revision 1.15 by jsr166, Thu Dec 18 18:43:22 2014 UTC

# Line 38 | Line 38 | import java.math.*;
38   public class MapMicroBenchmark {
39      static final String wordFile = "testwords.txt";
40  
41 <    static Class mapClass;
41 >    static Class<?> mapClass;
42      static boolean randomSearches = true;
43  
44      // Nanoseconds per run
# Line 147 | Line 147 | public class MapMicroBenchmark {
147      }
148  
149      static void runWork(Job[] jobs, int minIters, int maxIters, long timeLimit) throws Throwable {
150 <        for (int k = 0; k <  nsizes; ++k) {
150 >        for (int k = 0; k < nsizes; ++k) {
151              int len = sizes[k];
152              for (int i = 0; i < jobs.length; i++) {
153                  Thread.sleep(50);
# Line 160 | Line 160 | public class MapMicroBenchmark {
160  
161      // First warmup -- run only mixed job to discourage type specialization
162      static void warmup1(Job job) throws Throwable {
163 <        for (int k = 0; k <  nsizes; ++k)
163 >        for (int k = 0; k < nsizes; ++k)
164              job.work(sizes[k], 1, 1, 0);
165      }
166  
# Line 213 | Line 213 | public class MapMicroBenchmark {
213  
214      static final class Job {
215          final String name;
216 <        final Class elementClass;
216 >        final Class<?> elementClass;
217          long[] nanos = new long[nsizes];
218          final Object[] items;
219          Object[] searches;
220          volatile long checkSum;
221          volatile int lastSum;
222 <        Job(String name, Object[] items, Class elementClass) {
222 >        Job(String name, Object[] items, Class<?> elementClass) {
223              this.name = name;
224              this.items = items;
225              this.elementClass = elementClass;
# Line 334 | Line 334 | public class MapMicroBenchmark {
334                      if (m.put(x, x) == null)
335                          ++sum;
336                  }
337 +                /*  // uncomment to avoid calling clear()
338 +                for (int i = 0; i < len; ++i) {
339 +                    Object x = keys[i];
340 +                    m.remove(x);
341 +                }
342 +                */
343                  m.clear();
344                  sum += len - (quarter * 2);
345                  checkSum += sum ^ (sum << 12);
# Line 377 | Line 383 | public class MapMicroBenchmark {
383  
384      // plain array shuffle
385      static void shuffle(Object[] a, int size) {
386 <        for (int i= size; i>1; i--) {
386 >        for (int i = size; i > 1; i--) {
387              Object t = a[i-1];
388              int r = rng.nextInt(i);
389              a[i-1] = a[r];
# Line 438 | Line 444 | public class MapMicroBenchmark {
444  
445          BufferedInputStream in = new BufferedInputStream(fr);
446          int k = 0;
447 <        outer:while (k < n) {
447 >        outer: while (k < n) {
448              StringBuffer sb = new StringBuffer();
449              for (;;) {
450                  int c = in.read();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines