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.8 by jsr166, Thu Apr 14 23:16:10 2011 UTC vs.
Revision 1.15 by jsr166, Sun Oct 23 02:21:56 2016 UTC

# Line 3 | Line 3
3   * as explained at http://creativecommons.org/publicdomain/zero/1.0/.
4   */
5  
6 import java.util.*;
6   import java.io.*;
7 + import java.util.*;
8  
9   /**
10   * Interface-based Deque tester.  This test currently makes three
# Line 22 | Line 22 | public class DequeBash {
22      static int nextHead = -1;
23      static int size() { return nextTail - nextHead - 1; }
24  
25 <
26 <    static int random(int bound) {
27 <        int x = seed;
28 <        int t = (x % 127773) * 16807 - (x / 127773) * 2836;
29 <        seed = (t > 0) ? t : t + 0x7fffffff;
30 <        return (t & 0x7fffffff) % bound;
25 >    static int random() {
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() {
33 <        int x = seed;
35 <        int t = (x % 127773) * 16807 - (x / 127773) * 2836;
36 <        seed = (t > 0) ? t : t + 0x7fffffff;
37 <        return (t & 0x7fffffff);
32 >    static int random(int bound) {
33 >        return (random() & 0x7fffffff) % bound;
34      }
35  
36 <    public static void main(String args[]) throws Exception {
36 >    public static void main(String[] args) throws Exception {
37          Class<?> cls = Class.forName(args[0]);
38 <        int n = 1000000;
39 <
44 <        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();
41 >            Deque<Integer> deque =
42 >                (Deque<Integer>) cls.getConstructor().newInstance();
43              nextTail =  0;
44              nextHead = -1;
45 <            long start = System.nanoTime();
50 <            mainTest(deque, n);
51 <            long end = System.nanoTime();
52 <            long elapsedTimeMillis = (end - start) / (1000L * 1000L);
53 <            System.out.printf("Time: %d ms%n", elapsedTimeMillis);
45 >            mainTest(deque, (random() & ((1 << 20) - 1)));
46              if (deque.isEmpty()) System.out.print(" ");
47 +            if ((j % 10) == 9) System.out.print(".");
48          }
49 +        long now = System.nanoTime();
50 +        long elapsedTimeMillis = (now - startTime) / (1000L * 1000L);
51 +        System.out.printf("\ntotal time %d ms\n", elapsedTimeMillis);
52  
53      }
54  
# Line 80 | Line 76 | public class DequeBash {
76              // Test fancy removal stuff once in a blue moon
77              if ((i & 8191) == 0)
78                  testRemove(deque);
83
79          }
80  
81          // Stupid tests for clear, toString
# Line 154 | Line 149 | public class DequeBash {
149                                  deque.getLast() + " expecting " + (nextTail - 1));
150      }
151  
157
152      static void randomOp(Deque<Integer> deque) throws Exception {
153  
154          // Perform a random operation
# Line 231 | Line 225 | public class DequeBash {
225          }
226      }
227  
234
228      private static void testEqual(Deque<Integer> d1, Deque<Integer> d2)
229          throws Exception
230      {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines