diff options
author | Xueliang Zhong <xueliang.zhong@linaro.org> | 2016-02-02 15:46:33 +0000 |
---|---|---|
committer | Alexandre Rames <alexandre.rames@linaro.org> | 2016-02-05 10:48:16 +0000 |
commit | bdccbf5c2d8a97c202fb5dbcb98f2f29a6b01d4d (patch) | |
tree | 4c69597fc6d2d8f7e5c1ff2677f7fbfa18d5bbe9 | |
parent | 6739dea0a8c4525593883e20a1e68c38067be844 (diff) | |
download | art-testing-bdccbf5c2d8a97c202fb5dbcb98f2f29a6b01d4d.tar.gz |
Modify and fit the DeltaBlue benchmark into ART testing framework
Change-Id: I0790bc1442299ee3880a69fb19775fa710a7b068
-rw-r--r-- | benchmarks/algorithm/DeltaBlue.java | 65 | ||||
-rwxr-xr-x | build.sh | 4 | ||||
-rwxr-xr-x | tools/lint.py | 4 |
3 files changed, 59 insertions, 14 deletions
diff --git a/benchmarks/algorithm/DeltaBlue.java b/benchmarks/algorithm/DeltaBlue.java index a304503..b7ffc82 100644 --- a/benchmarks/algorithm/DeltaBlue.java +++ b/benchmarks/algorithm/DeltaBlue.java @@ -7,6 +7,7 @@ * CL_SUN_COPYRIGHT_JVM_END */ +// CHECKSTYLE.OFF: .* /* * @(#)DeltaBlue.java 1.6 06/10/10 * @@ -46,7 +47,19 @@ */ +/* + * The original file is available at: + * https://github.com/xxgreg/deltablue/blob/master/DeltaBlue.java + * + * Modifications: + * (1) Added timeDeltaBlue() method for running with different iterations. + * (2) Added verifyDeltaBlue() method for verifying the benchmark. + * (3) Changed main() method. + * (4) On test failure, change from 'exit(1)' to print to stdout. + */ + //package COM.sun.labs.kanban.DeltaBlue; +package benchmarks.algorithm; import java.util.ArrayList; @@ -884,7 +897,7 @@ public class DeltaBlue /* implements Benchmark */ { public static Planner planner; - public static void main(String[] args) { + public static void main_(String[] args) { (new DeltaBlue()).inst_main(args); } @@ -924,7 +937,7 @@ public class DeltaBlue /* implements Benchmark */ { // low. Typical situations lie somewhere between these two // extremes. // - private void chainTest(int n) + private boolean chainTest(int n) { planner= new Planner(); @@ -950,9 +963,10 @@ public class DeltaBlue /* implements Benchmark */ { first.value= i; plan.execute(); if (last.value != i) - error("Chain test failed!"); + return false; } editC.destroyConstraint(); + return true; } @@ -961,7 +975,7 @@ public class DeltaBlue /* implements Benchmark */ { // time is measured to change a variable on either side of the // mapping and to change the scale and offset factors. // - private void projectionTest(int n) + private boolean projectionTest(int n) { planner= new Planner(); @@ -980,22 +994,23 @@ public class DeltaBlue /* implements Benchmark */ { } change(src, 17); - if (dst.value != 1170) error("Projection test 1 failed!"); + if (dst.value != 1170) return false; change(dst, 1050); - if (src.value != 5) error("Projection test 2 failed!"); + if (src.value != 5) return false; change(scale, 5); for (int i= 0; i < n - 1; ++i) { if ((dests.get(i)).value != i * 5 + 1000) - error("Projection test 3 failed!"); + return false; } change(offset, 2000); for (int i= 0; i < n - 1; ++i) { if ((dests.get(i)).value != i * 5 + 2000) - error("Projection test 4 failed!"); + return false; } + return true; } private void change(Variable var, int newValue) @@ -1017,5 +1032,39 @@ public class DeltaBlue /* implements Benchmark */ { System.exit(1); } + // CHECKSTYLE.ON: .* + public void timeDeltaBlue(int iterations) { + for (int iter = 0; iter < iterations; iter++) { + chainTest(100); + projectionTest(100); + } + } + + public boolean verifyDeltaBlue() { + if (!chainTest(100)) { + System.out.println("ERROR: Chain test failed"); + return false; + } + if (!projectionTest(100)) { + System.out.println("ERROR: Projection test failed"); + return false; + } + return true; + } + + public static void main(String[] args) { + int rc = 0; + DeltaBlue obj = new DeltaBlue(); + + long before = System.currentTimeMillis(); + obj.timeDeltaBlue(300); + long after = System.currentTimeMillis(); + + System.out.println("benchmarks/algorithm/DeltaBlue: " + (after - before)); + if (!obj.verifyDeltaBlue()) { + rc++; + } + System.exit(rc); + } } @@ -109,9 +109,7 @@ shift $((OPTIND - 1)) # Disable wildcard expansion. set -f # Find what Java files we need to compile. -JAVA_BENCHMARK_FILES="$(find $DIR_BENCHMARKS -type f -name '*'.java \ - ! -name DeltaBlue.java \ -)" +JAVA_BENCHMARK_FILES="$(find $DIR_BENCHMARKS -type f -name '*'.java)" # Reenable wildcard expansion. set +f diff --git a/tools/lint.py b/tools/lint.py index 4ddef95..5e87f6e 100755 --- a/tools/lint.py +++ b/tools/lint.py @@ -33,15 +33,13 @@ def BuildOptions(): help='Lint using N jobs') return parser.parse_args() -def ExcludeJavaFiles(filename): - return filename.endswith('DeltaBlue.java') def GetJavaFiles(): java_files = [] for dir_java_files in [utils.dir_framework, utils.dir_benchmarks]: for root, dirs, files in os.walk(dir_java_files): files = map(lambda x : os.path.join(root, x), files) - java_files += [f for f in files if (f.endswith('.java') and (not ExcludeJavaFiles(f)))] + java_files += [f for f in files if f.endswith('.java')] java_files.sort() return java_files |