diff options
author | Alexandre Rames <alexandre.rames@linaro.org> | 2015-09-28 10:15:06 +0100 |
---|---|---|
committer | Alexandre Rames <alexandre.rames@linaro.org> | 2015-09-28 10:26:41 +0100 |
commit | a398b7cc87434edf6c049d313857e5646ece26d3 (patch) | |
tree | 04efd4ff0d0dc561793496aa0e2b3baaa70fe061 | |
parent | 2d5b14c759c94a8747a20bd977717ff268258f8a (diff) |
Reformat the deprecated benchmark files.
Change-Id: I70ebefa50c9daae1a3c06b43c082480eb3be1fe1
29 files changed, 494 insertions, 465 deletions
diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/BubbleSort.java b/benchmarking/java-ubenchs/benchmarks/deprecated/BubbleSort.java index 7aa4cd8..39a5460 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/BubbleSort.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/BubbleSort.java @@ -21,44 +21,45 @@ import java.lang.System; // This benchmark performs bubble sort in the worst case scenario. public class BubbleSort { - public int[] inputArr; - public int ARRAY_COUNT = 512; + public int inputArr[]; + public static final int ARRAY_COUNT = 512; + public void timeSort(int iterations) { this.inputArr = new int[ARRAY_COUNT]; - for(int iter = 0; iter < iterations; ++iter) { + for (int iter = 0; iter < iterations; ++iter) { // Initialize the array. - for(int i = 0; i < this.inputArr.length; ++i) { - this.inputArr[i] = i; + for (int i = 0; i < this.inputArr.length; ++i) { + this.inputArr[i] = i; } // Perform sort. - for(int i = 0; i < this.inputArr.length; ++i) { - for(int j = 0; j < this.inputArr.length - 1; ++j) { - if (this.inputArr[j] < this.inputArr[j + 1]) { - int temp = this.inputArr[j]; - this.inputArr[j] = this.inputArr[j + 1]; - this.inputArr[j + 1] = temp; - } + for (int i = 0; i < this.inputArr.length; ++i) { + for (int j = 0; j < this.inputArr.length - 1; ++j) { + if (this.inputArr[j] < this.inputArr[j + 1]) { + int temp = this.inputArr[j]; + this.inputArr[j] = this.inputArr[j + 1]; + this.inputArr[j + 1] = temp; } - } + } + } } } public boolean verify() { // Verify sorted output. - for(int i = 0; i < this.inputArr.length; ++i) { - int expected = this.inputArr.length - i - 1; - int actual = this.inputArr[i]; - if(expected != actual) { - System.out.println("ERROR: Mismatch at position " + i + - " Expected " + expected + - " Actual " + actual); - return false; - } + for (int i = 0; i < this.inputArr.length; ++i) { + int expected = this.inputArr.length - i - 1; + int actual = this.inputArr[i]; + if (expected != actual) { + System.out.println("ERROR: Mismatch at position " + i + + " Expected " + expected + + " Actual " + actual); + return false; + } } return true; } - public static void main(String[] args) { + public static void main(String args[]) { BubbleSort obj = new BubbleSort(); long before = System.currentTimeMillis(); obj.timeSort(1); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/ControlFlow.java b/benchmarking/java-ubenchs/benchmarks/deprecated/ControlFlow.java index 74082a5..d08fe1c 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/ControlFlow.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/ControlFlow.java @@ -21,10 +21,10 @@ import java.lang.System; public class ControlFlow { - public final static int ITERATIONS = 100000; - public final static int VALUE = 500; + public static final int ITERATIONS = 100000; + public static final int VALUE = 500; - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); int sum = timeForUp(ITERATIONS); long after = System.currentTimeMillis(); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/DoNothing.java b/benchmarking/java-ubenchs/benchmarks/deprecated/DoNothing.java index 357b991..3301107 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/DoNothing.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/DoNothing.java @@ -18,16 +18,16 @@ package benchmarks.deprecated; public class DoNothing { - public static void main(String[] args) { - System.out.println("DoNothing: " + 0); - } + public static void main(String args[]) { + System.out.println("DoNothing: " + 0); + } - /* - * Do nothing in the loop to check the loop overhead. - */ - public static int timeDoNothing(int iters) { - for (int i = 0; i < iters; i++) { - } - return 0; + /* + * Do nothing in the loop to check the loop overhead. + */ + public static int timeDoNothing(int iters) { + for (int i = 0; i < iters; i++) { } + return 0; + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialDouble.java b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialDouble.java index aa5762c..a92236b 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialDouble.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialDouble.java @@ -18,19 +18,21 @@ package benchmarks.deprecated; public class FactorialDouble { - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); double result = 0; - for (int i = 0; i < 10000; ++i) + for (int i = 0; i < 10000; ++i) { result += timeFactorial(i); + } long after = System.currentTimeMillis(); System.out.println("factorial double: " + (after - before)); } - public static double timeFactorial(int n) { + public static double timeFactorial(int iterations) { double result = 1; - for (int i = 1; i < n; ++i) + for (int i = 1; i < iterations; ++i) { result *= i; + } return result; } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialFloat.java b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialFloat.java index e9f5ec9..bfd7a65 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialFloat.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialFloat.java @@ -18,19 +18,21 @@ package benchmarks.deprecated; public class FactorialFloat { - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); float result = 0; - for (int i = 0; i < 10000; ++i) + for (int i = 0; i < 10000; ++i) { result += timeFactorial(i); + } long after = System.currentTimeMillis(); System.out.println("factorial float: " + (after - before)); } public static float timeFactorial(int n) { float result = 1; - for (int i = 1; i < n; ++i) + for (int i = 1; i < n; ++i) { result *= i; + } return result; } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialInt.java b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialInt.java index e1f135b..0fe9262 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialInt.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialInt.java @@ -18,19 +18,21 @@ package benchmarks.deprecated; public class FactorialInt { - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); long result = 0; - for (int i = 0; i < 10000; ++i) + for (int i = 0; i < 10000; ++i) { result += timeFactorial(i); + } long after = System.currentTimeMillis(); System.out.println("factorial int: " + (after - before)); } public static int timeFactorial(int n) { int result = 1; - for (int i = 1; i < n; ++i) + for (int i = 1; i < n; ++i) { result *= i; + } return result; } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialLong.java b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialLong.java index 6a89b32..bd637e7 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialLong.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/FactorialLong.java @@ -18,19 +18,21 @@ package benchmarks.deprecated; public class FactorialLong { - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); long result = 0; - for (int i = 0; i < 10000; ++i) + for (int i = 0; i < 10000; ++i) { result += timeFactorial(i); + } long after = System.currentTimeMillis(); System.out.println("factorial long: " + (after - before)); } public static long timeFactorial(int n) { long result = 1; - for (int i = 1; i < n; ++i) + for (int i = 1; i < n; ++i) { result *= i; + } return result; } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/GCTest.java b/benchmarking/java-ubenchs/benchmarks/deprecated/GCTest.java index 7807299..c0da556 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/GCTest.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/GCTest.java @@ -23,13 +23,13 @@ import java.util.Random; public class GCTest { - public final static int FACTOR = 10; - public final static int ITERATIONS = 5; - public final static int LIVE = FACTOR * 10; - public final static int BORN = LIVE * FACTOR * 100; - public final static int SIZE = FACTOR; + public static final int FACTOR = 10; + public static final int ITERATIONS = 5; + public static final int LIVE = FACTOR * 10; + public static final int BORN = LIVE * FACTOR * 100; + public static final int SIZE = FACTOR; - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); timeSmash(BORN); long after = System.currentTimeMillis(); @@ -40,14 +40,14 @@ public class GCTest { } public static void timeSmash(int iters) { - GCTest[] list = new GCTest[LIVE]; - Random rnd = new Random(123456789); - for (int i = 0; i < iters; i++) { - smash(list, rnd); - } + GCTest list[] = new GCTest[LIVE]; + Random rnd = new Random(123456789); + for (int i = 0; i < iters; i++) { + smash(list, rnd); + } } - public static void smash(GCTest[] list, Random rnd) { + public static void smash(GCTest list[], Random rnd) { for (int i = 0; i < ITERATIONS; i++) { int index = rnd.nextInt(list.length); int size = rnd.nextInt(SIZE); @@ -63,6 +63,6 @@ public class GCTest { } private Object pointer = null; - private int[] variable = null; + private int variable[] = null; } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/InstanceTest.java b/benchmarking/java-ubenchs/benchmarks/deprecated/InstanceTest.java index 9a14870..de56ecf 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/InstanceTest.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/InstanceTest.java @@ -25,10 +25,10 @@ import org.linaro.bench.IterationsAnnotation; public class InstanceTest { - public final static int ITERATIONS = 1000; - public final static int INSTANCES = 1000; + public static final int ITERATIONS = 1000; + public static final int INSTANCES = 1000; - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); timeCheckInstances(ITERATIONS); long after = System.currentTimeMillis(); @@ -39,24 +39,32 @@ public class InstanceTest { Object o = null; for (int i = 0; i < INSTANCES; i++) { switch (rnd.nextInt(4)) { - case 0: o = new A(); break; - case 1: o = new B(); break; - case 2: o = new C(); break; - case 3: o = new D(); break; + case 0: + o = new A(); + break; + case 1: + o = new B(); + break; + case 2: + o = new C(); + break; + case 3: + o = new D(); + break; default: o = null; } list.add(o); } } - @IterationsAnnotation(noWarmup=true, iterations=1000) + @IterationsAnnotation(noWarmup = true, iterations = 1000) public static void timeCheckInstances(int iters) { - ArrayList<Object> list = new ArrayList<Object>(); - Random rnd = new Random(123456789); - initializeInstances(list, rnd); - for (int i = 0; i < iters; i++) { - checkInstances(list); - } + ArrayList<Object> list = new ArrayList<Object>(); + Random rnd = new Random(123456789); + initializeInstances(list, rnd); + for (int i = 0; i < iters; i++) { + checkInstances(list); + } } public static void checkInstances(ArrayList<Object> list) { diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/JoinTest.java b/benchmarking/java-ubenchs/benchmarks/deprecated/JoinTest.java index bd0e4a6..9c1e899 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/JoinTest.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/JoinTest.java @@ -17,9 +17,9 @@ package benchmarks.deprecated; +import java.lang.InterruptedException; import java.lang.System; import java.lang.Thread; -import java.lang.InterruptedException; import java.util.ArrayList; import java.util.Random; @@ -27,75 +27,75 @@ import org.linaro.bench.IterationsAnnotation; public class JoinTest extends Thread { - public final static int THREAD_NUMBER = 50; - public final static int MAX_PAUSE = 1000; - - @IterationsAnnotation(noWarmup = true, iterations = 1) - public static void timeJoinOfFiftyThreads(int iters) { - for (int i = 0; i < iters; i++) { - Random rnd = new Random(123456789); - ArrayList<Thread> list = new ArrayList<Thread>(); - for (int x = 0; x < THREAD_NUMBER; x++) { - list.add(new JoinTest(rnd)); - } - for (Thread t : list) { - t.start(); - } - - for (Thread t : list) { - try { - t.join(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - System.out.println("While joining"); - } - } + public static final int THREAD_NUMBER = 50; + public static final int MAX_PAUSE = 1000; + + @IterationsAnnotation(noWarmup = true, iterations = 1) + public static void timeJoinOfFiftyThreads(int iters) { + for (int i = 0; i < iters; i++) { + Random rnd = new Random(123456789); + ArrayList<Thread> list = new ArrayList<Thread>(); + for (int x = 0; x < THREAD_NUMBER; x++) { + list.add(new JoinTest(rnd)); + } + for (Thread t : list) { + t.start(); + } + + for (Thread t : list) { + try { + t.join(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + System.out.println("While joining"); } + } } - - public static void main(String[] args) { - - long before = System.currentTimeMillis(); - timeJoinOfFiftyThreads(1); - long after = System.currentTimeMillis(); - System.out.println("join of " + THREAD_NUMBER + ": " + (after - before)); - } - - public JoinTest() { + } + + public static void main(String args[]) { + + long before = System.currentTimeMillis(); + timeJoinOfFiftyThreads(1); + long after = System.currentTimeMillis(); + System.out.println("join of " + THREAD_NUMBER + ": " + (after - before)); + } + + public JoinTest() { + } + + public JoinTest(Random rnd) { + dummy = 0; + firstPause = (long) rnd.nextInt(MAX_PAUSE); + secondPause = (long) rnd.nextInt(MAX_PAUSE); + } + + public void run() { + try { + sleep(firstPause); + } catch (InterruptedException ie) { + ie.printStackTrace(); + System.out.println("While first pause"); } - public JoinTest(Random rnd) { - dummy = 0; - first_pause = (long) rnd.nextInt(MAX_PAUSE); - second_pause = (long) rnd.nextInt(MAX_PAUSE); + synchronized (lock) { + dummy++; } - public void run() { - try { - sleep(first_pause); - } catch (InterruptedException ie) { - ie.printStackTrace(); - System.out.println("While first pause"); - } - - synchronized (lock) { - dummy++; - } - - try { - sleep(second_pause); - } catch (InterruptedException ie) { - ie.printStackTrace(); - System.out.println("While second pause"); - } + try { + sleep(secondPause); + } catch (InterruptedException ie) { + ie.printStackTrace(); + System.out.println("While second pause"); } + } - public int dummy() { - return dummy; - } + public int dummy() { + return dummy; + } - private int dummy; - private long first_pause; - private long second_pause; - private static Object lock = new Object(); + private int dummy; + private long firstPause; + private long secondPause; + private static Object lock = new Object(); } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/LockTest.java b/benchmarking/java-ubenchs/benchmarks/deprecated/LockTest.java index 476334c..72dfca1 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/LockTest.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/LockTest.java @@ -23,9 +23,9 @@ import org.linaro.bench.IterationsAnnotation; public class LockTest { - public final static int ITERATIONS = 200000; + public static final int ITERATIONS = 200000; - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); timeStaticLockWithDepth1(ITERATIONS); long after = System.currentTimeMillis(); @@ -59,41 +59,42 @@ public class LockTest { } public static synchronized void timeStaticLockWithDepth1(int iters) { - for (int i = 0; i < iters; i++) { - staticLockWithDepth(1); - } + for (int i = 0; i < iters; i++) { + staticLockWithDepth(1); + } } - @IterationsAnnotation(noWarmup=true) + @IterationsAnnotation(noWarmup = true) public static synchronized void timeStaticLockWithDepth2(int iters) { - for (int i = 0; i < iters; i++) { - staticLockWithDepth(2); - } + for (int i = 0; i < iters; i++) { + staticLockWithDepth(2); + } } - @IterationsAnnotation(noWarmup=true) + @IterationsAnnotation(noWarmup = true) public static synchronized void timeStaticLockWithDepth20(int iters) { - for (int i = 0; i < iters; i++) { - staticLockWithDepth(20); - } + for (int i = 0; i < iters; i++) { + staticLockWithDepth(20); + } } public synchronized void timeDynamicLockWithDepth1(int iters) { - for (int i = 0; i < iters; i++) { - dynamicLockWithDepth(1); - } + for (int i = 0; i < iters; i++) { + dynamicLockWithDepth(1); + } } public synchronized void timeDynamicLockWithDepth2(int iters) { - for (int i = 0; i < iters; i++) { - dynamicLockWithDepth(2); - } + for (int i = 0; i < iters; i++) { + dynamicLockWithDepth(2); + } } - @IterationsAnnotation(noWarmup=true) + + @IterationsAnnotation(noWarmup = true) public synchronized void timeDynamicLockWithDepth20(int iters) { - for (int i = 0; i < iters; i++) { - dynamicLockWithDepth(20); - } + for (int i = 0; i < iters; i++) { + dynamicLockWithDepth(20); + } } public static synchronized void staticLockWithDepth(int depth) { diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Loop.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Loop.java index 1f5e0c6..db4f7b4 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Loop.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Loop.java @@ -21,9 +21,9 @@ import java.lang.System; // This benchmark performs various loop operations. public class Loop { - public int LOOP_COUNT = 500; - public int VALUE1 = 50; - public int VALUE2 = 90; + public static final int LOOP_COUNT = 500; + public static final int VALUE1 = 50; + public static final int VALUE2 = 90; public int result; public Loop() { @@ -43,7 +43,7 @@ public class Loop { return; } - public static void main(String[] args) { + public static void main(String args[]) { long before; long after; Loop obj = new Loop(); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Matrix.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Matrix.java index 50b9e95..849d712 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Matrix.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Matrix.java @@ -19,40 +19,40 @@ package benchmarks.deprecated; public class Matrix { - public static void main(String[] args) { - Matrix m = new Matrix(); - long before = System.currentTimeMillis(); - m.timeMatrixMultiply(50000); - long after = System.currentTimeMillis(); - System.out.println("matrix int: " + (after - before)); + public static void main(String args[]) { + Matrix m = new Matrix(); + long before = System.currentTimeMillis(); + m.timeMatrixMultiply(50000); + long after = System.currentTimeMillis(); + System.out.println("matrix int: " + (after - before)); + } + + public int timeMatrixMultiply(int iters) { + int result = 0; + for (int i = 0; i < iters; ++i) { + int[][] test1 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; + int[][] res = multiply(test1, test1); + result += res[0][0]; } + return result; + } - public int timeMatrixMultiply(int iters) { - int result = 0; - for (int i = 0; i < iters; ++i) { - int[][] test1 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - int[][] res = multiply(test1, test1); - result += res[0][0]; - } - return result; - } - - public static int[][] multiply(int[][] A, int[][] B) { - int mA = A.length; - int nA = A[0].length; - int mB = B.length; - int nB = A[0].length; + public static int[][] multiply(int[][] A, int[][] B) { + int mA = A.length; + int nA = A[0].length; + int mB = B.length; + int nB = A[0].length; - if (nA != mB) - throw new RuntimeException("Illegal matrix dimensions."); + if (nA != mB) + throw new RuntimeException("Illegal matrix dimensions."); - int[][] result = new int[mA][nB]; + int[][] result = new int[mA][nB]; - for (int i = 0; i < mA; i++) - for (int j = 0; j < nB; j++) - for (int k = 0; k < nA; k++) - result[i][j] += (A[i][k] * B[k][j]); + for (int i = 0; i < mA; i++) + for (int j = 0; j < nB; j++) + for (int k = 0; k < nA; k++) + result[i][j] += (A[i][k] * B[k][j]); - return result; - } + return result; + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/MatrixDouble.java b/benchmarking/java-ubenchs/benchmarks/deprecated/MatrixDouble.java index 1a60571..59c38fb 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/MatrixDouble.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/MatrixDouble.java @@ -19,7 +19,7 @@ package benchmarks.deprecated; public class MatrixDouble { - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); timeMultiply(5000); long after = System.currentTimeMillis(); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/MultiplyAdd.java b/benchmarking/java-ubenchs/benchmarks/deprecated/MultiplyAdd.java index 4cc1f70..f5f1822 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/MultiplyAdd.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/MultiplyAdd.java @@ -20,139 +20,140 @@ package benchmarks.deprecated; import java.lang.reflect.Method; public class MultiplyAdd { - public final static int ITERATIONS = 100000000; - public final static int VALUE = 500; + public static final int ITERATIONS = 100000000; + public static final int VALUE = 500; - public static void main(String[] args) { - long start, end = 0; - MultiplyAdd test = new MultiplyAdd(); + public static void main(String args[]) { + long start = 0; + long end = 0; + MultiplyAdd test = new MultiplyAdd(); - Method[] methods = test.getClass().getDeclaredMethods(); - // sort methods by name - for (int i = 0; i < methods.length; i++) { - for (int j = 0; j < methods.length - i - 1; j++) { - if (methods[j].getName().compareTo(methods[j + 1].getName()) > 0) { - Method tmp = methods[j]; - methods[j] = methods[j + 1]; - methods[j + 1] = tmp; - } - } + Method methods[] = test.getClass().getDeclaredMethods(); + // sort methods by name + for (int i = 0; i < methods.length; i++) { + for (int j = 0; j < methods.length - i - 1; j++) { + if (methods[j].getName().compareTo(methods[j + 1].getName()) > 0) { + Method tmp = methods[j]; + methods[j] = methods[j + 1]; + methods[j + 1] = tmp; } + } + } - for (int i = 0; i < methods.length; i++) { - Method m = methods[i]; - if (m.getName().startsWith("time")) { - start = System.currentTimeMillis(); - end = start - 1; - try { - Object o = m.invoke(test, ITERATIONS); - end = System.currentTimeMillis(); - } catch (Exception e) { - System.err.println("Invoke method: " + m.toGenericString()); - } - System.out.println(m.getDeclaringClass().getName() + "." - + m.getName().substring(4) + ": " + (end - start)); - } + for (int i = 0; i < methods.length; i++) { + Method m = methods[i]; + if (m.getName().startsWith("time")) { + start = System.currentTimeMillis(); + end = start - 1; + try { + Object o = m.invoke(test, ITERATIONS); + end = System.currentTimeMillis(); + } catch (Exception e) { + System.err.println("Invoke method: " + m.toGenericString()); } + System.out.println(m.getDeclaringClass().getName() + "." + + m.getName().substring(4) + ": " + (end - start)); + } } + } - public int timeSimpleMaddw(int iters) { - int result = 0; - for (int i = 0; i < iters; i++) { - result += i * i; - } - return result; + public int timeSimpleMaddw(int iters) { + int result = 0; + for (int i = 0; i < iters; i++) { + result += i * i; } + return result; + } - public long timeSimpleMaddx(int iters) { - long result = 0; - for (int i = 0; i < iters; i++) { - long tmp = i; - result += tmp * tmp; - } - return result; + public long timeSimpleMaddx(int iters) { + long result = 0; + for (int i = 0; i < iters; i++) { + long tmp = i; + result += tmp * tmp; } + return result; + } - public int timeSimpleMsubw(int iters) { - int result = 0; - for (int i = 0; i < iters; i++) { - result -= i * i; - } - return result; + public int timeSimpleMsubw(int iters) { + int result = 0; + for (int i = 0; i < iters; i++) { + result -= i * i; } + return result; + } - public long timeSimpleMsubx(int iters) { - long result = 0; - for (int i = 0; i < iters; i++) { - long tmp = i; - result += tmp * tmp; - } - return result; + public long timeSimpleMsubx(int iters) { + long result = 0; + for (int i = 0; i < iters; i++) { + long tmp = i; + result += tmp * tmp; } + return result; + } - public int timeMaddwBack2back(int iters) { - int result = 0; - int tmp1 = 0; - int tmp2 = 0; - for (int i = 0; i < iters; i++) { - tmp1 += i * i; - tmp2 += tmp1 * tmp1; - result += tmp2 * tmp2; - } - return result; + public int timeMaddwBack2back(int iters) { + int result = 0; + int tmp1 = 0; + int tmp2 = 0; + for (int i = 0; i < iters; i++) { + tmp1 += i * i; + tmp2 += tmp1 * tmp1; + result += tmp2 * tmp2; } + return result; + } - public long timeMaddxBack2back(int iters) { - long result = 0; - long tmp1 = 0; - long tmp2 = 0; - for (int i = 0; i < iters; i++) { - long a = i; - tmp1 += a * a; - tmp2 += tmp1 * tmp1; - result += tmp2 * tmp2; - } - return result; + public long timeMaddxBack2back(int iters) { + long result = 0; + long tmp1 = 0; + long tmp2 = 0; + for (int i = 0; i < iters; i++) { + long a = i; + tmp1 += a * a; + tmp2 += tmp1 * tmp1; + result += tmp2 * tmp2; } + return result; + } - public int timeMaddwInterleave(int iters) { - int result = 0; - int tmp1 = 0; - int tmp2 = 0; - for (int i = 0; i < iters; i++) { - tmp1 += i * i; - tmp2 = tmp1 + tmp1; - result += tmp2 * tmp2; - } - return result; + public int timeMaddwInterleave(int iters) { + int result = 0; + int tmp1 = 0; + int tmp2 = 0; + for (int i = 0; i < iters; i++) { + tmp1 += i * i; + tmp2 = tmp1 + tmp1; + result += tmp2 * tmp2; } + return result; + } - public long timeMaddxInterleave(int iters) { - long result = 0; - long tmp1 = 0; - long tmp2 = 0; - for (int i = 0; i < iters; i++) { - long a = i; - tmp1 += a * a; - tmp2 += tmp1 + tmp1; - result += tmp2 * tmp2; - } - return result; + public long timeMaddxInterleave(int iters) { + long result = 0; + long tmp1 = 0; + long tmp2 = 0; + for (int i = 0; i < iters; i++) { + long a = i; + tmp1 += a * a; + tmp2 += tmp1 + tmp1; + result += tmp2 * tmp2; } + return result; + } - public long timeMixed(int iters) { - long result = 0; - long tmp = 0; - long lt = 12; - int a = 0; - for (int i = 0; i < iters; i++) { - a = (i - 2) + i * i; - a = 1 + a * a; - tmp = a; - result -= tmp * tmp; - tmp++; - result += tmp * tmp + (tmp >> 2) * tmp + (tmp >> 2) * lt; - } - return result; + public long timeMixed(int iters) { + long result = 0; + long tmp = 0; + long lt = 12; + int a = 0; + for (int i = 0; i < iters; i++) { + a = (i - 2) + i * i; + a = 1 + a * a; + tmp = a; + result -= tmp * tmp; + tmp++; + result += tmp * tmp + (tmp >> 2) * tmp + (tmp >> 2) * lt; } + return result; + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/ObjFactorial.java b/benchmarking/java-ubenchs/benchmarks/deprecated/ObjFactorial.java index 1e15b2e..f17fbc8 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/ObjFactorial.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/ObjFactorial.java @@ -21,69 +21,71 @@ import java.lang.System; import java.math.BigInteger; class MyLong { - private long value; + private long value; - public MyLong(long value) { - this.value = value; - } + public MyLong(long value) { + this.value = value; + } - public long get() { - return value; - } + public long get() { + return value; + } - public void set(long newValue) { - value = newValue; - } + public void set(long newValue) { + value = newValue; + } - public int compareTo(MyLong other) { - if (value > other.value) - return 1; - if (value == other.value) - return 0; - return -1; + public int compareTo(MyLong other) { + if (value > other.value) { + return 1; } + if (value == other.value) { + return 0; + } + return -1; + } } public class ObjFactorial { - public static void timeBigFact(int iters) { - BigInteger bigOne = new BigInteger("1"); - BigInteger bigInput = new BigInteger("20"); - BigInteger bigResult = bigOne; - for (int x = 0; x < iters; x++) { - bigResult = bigOne; - for (BigInteger i = bigOne; i.compareTo(bigInput) == -1; i = i.add(bigOne)) { - bigResult = bigResult.multiply(i); - } - } + public static void timeBigFact(int iters) { + BigInteger bigOne = new BigInteger("1"); + BigInteger bigInput = new BigInteger("20"); + BigInteger bigResult = bigOne; + for (int x = 0; x < iters; x++) { + bigResult = bigOne; + for (BigInteger i = bigOne; i.compareTo(bigInput) == -1; i = i.add(bigOne)) { + bigResult = bigResult.multiply(i); + } } - - public static void timeMyFact(int iters) { - MyLong myInput = new MyLong(20); - MyLong myResult = new MyLong(1); - for (int x = 0; x < iters; x++) { - myResult = new MyLong(1); - for (MyLong i = new MyLong(1); i.compareTo(myInput) == -1; i.set(i.get() + 1)) { - myResult.set(myResult.get() * i.get()); - } - } + } + + public static void timeMyFact(int iters) { + MyLong myInput = new MyLong(20); + MyLong myResult = new MyLong(1); + for (int x = 0; x < iters; x++) { + myResult = new MyLong(1); + for (MyLong i = new MyLong(1); i.compareTo(myInput) == -1; i.set(i.get() + 1)) { + myResult.set(myResult.get() * i.get()); + } } + } - public static void main(String[] args) { + public static void main(String args[]) { - final int ITERATIONS_BIG = 1000; - final int ITERATIONS_MY = 100000; + final int ITERATIONS_BIG = 1000; + final int ITERATIONS_MY = 100000; - long before = System.currentTimeMillis(); - timeBigFact(ITERATIONS_BIG); - long after = System.currentTimeMillis(); - System.out.println("bigFact: " + (after - before)); + long before = System.currentTimeMillis(); + timeBigFact(ITERATIONS_BIG); + long after = System.currentTimeMillis(); + System.out.println("bigFact: " + (after - before)); - before = System.currentTimeMillis(); - timeMyFact(ITERATIONS_MY); - after = System.currentTimeMillis(); + before = System.currentTimeMillis(); + timeMyFact(ITERATIONS_MY); + after = System.currentTimeMillis(); - System.out.println("myFact: " + (after - before)); + System.out.println("myFact: " + (after - before)); - } + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Pi.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Pi.java index 4dde44f..f7dfb3f 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Pi.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Pi.java @@ -23,18 +23,17 @@ import java.lang.System; public class Pi { public double piValue; - public double timeGeneratePi(int terms) - { + public double timeGeneratePi(int terms) { this.piValue = 0.0D; double sign = 1.0D; for (int i = 0; i < terms; ++i) { - piValue += sign * (1.0D/(2.0D * i + 1.0D)); + piValue += sign * (1.0D / (2.0D * i + 1.0D)); sign *= -1; } return this.piValue; } - public static void main(String[] args) { + public static void main(String args[]) { Pi obj = new Pi(); long before = System.currentTimeMillis(); obj.timeGeneratePi(10000); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/PrimeNumber.java b/benchmarking/java-ubenchs/benchmarks/deprecated/PrimeNumber.java index 55fd8b9..d1dbe0c 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/PrimeNumber.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/PrimeNumber.java @@ -21,12 +21,11 @@ import java.lang.System; // This benchmark generates primes up to a number. public class PrimeNumber { - public int[] primes; - public int MAX_PRIME = 512; + public int primes[]; + public static final int MAX_PRIME = 512; public int numPrimes; - public int timeGeneratePrime(int iteration) - { + public int timeGeneratePrime(int iteration) { this.primes = new int[this.MAX_PRIME]; this.numPrimes = 0; @@ -34,18 +33,15 @@ public class PrimeNumber { this.primes[0] = 1; this.primes[1] = 2; this.numPrimes = 2; - for (int num = 3; num < this.MAX_PRIME; num++) - { + for (int num = 3; num < this.MAX_PRIME; num++) { boolean isPrime = true; - for(int m = 1; m < this.numPrimes && this.primes[m] <= num / 2; m++) - { + for (int m = 1; m < this.numPrimes && this.primes[m] <= num / 2; m++) { if (num % this.primes[m] == 0) { isPrime = false; break; } } - if (isPrime) - { + if (isPrime) { this.primes[this.numPrimes] = num; this.numPrimes++; } @@ -54,7 +50,7 @@ public class PrimeNumber { return this.numPrimes; } - public static void main(String[] args) { + public static void main(String args[]) { PrimeNumber obj = new PrimeNumber(); long before = System.currentTimeMillis(); obj.timeGeneratePrime(1); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Recursion.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Recursion.java index 406b78b..8e45ee8 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Recursion.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Recursion.java @@ -21,17 +21,17 @@ import java.lang.System; // This benchmark measures time taken for recursive method calls. public class Recursion { - private int MAX_VAL = 64; + private static final int MAX_VAL = 64; private long result; public Recursion() { } - public int SumSeriesA(int num) { + public int sumSeriesA(int num) { if (num == 0) { return num; } else { - return num + SumSeriesA(num - 1); + return num + sumSeriesA(num - 1); } } @@ -39,19 +39,19 @@ public class Recursion { for (int iter = 0; iter < iterations; ++iter) { this.result = 0; for (int i = 0; i < MAX_VAL; i++) { - this.result += SumSeriesA(i); + this.result += sumSeriesA(i); } } return; } - public int SumSeriesB(int num) { + public int sumSeriesB(int num) { if (num == 0) { return num; } else if ((num & 0x1) != 0) { - return num + 1 + SumSeriesB(num - 1); + return num + 1 + sumSeriesB(num - 1); } else { - return num + SumSeriesB(num - 1); + return num + sumSeriesB(num - 1); } } @@ -59,13 +59,13 @@ public class Recursion { for (int iter = 0; iter < iterations; ++iter) { this.result = 0; for (int i = 0; i < MAX_VAL; i++) { - this.result += SumSeriesB(i); + this.result += sumSeriesB(i); } } return; } - public static void main(String[] args) { + public static void main(String args[]) { long before; long after; Recursion obj = new Recursion(); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Rotation.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Rotation.java index dc5fd15..8bbc824 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Rotation.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Rotation.java @@ -21,10 +21,10 @@ import java.lang.System; // This benchmark rotates three dimensional points. public class Rotation { - public final int NUM_POINTS = 50; - public final int MAX_DEGREES = 90; - public double[][] point; - public double[][] coeff; + public static final int NUM_POINTS = 50; + public static final int MAX_DEGREES = 90; + public double point[][]; + public double coeff[][]; public Rotation() { point = new double[3][NUM_POINTS]; @@ -34,15 +34,15 @@ public class Rotation { public void timeRotate(int iterations) { for (int iter = 0; iter < iterations; ++iter) { for (int degree = 0; degree < MAX_DEGREES; degree += 5) { - double sin_value = Math.sin(degree * Math.PI / 180.0D); - double cos_value = Math.cos(degree * Math.PI / 180.0D); + double sinValue = Math.sin(degree * Math.PI / 180.0D); + double cosValue = Math.cos(degree * Math.PI / 180.0D); - coeff[0][0] = cos_value; - coeff[1][0] = sin_value; + coeff[0][0] = cosValue; + coeff[1][0] = sinValue; coeff[2][0] = 0.0D; - coeff[0][1] = -sin_value; - coeff[1][1] = cos_value; + coeff[0][1] = -sinValue; + coeff[1][1] = cosValue; coeff[2][1] = 0.0D; coeff[0][2] = 0.0D; @@ -65,7 +65,7 @@ public class Rotation { return; } - public static void main(String[] args) { + public static void main(String args[]) { long before; long after; Rotation obj = new Rotation(); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/StringOps.java b/benchmarking/java-ubenchs/benchmarks/deprecated/StringOps.java index 476f414..3c26be1 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/StringOps.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/StringOps.java @@ -21,7 +21,7 @@ import java.lang.System; // This benchmark performs various string operations. public class StringOps { - public int INNER_LOOP_COUNT = 512; + public static final int INNER_LOOP_COUNT = 512; public String string1; public String string2; public String string3; @@ -38,8 +38,8 @@ public class StringOps { public int timeAppend(int iterations) { StringBuffer str = new StringBuffer(" "); - for(int i = 0; i < iterations; ++i) { - for(int j = 0; j < this.INNER_LOOP_COUNT; ++j) { + for (int i = 0; i < iterations; ++i) { + for (int j = 0; j < this.INNER_LOOP_COUNT; ++j) { str.append(this.string1); str.append(this.string2); str.append(this.string3); @@ -53,19 +53,19 @@ public class StringOps { public int timeAppendAndSearch(int iterations) { StringBuffer str = new StringBuffer(" "); int index = 0; - for(int i = 0; i < iterations; ++i) { - for(int j = 0; j < this.INNER_LOOP_COUNT; ++j) { + for (int i = 0; i < iterations; ++i) { + for (int j = 0; j < this.INNER_LOOP_COUNT; ++j) { str.append(this.string1); } str.append(this.string2); - for(int j = 0; j < this.INNER_LOOP_COUNT; ++j) { + for (int j = 0; j < this.INNER_LOOP_COUNT; ++j) { index = str.toString().indexOf(this.string2, j * this.string1.length()); } } return index; } - public static void main(String[] args) { + public static void main(String args[]) { StringOps obj = new StringOps(); long before = System.currentTimeMillis(); obj.timeAppend(1); diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Switch.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Switch.java index c393484..910b85f 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Switch.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Switch.java @@ -21,11 +21,11 @@ import java.lang.System; public class Switch { - public final static int ITERATIONS_DENSE = 20000000; - public final static int ITERATIONS_SPARSE = 5000000; - public final static int ITERATIONS_IFELSE = 5000000; + public static final int ITERATIONS_DENSE = 20000000; + public static final int ITERATIONS_SPARSE = 5000000; + public static final int ITERATIONS_IFELSE = 5000000; - public static void main(String[] args) { + public static void main(String args[]) { long before = System.currentTimeMillis(); timeDense(ITERATIONS_DENSE); long after = System.currentTimeMillis(); @@ -47,6 +47,7 @@ public class Switch { for (int i = 0; i < iters; i++) { switch (i & 0x1f) { + // CHECKSTYLE.OFF: OneStatementPerLine case 0: sum++; break; case 1: sum--; break; case 2: sum++; break; @@ -68,6 +69,7 @@ public class Switch { case 18: sum++; break; case 19: sum--; break; default: sum += 2; + // CHECKSTYLE.ON: OneStatementPerLine } } @@ -79,6 +81,7 @@ public class Switch { for (int i = 0; i < iters; i++) { switch (i & 0x7ff) { + // CHECKSTYLE.OFF: OneStatementPerLine case 0: sum++; break; case 11: sum--; break; case 22: sum++; break; @@ -100,6 +103,7 @@ public class Switch { case 1818: sum++; break; case 1919: sum--; break; default: sum += 2; + // CHECKSTYLE.ON: OneStatementPerLine } } @@ -110,6 +114,7 @@ public class Switch { int sum = 0; for (int i = 0; i < iters; i++) { + // CHECKSTYLE.OFF: NeedBraces int val = i & 0x7ff; if (val == 0) sum++; else if (val == 11) sum--; @@ -132,6 +137,7 @@ public class Switch { else if (val == 1818) sum++; else if (val == 1919) sum--; else sum += 2; + // CHECKSTYLE.ON: NeedBraces } return sum; diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/SyncFib.java b/benchmarking/java-ubenchs/benchmarks/deprecated/SyncFib.java index f7d0909..2adccf7 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/SyncFib.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/SyncFib.java @@ -23,10 +23,10 @@ import org.linaro.bench.IterationsAnnotation; public class SyncFib { - public final static int ITERATIONS_SFIB = 300; - public final static int ITERATIONS_AFIB = 500; + public static final int ITERATIONS_SFIB = 300; + public static final int ITERATIONS_AFIB = 500; - public static void main(String[] args) { + public static void main(String args[]) { long sum = 0; long before = System.currentTimeMillis(); timeSfib(ITERATIONS_SFIB); @@ -39,22 +39,22 @@ public class SyncFib { System.out.println("afib: " + (after - before)); } - @IterationsAnnotation(noWarmup=true, iterations=600) + @IterationsAnnotation(noWarmup = true, iterations = 600) public static long timeSfib(int iters) { - long sum = 0; - for (int i = 0; i < iters; i++) { - sum += sfib(20); - } - return sum; + long sum = 0; + for (int i = 0; i < iters; i++) { + sum += sfib(20); + } + return sum; } - @IterationsAnnotation(noWarmup=true, iterations=1000) + @IterationsAnnotation(noWarmup = true, iterations = 1000) public static long timeAfib(int iters) { - long sum = 0; - for (int i = 0; i < iters; i++) { - sum += afib(20); - } - return sum; + long sum = 0; + for (int i = 0; i < iters; i++) { + sum += afib(20); + } + return sum; } static synchronized int sfib(int n) { diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/SyncNorec.java b/benchmarking/java-ubenchs/benchmarks/deprecated/SyncNorec.java index 9b60273..aee3e6e 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/SyncNorec.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/SyncNorec.java @@ -21,9 +21,9 @@ import java.lang.System; public class SyncNorec { - public final static int ITERATIONS = 1000000; + public static final int ITERATIONS = 1000000; - public static void main(String[] args) { + public static void main(String args[]) { SyncNorec dummy = new SyncNorec(); long before = System.currentTimeMillis(); dummy.timeInc(ITERATIONS); @@ -45,9 +45,9 @@ public class SyncNorec { public void timeInc(int iters) { for (int i = 0; i < iters; ++i) { - synchronized(lock1) { - synchronized(lock2) { - synchronized(lock3) { + synchronized (lock1) { + synchronized (lock2) { + synchronized (lock3) { value++; } } @@ -55,6 +55,8 @@ public class SyncNorec { } } - public int value() { return value; } + public int value() { + return value; + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/Synchro.java b/benchmarking/java-ubenchs/benchmarks/deprecated/Synchro.java index a97fdd8..1c1e961 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/Synchro.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/Synchro.java @@ -21,9 +21,9 @@ import java.lang.System; public class Synchro { - public final static int ITERATIONS = 100000; + public static final int ITERATIONS = 100000; - public static void main(String[] args) { + public static void main(String args[]) { Synchro dummy = new Synchro(); long before = System.currentTimeMillis(); dummy.timeInc(ITERATIONS); @@ -44,17 +44,17 @@ public class Synchro { } public void timeInc(int iters) { - for (int i = 0; i < iters; i++) { - inc(); - } + for (int i = 0; i < iters; i++) { + inc(); + } } public void inc() { - synchronized(lock1) { - synchronized(lock2) { - synchronized(lock1) { - synchronized(lock2) { - synchronized(lock3) { + synchronized (lock1) { + synchronized (lock2) { + synchronized (lock1) { + synchronized (lock2) { + synchronized (lock3) { value++; } } @@ -63,6 +63,8 @@ public class Synchro { } } - public int value() { return value; } + public int value() { + return value; + } } diff --git a/benchmarking/java-ubenchs/benchmarks/deprecated/VolatileTest.java b/benchmarking/java-ubenchs/benchmarks/deprecated/VolatileTest.java index 7cb7613..404899b 100644 --- a/benchmarking/java-ubenchs/benchmarks/deprecated/VolatileTest.java +++ b/benchmarking/java-ubenchs/benchmarks/deprecated/VolatileTest.java @@ -21,9 +21,9 @@ import java.lang.System; public class VolatileTest { - public final static int ITERATIONS = 1000000; + public static final int ITERATIONS = 1000000; - public static void main(String[] args) { + public static void main(String args[]) { VolatileTest test = new VolatileTest(); long before = System.currentTimeMillis(); @@ -33,14 +33,15 @@ public class VolatileTest { } public void timeLoadStores(int iters) { - for (int i = 0; i < iters; i++) { - loadStores(); - } + for (int i = 0; i < iters; i++) { + loadStores(); + } } // from the jsr 133 cook book. public void loadStores() { - int i, j; + int i; + int j; i = a; j = b; @@ -62,7 +63,9 @@ public class VolatileTest { a = i; } - private int a, b; - private volatile int u, v; + private int a; + private int b; + private volatile int u; + private volatile int v; } diff --git a/benchmarking/java-ubenchs/benchmarks/micro/Intrinsics.java b/benchmarking/java-ubenchs/benchmarks/micro/Intrinsics.java index 24265bd..197fc38 100644 --- a/benchmarking/java-ubenchs/benchmarks/micro/Intrinsics.java +++ b/benchmarking/java-ubenchs/benchmarks/micro/Intrinsics.java @@ -31,7 +31,7 @@ public class Intrinsics { private static final int NUM_RANDS = 1000; /* Pre-allocated pool of random integers from [0, Integer.MAX_VALUE) */ - private static final int[] rand = new int[NUM_RANDS]; + private static final int rand[] = new int[NUM_RANDS]; static { // Allocate a pool of random integers to use in benchmarks that @@ -47,10 +47,10 @@ public class Intrinsics { * NumberOfLeadingZeros. **/ - private static int[] resultsNumberOfLeadingZerosInteger = new int[NUM_INVOKES]; - private static int[] resultsNumberOfLeadingZerosLong = new int[NUM_INVOKES]; - private static int[] resultsNumberOfLeadingZerosIntegerRandom = new int[NUM_INVOKES]; - private static int[] resultsNumberOfLeadingZerosLongRandom = new int[NUM_INVOKES]; + private static int resultsNumberOfLeadingZerosInteger[] = new int[NUM_INVOKES]; + private static int resultsNumberOfLeadingZerosLong[] = new int[NUM_INVOKES]; + private static int resultsNumberOfLeadingZerosIntegerRandom[] = new int[NUM_INVOKES]; + private static int resultsNumberOfLeadingZerosLongRandom[] = new int[NUM_INVOKES]; public void timeNumberOfLeadingZerosInteger(int iterations) { for (int iter = 0; iter < iterations; ++iter) { @@ -92,10 +92,10 @@ public class Intrinsics { * NumberOfTrailingZeros. **/ - private static int[] resultsNumberOfTrailingZerosInteger = new int[NUM_INVOKES]; - private static int[] resultsNumberOfTrailingZerosLong = new int[NUM_INVOKES]; - private static int[] resultsNumberOfTrailingZerosIntegerRandom = new int[NUM_INVOKES]; - private static int[] resultsNumberOfTrailingZerosLongRandom = new int[NUM_INVOKES]; + private static int resultsNumberOfTrailingZerosInteger[] = new int[NUM_INVOKES]; + private static int resultsNumberOfTrailingZerosLong[] = new int[NUM_INVOKES]; + private static int resultsNumberOfTrailingZerosIntegerRandom[] = new int[NUM_INVOKES]; + private static int resultsNumberOfTrailingZerosLongRandom[] = new int[NUM_INVOKES]; public void timeNumberOfTrailingZerosInteger(int iterations) { for (int iter = 0; iter < iterations; ++iter) { @@ -137,10 +137,10 @@ public class Intrinsics { * RotateRight. **/ - private static int[] resultsRotateRightInteger = new int[NUM_INVOKES]; - private static int[] resultsRotateRightIntegerConstant = new int[NUM_INVOKES]; - private static long[] resultsRotateRightLong = new long[NUM_INVOKES]; - private static long[] resultsRotateRightLongConstant = new long[NUM_INVOKES]; + private static int resultsRotateRightInteger[] = new int[NUM_INVOKES]; + private static int resultsRotateRightIntegerConstant[] = new int[NUM_INVOKES]; + private static long resultsRotateRightLong[] = new long[NUM_INVOKES]; + private static long resultsRotateRightLongConstant[] = new long[NUM_INVOKES]; public void timeRotateRightInteger(int iterations) { for (int iter = 0; iter < iterations; ++iter) { @@ -178,10 +178,10 @@ public class Intrinsics { * RotateLeft. **/ - private static int[] resultsRotateLeftInteger = new int[NUM_INVOKES]; - private static int[] resultsRotateLeftIntegerConstant = new int[NUM_INVOKES]; - private static long[] resultsRotateLeftLong = new long[NUM_INVOKES]; - private static long[] resultsRotateLeftLongConstant = new long[NUM_INVOKES]; + private static int resultsRotateLeftInteger[] = new int[NUM_INVOKES]; + private static int resultsRotateLeftIntegerConstant[] = new int[NUM_INVOKES]; + private static long resultsRotateLeftLong[] = new long[NUM_INVOKES]; + private static long resultsRotateLeftLongConstant[] = new long[NUM_INVOKES]; public void timeRotateLeftInteger(int iterations) { for (int iter = 0; iter < iterations; ++iter) { @@ -219,8 +219,8 @@ public class Intrinsics { * RotateRandom. **/ - private static int[] resultsRotateRandomInteger = new int[NUM_INVOKES]; - private static long[] resultsRotateRandomLong = new long[NUM_INVOKES]; + private static int resultsRotateRandomInteger[] = new int[NUM_INVOKES]; + private static long resultsRotateRandomLong[] = new long[NUM_INVOKES]; public void timeRotateRandomInteger(int iterations) { for (int iter = 0; iter < iterations; ++iter) { @@ -256,7 +256,7 @@ public class Intrinsics { /** * *NOT* called by the framework by default, provided for direct use only. **/ - public static void main(String[] args) { + public static void main(String args[]) { Intrinsics obj = new Intrinsics(); long before = System.currentTimeMillis(); obj.timeNumberOfLeadingZerosInteger(100000); diff --git a/benchmarking/java-ubenchs/framework/org/linaro/bench/BenchmarkList.java.template b/benchmarking/java-ubenchs/framework/org/linaro/bench/BenchmarkList.java.template index 7c4c55e..d8a1335 100644 --- a/benchmarking/java-ubenchs/framework/org/linaro/bench/BenchmarkList.java.template +++ b/benchmarking/java-ubenchs/framework/org/linaro/bench/BenchmarkList.java.template @@ -19,7 +19,7 @@ package org.linaro.bench; public class BenchmarkList { - public static final String[] benchmarkList = { + public static final String benchmarkList[] = { <to be filled by the build system> }; } diff --git a/benchmarking/java-ubenchs/framework/org/linaro/bench/RunBench.java b/benchmarking/java-ubenchs/framework/org/linaro/bench/RunBench.java index 54857c7..0b929f6 100644 --- a/benchmarking/java-ubenchs/framework/org/linaro/bench/RunBench.java +++ b/benchmarking/java-ubenchs/framework/org/linaro/bench/RunBench.java @@ -206,7 +206,7 @@ public class RunBench { + "\t (default: " + DEFAULT_CALIBRATION_MIN_TIME_NS + ")\n" + ""; - public void parseCmdlineAndRun(String[] args) { + public void parseCmdlineAndRun(String args[]) { String subtest = null; boolean verify = true; // Verify all benchmark results by default. List<String> benchmarks = new ArrayList<String>(); @@ -269,7 +269,7 @@ public class RunBench { } } - public static void main(String[] args) { + public static void main(String args[]) { RunBench bench = new RunBench(); // Set default log level. bench.parseCmdlineAndRun(args); |