aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/tools.gyp7
-rw-r--r--tools/bench_pictures_main.cpp34
2 files changed, 39 insertions, 2 deletions
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index f30f31111e..2fee6da122 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -82,15 +82,18 @@
'target_name': 'bench_pictures',
'type': 'executable',
'sources': [
- '../tools/bench_pictures_main.cpp'
+ '../tools/bench_pictures_main.cpp',
+ '../src/pipe/utils/SamplePipeControllers.h',
+ '../src/pipe/utils/SamplePipeControllers.cpp',
],
'include_dirs': [
'../bench',
+ '../src/pipe/utils/',
],
'dependencies': [
'core.gyp:core',
'ports.gyp:ports',
- 'images.gyp:images',
+ 'images.gyp:images',
'tools.gyp:picture_utils',
'bench.gyp:bench_timer',
],
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index e06a63bdb1..88163110fb 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -6,8 +6,10 @@
*/
#include "BenchTimer.h"
+#include "SamplePipeControllers.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkGPipe.h"
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkStream.h"
@@ -45,6 +47,10 @@ static void usage(const char* argv0) {
" inputDir: A list of directories and files to use as input.\n"
" Files are expected to have the .skp extension.\n\n");
SkDebugf(
+" --pipe : "
+"Set to use piping."
+" Default is to not use piping.\n");
+ SkDebugf(
" --repeat : "
"Set the number of times to repeat each test."
" Default is %i.\n", DEFAULT_REPEATS);
@@ -133,6 +139,32 @@ static void run_tile_benchmark(SkPicture* picture, const SkBitmap& bitmap,
options.fTileHeight, timer.fWall / options.fRepeats);
}
+static void pipe_run(SkPicture* picture, SkCanvas* canvas) {
+ PipeController pipeController(canvas);
+ SkGPipeWriter writer;
+ SkCanvas* pipeCanvas = writer.startRecording(&pipeController);
+ pipeCanvas->drawPicture(*picture);
+ writer.endRecording();
+}
+
+static void run_pipe_benchmark(SkPicture* picture, const SkBitmap& bitmap,
+ const Options& options) {
+ SkCanvas canvas(bitmap);
+
+ // We throw this away to remove first time effects (such as paging in this
+ // program)
+ pipe_run(picture, &canvas);
+
+ BenchTimer timer = BenchTimer(NULL);
+ timer.start();
+ for (int i = 0; i < options.fRepeats; ++i) {
+ pipe_run(picture, &canvas);
+ }
+ timer.end();
+
+ printf("pipe: cmsecs = %6.2f\n", timer.fWall / options.fRepeats);
+}
+
static void run_single_benchmark(const SkString& inputPath,
const Options& options) {
SkFILEStream inputStream;
@@ -201,6 +233,8 @@ static void parse_commandline(int argc, char* const argv[],
usage(argv0);\
exit(-1);
}
+ } else if (0 == strcmp(*argv, "--pipe")) {
+ options->fBenchmark = run_pipe_benchmark;
} else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
usage(argv0);
exit(0);