File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
test/micro/org/openjdk/bench/java/util/concurrent Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3232import org .openjdk .jmh .annotations .State ;
3333import org .openjdk .jmh .annotations .TearDown ;
3434import org .openjdk .jmh .infra .Blackhole ;
35+ import org .openjdk .jmh .infra .ThreadParams ;
3536
3637import java .util .concurrent .ArrayBlockingQueue ;
3738import java .util .concurrent .BlockingQueue ;
4950@ State (Scope .Benchmark )
5051public class ProducerConsumer {
5152
52- @ Param ("100" )
53+ @ Param ("100" ) // Will be expanded to at least the number of threads used
5354 private int capacity ;
5455
5556 @ Param
@@ -59,7 +60,9 @@ public class ProducerConsumer {
5960 private Producer prod ;
6061
6162 @ Setup
62- public void prepare () {
63+ public void prepare (ThreadParams params ) {
64+ capacity = Math .max (params .getThreadCount (), capacity );
65+
6366 switch (type ) {
6467 case ABQ_F :
6568 q = new ArrayBlockingQueue <>(capacity , true );
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3131import org .openjdk .jmh .annotations .Setup ;
3232import org .openjdk .jmh .annotations .State ;
3333import org .openjdk .jmh .infra .Blackhole ;
34+ import org .openjdk .jmh .infra .ThreadParams ;
3435
3536import java .util .concurrent .ArrayBlockingQueue ;
3637import java .util .concurrent .BlockingQueue ;
4344@ State (Scope .Benchmark )
4445public class Queues {
4546
46- @ Param ("100" )
47+ @ Param ("100" ) // Will be expanded to at least the number of threads used
4748 private int capacity ;
4849
4950 @ Param
@@ -59,7 +60,9 @@ public enum QueueType {
5960 private BlockingQueue <Integer > q ;
6061
6162 @ Setup
62- public void setup () {
63+ public void setup (ThreadParams params ) {
64+ capacity = Math .max (params .getThreadCount (), capacity );
65+
6366 switch (type ) {
6467 case ABQ_F :
6568 q = new ArrayBlockingQueue <>(capacity , true );
You can’t perform that action at this time.
0 commit comments