From 0a76b413eac46ec218b367c5456709059557f5db Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Mon, 22 May 2017 12:01:59 -0400 Subject: add compile, use it in blitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I expanded an existing bench to show off the difference: SkRasterPipeline_… 300 …compile 1x …run 1.14x Change-Id: I5d63d602cda3f78d2d0891fcc85baf5514632900 Reviewed-on: https://skia-review.googlesource.com/17458 Commit-Queue: Mike Klein Reviewed-by: Herb Derby --- bench/SkRasterPipelineBench.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'bench/SkRasterPipelineBench.cpp') diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp index 2848218977..bef80b3fca 100644 --- a/bench/SkRasterPipelineBench.cpp +++ b/bench/SkRasterPipelineBench.cpp @@ -66,11 +66,13 @@ public: DEF_BENCH( return (new SkRasterPipelineBench< true>); ) DEF_BENCH( return (new SkRasterPipelineBench); ) -class SkRasterPipelineLegacyBench : public Benchmark { +class SkRasterPipelineCompileVsRunBench : public Benchmark { public: + explicit SkRasterPipelineCompileVsRunBench(bool compile) : fCompile(compile) {} bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; } const char* onGetName() override { - return "SkRasterPipeline_legacy"; + return fCompile ? "SkRasterPipeline_compile" + : "SkRasterPipeline_run"; } void onDraw(int loops, SkCanvas*) override { @@ -84,12 +86,24 @@ public: p.append(SkRasterPipeline::srcover); p.append(SkRasterPipeline::store_8888, &dst_ctx); - while (loops --> 0) { - p.run(0,N); + if (fCompile) { + char buffer[1024]; + SkArenaAlloc alloc(buffer); + auto fn = p.compile(&alloc); + while (loops --> 0) { + fn(0,N); + } + } else { + while (loops --> 0) { + p.run(0,N); + } } } +private: + bool fCompile; }; -DEF_BENCH( return (new SkRasterPipelineLegacyBench); ) +DEF_BENCH( return (new SkRasterPipelineCompileVsRunBench(true )); ) +DEF_BENCH( return (new SkRasterPipelineCompileVsRunBench(false)); ) static SkColorSpaceTransferFn gamma(float g) { SkColorSpaceTransferFn fn = {0,0,0,0,0,0,0}; -- cgit v1.2.3