Benchmark results will now print to STDOUT if on not-Android.
Review URL: https://codereview.appspot.com/6446164
git-svn-id: http://skia.googlecode.com/svn/trunk@5215 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index e45c5e8..4f7cbac 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -62,16 +62,17 @@
#endif
}
- fRenderer.end();
-
- SkDebugf("pipe: msecs = %6.2f", wall_time / fRepeats);
+ SkString result;
+ result.printf("pipe: msecs = %6.2f", wall_time / fRepeats);
#if SK_SUPPORT_GPU
if (fRenderer.isUsingGpuDevice()) {
- SkDebugf(" gmsecs = %6.2f", gpu_time / fRepeats);
+ result.appendf(" gmsecs = %6.2f", gpu_time / fRepeats);
}
#endif
- SkDebugf("\n");
+ result.appendf("\n");
+ sk_tools::print_msg(result.c_str());
+ fRenderer.end();
SkDELETE(timer);
}
@@ -98,7 +99,9 @@
}
}
- SkDebugf("record: msecs = %6.5f\n", wall_time / fRepeats);
+ SkString result;
+ result.printf("record: msecs = %6.5f\n", wall_time / fRepeats);
+ sk_tools::print_msg(result.c_str());
SkDELETE(timer);
}
@@ -137,16 +140,18 @@
#endif
}
- fRenderer.end();
- SkDebugf("simple: msecs = %6.2f", wall_time / fRepeats);
+ SkString result;
+ result.printf("simple: msecs = %6.2f", wall_time / fRepeats);
#if SK_SUPPORT_GPU
if (fRenderer.isUsingGpuDevice()) {
- SkDebugf(" gmsecs = %6.2f", gpu_time / fRepeats);
+ result.appendf(" gmsecs = %6.2f", gpu_time / fRepeats);
}
#endif
- SkDebugf("\n");
+ result.appendf("\n");
+ sk_tools::print_msg(result.c_str());
+ fRenderer.end();
SkDELETE(timer);
}
@@ -183,17 +188,18 @@
#endif
}
- fRenderer.end();
-
- SkDebugf("%i_tiles_%ix%i: msecs = %6.2f", fRenderer.numTiles(), fRenderer.getTileWidth(),
- fRenderer.getTileHeight(), wall_time / fRepeats);
+ SkString result;
+ result.printf("%i_tiles_%ix%i: msecs = %6.2f", fRenderer.numTiles(), fRenderer.getTileWidth(),
+ fRenderer.getTileHeight(), wall_time / fRepeats);
#if SK_SUPPORT_GPU
if (fRenderer.isUsingGpuDevice()) {
- SkDebugf(" gmsecs = %6.2f", gpu_time / fRepeats);
+ result.appendf(" gmsecs = %6.2f", gpu_time / fRepeats);
}
#endif
- SkDebugf("\n");
+ result.appendf("\n");
+ sk_tools::print_msg(result.c_str());
+ fRenderer.end();
SkDELETE(timer);
}
@@ -222,7 +228,9 @@
}
}
- SkDebugf("unflatten: msecs = %6.4f\n", wall_time / fRepeats);
+ SkString result;
+ result.printf("unflatten: msecs = %6.4f\n", wall_time / fRepeats);
+ sk_tools::print_msg(result.c_str());
SkDELETE(timer);
}
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index d906214..88b5422 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -81,8 +81,11 @@
SkString filename;
sk_tools::get_basename(&filename, inputPath);
- SkDebugf("running bench [%i %i] %s ", picture.width(), picture.height(),
- filename.c_str());
+
+ SkString result;
+ result.printf("running bench [%i %i] %s ", picture.width(), picture.height(),
+ filename.c_str());
+ sk_tools::print_msg(result.c_str());
benchmark.run(&picture);
}
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 26788ee..d38cbb0 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -70,10 +70,16 @@
return skString.endsWith("%");
}
+ // This copies how bench does printing of test results.
+#ifdef SK_BUILD_FOR_ANDROID
+ void print_msg(const char msg[]) { SkDebugf("%s", msg); }
+#else
+ void print_msg(const char msg[]) { printf("%s", msg); }
+#endif
+
void setup_bitmap(SkBitmap* bitmap, int width, int height) {
bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap->allocPixels();
bitmap->eraseColor(0);
}
-
}
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
index 2cda45b..c0c5d8f 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -28,6 +28,11 @@
// Returns true if the string ends with %
bool is_percentage(char* const string);
+ // Prints to STDOUT so that test results can be easily seperated from the
+ // error stream. Note, that this still prints to the same stream as SkDebugf
+ // on Andoid.
+ void print_msg(const char msg[]);
+
// Prepares the bitmap so that it can be written.
//
// Specifically, it configures the bitmap, allocates pixels and then