diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-25 21:30:52 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-25 21:30:52 +0000 |
commit | 68f2a0df144197d8221f4761285e597f1788e4ff (patch) | |
tree | 3a45395747e6deafcd1df3fa299632ea7e29a04c /tools | |
parent | 5dbdfee3bd9033e05362399297f74bb4c14c0999 (diff) |
This reverts commit 4052fd051db67bd1099fde2c4fe400cfbe1f2426.
git-svn-id: http://skia.googlecode.com/svn/trunk@10374 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/PictureBenchmark.cpp | 73 | ||||
-rw-r--r-- | tools/PictureBenchmark.h | 30 | ||||
-rw-r--r-- | tools/bbh_shootout.cpp | 15 | ||||
-rw-r--r-- | tools/bench_pictures_main.cpp | 9 |
4 files changed, 61 insertions, 66 deletions
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp index adab9453d6..a358ad4179 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 @@ PictureBenchmark::PictureBenchmark() : 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 @@ PictureBenchmark::~PictureBenchmark() { 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 @@ void PictureBenchmark::run(SkPicture* pict) { 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 @@ void PictureBenchmark::run(SkPicture* pict) { // 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 @@ void PictureBenchmark::run(SkPicture* pict) { 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 @@ void PictureBenchmark::run(SkPicture* pict) { #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 @@ void PictureBenchmark::run(SkPicture* pict) { 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 1f01ce533a..70c56d9949 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 @@ public: 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 36fe758f41..24d7b86500 100644 --- a/tools/bbh_shootout.cpp +++ b/tools/bbh_shootout.cpp @@ -268,7 +268,7 @@ static bool benchmark_loop( 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 @@ static bool benchmark_loop( 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 cd4b735d5e..eea9644cf1 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -349,13 +349,8 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) { } 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); |