You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by re...@apache.org on 2015/08/03 19:21:26 UTC

svn commit: r1693939 - /devicemap/trunk/clients/2.0/reference/src/Main.java

Author: rezan
Date: Mon Aug  3 17:21:26 2015
New Revision: 1693939

URL: http://svn.apache.org/r1693939
Log:
warmup iterations

Modified:
    devicemap/trunk/clients/2.0/reference/src/Main.java

Modified: devicemap/trunk/clients/2.0/reference/src/Main.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/Main.java?rev=1693939&r1=1693938&r2=1693939&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/Main.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/Main.java Mon Aug  3 17:21:26 2015
@@ -38,7 +38,7 @@ public class Main {
     String testString = null;
 
     boolean failure = false;
-    int warmup_sec = 0;
+    String warmup = null;
 
     long start, time;
 
@@ -59,7 +59,7 @@ public class Main {
       } else if(!option.startsWith("-") && testString == null) {
         testString = option;
       } else if(option.equals("-w")) {
-        warmup_sec = 3;
+        warmup = getParam(args, ++i, "-w iterations missing");
       } else if(option.equals("-q")) {
         verbose = -1;
       } else if(option.equals("-v")) {
@@ -79,8 +79,8 @@ public class Main {
 
     //WARMUP
     
-    if(warmup_sec > 0) {
-      runWarmup(warmup_sec, patterns, attributes, tests);
+    if(warmup != null) {
+      runWarmup(warmup, patterns, attributes, tests);
     }
 
     //BUILD THE DEVICEMAP CLIENT
@@ -133,7 +133,7 @@ public class Main {
     log("  -a <file>            load DeviceMap 2.0 attribute file", -1);
     log("  -t <file>            load DeviceMap 2.0 test file", -1);
     log("  -h                   print help", -1);
-    log("  -w                   run warmup", -1);
+    log("  -w <iterations>      run warmup", -1);
     log("  -q                   quiet", -1);
     log("  -v                   verbose", -1);
     log("  -vv                  very verbose", -1);
@@ -263,17 +263,27 @@ public class Main {
     return testCount != passCount;
   }
 
-  public static void runWarmup(int secs, List<String> p, List<String> a, List<String> t) throws Exception {
-    log("Warmup " + secs + " sec(s)...", -1);
+  public static void runWarmup(String warmupStr, List<String> p, List<String> a, List<String> t) throws Exception {
+    int warmup = 0;
+
+    try {
+      warmup = Integer.parseInt(warmupStr);
+    } catch(NumberFormatException e) {
+      throw new Exception("Invalid warmup value: " + warmupStr);
+    }
+
+    if(warmup < 1) {
+      throw new Exception("Invalid warmup value: " + warmup);
+    }
+
+    log("Warmup " + warmup + " iterations(s)...", -1);
 
     int origVerbose = verbose;
     verbose = -2;
 
-    long start = System.nanoTime();
-    long runtime = 0;
     long iterations = 0;
 
-    while(runtime < ((long)secs * 1000 * 1000 * 1000)) {
+    while(iterations < warmup) {
       DeviceMapClient client = new DeviceMapClient();
 
       for(String pattern : p) {
@@ -289,8 +299,6 @@ public class Main {
       }
 
       iterations++;
-
-      runtime = System.nanoTime() - start;
     }
 
     System.gc();
@@ -298,7 +306,7 @@ public class Main {
 
     verbose = origVerbose;
 
-    log("Warmup completed, " + iterations + " iteration(s)", -1);
+    log("Warmup completed", -1);
   }
 
   public static String getTime(long ns)