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

Comparing jsr166/src/test/loops/DenseMapMicroBenchmark.java (file contents):
Revision 1.5 by jsr166, Wed Sep 1 07:20:36 2010 UTC vs.
Revision 1.10 by jsr166, Sun Oct 23 03:03:23 2016 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 47 | Line 47 | public class DenseMapMicroBenchmark {
47          time0(NANOS_PER_JOB, jobs);
48  
49          final String nameHeader = "Method";
50 <        int nameWidth  = nameHeader.length();
50 >        int nameWidth = nameHeader.length();
51          for (Job job : jobs)
52              nameWidth = Math.max(nameWidth, job.name().length());
53  
54          final int itemsPerTest = SIZE * OPS_PER_ITER * ITERS_PER_TEST;
55          final String timeHeader = "Nanos/item";
56 <        int timeWidth  = timeHeader.length();
56 >        int timeWidth = timeHeader.length();
57          final String ratioHeader = "Ratio";
58          int ratioWidth = ratioHeader.length();
59          String format = String.format("%%-%ds %%%dd %%.3f%%n",
# Line 70 | Line 70 | public class DenseMapMicroBenchmark {
70          }
71      }
72  
73
73      static Long[] toLongs(Integer[] ints) {
74          Long[] longs = new Long[ints.length];
75          for (int i = 0; i < ints.length; i++)
# Line 100 | Line 99 | public class DenseMapMicroBenchmark {
99          return doubles;
100      }
101  
103
102      static final class Hasher extends Job {
103          final Object[] elts;
104 <        final Class mapClass;
104 >        final Class<?> mapClass;
105          volatile int matches;
106 <        Hasher(String name, Object[] elts, Class mapClass) {
106 >        Hasher(String name, Object[] elts, Class<?> mapClass) {
107              super(name);
108              this.elts = elts;
109              this.mapClass = mapClass;
110          }
111          public void work() {
112 <            Map m = null;
112 >            final Map m;
113              try {
114 <                m = (Map) mapClass.newInstance();
114 >                m = (Map) mapClass.getConstructor().newInstance();
115              } catch (Exception e) {
116                  throw new RuntimeException("Can't instantiate " + mapClass + ": " + e);
117              }
# Line 151 | Line 149 | public class DenseMapMicroBenchmark {
149      }
150  
151      public static void main(String[] args) throws Throwable {
152 <        Class mc = java.util.HashMap.class;
152 >        Class<?> mc = java.util.HashMap.class;
153          if (args.length > 0)
154              mc = Class.forName(args[0]);
155          if (args.length > 1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines