diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-31 20:00:56 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-31 20:00:56 +0000 |
commit | 55fd612adfd08f5c64fb728bc37a2cb4ae224656 (patch) | |
tree | b49828f094c0bec2e2468f2820449c5df0d9a2d7 /tools | |
parent | 65a629ab33eb829efdfe258e48395d3d43da61ca (diff) |
R=borenet@google.com, bungeman@google.com, robertphillips@google.com, scroggo@google.com, sglez@google.com
Author: bsalomon@google.com
Review URL: https://chromiumcodereview.appspot.com/19862002
git-svn-id: http://skia.googlecode.com/svn/trunk@10473 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, 66 insertions, 61 deletions
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp index a358ad4179..155d097760 100644 --- a/tools/PictureBenchmark.cpp +++ b/tools/PictureBenchmark.cpp @@ -12,7 +12,6 @@ #include "SkPicture.h" #include "SkString.h" #include "picture_utils.h" -#include "TimerData.h" namespace sk_tools { @@ -20,13 +19,8 @@ PictureBenchmark::PictureBenchmark() : fRepeats(1) , fLogger(NULL) , fRenderer(NULL) -, fLogPerIter(false) -, fPrintMin(false) -, fShowWallTime(false) -, fShowTruncatedWallTime(false) -, fShowCpuTime(true) -, fShowTruncatedCpuTime(false) -, fShowGpuTime(false) +, fTimerResult(TimerData::kAvg_Result) +, fTimerTypes(0) , fTimeIndividualTiles(false) {} @@ -34,6 +28,19 @@ 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()) { @@ -77,6 +84,18 @@ void PictureBenchmark::run(SkPicture* pict) { usingGpu = fRenderer->isUsingGpuDevice(); #endif + uint32_t timerTypes = fTimerTypes; + if (!usingGpu) { + timerTypes &= ~TimerData::kGpu_Flag; + } + + SkString timeFormat; + if (TimerData::kPerIter_Result == fTimerResult) { + timeFormat = fRenderer->getPerIterTimeFormat(); + } else { + timeFormat = fRenderer->getNormalTimeFormat(); + } + if (fTimeIndividualTiles) { TiledPictureRenderer* tiledRenderer = fRenderer->getTiledRenderer(); SkASSERT(tiledRenderer && tiledRenderer->supportsTimingIndividualTiles()); @@ -110,11 +129,9 @@ 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(tiledRenderer->getPerIterTimeFormat(), - tiledRenderer->getNormalTimeFormat()); + TimerData longRunningTimerData(1); SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false)); - TimerData perTileTimerData(tiledRenderer->getPerIterTimeFormat(), - tiledRenderer->getNormalTimeFormat()); + TimerData perTileTimerData(fRepeats); longRunningTimer->start(); for (int i = 0; i < fRepeats; ++i) { perTileTimer->start(); @@ -122,20 +139,18 @@ void PictureBenchmark::run(SkPicture* pict) { perTileTimer->truncatedEnd(); tiledRenderer->resetState(false); perTileTimer->end(); - perTileTimerData.appendTimes(perTileTimer.get(), fRepeats - 1 == i); + SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get())); } longRunningTimer->truncatedEnd(); tiledRenderer->resetState(true); longRunningTimer->end(); - longRunningTimerData.appendTimes(longRunningTimer.get(), true); + SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get())); SkString configName = tiledRenderer->getConfigName(); configName.appendf(": tile [%i,%i] out of [%i,%i]", x, y, xTiles, yTiles); - SkString result = perTileTimerData.getResult(fLogPerIter, fPrintMin, fRepeats, - configName.c_str(), fShowWallTime, - fShowTruncatedWallTime, fShowCpuTime, - fShowTruncatedCpuTime, - usingGpu && fShowGpuTime); + + SkString result = perTileTimerData.getResult(timeFormat.c_str(), fTimerResult, + configName.c_str(), timerTypes); result.append("\n"); // TODO(borenet): Turn off per-iteration tile time reporting for now. Avoiding logging the time @@ -147,15 +162,16 @@ void PictureBenchmark::run(SkPicture* pict) { #endif configName.append(" <averaged>"); - SkString longRunningResult = longRunningTimerData.getResult(false, false, fRepeats, - configName.c_str(), fShowWallTime, fShowTruncatedWallTime, - fShowCpuTime, fShowTruncatedCpuTime, usingGpu && fShowGpuTime); + SkString longRunningResult = longRunningTimerData.getResult( + tiledRenderer->getNormalTimeFormat().c_str(), + TimerData::kAvg_Result, + configName.c_str(), timerTypes, fRepeats); longRunningResult.append("\n"); this->logProgress(longRunningResult.c_str()); } } else { SkAutoTDelete<BenchTimer> timer(this->setupTimer()); - TimerData timerData(fRenderer->getPerIterTimeFormat(), fRenderer->getNormalTimeFormat()); + TimerData timerData(fRepeats); for (int i = 0; i < fRepeats; ++i) { fRenderer->setup(); @@ -167,14 +183,15 @@ void PictureBenchmark::run(SkPicture* pict) { fRenderer->resetState(true); timer->end(); - timerData.appendTimes(timer.get(), fRepeats - 1 == i); + SkAssertResult(timerData.appendTimes(timer.get())); } SkString configName = fRenderer->getConfigName(); - SkString result = timerData.getResult(fLogPerIter, fPrintMin, fRepeats, - configName.c_str(), fShowWallTime, - fShowTruncatedWallTime, fShowCpuTime, - fShowTruncatedCpuTime, usingGpu && fShowGpuTime); + + SkString result = timerData.getResult(timeFormat.c_str(), + fTimerResult, + configName.c_str(), + timerTypes); result.append("\n"); this->logProgress(result.c_str()); } diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h index 70c56d9949..1f01ce533a 100644 --- a/tools/PictureBenchmark.h +++ b/tools/PictureBenchmark.h @@ -10,6 +10,7 @@ #include "SkTypes.h" #include "PictureRenderer.h" +#include "TimerData.h" class BenchTimer; class SkBenchLogger; @@ -45,32 +46,19 @@ public: PictureRenderer* setRenderer(PictureRenderer*); - void setLogPerIter(bool log) { fLogPerIter = log; } + void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; } - 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 setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu); void setLogger(SkBenchLogger* logger) { fLogger = logger; } private: - int fRepeats; - SkBenchLogger* fLogger; - PictureRenderer* fRenderer; - bool fLogPerIter; - bool fPrintMin; - bool fShowWallTime; - bool fShowTruncatedWallTime; - bool fShowCpuTime; - bool fShowTruncatedCpuTime; - bool fShowGpuTime; - bool fTimeIndividualTiles; + int fRepeats; + SkBenchLogger* fLogger; + PictureRenderer* fRenderer; + TimerData::Result fTimerResult; + uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values + bool fTimeIndividualTiles; void logProgress(const char msg[]); diff --git a/tools/bbh_shootout.cpp b/tools/bbh_shootout.cpp index 24d7b86500..9de0bfcf82 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(timeFormat, timeFormat); + TimerData timerData(argc - 1); for (int index = 1; index < argc; ++index) { BenchTimer timer; SkString path(argv[index]); @@ -278,22 +278,17 @@ static bool benchmark_loop( continue; } benchControl.fFunction(benchControl.fType, benchControl.fTileSize, path, pic, &timer); - timerData.appendTimes(&timer, argc - 1 == index); + SkAssertResult(timerData.appendTimes(&timer)); histogram[index - 1].fPath = path; histogram[index - 1].fCpuTime = SkDoubleToScalar(timer.fCpu); } const SkString timerResult = timerData.getResult( - /*logPerIter = */ false, - /*printMin = */ false, - /*repeatDraw = */ 1, + /*doubleFormat = */ timeFormat.c_str(), + /*result = */ TimerData::kAvg_Result, /*configName = */ benchControl.fName.c_str(), - /*showWallTime = */ false, - /*showTruncatedWallTime = */ false, - /*showCpuTime = */ true, - /*showTruncatedCpuTime = */ false, - /*showGpuTime = */ false); + /*timerFlags = */ TimerData::kCpu_Flag); const char findStr[] = "= "; int pos = timerResult.find(findStr); diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index eea9644cf1..cd4b735d5e 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -349,8 +349,13 @@ static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) { } renderer->setDrawFilters(drawFilters, filtersName(drawFilters)); - benchmark->setPrintMin(FLAGS_min); - benchmark->setLogPerIter(FLAGS_logPerIter); + if (FLAGS_logPerIter) { + benchmark->setTimerResultType(TimerData::kPerIter_Result); + } else if (FLAGS_min) { + benchmark->setTimerResultType(TimerData::kMin_Result); + } else { + benchmark->setTimerResultType(TimerData::kAvg_Result); + } benchmark->setRenderer(renderer); benchmark->setRepeats(FLAGS_repeat); benchmark->setLogger(&gLogger); |