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

Comparing jsr166/src/test/loops/DequeBash.java (file contents):
Revision 1.12 by jsr166, Mon Aug 10 03:13:33 2015 UTC vs.
Revision 1.13 by dl, Sat Oct 22 19:30:48 2016 UTC

# Line 22 | Line 22 | public class DequeBash {
22      static int nextHead = -1;
23      static int size() { return nextTail - nextHead - 1; }
24  
25    static int random(int bound) {
26        int x = seed;
27        int t = (x % 127773) * 16807 - (x / 127773) * 2836;
28        seed = (t > 0) ? t : t + 0x7fffffff;
29        return (t & 0x7fffffff) % bound;
30    }
31
25      static int random() {
26 <        int x = seed;
27 <        int t = (x % 127773) * 16807 - (x / 127773) * 2836;
28 <        seed = (t > 0) ? t : t + 0x7fffffff;
29 <        return (t & 0x7fffffff);
26 >        int r = seed;
27 >        r ^= r << 13;   // xorshift
28 >        r ^= r >>> 17;
29 >        return seed = r ^ (r << 5);
30      }
31  
32 +    static int random(int bound) {
33 +        return (random() & 0x7fffffff) % bound;
34 +    }
35 +    
36      public static void main(String[] args) throws Exception {
37          Class<?> cls = Class.forName(args[0]);
38 <        int n = 1000000;
39 <
43 <        for (int j = 0; j < 3; ++j) {
38 >        long startTime = System.nanoTime();
39 >        for (int j = 0; j < 200; ++j) {
40              @SuppressWarnings("unchecked")
41              Deque<Integer> deque = (Deque<Integer>) cls.newInstance();
42              nextTail =  0;
43              nextHead = -1;
44 <            long start = System.nanoTime();
49 <            mainTest(deque, n);
50 <            long end = System.nanoTime();
51 <            long elapsedTimeMillis = (end - start) / (1000L * 1000L);
52 <            System.out.printf("Time: %d ms%n", elapsedTimeMillis);
44 >            mainTest(deque, (random() & ((1 << 20) - 1)));
45              if (deque.isEmpty()) System.out.print(" ");
46 +            if ((j % 10) == 9) System.out.print(".");
47          }
48 +        long now = System.nanoTime();
49 +        long elapsedTimeMillis = (now - startTime) / (1000L * 1000L);
50 +        System.out.printf("\ntotal time %d ms\n", elapsedTimeMillis);
51 +        
52      }
53  
54      static void mainTest(Deque<Integer> deque, int n) throws Exception {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines