diff options
author | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-12 19:19:55 +0000 |
---|---|---|
committer | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-12 19:19:55 +0000 |
commit | 4916971526d53d873179ba1377e128a3a38a0056 (patch) | |
tree | 09d49c2bf971f37d5b07c576583c193a3a04ee8c | |
parent | 70044cc4964c32e0125e46c3c5f7f82446ddda85 (diff) |
Added a benchmark for measuring picture unflattening time.
Review URL: https://codereview.appspot.com/6354097
git-svn-id: http://skia.googlecode.com/svn/trunk@4582 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | tools/bench_pictures_main.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index eb5726a6ea..1a1dad179c 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -59,6 +59,9 @@ static void usage(const char* argv0) { " --tile width[%] height[%]: " "Set to use the tiling size and specify the dimensions of each tile.\n" " Default is to not use tiling\n"); + SkDebugf( +" --unflatten: " +"Set to do a picture unflattening benchmark. Default is not to do this.\n"); } static void run_simple_benchmark(SkPicture* picture, const Options& options) { @@ -179,6 +182,29 @@ static void run_pipe_benchmark(SkPicture* picture, const Options& options) { printf("pipe: cmsecs = %6.2f\n", timer.fWall / options.fRepeats); } +static void run_unflatten_benchmark(SkPicture* commands, const Options& options) { + BenchTimer timer = BenchTimer(NULL); + double wall_time = 0; + + for (int i = 0; i < options.fRepeats + 1; ++i) { + SkPicture replayer; + SkCanvas* recorder = replayer.beginRecording(commands->width(), commands->height()); + + recorder->drawPicture(*commands); + + timer.start(); + replayer.endRecording(); + timer.end(); + + // We want to ignore first time effects + if (i > 0) { + wall_time += timer.fWall; + } + } + + printf("unflatten: cmsecs = %6.4f\n", wall_time / options.fRepeats); +} + static void run_single_benchmark(const SkString& inputPath, Options* options) { SkFILEStream inputStream; @@ -277,6 +303,8 @@ static void parse_commandline(int argc, char* const argv[], } } else if (0 == strcmp(*argv, "--pipe")) { options->fBenchmark = run_pipe_benchmark; + } else if (0 == strcmp(*argv, "--unflatten")) { + options->fBenchmark = run_unflatten_benchmark; } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) { usage(argv0); exit(0); |