This reverts commit 4052fd051db67bd1099fde2c4fe400cfbe1f2426.

git-svn-id: http://skia.googlecode.com/svn/trunk@10374 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/TimerData.cpp b/bench/TimerData.cpp
index f3084b0..18d41e4 100644
--- a/bench/TimerData.cpp
+++ b/bench/TimerData.cpp
@@ -13,130 +13,97 @@
 
 using namespace std;
 
-TimerData::TimerData(int maxNumTimings)
-: fMaxNumTimings(maxNumTimings)
-, fCurrTiming(0)
-, fWallTimes(maxNumTimings)
-, fTruncatedWallTimes(maxNumTimings)
-, fCpuTimes(maxNumTimings)
-, fTruncatedCpuTimes(maxNumTimings)
-, fGpuTimes(maxNumTimings){
+TimerData::TimerData(const SkString& perIterTimeFormat, const SkString& normalTimeFormat)
+: fWallStr(" msecs = ")
+, fTruncatedWallStr(" Wmsecs = ")
+, fCpuStr(" cmsecs = ")
+, fTruncatedCpuStr(" Cmsecs = ")
+, fGpuStr(" gmsecs = ")
+, fWallSum(0.0)
+, fWallMin((numeric_limits<double>::max)()) // Extra parens to make the windows build work, due to
+                                            // 'max' macro
+, fTruncatedWallSum(0.0)
+, fTruncatedWallMin((numeric_limits<double>::max)())
+, fCpuSum(0.0)
+, fCpuMin((numeric_limits<double>::max)())
+, fTruncatedCpuSum(0.0)
+, fTruncatedCpuMin((numeric_limits<double>::max)())
+, fGpuSum(0.0)
+, fGpuMin((numeric_limits<double>::max)())
+, fPerIterTimeFormat(perIterTimeFormat)
+, fNormalTimeFormat(normalTimeFormat)
+{}
+
+static double Min(double a, double b) {
+    return (a < b) ? a : b;
 }
 
-bool TimerData::appendTimes(BenchTimer* timer) {
+void TimerData::appendTimes(BenchTimer* timer, bool last) {
     SkASSERT(timer != NULL);
-    if (fCurrTiming >= fMaxNumTimings) {
-        return false;
+    SkString formatString(fPerIterTimeFormat);
+    if (!last) {
+        formatString.append(",");
     }
+    const char* format = formatString.c_str();
+    fWallStr.appendf(format, timer->fWall);
+    fCpuStr.appendf(format, timer->fCpu);
+    fTruncatedWallStr.appendf(format, timer->fTruncatedWall);
+    fTruncatedCpuStr.appendf(format, timer->fTruncatedCpu);
+    fGpuStr.appendf(format, timer->fGpu);
 
-    fWallTimes[fCurrTiming] = timer->fWall;
-    fTruncatedWallTimes[fCurrTiming] = timer->fTruncatedWall;
-    fCpuTimes[fCurrTiming] = timer->fCpu;
-    fTruncatedCpuTimes[fCurrTiming] = timer->fTruncatedCpu;
-    fGpuTimes[fCurrTiming] = timer->fGpu;
+    // Store the minimum values. We do not need to special case the first time since we initialized
+    // to max double.
+    fWallMin = Min(fWallMin, timer->fWall);
+    fCpuMin  = Min(fCpuMin,  timer->fCpu);
+    fTruncatedWallMin = Min(fTruncatedWallMin, timer->fTruncatedWall);
+    fTruncatedCpuMin  = Min(fTruncatedCpuMin,  timer->fTruncatedCpu);
+    fGpuMin  = Min(fGpuMin,  timer->fGpu);
 
-    ++fCurrTiming;
+    // Tally the sum of each timer type.
+    fWallSum += timer->fWall;
+    fCpuSum += timer->fCpu;
+    fTruncatedWallSum += timer->fTruncatedWall;
+    fTruncatedCpuSum += timer->fTruncatedCpu;
+    fGpuSum += timer->fGpu;
 
-    return true;
 }
 
-SkString TimerData::getResult(const char* doubleFormat,
-                              Result result,
-                              const char *configName,
-                              uint32_t timerFlags,
-                              int itersPerTiming) {
-    SkASSERT(itersPerTiming >= 1);
-
-    if (!fCurrTiming) {
-        return SkString("");
+SkString TimerData::getResult(bool logPerIter, bool printMin, int repeatDraw,
+                              const char *configName, bool showWallTime, bool showTruncatedWallTime,
+                              bool showCpuTime, bool showTruncatedCpuTime, bool showGpuTime) {
+    // output each repeat (no average) if logPerIter is set,
+    // otherwise output only the average
+    if (!logPerIter) {
+        const char* format = fNormalTimeFormat.c_str();
+        fWallStr.set(" msecs = ");
+        fWallStr.appendf(format, printMin ? fWallMin : fWallSum / repeatDraw);
+        fCpuStr.set(" cmsecs = ");
+        fCpuStr.appendf(format, printMin ? fCpuMin : fCpuSum / repeatDraw);
+        fTruncatedWallStr.set(" Wmsecs = ");
+        fTruncatedWallStr.appendf(format,
+                                  printMin ? fTruncatedWallMin : fTruncatedWallSum / repeatDraw);
+        fTruncatedCpuStr.set(" Cmsecs = ");
+        fTruncatedCpuStr.appendf(format,
+                                 printMin ? fTruncatedCpuMin : fTruncatedCpuSum / repeatDraw);
+        fGpuStr.set(" gmsecs = ");
+        fGpuStr.appendf(format, printMin ? fGpuMin : fGpuSum / repeatDraw);
     }
-
-    int numTimings = fCurrTiming;
-
-    SkString wallStr(" msecs = ");
-    SkString truncWallStr(" Wmsecs = ");
-    SkString cpuStr(" cmsecs = ");
-    SkString truncCpuStr(" Cmsecs = ");
-    SkString gpuStr(" gmsecs = ");
-
-    double wallMin = std::numeric_limits<double>::max();
-    double truncWallMin = std::numeric_limits<double>::max();
-    double cpuMin = std::numeric_limits<double>::max();
-    double truncCpuMin = std::numeric_limits<double>::max();
-    double gpuMin = std::numeric_limits<double>::max();
-
-    double wallSum = 0;
-    double truncWallSum = 0;
-    double cpuSum = 0;
-    double truncCpuSum = 0;
-    double gpuSum = 0;
-
-    for (int i = 0; i < numTimings; ++i) {
-        if (kPerIter_Result == result) {
-            wallStr.appendf(doubleFormat, fWallTimes[i]);
-            truncWallStr.appendf(doubleFormat, fTruncatedWallTimes[i]);
-            cpuStr.appendf(doubleFormat, fCpuTimes[i]);
-            truncCpuStr.appendf(doubleFormat, fTruncatedCpuTimes[i]);
-            gpuStr.appendf(doubleFormat, fGpuTimes[i]);
-
-            if (i != numTimings - 1) {
-                static const char kSep[] = ", ";
-                wallStr.append(kSep);
-                truncWallStr.append(kSep);
-                cpuStr.append(kSep);
-                truncCpuStr.append(kSep);
-                gpuStr.append(kSep);
-            }
-        } else if (kMin_Result == result) {
-            wallMin = SkTMin(wallMin, fWallTimes[i]);
-            truncWallMin = SkTMin(truncWallMin, fTruncatedWallTimes[i]);
-            cpuMin = SkTMin(cpuMin, fCpuTimes[i]);
-            truncCpuMin = SkTMin(truncCpuMin, fTruncatedCpuTimes[i]);
-            gpuMin = SkTMin(gpuMin, fGpuTimes[i]);
-        } else {
-            SkASSERT(kAvg_Result == result);
-            wallSum += fWallTimes[i];
-            truncWallSum += fTruncatedWallTimes[i];
-            cpuSum += fCpuTimes[i];
-            truncCpuSum += fTruncatedCpuTimes[i];
-        }
-
-        // We always track the GPU sum because whether it is non-zero indicates if valid gpu times
-        // were recorded at all.
-        gpuSum += fGpuTimes[i];
-    }
-
-    if (kMin_Result == result) {
-        wallStr.appendf(doubleFormat, wallMin / itersPerTiming);
-        truncWallStr.appendf(doubleFormat, truncWallMin / itersPerTiming);
-        cpuStr.appendf(doubleFormat, cpuMin / itersPerTiming);
-        truncCpuStr.appendf(doubleFormat, truncCpuMin / itersPerTiming);
-        gpuStr.appendf(doubleFormat, gpuMin / itersPerTiming);
-    } else if (kAvg_Result == result) {
-        int divisor = numTimings * itersPerTiming;
-        wallStr.appendf(doubleFormat, wallSum / divisor);
-        truncWallStr.appendf(doubleFormat, truncWallSum / divisor);
-        cpuStr.appendf(doubleFormat, cpuSum / divisor);
-        truncCpuStr.appendf(doubleFormat, truncCpuSum / divisor);
-        gpuStr.appendf(doubleFormat, gpuSum / divisor);
-    }
-
     SkString str;
     str.printf("  %4s:", configName);
-    if (timerFlags & kWall_Flag) {
-        str += wallStr;
+    if (showWallTime) {
+        str += fWallStr;
     }
-    if (timerFlags & kTruncatedWall_Flag) {
-        str += truncWallStr;
+    if (showTruncatedWallTime) {
+        str += fTruncatedWallStr;
     }
-    if (timerFlags & kCpu_Flag) {
-        str += cpuStr;
+    if (showCpuTime) {
+        str += fCpuStr;
     }
-    if (timerFlags & kTruncatedCpu_Flag) {
-        str += truncCpuStr;
+    if (showTruncatedCpuTime) {
+        str += fTruncatedCpuStr;
     }
-    if ((timerFlags & kGpu_Flag) && gpuSum > 0) {
-        str += gpuStr;
+    if (showGpuTime && fGpuSum > 0) {
+        str += fGpuStr;
     }
     return str;
 }
diff --git a/bench/TimerData.h b/bench/TimerData.h
index db7c781..d97a063 100644
--- a/bench/TimerData.h
+++ b/bench/TimerData.h
@@ -10,54 +10,37 @@
 #define TimerData_DEFINED
 
 #include "SkString.h"
-#include "SkTemplates.h"
-
 
 class BenchTimer;
 
 class TimerData {
 public:
-    /**
-     * Constructs a TimerData to hold at most maxNumTimings sets of elapsed timer values.
-     **/
-    explicit TimerData(int maxNumTimings);
+    TimerData(const SkString& perIterTimeFormat, const SkString& normalTimeFormat);
 
     /**
-     * Collect times from the BenchTimer for an iteration. It will fail if called more often than
-     * indicated in the constructor.
-     *
+     * Append the value from each timer in BenchTimer to our various strings, and update the
+     * minimum and sum times.
      * @param BenchTimer Must not be null.
+     * @param last True if this is the last set of times to add.
      */
-    bool appendTimes(BenchTimer*);
-
-    enum Result {
-        kMin_Result,
-        kAvg_Result,
-        kPerIter_Result
-    };
-
-    enum TimerFlags {
-        kWall_Flag              = 0x1,
-        kTruncatedWall_Flag     = 0x2,
-        kCpu_Flag               = 0x4,
-        kTruncatedCpu_Flag      = 0x8,
-        kGpu_Flag               = 0x10
-    };
-
-    SkString getResult(const char* doubleFormat,
-                       Result result,
-                       const char* configName,
-                       uint32_t timerFlags,
-                       int itersPerTiming = 1);
+    void appendTimes(BenchTimer*, bool last);
+    SkString getResult(bool logPerIter, bool printMin, int repeatDraw, const char* configName,
+                       bool showWallTime, bool showTruncatedWallTime, bool showCpuTime,
+                       bool showTruncatedCpuTime, bool showGpuTime);
 private:
-    int fMaxNumTimings;
-    int fCurrTiming;
+    SkString fWallStr;
+    SkString fTruncatedWallStr;
+    SkString fCpuStr;
+    SkString fTruncatedCpuStr;
+    SkString fGpuStr;
+    double fWallSum, fWallMin;
+    double fTruncatedWallSum, fTruncatedWallMin;
+    double fCpuSum, fCpuMin;
+    double fTruncatedCpuSum, fTruncatedCpuMin;
+    double fGpuSum, fGpuMin;
 
-    SkAutoTArray<double> fWallTimes;
-    SkAutoTArray<double> fTruncatedWallTimes;
-    SkAutoTArray<double> fCpuTimes;
-    SkAutoTArray<double> fTruncatedCpuTimes;
-    SkAutoTArray<double> fGpuTimes;
+    SkString fPerIterTimeFormat;
+    SkString fNormalTimeFormat;
 };
 
 #endif // TimerData_DEFINED
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 14ef3b3..1ace7d1 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -348,20 +348,20 @@
 
     SkTDict<const char*> defineDict(1024);
     int repeatDraw = 1;
-
+    bool logPerIter = false;
     int forceAlpha = 0xFF;
     bool forceAA = true;
     bool forceFilter = false;
     SkTriState::State forceDither = SkTriState::kDefault;
-
-    static const uint32_t kDefaultTimerTypes = TimerData::kCpu_Flag | TimerData::kGpu_Flag;
-    static const TimerData::Result kDefaultTimerResult = TimerData::kAvg_Result;
-    uint32_t timerTypes = kDefaultTimerTypes;
-    TimerData::Result timerResult = kDefaultTimerResult;
-
+    bool timerWall = false;
+    bool truncatedTimerWall = false;
+    bool timerCpu = true;
+    bool truncatedTimerCpu = false;
+    bool timerGpu = true;
     bool doScale = false;
     bool doRotate = false;
     bool doClip = false;
+    bool printMin = false;
     bool hasStrokeWidth = false;
 
 #if SK_SUPPORT_GPU
@@ -410,18 +410,22 @@
                 return -1;
             }
         } else if (strcmp(*argv, "--logPerIter") == 0) {
-            timerResult = TimerData::kPerIter_Result;
+            logPerIter = true;
         } else if (strcmp(*argv, "--timers") == 0) {
             argv++;
             if (argv < stop) {
-                timerTypes = 0;
+                timerWall = false;
+                truncatedTimerWall = false;
+                timerCpu = false;
+                truncatedTimerCpu = false;
+                timerGpu = false;
                 for (char* t = *argv; *t; ++t) {
                     switch (*t) {
-                    case 'w': timerTypes |= TimerData::kWall_Flag; break;
-                    case 'c': timerTypes |= TimerData::kCpu_Flag; break;
-                    case 'W': timerTypes |= TimerData::kTruncatedWall_Flag; break;
-                    case 'C': timerTypes |= TimerData::kTruncatedCpu_Flag; break;
-                    case 'g': timerTypes |= TimerData::kGpu_Flag; break;
+                    case 'w': timerWall = true; break;
+                    case 'c': timerCpu = true; break;
+                    case 'W': truncatedTimerWall = true; break;
+                    case 'C': truncatedTimerCpu = true; break;
+                    case 'g': timerGpu = true; break;
                     }
                 }
             } else {
@@ -436,7 +440,7 @@
         } else if (!strcmp(*argv, "--clip")) {
             doClip = true;
         } else if (!strcmp(*argv, "--min")) {
-            timerResult = TimerData::kMin_Result;
+            printMin = true;
         } else if (strcmp(*argv, "--forceAA") == 0) {
             if (!parse_bool_arg(++argv, stop, &forceAA)) {
                 logger.logError("missing arg for --forceAA\n");
@@ -644,9 +648,9 @@
         str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d "
                    "deferred=%s logperiter=%d",
                    forceAlpha, forceAA, forceFilter, deferredMode,
-                   TimerData::kPerIter_Result == timerResult);
+                   logPerIter);
         str.appendf(" rotate=%d scale=%d clip=%d min=%d",
-                   doRotate, doScale, doClip, TimerData::kMin_Result == timerResult);
+                   doRotate, doScale, doClip, printMin);
         str.appendf(" record=%d picturerecord=%d",
                     benchMode == kRecord_benchModes,
                     benchMode == kPictureRecord_benchModes);
@@ -879,7 +883,7 @@
                 }
 
                 // record timer values for each repeat, and their sum
-                TimerData timerData(repeatDraw);
+                TimerData timerData(perIterTimeformat, normalTimeFormat);
                 for (int i = 0; i < repeatDraw; i++) {
                     if ((benchMode == kRecord_benchModes || benchMode == kPictureRecord_benchModes)) {
                         // This will clear the recorded commands so that they do not
@@ -921,24 +925,15 @@
                     // have completed
                     timer->end();
 
-                    timerData.appendTimes(timer);
+                    timerData.appendTimes(timer, repeatDraw - 1 == i);
 
                 }
                 if (repeatDraw > 1) {
-                    const char* timeFormat;
-                    if (TimerData::kPerIter_Result == timerResult) {
-                        timeFormat = perIterTimeformat.c_str();
-                    } else {
-                        timeFormat = normalTimeFormat.c_str();
-                    }
-                    uint32_t filteredTimerTypes = timerTypes;
-                    if (NULL == context) {
-                        filteredTimerTypes &= ~TimerData::kGpu_Flag;
-                    }
-                    SkString result = timerData.getResult(timeFormat,
-                                        timerResult,
-                                        configName,
-                                        filteredTimerTypes);
+                    SkString result = timerData.getResult(
+                                        logPerIter, printMin, repeatDraw, configName,
+                                        timerWall, truncatedTimerWall, timerCpu,
+                                        truncatedTimerCpu,
+                                        timerGpu && NULL != context);
                     logger.logProgress(result);
                 }
                 if (outDir.size() > 0 && kNonRendering_Backend != backend) {
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index 0227575..39d4eb7 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -140,23 +140,13 @@
         #define WIN32_LEAN_AND_MEAN
         #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
     #endif
-    #ifndef NOMINMAX
-        #define NOMINMAX
-        #define NOMINMAX_WAS_LOCALLY_DEFINED
-    #endif
 
     #include <windows.h>
 
     #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
-        #undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
         #undef WIN32_LEAN_AND_MEAN
     #endif
 
-    #ifdef NOMINMAX_WAS_LOCALLY_DEFINED
-        #undef NOMINMAX_WAS_LOCALLY_DEFINED
-        #undef NOMINMAX
-    #endif
-
     #ifndef SK_DEBUGBREAK
         #define SK_DEBUGBREAK(cond)     do { if (!(cond)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false)
     #endif
diff --git a/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp
index 4b3b3e6..f20262b 100644
--- a/src/utils/win/SkWGL_win.cpp
+++ b/src/utils/win/SkWGL_win.cpp
@@ -312,7 +312,7 @@
         unsigned int num;
         int formats[64];
         extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);
-        num = SkTMin(num, 64U);
+        num = min(num,64);
         int formatToTry = extensions.selectFormat(formats,
                                                   num,
                                                   dc,
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index adab945..a358ad4 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -12,6 +12,7 @@
 #include "SkPicture.h"
 #include "SkString.h"
 #include "picture_utils.h"
+#include "TimerData.h"
 
 namespace sk_tools {
 
@@ -19,8 +20,13 @@
 : fRepeats(1)
 , fLogger(NULL)
 , fRenderer(NULL)
-, fTimerResult(TimerData::kAvg_Result)
-, fTimerTypes(0)
+, fLogPerIter(false)
+, fPrintMin(false)
+, fShowWallTime(false)
+, fShowTruncatedWallTime(false)
+, fShowCpuTime(true)
+, fShowTruncatedCpuTime(false)
+, fShowGpuTime(false)
 , fTimeIndividualTiles(false)
 {}
 
@@ -28,19 +34,6 @@
     SkSafeUnref(fRenderer);
 }
 
-void PictureBenchmark::setTimersToShow(bool wall,
-                                       bool truncatedWall,
-                                       bool cpu,
-                                       bool truncatedCpu,
-                                       bool gpu) {
-    fTimerTypes = 0;
-    fTimerTypes |= wall ? TimerData::kWall_Flag : 0;
-    fTimerTypes |= truncatedWall ? TimerData::kTruncatedWall_Flag : 0;
-    fTimerTypes |= cpu ? TimerData::kCpu_Flag : 0;
-    fTimerTypes |= truncatedCpu ? TimerData::kTruncatedCpu_Flag : 0;
-    fTimerTypes |= gpu ? TimerData::kGpu_Flag : 0;
-}
-
 BenchTimer* PictureBenchmark::setupTimer(bool useGLTimer) {
 #if SK_SUPPORT_GPU
     if (useGLTimer && fRenderer != NULL && fRenderer->isUsingGpuDevice()) {
@@ -84,18 +77,6 @@
     usingGpu = fRenderer->isUsingGpuDevice();
 #endif
 
-    uint32_t timerTypes = fTimerTypes;
-    if (!usingGpu) {
-        timerTypes &= ~TimerData::kGpu_Flag;
-    }
-
-    const char* timeFormat;
-    if (TimerData::kPerIter_Result == fTimerResult) {
-        timeFormat = fRenderer->getPerIterTimeFormat().c_str();
-    } else {
-        timeFormat = fRenderer->getNormalTimeFormat().c_str();
-    }
-
     if (fTimeIndividualTiles) {
         TiledPictureRenderer* tiledRenderer = fRenderer->getTiledRenderer();
         SkASSERT(tiledRenderer && tiledRenderer->supportsTimingIndividualTiles());
@@ -129,9 +110,11 @@
             // platforms. To work around this, we disable the gpu timer on the
             // long running timer.
             SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
-            TimerData longRunningTimerData(1);
+            TimerData longRunningTimerData(tiledRenderer->getPerIterTimeFormat(),
+                                           tiledRenderer->getNormalTimeFormat());
             SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
-            TimerData perTileTimerData(fRepeats);
+            TimerData perTileTimerData(tiledRenderer->getPerIterTimeFormat(),
+                                       tiledRenderer->getNormalTimeFormat());
             longRunningTimer->start();
             for (int i = 0; i < fRepeats; ++i) {
                 perTileTimer->start();
@@ -139,18 +122,20 @@
                 perTileTimer->truncatedEnd();
                 tiledRenderer->resetState(false);
                 perTileTimer->end();
-                perTileTimerData.appendTimes(perTileTimer.get());
+                perTileTimerData.appendTimes(perTileTimer.get(), fRepeats - 1 == i);
             }
             longRunningTimer->truncatedEnd();
             tiledRenderer->resetState(true);
             longRunningTimer->end();
-            longRunningTimerData.appendTimes(longRunningTimer.get());
+            longRunningTimerData.appendTimes(longRunningTimer.get(), true);
 
             SkString configName = tiledRenderer->getConfigName();
             configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yTiles);
-
-            SkString result = perTileTimerData.getResult(timeFormat, fTimerResult,
-                                                         configName.c_str(), timerTypes);
+            SkString result = perTileTimerData.getResult(fLogPerIter, fPrintMin, fRepeats,
+                                                         configName.c_str(), fShowWallTime,
+                                                         fShowTruncatedWallTime, fShowCpuTime,
+                                                         fShowTruncatedCpuTime,
+                                                         usingGpu && fShowGpuTime);
             result.append("\n");
 
 // TODO(borenet): Turn off per-iteration tile time reporting for now.  Avoiding logging the time
@@ -162,16 +147,15 @@
 #endif
 
             configName.append(" <averaged>");
-            SkString longRunningResult = longRunningTimerData.getResult(
-                tiledRenderer->getNormalTimeFormat().c_str(),
-                TimerData::kAvg_Result,
-                configName.c_str(), timerTypes, fRepeats);
+            SkString longRunningResult = longRunningTimerData.getResult(false, false, fRepeats,
+                    configName.c_str(), fShowWallTime, fShowTruncatedWallTime,
+                    fShowCpuTime, fShowTruncatedCpuTime, usingGpu && fShowGpuTime);
             longRunningResult.append("\n");
             this->logProgress(longRunningResult.c_str());
         }
     } else {
         SkAutoTDelete<BenchTimer> timer(this->setupTimer());
-        TimerData timerData(fRepeats);
+        TimerData timerData(fRenderer->getPerIterTimeFormat(), fRenderer->getNormalTimeFormat());
         for (int i = 0; i < fRepeats; ++i) {
             fRenderer->setup();
 
@@ -183,15 +167,14 @@
             fRenderer->resetState(true);
             timer->end();
 
-            timerData.appendTimes(timer.get());
+            timerData.appendTimes(timer.get(), fRepeats - 1 == i);
         }
 
         SkString configName = fRenderer->getConfigName();
-
-        SkString result = timerData.getResult(timeFormat,
-                                              fTimerResult,
-                                              configName.c_str(),
-                                              timerTypes);
+        SkString result = timerData.getResult(fLogPerIter, fPrintMin, fRepeats,
+                                              configName.c_str(), fShowWallTime,
+                                              fShowTruncatedWallTime, fShowCpuTime,
+                                              fShowTruncatedCpuTime, usingGpu && fShowGpuTime);
         result.append("\n");
         this->logProgress(result.c_str());
     }
diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h
index 1f01ce5..70c56d9 100644
--- a/tools/PictureBenchmark.h
+++ b/tools/PictureBenchmark.h
@@ -10,7 +10,6 @@
 
 #include "SkTypes.h"
 #include "PictureRenderer.h"
-#include "TimerData.h"
 
 class BenchTimer;
 class SkBenchLogger;
@@ -46,19 +45,32 @@
 
     PictureRenderer* setRenderer(PictureRenderer*);
 
-    void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
+    void setLogPerIter(bool log) { fLogPerIter = log; }
 
-    void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
+    void setPrintMin(bool min) { fPrintMin = min; }
+
+    void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) {
+        fShowWallTime = wall;
+        fShowTruncatedWallTime = truncatedWall;
+        fShowCpuTime = cpu;
+        fShowTruncatedCpuTime = truncatedCpu;
+        fShowGpuTime = gpu;
+    }
 
     void setLogger(SkBenchLogger* logger) { fLogger = logger; }
 
 private:
-    int               fRepeats;
-    SkBenchLogger*    fLogger;
-    PictureRenderer*  fRenderer;
-    TimerData::Result fTimerResult;
-    uint32_t          fTimerTypes; // bitfield of TimerData::TimerFlags values
-    bool              fTimeIndividualTiles;
+    int              fRepeats;
+    SkBenchLogger*   fLogger;
+    PictureRenderer* fRenderer;
+    bool             fLogPerIter;
+    bool             fPrintMin;
+    bool             fShowWallTime;
+    bool             fShowTruncatedWallTime;
+    bool             fShowCpuTime;
+    bool             fShowTruncatedCpuTime;
+    bool             fShowGpuTime;
+    bool             fTimeIndividualTiles;
 
     void logProgress(const char msg[]);
 
diff --git a/tools/bbh_shootout.cpp b/tools/bbh_shootout.cpp
index 36fe758..24d7b86 100644
--- a/tools/bbh_shootout.cpp
+++ b/tools/bbh_shootout.cpp
@@ -268,7 +268,7 @@
         const BenchmarkControl& benchControl,
         SkTArray<Histogram>& histogram) {
     static const SkString timeFormat("%f");
-    TimerData timerData(argc - 1);
+    TimerData timerData(timeFormat, timeFormat);
     for (int index = 1; index < argc; ++index) {
         BenchTimer timer;
         SkString path(argv[index]);
@@ -278,17 +278,22 @@
             continue;
         }
         benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path, pic, &timer);
-        timerData.appendTimes(&timer);
+        timerData.appendTimes(&timer, argc - 1 == index);
 
         histogram[index - 1].fPath = path;
         histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu);
     }
 
     const SkString timerResult = timerData.getResult(
-            /*doubleFormat = */ timeFormat.c_str(),
-            /*result = */ TimerData::kAvg_Result,
+            /*logPerIter = */ false,
+            /*printMin = */ false,
+            /*repeatDraw = */ 1,
             /*configName = */ benchControl.fName.c_str(),
-            /*timerFlags = */ TimerData::kCpu_Flag);
+            /*showWallTime = */ false,
+            /*showTruncatedWallTime = */ false,
+            /*showCpuTime = */ true,
+            /*showTruncatedCpuTime = */ false,
+            /*showGpuTime = */ false);
 
     const char findStr[] = "= ";
     int pos = timerResult.find(findStr);
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index cd4b735..eea9644 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -349,13 +349,8 @@
     }
 
     renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
-    if (FLAGS_logPerIter) {
-        benchmark->setTimerResultType(TimerData::kPerIter_Result);
-    } else if (FLAGS_min) {
-        benchmark->setTimerResultType(TimerData::kMin_Result);
-    } else {
-        benchmark->setTimerResultType(TimerData::kAvg_Result);
-    }
+    benchmark->setPrintMin(FLAGS_min);
+    benchmark->setLogPerIter(FLAGS_logPerIter);
     benchmark->setRenderer(renderer);
     benchmark->setRepeats(FLAGS_repeat);
     benchmark->setLogger(&gLogger);