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

Comparing jsr166/src/test/loops/FutileTimedTryLockLoops.java (file contents):
Revision 1.1 by jsr166, Mon Dec 22 06:29:44 2014 UTC vs.
Revision 1.4 by jsr166, Mon Jan 26 17:40:39 2015 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.locks.*;
9 import java.util.*;
10  
11   /**
12   * Measures repeated futile timed attempts to acquire a ReentrantLock.
# Line 51 | Line 51 | public final class FutileTimedTryLockLoo
51                      continue nextArg;
52                  }
53              }
54 <            throw new Error("Usage: FutileTimedTryLockLoops minThreads=n maxThreads=n Threads=n nanos=n iters=n");
54 >            throw new Error("Usage: FutileTimedTryLockLoops minThreads=n maxThreads=n threads=n nanos=n iters=n");
55          }
56          final ExecutorService pool = Executors.newCachedThreadPool();
57          final ReentrantLock lock = new ReentrantLock();
# Line 59 | Line 59 | public final class FutileTimedTryLockLoo
59          lock.lock();
60  
61          for (int i = minThreads; i <= maxThreads; i += (i+1) >>> 1) {
62 +            // warmup
63 +            if (i == minThreads)
64 +                pool.invokeAll(Collections.nCopies(i, task));
65 +
66              long startTime = System.nanoTime();
67              pool.invokeAll(Collections.nCopies(i, task));
68              long elapsed = System.nanoTime() - startTime;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines