test/compiler/7177917/Test7177917.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff test/compiler/7177917/Test7177917.java

test/compiler/7177917/Test7177917.java

Print this page
rev 7259 : 8044186: Introduce a reproducible random generator
Reviewed-by: iignatyev
Contributed-by: sergei.kovalev@oracle.com

*** 1,7 **** /* ! * Copyright (c) 2012, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2012, 2014, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 24,40 **** /* * Micro-benchmark for Math.pow() and Math.exp() */ ! import java.util.*; public class Test7177917 { static double d; ! static Random r = new Random(0); static long m_pow(double[][] values) { double res = 0; long start = System.nanoTime(); for (int i = 0; i < values.length; i++) { --- 24,41 ---- /* * Micro-benchmark for Math.pow() and Math.exp() */ ! import com.oracle.java.testlibrary.Utils; ! import java.util.Random; public class Test7177917 { static double d; ! static final Random R = Utils.getRandomInstance(); static long m_pow(double[][] values) { double res = 0; long start = System.nanoTime(); for (int i = 0; i < values.length; i++) {
*** 57,70 **** } static double[][] pow_values(int nb) { double[][] res = new double[nb][2]; for (int i = 0; i < nb; i++) { ! double ylogx = (1 + (r.nextDouble() * 2045)) - 1023; // 2045 rather than 2046 as a safety margin ! double x = Math.abs(Double.longBitsToDouble(r.nextLong())); while (x != x) { ! x = Math.abs(Double.longBitsToDouble(r.nextLong())); } double logx = Math.log(x) / Math.log(2); double y = ylogx / logx; res[i][0] = x; --- 58,71 ---- } static double[][] pow_values(int nb) { double[][] res = new double[nb][2]; for (int i = 0; i < nb; i++) { ! double ylogx = (1 + (R.nextDouble() * 2045)) - 1023; // 2045 rather than 2046 as a safety margin ! double x = Math.abs(Double.longBitsToDouble(R.nextLong())); while (x != x) { ! x = Math.abs(Double.longBitsToDouble(R.nextLong())); } double logx = Math.log(x) / Math.log(2); double y = ylogx / logx; res[i][0] = x;
*** 74,84 **** } static double[] exp_values(int nb) { double[] res = new double[nb]; for (int i = 0; i < nb; i++) { ! double ylogx = (1 + (r.nextDouble() * 2045)) - 1023; // 2045 rather than 2046 as a safety margin double x = Math.E; double logx = Math.log(x) / Math.log(2); double y = ylogx / logx; res[i] = y; } --- 75,85 ---- } static double[] exp_values(int nb) { double[] res = new double[nb]; for (int i = 0; i < nb; i++) { ! double ylogx = (1 + (R.nextDouble() * 2045)) - 1023; // 2045 rather than 2046 as a safety margin double x = Math.E; double logx = Math.log(x) / Math.log(2); double y = ylogx / logx; res[i] = y; }
test/compiler/7177917/Test7177917.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File