< prev index next >

test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestOneArenaManyThreads.java

Print this page
rev 60811 : imported patch jep387-all.patch
rev 60812 : [mq]: diff1


  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 import java.util.concurrent.CyclicBarrier;
  27 
  28 import static java.lang.System.currentTimeMillis;
  29 
  30 public class MetaspaceTestOneArenaManyThreads extends MetaspaceTestWithThreads {
  31 
  32     // Several threads allocate from a single arena.
  33     // This mimicks several threads loading classes via the same class loader.
  34 
  35 
  36     public MetaspaceTestOneArenaManyThreads(MetaspaceTestContext context, long testAllocationCeiling, int numThreads, int seconds) {
  37         super(context, testAllocationCeiling, numThreads, seconds);
  38     }
  39 
  40     public void runTest() throws Exception {
  41 
  42         long t_start = currentTimeMillis();
  43         long t_stop = t_start + (seconds * 1000);
  44 
  45         // We create a single arena, and n threads which will allocate from that single arena.
  46 
  47         MetaspaceTestArena arena = context.createArena(RandomHelper.fiftyfifty(), testAllocationCeiling);
  48         CyclicBarrier gate = new CyclicBarrier(numThreads + 1);
  49 
  50         for (int i = 0; i < numThreads; i ++) {
  51             RandomAllocator allocator = new RandomAllocator(arena);
  52             RandomAllocatorThread thread = new RandomAllocatorThread(gate, allocator, i);
  53             threads[i] = thread;
  54             thread.start();
  55         }




  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 import java.util.concurrent.CyclicBarrier;
  27 
  28 import static java.lang.System.currentTimeMillis;
  29 
  30 public class MetaspaceTestOneArenaManyThreads extends MetaspaceTestWithThreads {
  31 
  32     // Several threads allocate from a single arena.
  33     // This mimicks several threads loading classes via the same class loader.
  34 

  35     public MetaspaceTestOneArenaManyThreads(MetaspaceTestContext context, long testAllocationCeiling, int numThreads, int seconds) {
  36         super(context, testAllocationCeiling, numThreads, seconds);
  37     }
  38 
  39     public void runTest() throws Exception {
  40 
  41         long t_start = currentTimeMillis();
  42         long t_stop = t_start + (seconds * 1000);
  43 
  44         // We create a single arena, and n threads which will allocate from that single arena.
  45 
  46         MetaspaceTestArena arena = context.createArena(RandomHelper.fiftyfifty(), testAllocationCeiling);
  47         CyclicBarrier gate = new CyclicBarrier(numThreads + 1);
  48 
  49         for (int i = 0; i < numThreads; i ++) {
  50             RandomAllocator allocator = new RandomAllocator(arena);
  51             RandomAllocatorThread thread = new RandomAllocatorThread(gate, allocator, i);
  52             threads[i] = thread;
  53             thread.start();
  54         }


< prev index next >