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.6 by jsr166, Sat Dec 31 22:17:40 2016 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import java.util.concurrent.*;
8 < import java.util.concurrent.locks.*;
9 < import java.util.*;
7 > import java.util.Collections;
8 > import java.util.concurrent.Callable;
9 > import java.util.concurrent.ExecutorService;
10 > import java.util.concurrent.Executors;
11 > import java.util.concurrent.TimeUnit;
12 > import java.util.concurrent.locks.ReentrantLock;
13  
14   /**
15   * Measures repeated futile timed attempts to acquire a ReentrantLock.
# Line 51 | Line 54 | public final class FutileTimedTryLockLoo
54                      continue nextArg;
55                  }
56              }
57 <            throw new Error("Usage: FutileTimedTryLockLoops minThreads=n maxThreads=n Threads=n nanos=n iters=n");
57 >            throw new Error("Usage: FutileTimedTryLockLoops minThreads=n maxThreads=n threads=n nanos=n iters=n");
58          }
59          final ExecutorService pool = Executors.newCachedThreadPool();
60          final ReentrantLock lock = new ReentrantLock();
# Line 59 | Line 62 | public final class FutileTimedTryLockLoo
62          lock.lock();
63  
64          for (int i = minThreads; i <= maxThreads; i += (i+1) >>> 1) {
65 +            // warmup
66 +            if (i == minThreads)
67 +                pool.invokeAll(Collections.nCopies(i, task));
68 +
69              long startTime = System.nanoTime();
70              pool.invokeAll(Collections.nCopies(i, task));
71              long elapsed = System.nanoTime() - startTime;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines