Add --timescale to bench_record and bench_playback.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 28 Apr 2014 19:41:17 +0000 (19:41 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 28 Apr 2014 19:41:17 +0000 (19:41 +0000)
Default bench_record to report us, bench_playback ms.

BUG=skia:2378
R=mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/253843004

git-svn-id: http://skia.googlecode.com/svn/trunk@14417 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/bench_playback.cpp
tools/bench_record.cpp

index 95dd482..89b3848 100644 (file)
@@ -24,6 +24,13 @@ DEFINE_int32(loops, 10, "Number of times to play back each SKP.");
 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture.");
 DEFINE_int32(tile, 1000000000, "Simulated tile size.");
 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench.");
+DEFINE_string(timescale, "ms", "Print times in ms, us, or ns");
+
+static double scale_time(double ms) {
+    if (FLAGS_timescale.contains("us")) ms *= 1000;
+    if (FLAGS_timescale.contains("ns")) ms *= 1000000;
+    return ms;
+}
 
 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
     // We don't use the public SkRecording interface here because we need kWriteOnly_Mode.
@@ -52,7 +59,7 @@ static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
     timer.end();
 
     const double msPerLoop = timer.fCpu / (double)FLAGS_loops;
-    printf("%u\t%s\n", unsigned(1000 * msPerLoop), name);
+    printf("%f\t%s\n", scale_time(msPerLoop), name);
 }
 
 int tool_main(int argc, char** argv);
index cb0410d..c7941ed 100644 (file)
@@ -32,6 +32,13 @@ DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tilegrid, quadtree");
 DEFINE_bool(skr, false, "Record SKR instead of SKP.");
 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench.");
+DEFINE_string(timescale, "us", "Print times in ms, us, or ns");
+
+static double scale_time(double ms) {
+    if (FLAGS_timescale.contains("us")) ms *= 1000;
+    if (FLAGS_timescale.contains("ns")) ms *= 1000000;
+    return ms;
+}
 
 static SkBBHFactory* parse_FLAGS_bbh() {
     if (FLAGS_bbh.isEmpty()) {
@@ -83,7 +90,7 @@ static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFact
     timer.end();
 
     const double msPerLoop = timer.fCpu / (double)FLAGS_loops;
-    printf("%u\t%s\n", unsigned(1000 * msPerLoop), name);
+    printf("%f\t%s\n", scale_time(msPerLoop), name);
 }
 
 int tool_main(int argc, char** argv);