diff options
author | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-16 19:20:14 +0000 |
---|---|---|
committer | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-16 19:20:14 +0000 |
commit | 21e3ed2e9af0e4b5ae813334e631714d198f9d94 (patch) | |
tree | ea803ae5a2f092b383a8934c857069dd4cf17087 /tools | |
parent | 52cb2c7cdf87f1e7d4b5d24b3609aaa514a26c10 (diff) |
bench_pictures now has an option for benchmarking record time.
Review URL: https://codereview.appspot.com/6350102
git-svn-id: http://skia.googlecode.com/svn/trunk@4632 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bench_pictures_main.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index aca98e4300..a9cca9658f 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -52,6 +52,9 @@ static void usage(const char* argv0) { "Set to use piping." " Default is to not use piping.\n"); SkDebugf( +" --record : " +"Set to do a picture recording benchmark. Default is not to do this.\n"); + SkDebugf( " --repeat : " "Set the number of times to repeat each test." " Default is %i.\n", DEFAULT_REPEATS); @@ -197,6 +200,27 @@ static void run_unflatten_benchmark(SkPicture* commands, const Options& options) printf("unflatten: msecs = %6.4f\n", wall_time / options.fRepeats); } +static void run_record_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()); + + timer.start(); + recorder->drawPicture(*commands); + timer.end(); + + // We want to ignore first time effects + if (i > 0) { + wall_time += timer.fWall; + } + } + + printf("record: msecs = %6.5f\n", wall_time / options.fRepeats); +} + static void run_single_benchmark(const SkString& inputPath, Options* options) { SkFILEStream inputStream; @@ -295,6 +319,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, "--record")) { + options->fBenchmark = run_record_benchmark; } else if (0 == strcmp(*argv, "--unflatten")) { options->fBenchmark = run_unflatten_benchmark; } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) { |