harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r471363 - in /incubator/harmony/enhanced/drlvm/trunk: build/make/components/vm/gc_gen.xml vm/gc_gen/src/tests/ vm/gc_gen/src/tests/ThreadSim.java
Date Sun, 05 Nov 2006 05:10:09 GMT
Author: wjwashburn
Date: Sat Nov  4 21:10:08 2006
New Revision: 471363

URL: http://svn.apache.org/viewvc?view=rev&rev=471363
Log:
HARMONY-1993, local mods to gc_gen directory only
This directory is not in the path of "build" or "build test" (no testing done)

Added:
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/
    incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/ThreadSim.java
Modified:
    incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml

Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml?view=diff&rev=471363&r1=471362&r2=471363
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_gen.xml Sat Nov  4
21:10:08 2006
@@ -111,5 +111,16 @@
                 <linkerarg value="-Bsymbolic" />
             </select>
         </linker>
+        <path id="java.source">
+            <pathelement location="${build.vm.home}/gc_gen/src/tests" />
+        </path>                 
+
+        <path id="java.class.path">
+            <pathelement location="${java.build.dir}"/>
+
+            <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
+            <fileset dir="${build.ANTLR.home}" includes="antlr-2.7.5.jar" />
+        </path>
+
     </target>
 </project>

Added: incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/ThreadSim.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/ThreadSim.java?view=auto&rev=471363
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/ThreadSim.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/tests/ThreadSim.java Sat Nov  4 21:10:08
2006
@@ -0,0 +1,93 @@
+class Small
+{
+    private int i, j;
+};
+
+class MyThread extends Thread
+{
+    int tableSize;
+    int iterations;
+
+    public MyThread(int _tableSize, int _iterations)
+    {
+        tableSize = _tableSize;
+        iterations = _iterations;
+    }
+
+    public  void    run()
+    {
+        Small[] table = new Small[tableSize];
+
+        int iter = 0;
+        while (iter < iterations)
+        {
+            for (int i = 0; i < table.length; i++)
+            {
+                table[i] = new Small();             
+                iter++;
+            }
+        }
+    }
+};
+
+public class ThreadSim
+{
+    public static void test(int threadCount, int tableSize, int iterations)
+    {
+        MyThread t;
+
+        System.out.println("Timing  " + threadCount + " threads, retaining "  + tableSize*threadCount
+ " Objects:  " );
+
+        long    start = System.currentTimeMillis();
+
+        MyThread[] threads = new MyThread[threadCount];
+
+        
+        for (int i = 0; i < threadCount; i++)
+        {
+             
+             threads[i] = new MyThread(tableSize, iterations);
+             threads[i].start();
+        }
+
+	try{
+        	for (int i = 0; i < threadCount; i++)
+        	{
+             	threads[i].join();
+        	}
+	}
+	catch(Exception e)
+	{}
+        
+    
+        double elapsedSeconds = (System.currentTimeMillis() - start)/1000.0;
+        int smallSize = 16;
+        long allocatedMegaBytes = (long)iterations*threadCount*smallSize/(1024*1024);
+
+        System.out.println(elapsedSeconds + " seconds  " + allocatedMegaBytes/elapsedSeconds
+ " MB/sec");
+    }
+
+    public static void main (String[] args)
+    {
+        int iter = 50*1000*1000;
+
+        if (args.length >= 1)
+            iter = Integer.parseInt(args[0]);
+
+        System.out.println("Timing " + iter/(1000*1000) + " million total object allocations");
+        System.out.println("Varying number of threads and number of objects retained");
+        System.out.println();
+
+        long    start = System.currentTimeMillis();
+
+        for (int threadCount = 1; threadCount <= 32; threadCount *= 2)
+        {
+            for (int tableSize = 64; tableSize <= 8192; tableSize *= 2)
+            {
+                test(threadCount, tableSize/threadCount, iter/threadCount);
+            }   
+        }
+
+        System.out.println("Total: " + (System.currentTimeMillis() - start)/1000.0 + " seconds");
+    }
+}



Mime
View raw message