Skip to content
Permalink
Browse files

8243429: use reproducible random in :vmTestbase_nsk_stress

Reviewed-by: epavlova, dholmes
  • Loading branch information
iignatev committed May 1, 2020
1 parent da064f8 commit 0264b050f6128e4e0277e60f9facd894ab495662
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -302,7 +302,7 @@ public Class loadClass(String name) throws ClassNotFoundException {

static {
crazyBytecode = new byte[1000];
Random random = new Random(0);
Random random = new Random(42);
for (int i = 0; i < crazyBytecode.length; i++)
crazyBytecode[i] = (byte) random.nextInt(256);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, 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
@@ -69,8 +69,6 @@
import nsk.share.test.ExecutionController;
import nsk.share.test.LocalRandom;

import java.util.Random;

public class gcl001 extends ThreadedGCTest {

static {
@@ -281,10 +279,9 @@ public JNICharWorker(int size) {

void doit(int size) {
char[] array = gp.create(size);
Random rand = new Random();
char min = 0xffff, max = 0;
for (int i = 0; i < array.length; ++i) {
array[i] = (char) rand.nextInt();
array[i] = (char) LocalRandom.nextInt();
if (array[i] > max) {
max = array[i];
}
@@ -455,7 +452,6 @@ public JNIDoubleWorker(int size) {
void doit(int size) {

double[] array = gp.create(size);
Random rand = new Random();
double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
for (int i = 0; i < array.length; ++i) {
if (array[i] > max) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, 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
@@ -37,7 +37,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/jni/jnistress002.
* VM testbase keywords: [stress, quick, feature_283, nonconcurrent]
@@ -61,6 +61,7 @@
import nsk.share.Consts;
import nsk.share.Debug;
import nsk.share.test.StressOptions;
import jdk.test.lib.Utils;

import java.lang.reflect.Field;
import java.util.Random;
@@ -433,7 +434,7 @@ public boolean equals(Object o) {
System.loadLibrary("jnistress002");
}

static Random myRandom = new Random();
Random myRandom = new Random(Utils.getRandomInstance().nextLong());

public JNIter002(Synchronizer[] aSync) {
sync = aSync;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric001.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -49,12 +49,15 @@
* which is used by this test:
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric001.numeric001 300 300
*/

package nsk.stress.numeric.numeric001;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <b>A</b><sup>.</sup><b>A</b> for
@@ -82,6 +85,7 @@
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric001 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -288,7 +292,7 @@ public SquareMatrix(int size) {
value = new double[size][size];
for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
value[line][column] = Math.random() * size;
value[line][column] = RNG.nextDouble() * size;
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric002.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -49,12 +49,15 @@
* which is used by this test:
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric002.numeric002 300 300
*/

package nsk.stress.numeric.numeric002;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <b>A</b><sup>.</sup><b>A</b> for
@@ -82,6 +85,7 @@
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric002 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -306,7 +310,7 @@ public SquareMatrix(int size) {
value = new float[size][size];
for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
value[line][column] = (float) (Math.random() * size);
value[line][column] = (float) (RNG.nextDouble() * size);
isConsistent = true;
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric003.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -49,12 +49,15 @@
* which is used by this test:
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric003.numeric003 300 300
*/

package nsk.stress.numeric.numeric003;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <b>A</b><sup>.</sup><b>A</b> for
@@ -82,6 +85,7 @@
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric003 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -288,7 +292,7 @@ public SquareMatrix(int size) {
value = new long[size][size];
for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
value[line][column] = Math.round(Math.random() * size);
value[line][column] = Math.round(RNG.nextDouble() * size);
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric004.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -49,12 +49,15 @@
* which is used by this test:
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric004.numeric004 300 300
*/

package nsk.stress.numeric.numeric004;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <b>A</b><sup>.</sup><b>A</b> for
@@ -82,6 +85,7 @@
* 4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric004 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -288,7 +292,7 @@ public SquareMatrix(int size) {
value = new int[size][size];
for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
value[line][column] = Math.round((float) (Math.random() * size));
value[line][column] = Math.round((float) (RNG.nextDouble() * size));
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric005.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -61,12 +61,15 @@
* See the bug-report:
* #4242172 (P3/S5) 2.0: poor performance in matrix calculations
*
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric005.numeric005 300 3
*/

package nsk.stress.numeric.numeric005;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <code>A<sup>.</sup>A</code> for
@@ -110,6 +113,7 @@
* #4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric005 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -374,7 +378,7 @@ private static void setSquare(double[][] A, double[][] AA) {

for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
A[line][column] = (1 - 2 * Math.random()) * size;
A[line][column] = (1 - 2 * RNG.nextDouble()) * size;

return A;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -23,7 +23,7 @@

/*
* @test
* @key stress
* @key stress randomness
*
* @summary converted from VM testbase nsk/stress/numeric/numeric006.
* VM testbase keywords: [stress, slow, nonconcurrent, quick]
@@ -60,12 +60,15 @@
* COMMENTS
* See the bug-report:
* #4242172 (P3/S5) 2.0: poor performance in matrix calculations
* @library /test/lib
* @run main/othervm nsk.stress.numeric.numeric006.numeric006 300 3
*/

package nsk.stress.numeric.numeric006;

import java.io.PrintStream;
import java.util.Random;
import jdk.test.lib.Utils;

/**
* This test calculates the product <code>A<sup>.</sup>A</code> for
@@ -109,6 +112,7 @@
* #4242172 (P3/S5) 2.0: poor performance in matrix calculations
*/
public class numeric006 {
private static final Random RNG = Utils.getRandomInstance();
/**
* When testing performance, single thread calculation is allowed to
* be 10% slower than multi-threads calculation (<code>TOLERANCE</code>
@@ -373,7 +377,7 @@ private static void setSquare(float[][] A, float[][] AA) {

for (int line = 0; line < size; line++)
for (int column = 0; column < size; column++)
A[line][column] = (float) ((1 - 2 * Math.random()) * size);
A[line][column] = (float) ((1 - 2 * RNG.nextDouble()) * size);

return A;
}

0 comments on commit 0264b05

Please sign in to comment.