harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r478184 - in /harmony/enhanced/drlvm/trunk/src/test/microbenchmark: ./ harmony-2223/ harmony-2223/test_longmuldiv_speed.java harmony-2247/ harmony-2247/ArraycopyTest.java
Date Wed, 22 Nov 2006 15:08:52 GMT
Author: varlax
Date: Wed Nov 22 07:08:51 2006
New Revision: 478184

URL: http://svn.apache.org/viewvc?view=rev&rev=478184
Log:
Store microbenchmarks from JIRAs, just in case.

Added:
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/test_longmuldiv_speed.java
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java

Added: harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/test_longmuldiv_speed.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/test_longmuldiv_speed.java?view=auto&rev=478184
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/test_longmuldiv_speed.java
(added)
+++ harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2223/test_longmuldiv_speed.java
Wed Nov 22 07:08:51 2006
@@ -0,0 +1,51 @@
+import java.util.*;
+
+/**
+ * Microbenchmark on  64bit multiplications, division and remainder.
+ */
+public class test_longmuldiv_speed {
+    public static void main(String[] args) {
+        //
+        // warm-up - force the method to be recompiled
+        //
+        System.out.println("Warming up ...");
+        for (int i=0; i<20000; i++) {
+            test(false);
+        }
+        //
+        // The real measure
+        //
+    System.out.println("Measuring ...");
+        long startTime = System.currentTimeMillis();
+        test(true);
+        long endTime = System.currentTimeMillis();
+        //
+        //
+        long spentTime = endTime - startTime;
+        System.out.println("... done.");
+        System.out.println("The test took: "+spentTime+"ms");
+    }
+
+    static void test(boolean do_test) {
+        int problem_size = do_test ? 10000000 : 5;
+        int array_size = 300000;
+        long[] array = new long[array_size];
+        Random rndValue = new Random(0);
+
+        for (int i=0; i<problem_size; i++) {
+            int index = i % array.length;
+            long v1 = rndValue.nextLong();
+            long v2 = rndValue.nextLong();
+            int what = (rndValue.nextInt() % 3);
+            if (what == 0) {
+                array[index] = v1*v2;
+            }
+            else if (what == 1) {
+                array[index] = v1/v2;
+            }
+            else {
+                array[index] = v1%v2;
+            }
+        }
+    }
+}
\ No newline at end of file

Added: harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java?view=auto&rev=478184
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java Wed
Nov 22 07:08:51 2006
@@ -0,0 +1,153 @@
+/**
+ * Microbenchmark for System.arraycopy.
+ * Should be run with -Xms1048M -Xmx1048M options.
+ */
+class ArraycopyTest {
+
+    public static int length = 100000000;
+
+    public static void main(String[] args) {
+
+        int arrA[] = new int[length];
+        int arrB[] = new int[length];
+
+        for (int i=0;i<length;i++) {
+            arrA[i] = i;
+        }
+// this part is for debugging
+/*
+        printArr(arrA,0,10, "arrA initial");
+        printArr(arrB,0,10, "arrB initial");
+        
+        System.arraycopy(arrA,1,arrB,3,5);
+        printArr(arrB,0,10, "arrB changed");
+        
+        System.arraycopy(arrB,3,arrB,8,5);
+        printArr(arrB,0,10, "arrB self forward");
+        
+        System.arraycopy(arrB,4,arrB,0,3);
+        printArr(arrB,0,10, "arrB self backward");
+*/        
+        System.out.println("");
+        System.out.println("START!");
+
+        long start = System.currentTimeMillis();
+
+        System.arraycopy(arrA,1,arrB,0,length-1);
+        System.arraycopy(arrA,1,arrB,0,length-1);
+        System.arraycopy(arrA,1,arrB,0,length-1);
+        System.out.print(". ");
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.out.print(". ");
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.out.print(". ");
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.out.print(". ");
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.out.print(". ");
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.out.print(". ");
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.out.print(". ");
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.out.print(". ");
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.out.print(". ");
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.out.print(". ");
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.out.print(". ");
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.out.print(". ");
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.out.print(". ");
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.out.print(". ");
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.out.print(". ");
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.out.print(". ");
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.out.print(". ");
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.out.print(". ");
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.out.print(". ");
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.arraycopy(arrA,2,arrB,0,length-2);
+        System.out.print(". ");
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.arraycopy(arrA,3,arrB,0,length-3);
+        System.out.print(". ");
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.arraycopy(arrA,4,arrB,0,length-4);
+        System.out.print(". ");
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.arraycopy(arrA,5,arrB,0,length-5);
+        System.out.print(". ");
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.arraycopy(arrA,6,arrB,0,length-6);
+        System.out.println(". ");
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+        System.arraycopy(arrA,7,arrB,0,length-7);
+
+        long end = System.currentTimeMillis();
+
+        System.out.println("FINISHED");
+
+        System.out.println("duration = "+(end - start)+" millis");
+
+    }
+
+    public static void printArr(int[] arr, int pos, int count, String prefix) {
+
+        String out = prefix + " : ";
+        for(int i=pos;i < pos+count; i++) {
+            out = out + arr[i] + " ";
+        }
+        System.out.println(out);
+    }
+}
+



Mime
View raw message