From 24c5d2447fd15326f701400fd3178be437abd77d Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 29 Sep 2020 15:08:55 -0400 Subject: [PATCH] Add a benchmark that measures SkSL::Compiler startup time This is basically timing the rehydrator, but is helpful in conjunction with heap usage if a client wants to decide to throw away a compiler that they don't anticipate using for some amount of time. Change-Id: Ie9b27d9a3b7667b5492d870f242cdafd00784708 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320617 Commit-Queue: Brian Osman Commit-Queue: John Stiles Auto-Submit: Brian Osman Reviewed-by: John Stiles --- bench/SkSLBench.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bench/SkSLBench.cpp b/bench/SkSLBench.cpp index 1fdf40ac31..40bc7a756d 100644 --- a/bench/SkSLBench.cpp +++ b/bench/SkSLBench.cpp @@ -9,6 +9,25 @@ #include "bench/SkSLBench.h" #include "src/sksl/SkSLCompiler.h" +class SkSLCompilerStartupBench : public Benchmark { +protected: + const char* onGetName() override { + return "sksl_compiler_startup"; + } + + bool isSuitableFor(Backend backend) override { + return backend == kNonRendering_Backend; + } + + void onDraw(int loops, SkCanvas*) override { + for (int i = 0; i < loops; i++) { + SkSL::Compiler compiler; + } + } +}; + +DEF_BENCH(return new SkSLCompilerStartupBench();) + class SkSLBench : public Benchmark { public: SkSLBench(SkSL::String name, const char* src)