< prev index next >

test/jdk/java/lang/Thread/virtual/stress/Skynet.java

Print this page

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @summary Stress test virtual threads with a variation of the Skynet 1M benchmark
 27  * @requires vm.continuations
 28  * @run main/othervm/timeout=300 -Xmx1g Skynet
 29  */
 30 
 31 /*
 32  * @test
 33  * @requires vm.debug == true & vm.continuations
 34  * @requires vm.gc.Z
 35  * @run main/othervm/timeout=300 -XX:+UnlockDiagnosticVMOptions
 36  *     -XX:+ZVerifyOops -XX:ZCollectionInterval=0.01 -Xmx1g Skynet
 37  */
 38 
 39 import java.util.concurrent.BlockingQueue;
 40 import java.util.concurrent.SynchronousQueue;
 41 import java.util.concurrent.ThreadFactory;
 42 
 43 public class Skynet {
 44     public static void main(String[] args) {
 45         int iterations = (args.length > 0) ? Integer.parseInt(args[0]) : 10;
 46         for (int i = 0; i < iterations; i++) {
 47             skynet(1_000_000, 499999500000L);
 48         }
 49     }
 50 
 51     static void skynet(int num, long expected) {
 52         long start = System.currentTimeMillis();
 53         var chan = new Channel<Long>();
 54 
 55         Thread.startVirtualThread(() -> skynet(chan, 0, num, 10));
 56 

  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @summary Stress test virtual threads with a variation of the Skynet 1M benchmark
 27  * @requires vm.continuations
 28  * @run main/othervm/timeout=300 -Xmx1400m Skynet
 29  */
 30 
 31 /*
 32  * @test
 33  * @requires vm.debug == true & vm.continuations
 34  * @requires vm.gc.Z
 35  * @run main/othervm/timeout=300 -XX:+UnlockDiagnosticVMOptions
 36  *     -XX:+ZVerifyOops -XX:ZCollectionInterval=0.01 -Xmx1400m Skynet
 37  */
 38 
 39 import java.util.concurrent.BlockingQueue;
 40 import java.util.concurrent.SynchronousQueue;
 41 import java.util.concurrent.ThreadFactory;
 42 
 43 public class Skynet {
 44     public static void main(String[] args) {
 45         int iterations = (args.length > 0) ? Integer.parseInt(args[0]) : 10;
 46         for (int i = 0; i < iterations; i++) {
 47             skynet(1_000_000, 499999500000L);
 48         }
 49     }
 50 
 51     static void skynet(int num, long expected) {
 52         long start = System.currentTimeMillis();
 53         var chan = new Channel<Long>();
 54 
 55         Thread.startVirtualThread(() -> skynet(chan, 0, num, 10));
 56 
< prev index next >