Major bench refactoring.
   - Use FLAGS_.
   - Remove outer repeat loop.
   - Tune inner loop automatically.

BUG=skia:1590
R=epoger@google.com, scroggo@google.com

Review URL: https://codereview.chromium.org/23478013

git-svn-id: http://skia.googlecode.com/svn/trunk@11187 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/DecodeBench.cpp b/bench/DecodeBench.cpp
index c87e6f6..c45654c 100644
--- a/bench/DecodeBench.cpp
+++ b/bench/DecodeBench.cpp
@@ -7,29 +7,26 @@
  */
 #include "SkBenchmark.h"
 #include "SkBitmap.h"
+#include "SkCommandLineFlags.h"
 #include "SkImageDecoder.h"
 #include "SkString.h"
 
+DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for DecodeBench.");
+
 static const char* gConfigName[] = {
     "ERROR", "a1", "a8", "index8", "565", "4444", "8888"
 };
 
 class DecodeBench : public SkBenchmark {
-    const char* fFilename;
     SkBitmap::Config fPrefConfig;
     SkString fName;
-    enum { N = SkBENCHLOOP(10) };
 public:
     DecodeBench(void* param, SkBitmap::Config c) : SkBenchmark(param) {
-        fFilename = this->findDefine("decode-filename");
         fPrefConfig = c;
 
-        const char* fname = NULL;
-        if (fFilename) {
-            fname = strrchr(fFilename, '/');
-            if (fname) {
-                fname += 1; // skip the slash
-            }
+        const char* fname = strrchr(FLAGS_decodeBenchFilename[0], '/');
+        if (fname) {
+            fname++; // skip the slash
         }
         fName.printf("decode_%s_%s", gConfigName[c], fname);
         fIsRendering = false;
@@ -41,12 +38,12 @@
     }
 
     virtual void onDraw(SkCanvas*) {
-        if (fFilename) {
-            for (int i = 0; i < N; i++) {
-                SkBitmap bm;
-                SkImageDecoder::DecodeFile(fFilename, &bm, fPrefConfig,
-                                           SkImageDecoder::kDecodePixels_Mode);
-            }
+        for (int i = 0; i < this->getLoops(); i++) {
+            SkBitmap bm;
+            SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0],
+                                       &bm,
+                                       fPrefConfig,
+                                       SkImageDecoder::kDecodePixels_Mode);
         }
     }