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

Comparing jsr166/src/test/loops/UnboundedQueueFillEmptyLoops.java (file contents):
Revision 1.11 by jsr166, Wed Dec 31 17:00:58 2014 UTC vs.
Revision 1.15 by jsr166, Sat Oct 29 20:48:16 2016 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import java.util.*;
8 < import java.util.concurrent.*;
9 < import java.util.concurrent.atomic.*;
10 < import java.util.concurrent.locks.*;
7 > import java.util.Random;
8 > import java.util.Queue;
9  
10   public class UnboundedQueueFillEmptyLoops {
11 <    static int maxSize = 10000;
11 >    static int maxSize = 50000;
12      static Random rng = new Random(3153122688L);
13      static volatile int total;
14      static Integer[] numbers;
15  
16      public static void main(String[] args) throws Exception {
17 <        Class<?> klass = null;
18 <        if (args.length > 0) {
19 <            try {
20 <                klass = Class.forName(args[0]);
23 <            } catch (ClassNotFoundException e) {
24 <                throw new RuntimeException("Class " + args[0] + " not found.");
25 <            }
17 >        if (args.length < 1) {
18 >            System.out.printf(
19 >                "Usage: UnboundedQueueFillEmptyLoops className [maxSize]%n");
20 >            System.exit(1);
21          }
22  
23 <        if (args.length > 2)
24 <            maxSize = Integer.parseInt(args[2]);
23 >        final Class<?> klass;
24 >        try {
25 >            klass = Class.forName(args[0]);
26 >        } catch (ClassNotFoundException e) {
27 >            throw new RuntimeException("Class " + args[0] + " not found.");
28 >        }
29 >
30 >        if (args.length > 1)
31 >            maxSize = Integer.parseInt(args[1]);
32  
33 <        System.out.print("Class: " + klass.getName());
32 <        System.out.println(" size: " + maxSize);
33 >        System.out.printf("Class: %s size: %d%n", klass.getName(), maxSize);
34  
35          numbers = new Integer[maxSize];
36          for (int i = 0; i < maxSize; ++i)
# Line 45 | Line 46 | public class UnboundedQueueFillEmptyLoop
46      }
47  
48      static void oneRun(Class<?> klass, int n) throws Exception {
49 <        Queue<Integer> q = (Queue<Integer>) klass.newInstance();
49 >        Queue<Integer> q =
50 >            (Queue<Integer>) klass.getConstructor().newInstance();
51          int sum = total;
52          int m = rng.nextInt(numbers.length);
53          long startTime = System.nanoTime();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines