Use stack instead of malloc() for most calls to SkRasterPipeline::run().
Also split bench into run/compile variants to measure the effect:
Before …f16_compile 1x …f16_run 1.02x …srgb_compile 1.56x …srgb_run 1.61x
After …f16_run 1x …f16_compile 1.01x …srgb_compile 1.58x …srgb_run 1.59x
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: I8e65fb2acdbb05ccc0b3894f16d7646603c3e74d
Reviewed-on: https://skia-review.googlesource.com/6621
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp
index 16dea8a..376efde 100644
--- a/bench/SkRasterPipelineBench.cpp
+++ b/bench/SkRasterPipelineBench.cpp
@@ -22,13 +22,18 @@
// - src = srcover(dst, src)
// - store src back as srgb/f16
-template <bool kF16>
+template <bool kF16, bool kCompiled>
class SkRasterPipelineBench : public Benchmark {
public:
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
const char* onGetName() override {
- return kF16 ? "SkRasterPipeline_f16"
- : "SkRasterPipeline_srgb";
+ switch ((int)kCompiled << 1 | (int)kF16) {
+ case 0: return "SkRasterPipeline_srgb_run";
+ case 1: return "SkRasterPipeline_f16_run";
+ case 2: return "SkRasterPipeline_srgb_compile";
+ case 3: return "SkRasterPipeline_f16_compile";
+ }
+ return "whoops";
}
void onDraw(int loops, SkCanvas*) override {
@@ -53,12 +58,20 @@
p.append(SkRasterPipeline::to_srgb);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
}
- auto compiled = p.compile();
- while (loops --> 0) {
- compiled(0,0, N);
+ if (kCompiled) {
+ auto compiled = p.compile();
+ while (loops --> 0) {
+ compiled(0,0, N);
+ }
+ } else {
+ while (loops --> 0) {
+ p.run(0,0, N);
+ }
}
}
};
-DEF_BENCH( return new SkRasterPipelineBench<true>; )
-DEF_BENCH( return new SkRasterPipelineBench<false>; )
+DEF_BENCH( return (new SkRasterPipelineBench< true, true>); )
+DEF_BENCH( return (new SkRasterPipelineBench<false, true>); )
+DEF_BENCH( return (new SkRasterPipelineBench< true, false>); )
+DEF_BENCH( return (new SkRasterPipelineBench<false, false>); )