aboutsummaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorEvgeny Astigeevich <evgeny.astigeevich@linaro.org>2020-02-03 12:55:38 +0000
committerEvgeny Astigeevich <evgeny.astigeevich@linaro.org>2020-02-03 12:55:38 +0000
commitee28701ba925574dffcbf2b234246f5b0bcc1307 (patch)
treea5281f90c5e5ee5dc1a408b30ed1a7ef9f04f316 /benchmarks
parent23faae9675dce3b5398a2aef2fffd0eaa1d6a180 (diff)
downloadart-testing-ee28701ba925574dffcbf2b234246f5b0bcc1307.tar.gz
Fix checkstyle errors in benchmarksgame
Our presubmit test for benchmarks includes a run of checkstyle. It reports a lot of style errors. This CL fixes the errors. Test: art-testing/tools/checkstyle/checkstyle benchmarksgame/*.java Change-Id: I925ed7ddd25c3b6c51d0f7254709705a477499d9
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmarksgame/binarytrees_2.java5
-rw-r--r--benchmarks/benchmarksgame/binarytrees_6.java7
-rw-r--r--benchmarks/benchmarksgame/fannkuchredux.java2
-rw-r--r--benchmarks/benchmarksgame/fasta.java8
-rw-r--r--benchmarks/benchmarksgame/fasta_4.java18
-rw-r--r--benchmarks/benchmarksgame/fastaredux.java9
-rw-r--r--benchmarks/benchmarksgame/knucleotide.java4
-rw-r--r--benchmarks/benchmarksgame/mandelbrot.java5
-rw-r--r--benchmarks/benchmarksgame/meteor.java31
-rw-r--r--benchmarks/benchmarksgame/nbody_3.java6
-rw-r--r--benchmarks/benchmarksgame/nbody_5.java6
-rw-r--r--benchmarks/benchmarksgame/pidigits.java2
-rw-r--r--benchmarks/benchmarksgame/regexdna.java2
-rw-r--r--benchmarks/benchmarksgame/revcomp.java8
-rw-r--r--benchmarks/benchmarksgame/spectralnorm.java9
15 files changed, 102 insertions, 20 deletions
diff --git a/benchmarks/benchmarksgame/binarytrees_2.java b/benchmarks/benchmarksgame/binarytrees_2.java
index e483d66..fa6acb7 100644
--- a/benchmarks/benchmarksgame/binarytrees_2.java
+++ b/benchmarks/benchmarksgame/binarytrees_2.java
@@ -22,7 +22,9 @@
package benchmarks.benchmarksgame;
+// CHECKSTYLE.OFF: TypeName
public class binarytrees_2 {
+// CHECKSTYLE.ON: TypeName
private static final int PREDEFINED_DEPTH = 7;
private static final int minDepth = 4;
@@ -48,7 +50,8 @@ public class binarytrees_2 {
}
private static class TreeNode {
- private TreeNode left, right;
+ private TreeNode left;
+ private TreeNode right;
private static TreeNode bottomUpTree(int depth) {
if (depth > 0) {
diff --git a/benchmarks/benchmarksgame/binarytrees_6.java b/benchmarks/benchmarksgame/binarytrees_6.java
index e4f0fcc..8fd0b10 100644
--- a/benchmarks/benchmarksgame/binarytrees_6.java
+++ b/benchmarks/benchmarksgame/binarytrees_6.java
@@ -24,7 +24,9 @@
package benchmarks.benchmarksgame;
+// CHECKSTYLE.OFF: TypeName
public class binarytrees_6 {
+// CHECKSTYLE.ON: TypeName
private static final int PREDEFINED_DEPTH = 7;
private static final int minDepth = 4;
@@ -52,13 +54,16 @@ public class binarytrees_6 {
}
static class TreeNode {
- TreeNode left, right;
+ TreeNode left;
+ TreeNode right;
static TreeNode create(int depth) {
return ChildTreeNodes(depth);
}
+ // CHECKSTYLE.OFF: MethodName
static TreeNode ChildTreeNodes(int depth) {
+ // CHECKSTYLE.ON: MethodName
TreeNode node = new TreeNode();
if (depth > 0) {
node.left = ChildTreeNodes(depth - 1);
diff --git a/benchmarks/benchmarksgame/fannkuchredux.java b/benchmarks/benchmarksgame/fannkuchredux.java
index 4d628c2..5b36788 100644
--- a/benchmarks/benchmarksgame/fannkuchredux.java
+++ b/benchmarks/benchmarksgame/fannkuchredux.java
@@ -23,7 +23,9 @@
package benchmarks.benchmarksgame;
+// CHECKSTYLE.OFF: TypeName
public class fannkuchredux {
+// CHECKSTYLE.ON: TypeName
public int fannkuch(int n) {
int[] perm = new int[n];
int[] perm1 = new int[n];
diff --git a/benchmarks/benchmarksgame/fasta.java b/benchmarks/benchmarksgame/fasta.java
index 1529d42..afe458b 100644
--- a/benchmarks/benchmarksgame/fasta.java
+++ b/benchmarks/benchmarksgame/fasta.java
@@ -29,8 +29,10 @@ package benchmarks.benchmarksgame;
import java.io.IOException;
import java.io.OutputStream;
+// CHECKSTYLE.OFF: TypeName
public class fasta {
- private final static class NullOutputStream extends OutputStream {
+// CHECKSTYLE.ON: TypeName
+ private static final class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
// Do nothing
@@ -97,12 +99,14 @@ public class fasta {
}
// naive
+ // CHECKSTYLE.OFF: .*
public static final byte selectRandom(frequency[] a) {
int len = a.length;
double r = random(1.0);
for (int i = 0; i < len; i++) if (r < a[i].p) return a[i].c;
return a[len - 1].c;
}
+ // CHECKSTYLE.ON: .*
static int BUFFER_SIZE = 1024;
static int index = 0;
@@ -156,7 +160,9 @@ public class fasta {
if (index != 0) writer.write(bbuffer, 0, index);
}
+ // CHECKSTYLE.OFF: TypeName
public static class frequency {
+ // CHECKSTYLE.ON: TypeName
public byte c;
public double p;
diff --git a/benchmarks/benchmarksgame/fasta_4.java b/benchmarks/benchmarksgame/fasta_4.java
index 32220b9..47661b3 100644
--- a/benchmarks/benchmarksgame/fasta_4.java
+++ b/benchmarks/benchmarksgame/fasta_4.java
@@ -30,8 +30,10 @@ package benchmarks.benchmarksgame;
import java.io.IOException;
import java.io.OutputStream;
+// CHECKSTYLE.OFF: TypeName
public class fasta_4 {
- private final static class NullOutputStream extends OutputStream {
+// CHECKSTYLE.ON: TypeName
+ private static final class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
// Do nothing
@@ -267,4 +269,18 @@ public class fasta_4 {
return max * last * oneOverIM;
}
}
+
+ public static void main(String[] args) {
+ fasta_4 obj = new fasta_4();
+
+ final long before = System.currentTimeMillis();
+ obj.timeFasta(1700);
+ final long after = System.currentTimeMillis();
+
+ if (!obj.verifyFasta()) {
+ System.out.println("ERROR: verifyFasta failed.");
+ System.exit(1);
+ }
+ System.out.println("benchmarks/benchmarksgame/fasta: " + (after - before));
+ }
}
diff --git a/benchmarks/benchmarksgame/fastaredux.java b/benchmarks/benchmarksgame/fastaredux.java
index 8b3cd2e..6a65053 100644
--- a/benchmarks/benchmarksgame/fastaredux.java
+++ b/benchmarks/benchmarksgame/fastaredux.java
@@ -25,7 +25,9 @@ package benchmarks.benchmarksgame;
import java.io.*;
+// CHECKSTYLE.OFF: TypeName
public class fastaredux {
+// CHECKSTYLE.ON: TypeName
static final int LINE_LENGTH = 60;
static final int OUT_BUFFER_SIZE = 256 * 1024;
@@ -95,7 +97,7 @@ public class fastaredux {
static final class Out {
- static byte buf[] = new byte[OUT_BUFFER_SIZE];
+ static byte[] buf = new byte[OUT_BUFFER_SIZE];
static final int lim = OUT_BUFFER_SIZE - 2 * LINE_LENGTH - 1;
static int ct = 0;
static OutputStream stream;
@@ -158,9 +160,10 @@ public class fastaredux {
System.arraycopy(desc.getBytes(), 0, Out.buf, Out.ct, desc.length());
Out.ct += desc.length();
- byte buf[] = new byte[alu.length + LINE_LENGTH];
- for (int i = 0; i < buf.length; i += alu.length)
+ byte[] buf = new byte[alu.length + LINE_LENGTH];
+ for (int i = 0; i < buf.length; i += alu.length) {
System.arraycopy(alu, 0, buf, i, Math.min(alu.length, buf.length - i));
+ }
int pos = 0;
while (n > 0) {
diff --git a/benchmarks/benchmarksgame/knucleotide.java b/benchmarks/benchmarksgame/knucleotide.java
index 9389b37..ce764fe 100644
--- a/benchmarks/benchmarksgame/knucleotide.java
+++ b/benchmarks/benchmarksgame/knucleotide.java
@@ -35,7 +35,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+// CHECKSTYLE.OFF: TypeName
public class knucleotide {
+// CHECKSTYLE.ON: TypeName
private byte[] temp = null;
private byte[] buffer = null;
@@ -99,6 +101,7 @@ public class knucleotide {
List<Entry<Key, Value>> sequence2 = new ArrayList<>();
for (Entry<Key, Value> entry : MAP.entrySet()) {
+ // CHECKSTYLE.OFF: MissingSwitchDefault
switch (Long.numberOfLeadingZeros(entry.getKey().key)) {
case 61:
sequence1.add(entry);
@@ -106,6 +109,7 @@ public class knucleotide {
case 59:
sequence2.add(entry);
}
+ // CHECKSTYLE.ON: MissingSwitchDefault
}
printSequence(sequence1);
printSequence(sequence2);
diff --git a/benchmarks/benchmarksgame/mandelbrot.java b/benchmarks/benchmarksgame/mandelbrot.java
index faf49d4..e94d912 100644
--- a/benchmarks/benchmarksgame/mandelbrot.java
+++ b/benchmarks/benchmarksgame/mandelbrot.java
@@ -23,8 +23,9 @@
package benchmarks.benchmarksgame;
-
+// CHECKSTYLE.OFF: TypeName
public class mandelbrot {
+// CHECKSTYLE.ON: TypeName
private static final int PREDEFINED_SIZE = 200;
private static final int BUFFER_SIZE = 8192;
@@ -51,12 +52,14 @@ public class mandelbrot {
final double Ci = (y * fac - 1.0);
final byte[] bufLocal = buf;
for (int x = 0; x < size; x++) {
+ // CHECKSTYLE.OFF: LocalVariableName
double Zr = 0.0;
double Zi = 0.0;
double Cr = (x * fac - 1.5);
int i = 50;
double ZrN = 0;
double ZiN = 0;
+ // CHECKSTYLE.ON: LocalVariableName
do {
Zi = 2.0 * Zr * Zi + Ci;
Zr = ZrN - ZiN + Cr;
diff --git a/benchmarks/benchmarksgame/meteor.java b/benchmarks/benchmarksgame/meteor.java
index 9619a72..5668323 100644
--- a/benchmarks/benchmarksgame/meteor.java
+++ b/benchmarks/benchmarksgame/meteor.java
@@ -38,8 +38,11 @@ import java.util.TreeSet;
* @author Tony Seebregts
*/
-public class meteor { // CONSTANTS
+// CHECKSTYLE.OFF: TypeName
+public class meteor {
+// CHECKSTYLE.OFF: TypeName
+ // CONSTANTS
private static final int[] SHIFT = {0, 6, 11, 17, 22, 28, 33, 39, 44, 50};
private static final long[][] MASK = {
{0x01L, 0x02L, 0x04L, 0x08L, 0x10L},
@@ -204,21 +207,31 @@ public class meteor { // CONSTANTS
ArrayList[][] array = new ArrayList[10][10];
- for (int i = 0; i < 10; i++)
- for (int j = 0; j < 10; j++) array[i][j] = new ArrayList<Shape>();
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ array[i][j] = new ArrayList<Shape>();
+ }
+ }
// ... generate list
- for (Shape mutant : list)
- for (int row = 0; row <= mutant.maxRow; row++)
+ for (Shape mutant : list) {
+ for (int row = 0; row <= mutant.maxRow; row++) {
for (int col = mutant.minCol; col <= mutant.maxCol; col++) {
- if (!mutant.islet) array[row][col].add(new Shape(mutant, row, col));
- else if ((row != 0) || (col != 0)) array[row][col].add(new Shape(mutant, row, col));
+ if (!mutant.islet) {
+ array[row][col].add(new Shape(mutant, row, col));
+ } else if ((row != 0) || (col != 0)) {
+ array[row][col].add(new Shape(mutant, row, col));
+ }
}
+ }
+ }
- for (int row = 0; row < 10; row++)
- for (int col = 0; col < 10; col++)
+ for (int row = 0; row < 10; row++) {
+ for (int col = 0; col < 10; col++) {
shapes[row][col] = (Shape[]) array[row][col].toArray(new Shape[0]);
+ }
+ }
}
@SuppressWarnings("unchecked")
diff --git a/benchmarks/benchmarksgame/nbody_3.java b/benchmarks/benchmarksgame/nbody_3.java
index 97fa5db..65d69b2 100644
--- a/benchmarks/benchmarksgame/nbody_3.java
+++ b/benchmarks/benchmarksgame/nbody_3.java
@@ -72,7 +72,9 @@ final class NBodySystem {
}
public double energy() {
+ // CHECKSTYLE.OFF: MultipleVariableDeclarations
double dx, dy, dz, distance;
+ // CHECKSTYLE.ON: MultipleVariableDeclarations
double e = 0.0;
for (int i = 0; i < bodies.length; ++i) {
@@ -98,7 +100,9 @@ final class Body {
static final double SOLAR_MASS = 4 * PI * PI;
static final double DAYS_PER_YEAR = 365.24;
+ // CHECKSTYLE.OFF: MultipleVariableDeclarations|EmptyLineSeparator
public double x, y, z, vx, vy, vz, mass;
+ // CHECKSTYLE.ON: MultipleVariableDeclarations|EmptyLineSeparator
public Body() {}
@@ -164,7 +168,9 @@ final class Body {
}
}
+// CHECKSTYLE.OFF: TypeName
public final class nbody_3 {
+// CHECKSTYLE.ON: TypeName
private NBodySystem bodies;
public nbody_3() {
diff --git a/benchmarks/benchmarksgame/nbody_5.java b/benchmarks/benchmarksgame/nbody_5.java
index 1908322..3908f77 100644
--- a/benchmarks/benchmarksgame/nbody_5.java
+++ b/benchmarks/benchmarksgame/nbody_5.java
@@ -23,7 +23,9 @@
package benchmarks.benchmarksgame;
+// CHECKSTYLE.OFF: TypeName
public final class nbody_5 {
+// CHECKSTYLE.ON: TypeName
static final class NBodySystem {
private static final double PI = 3.141592653589793;
@@ -40,7 +42,9 @@ public final class nbody_5 {
private static final int vz = 5;
private static final int mass = 6;
+ // CHECKSTYLE.OFF: MemberName
private final double[] _bodies = {
+ // CHECKSTYLE.ON: MemberName
// sun begin
0,
0,
@@ -159,7 +163,9 @@ public final class nbody_5 {
public double energy() {
final double[] bodies = _bodies;
+ // CHECKSTYLE.OFF: MultipleVariableDeclarations
double dx, dy, dz, distance;
+ // CHECKSTYLE.ON: MultipleVariableDeclarations
double e = 0.0;
for (int i = 0; i < BODY_COUNT; ++i) {
diff --git a/benchmarks/benchmarksgame/pidigits.java b/benchmarks/benchmarksgame/pidigits.java
index 282d875..ce67e73 100644
--- a/benchmarks/benchmarksgame/pidigits.java
+++ b/benchmarks/benchmarksgame/pidigits.java
@@ -24,7 +24,9 @@ package benchmarks.benchmarksgame;
import java.math.BigInteger;
+// CHECKSTYLE.OFF: TypeName
public class pidigits {
+// CHECKSTYLE.ON: TypeName
static final int L = 10;
private static final int PREDEFINED_N_DIGITS = 27;
diff --git a/benchmarks/benchmarksgame/regexdna.java b/benchmarks/benchmarksgame/regexdna.java
index 07974d9..ac834ee 100644
--- a/benchmarks/benchmarksgame/regexdna.java
+++ b/benchmarks/benchmarksgame/regexdna.java
@@ -23,7 +23,9 @@ import java.io.*;
import java.util.*;
import java.util.regex.*;
+// CHECKSTYLE.OFF: TypeName
public final class regexdna {
+// CHECKSTYLE.ON: TypeName
private static final Map<String, String> replacements = new HashMap<String, String>();
private InputStream stream;
diff --git a/benchmarks/benchmarksgame/revcomp.java b/benchmarks/benchmarksgame/revcomp.java
index 8f0b949..323199b 100644
--- a/benchmarks/benchmarksgame/revcomp.java
+++ b/benchmarks/benchmarksgame/revcomp.java
@@ -24,7 +24,9 @@ package benchmarks.benchmarksgame;
import java.io.*;
+// CHECKSTYLE.OFF: TypeName
public class revcomp {
+// CHECKSTYLE.ON: TypeName
private ReversibleByteArray buf = new ReversibleByteArray();
InputStream stream = new ByteArrayInputStream(fastaStr.getBytes());
static final byte[] cmp = new byte[128];
@@ -49,7 +51,8 @@ public class revcomp {
static class ReversibleByteArray extends java.io.ByteArrayOutputStream {
void reverse() throws Exception {
if (count > 0) {
- int begin = 0, end = count - 1;
+ int begin = 0;
+ int end = count - 1;
while (buf[begin++] != '\n') ;
while (begin <= end) {
if (buf[begin] == '\n') begin++;
@@ -71,7 +74,8 @@ public class revcomp {
stream.reset();
while ((read = stream.read(line)) != -1) {
- int i = 0, last = 0;
+ int i = 0;
+ int last = 0;
while (i < read) {
if (line[i] == '>') {
buf.write(line, last, i - last);
diff --git a/benchmarks/benchmarksgame/spectralnorm.java b/benchmarks/benchmarksgame/spectralnorm.java
index 42432d8..d8e350f 100644
--- a/benchmarks/benchmarksgame/spectralnorm.java
+++ b/benchmarks/benchmarksgame/spectralnorm.java
@@ -27,11 +27,15 @@ package benchmarks.benchmarksgame;
import java.text.DecimalFormat;
import java.text.NumberFormat;
+// CHECKSTYLE.OFF: TypeName
public class spectralnorm {
+// CHECKSTYLE.ON: TypeName
private static final NumberFormat formatter = new DecimalFormat("#.000000000");
+ // CHECKSTYLE.OFF: MethodName
private final double Approximate(int n) {
+ // CHECKSTYLE.ON: MethodName
// create unit vector
double[] u = new double[n];
for (int i = 0; i < n; i++) u[i] = 1;
@@ -47,7 +51,8 @@ public class spectralnorm {
// B=AtA A multiplied by A transposed
// v.Bv /(v.v) eigenvalue of v
- double vBv = 0, vv = 0;
+ double vBv = 0;
+ double vv = 0;
for (int i = 0; i < n; i++) {
vBv += u[i] * v[i];
vv += v[i] * v[i];
@@ -57,6 +62,7 @@ public class spectralnorm {
}
/* return element i,j of infinite matrix A */
+ // CHECKSTYLE.OFF: MethodName|ParameterName
private final double A(int i, int j) {
return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1);
}
@@ -83,6 +89,7 @@ public class spectralnorm {
MultiplyAv(n, v, u);
MultiplyAtv(n, u, AtAv);
}
+ // CHECKSTYLE.ON: MethodName|ParameterName
private static final int APPROXIMATE_N = 100;