diff --git a/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java b/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java index ddf3f69c83d..5580033f249 100644 --- a/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java +++ b/test/micro/org/openjdk/bench/java/util/concurrent/ProducerConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.infra.ThreadParams; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -55,7 +56,7 @@ import java.util.concurrent.TimeUnit; @Fork(3) public class ProducerConsumer { - @Param("100") + @Param("100") // Will be expanded to at least the number of threads used private int capacity; @Param @@ -65,7 +66,9 @@ public class ProducerConsumer { private Producer prod; @Setup - public void prepare() { + public void prepare(ThreadParams params) { + capacity = Math.max(params.getThreadCount(), capacity); + switch (type) { case ABQ_F: q = new ArrayBlockingQueue<>(capacity, true); diff --git a/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java b/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java index 533754419bc..9ea4a05807a 100644 --- a/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java +++ b/test/micro/org/openjdk/bench/java/util/concurrent/Queues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.infra.ThreadParams; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -49,7 +50,7 @@ import java.util.concurrent.TimeUnit; @Fork(3) public class Queues { - @Param("100") + @Param("100") // Will be expanded to at least the number of threads used private int capacity; @Param @@ -65,7 +66,9 @@ public class Queues { private BlockingQueue q; @Setup - public void setup() { + public void setup(ThreadParams params) { + capacity = Math.max(params.getThreadCount(), capacity); + switch (type) { case ABQ_F: q = new ArrayBlockingQueue<>(capacity, true);