From 786406277e21a6ee51cf3e62f45f3e5fa5182300 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Thu, 19 Apr 2018 18:46:57 -0400
Subject: [PATCH] test: removed excessive print statements and replaced with
 assertions.

---
 .../com/aparapi/ConvolutionLargeTest.java     | 25 ++++---------------
 .../runtime/AccessGetterSetterTest.java       |  1 -
 .../aparapi/runtime/BarrierSupportTest.java   |  6 -----
 .../com/aparapi/runtime/RangeSizeTest.java    |  6 -----
 4 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/src/test/java/com/aparapi/ConvolutionLargeTest.java b/src/test/java/com/aparapi/ConvolutionLargeTest.java
index d61f2572..5277074d 100644
--- a/src/test/java/com/aparapi/ConvolutionLargeTest.java
+++ b/src/test/java/com/aparapi/ConvolutionLargeTest.java
@@ -44,9 +44,7 @@ public class ConvolutionLargeTest {
     public void testConvolutionLarge() {
         boolean testWithoutCaches = true;
         for (int i = 1; i <= TEST_ROUNDS; i++) {
-            System.out.println("-----------------------------");
             int pixels = (1_000 * 1_000 * (1 << (i - 1))) & ~(1 << 10 - 1);
-            System.out.println(MessageFormat.format("Round #{0}/{1} ({2} pixels)", i, TEST_ROUNDS, pixels));
 
             //prepare the size
             int side = (int) Math.sqrt(pixels);
@@ -55,8 +53,6 @@ public class ConvolutionLargeTest {
             byte[] inBytes = new byte[width * height * 3];
             byte[] outBytes = new byte[width * height * 3];
 
-            System.out.println("-----------------------------");
-            System.out.println();
             testWithSupplier(new ImageConvolutionCreationContext() {
                 private ImageConvolution convolution = new ImageConvolution();
 
@@ -125,18 +121,15 @@ public class ConvolutionLargeTest {
     }
 
     private void testWithSupplier(ImageConvolutionCreationContext imageConvolutionCreationContext, int seconds, boolean testWithoutCaches, byte[] inBytes, byte[] outBytes, int width, int height) {
-        System.out.println("Test context: " + imageConvolutionCreationContext.getName());
         CacheEnabler.setCachesEnabled(!testWithoutCaches);
         // Warmup
-        doTest("Warmup (caches " + (testWithoutCaches ? "not " : "") + "enabled)", SECONDS_PER_WARMUP, imageConvolutionCreationContext, inBytes, outBytes, width, height);
+        doTest( SECONDS_PER_WARMUP, imageConvolutionCreationContext, inBytes, outBytes, width, height);
         if (testWithoutCaches) {
-            long timeWithoutCaches = doTest("Without caches", seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
+            long timeWithoutCaches = doTest( seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
             CacheEnabler.setCachesEnabled(true);
-            long timeWithCaches = doTest("With    caches", seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
-            System.out.println(MessageFormat.format("\tSpeedup: {0} %", 100d * (timeWithoutCaches - timeWithCaches)
-                / timeWithoutCaches));
+            long timeWithCaches = doTest( seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
         } else {
-            doTest("With    caches", seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
+            doTest( seconds, imageConvolutionCreationContext, inBytes, outBytes, width, height);
         }
     }
 
@@ -156,11 +149,10 @@ public class ConvolutionLargeTest {
 
     }
 
-    private long doTest(String name, int seconds, ImageConvolutionCreationContext imageConvolutionCreationContext, byte[] inBytes, byte[] outBytes, int width, int height) {
+    private long doTest(int seconds, ImageConvolutionCreationContext imageConvolutionCreationContext, byte[] inBytes, byte[] outBytes, int width, int height) {
         long totalTime = 0;
         Supplier<ImageConvolution> imageConvolutionSupplier = imageConvolutionCreationContext.getSupplier();
         Consumer<ImageConvolution> disposer = imageConvolutionCreationContext.getDisposer();
-        System.out.print("\tTesting " + name + "[" + imageConvolutionCreationContext.getName() + "] (" + seconds + " seconds) ");
         int calls = 0;
         long initialTime = System.nanoTime();
         long maxElapsedNs = TimeUnit.SECONDS.toNanos(seconds);
@@ -178,16 +170,9 @@ public class ConvolutionLargeTest {
             long end = System.nanoTime();
             long roundTime = end - start;
             totalTime += roundTime;
-            //         System.out.print("#" + i + " - " + roundTime + "ms ");
-            //         System.out.print(roundTime + " ");
-            System.out.print(".");
             calls++;
         }
         imageConvolutionCreationContext.shutdown();
-        System.out.println();
-        System.out.println(MessageFormat.format("\tFinished in {0} s ({1} ms/call, {2} calls)", totalTime / 1e9d,
-            (totalTime / (calls * 1e6d)), calls));
-        System.out.println();
         return totalTime / calls;
     }
 
diff --git a/src/test/java/com/aparapi/runtime/AccessGetterSetterTest.java b/src/test/java/com/aparapi/runtime/AccessGetterSetterTest.java
index cbde25eb..17f4f488 100644
--- a/src/test/java/com/aparapi/runtime/AccessGetterSetterTest.java
+++ b/src/test/java/com/aparapi/runtime/AccessGetterSetterTest.java
@@ -50,7 +50,6 @@ public class AccessGetterSetterTest {
 
         void validate() {
             for (int i = 0; i < SIZE; i++) {
-                System.out.println(target[i] + " ... " + objects[i].getValue());
                 assertTrue("target == objects", target[i] == objects[i].getValue());
             }
         }
diff --git a/src/test/java/com/aparapi/runtime/BarrierSupportTest.java b/src/test/java/com/aparapi/runtime/BarrierSupportTest.java
index 249f35b0..c0403aba 100644
--- a/src/test/java/com/aparapi/runtime/BarrierSupportTest.java
+++ b/src/test/java/com/aparapi/runtime/BarrierSupportTest.java
@@ -67,7 +67,6 @@ public class BarrierSupportTest {
 
     @Test
     public void testBarrier1() {
-    	System.out.println("Executing on device: " + openCLDevice.getShortDescription() + " - " + openCLDevice.getName());
         final Barrrier1Kernel kernel = new Barrrier1Kernel(SIZE);
         try {
 	        final Range range = openCLDevice.createRange(SIZE, SIZE);
@@ -83,7 +82,6 @@ public class BarrierSupportTest {
     
     @Test
     public void testBarrier1Explicit() {
-    	System.out.println("Executing on device: " + openCLDevice.getShortDescription() + " - " + openCLDevice.getName());
         final Barrrier1Kernel kernel = new Barrrier1Kernel(SIZE);
         try {
 	        final Range range = openCLDevice.createRange(SIZE, SIZE);
@@ -104,7 +102,6 @@ public class BarrierSupportTest {
     	SIZE = 256;
     	KernelManager.setKernelManager(new JTPKernelManager());
         Device device = KernelManager.instance().bestDevice();
-        System.out.println("Executing on device: " + device.getShortDescription());
         assumeTrue (device != null && device instanceof JavaDevice);
 
         final Barrrier1Kernel kernel = new Barrrier1Kernel(SIZE);
@@ -122,7 +119,6 @@ public class BarrierSupportTest {
 
     @Test
     public void testBarrier2() {
-    	System.out.println("Executing on device: " + openCLDevice.getShortDescription() + " - " + openCLDevice.getName());
         final Barrrier2Kernel kernel = new Barrrier2Kernel(SIZE);
         try {
 	        final Range range = openCLDevice.createRange(SIZE, SIZE);
@@ -138,7 +134,6 @@ public class BarrierSupportTest {
     
     @Test
     public void testBarrier2Explicit() {
-    	System.out.println("Executing on device: " + openCLDevice.getShortDescription() + " - " + openCLDevice.getName());
         final Barrrier2Kernel kernel = new Barrrier2Kernel(SIZE);
         try {
 	        final Range range = openCLDevice.createRange(SIZE, SIZE);
@@ -159,7 +154,6 @@ public class BarrierSupportTest {
     	SIZE = 256;
     	KernelManager.setKernelManager(new JTPKernelManager());
         Device device = KernelManager.instance().bestDevice();
-        System.out.println("Executing on device: " + device.getShortDescription());
         assumeTrue (device != null && device instanceof JavaDevice);
 
         final Barrrier2Kernel kernel = new Barrrier2Kernel(SIZE);
diff --git a/src/test/java/com/aparapi/runtime/RangeSizeTest.java b/src/test/java/com/aparapi/runtime/RangeSizeTest.java
index 908da0d4..2b1db170 100644
--- a/src/test/java/com/aparapi/runtime/RangeSizeTest.java
+++ b/src/test/java/com/aparapi/runtime/RangeSizeTest.java
@@ -25,18 +25,12 @@ public class RangeSizeTest {
     @Test
     public void test384x384() {
         Range range = Range.create2D(384, 384);
-        System.out.println("local[0] " + range.getLocalSize(0));
-        System.out.println("local[1] " + range.getLocalSize(1));
-        System.out.println("workGroupSize " + range.getWorkGroupSize());
         assertTrue("Range > max work size", range.getLocalSize(0) * range.getLocalSize(1) <= range.getWorkGroupSize());
     }
 
     @Test
     public void test384x320() {
         Range range = Range.create2D(384, 320);
-        System.out.println("local[0] " + range.getLocalSize(0));
-        System.out.println("local[1] " + range.getLocalSize(1));
-        System.out.println("workGroupSize " + range.getWorkGroupSize());
         assertTrue("Range > max work size", range.getLocalSize(0) * range.getLocalSize(1) <= range.getWorkGroupSize());
     }
 
-- 
GitLab