You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/11/21 16:56:55 UTC

svn commit: r882934 - /activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java

Author: chirino
Date: Sat Nov 21 15:56:55 2009
New Revision: 882934

URL: http://svn.apache.org/viewvc?rev=882934&view=rev
Log:
Tweaking the output

Modified:
    activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java

Modified: activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java?rev=882934&r1=882933&r2=882934&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-syscall/src/main/java/org/apache/activemq/syscall/util/DiskBenchmark.java Sat Nov 21 15:56:55 2009
@@ -22,6 +22,7 @@
 import java.io.RandomAccessFile;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
@@ -204,6 +205,11 @@
             for (String operation : this.operation) {
                 for (boolean random : this.random) {
                     for (boolean sync : this.sync) {
+                        
+                        String title = "operation: "+operation+", random: "+random+", sync: "+sync+", memcopy: "+memcopy;
+                        System.out.println(title);
+                        System.out.println(repeat('-', title.length()));
+
                         ArrayList<Benchmark> results = new ArrayList<Benchmark>(this.api.length); 
                         for (String apiName : this.api) {
                             Benchmark benchmark = createBenchmark(apiName);
@@ -226,6 +232,13 @@
 
     }
 
+    private String repeat(char val, int length) {
+        char [] rc = new char[length];
+        Arrays.fill(rc, val);
+        return new String(rc);
+    }
+
+
     private void writeReportHeader(PrintWriter pw) {
         if(pw==null) 
             return;
@@ -364,9 +377,6 @@
                 }
             } catch (InterruptedException e) {
             } finally {
-                if( verbose ) {
-                    System.out.println();
-                }
                 this.samples.set(samples);
             }
         }
@@ -396,13 +406,26 @@
                 throw new RuntimeException();
             }
             
-            System.out.print("Benchmarking: api: "+apiName+", operation: "+operation+", random: "+random+", sync: "+sync+", memcopy: "+memcopy+" ");
-
+            System.out.println("  api: "+apiName);
+            
             AtomicLong ioCount=new AtomicLong();
             RateSampler sampler = new RateSampler(ioCount, sampleCount, samplePeriod);
             sampler.verbose = verbose;
             try {
                 init(true);
+                
+                // Pre-allocate the data file before we start sampling.
+                if( verbose ) {
+                    System.out.println("    pre-allocating: ... ");
+                }
+                for( long i=0; i < blocks; i++) {
+                    write();
+                }
+                sync();
+
+                if( verbose ) {
+                    System.out.print("    sampling: ");
+                }
                 sampler.start();
                 outer: while( true ) {
                     seek(0);
@@ -422,10 +445,13 @@
                     }
                 }
             } finally {
+                if( verbose ) {
+                    System.out.println(" done");
+                }
                 dispose();
             }
             samples = sampler.getSamples();
-            System.out.println("  results: "+samples);
+            System.out.println("    results: "+samples);
             System.out.println();
 
         }