jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java
changeset 36233 f85ed703cf7e
parent 34347 4a17f9e90a0f
equal deleted inserted replaced
36232:7a020ad42ac0 36233:f85ed703cf7e
    39  * though elements of "key" array. On each iteration, it checks if
    39  * though elements of "key" array. On each iteration, it checks if
    40  * table includes key.  If absent, with probability pinsert it
    40  * table includes key.  If absent, with probability pinsert it
    41  * inserts it, and if present, with probability premove it removes
    41  * inserts it, and if present, with probability premove it removes
    42  * it.  (pinsert and premove are expressed as percentages to simplify
    42  * it.  (pinsert and premove are expressed as percentages to simplify
    43  * parsing from command line.)
    43  * parsing from command line.)
       
    44  * @library /lib/testlibrary/
    44  */
    45  */
    45 
    46 
    46 import static java.util.concurrent.TimeUnit.SECONDS;
    47 import static java.util.concurrent.TimeUnit.MILLISECONDS;
    47 
    48 
    48 import java.util.Map;
    49 import java.util.Map;
    49 import java.util.SplittableRandom;
    50 import java.util.SplittableRandom;
    50 import java.util.concurrent.CyclicBarrier;
    51 import java.util.concurrent.CyclicBarrier;
    51 import java.util.concurrent.ExecutorService;
    52 import java.util.concurrent.ExecutorService;
    52 import java.util.concurrent.Executors;
    53 import java.util.concurrent.Executors;
       
    54 import jdk.testlibrary.Utils;
    53 
    55 
    54 public class MapLoops {
    56 public class MapLoops {
       
    57     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
    55     static final int NKEYS = 100000;
    58     static final int NKEYS = 100000;
    56     static int pinsert     = 60;
    59     static int pinsert     = 60;
    57     static int premove     = 2;
    60     static int premove     = 2;
    58     static int maxThreads  = 5;
    61     static int maxThreads  = 5;
    59     static int nops        = 10000; // 1000000
    62     static int nops        = 10000; // 1000000
   123             double secs = (double)(time) / 1000000000.0;
   126             double secs = (double)(time) / 1000000000.0;
   124             System.out.println("\t " + secs + "s run time");
   127             System.out.println("\t " + secs + "s run time");
   125             map.clear();
   128             map.clear();
   126         }
   129         }
   127         pool.shutdown();
   130         pool.shutdown();
   128         if (! pool.awaitTermination(10L, SECONDS))
   131         if (! pool.awaitTermination(LONG_DELAY_MS, MILLISECONDS))
   129             throw new Error();
   132             throw new Error();
   130     }
   133     }
   131 
   134 
   132     static class Runner implements Runnable {
   135     static class Runner implements Runnable {
   133         final Map<Integer,Integer> map;
   136         final Map<Integer,Integer> map;