Calculated total time taken by the benchmark, and also reported it in the UI (in...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 8 Jun 2009 19:17:34 +0000 (19:17 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 8 Jun 2009 19:17:34 +0000 (19:17 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@966 59b500cc-1b3d-0410-9834-0bbf25fbcc57

androidtest/src/com/google/zxing/client/androidtest/BenchmarkActivity.java
androidtest/src/com/google/zxing/client/androidtest/BenchmarkItem.java

index f2daa33..6b30808 100755 (executable)
@@ -68,7 +68,6 @@ public final class BenchmarkActivity extends Activity {
           handleBenchmarkDone(message);
           mBenchmarkThread = null;
           mRunBenchmarkButton.setEnabled(true);
-          mTextView.setText(R.string.benchmark_help);
           break;
         default:
           break;
@@ -76,17 +75,21 @@ public final class BenchmarkActivity extends Activity {
     }
   };
 
-  private static void handleBenchmarkDone(Message message) {
+  private void handleBenchmarkDone(Message message) {
     List<BenchmarkItem> items = (List<BenchmarkItem>) message.obj;
     int count = 0;
+    int time = 0;
     for (int x = 0; x < items.size(); x++) {
       BenchmarkItem item = items.get(x);
       if (item != null) {
         Log.v(TAG, item.toString());
         count++;
+        time += item.getAverageTime();
       }
     }
-    Log.v(TAG, "TOTAL: Decoded " + count + " images");
+    String totals = "TOTAL: Decoded " + count + " images in " + time + " us";
+    Log.v(TAG, totals);
+    mTextView.setText(totals + "\n\n" + getString(R.string.benchmark_help));
   }
 
 }
index e334ca0..2de00c7 100644 (file)
@@ -71,7 +71,7 @@ public final class BenchmarkItem {
    *
    * @return The average decoding time in microseconds.
    */
-  private int getAverageTime() {
+  public int getAverageTime() {
     int size = mTimes.length;
     int total = 0;
     int max = mTimes[0];