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 <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/bench/SkSLBench.cpp b/bench/SkSLBench.cpp
index 1fdf40a..40bc7a7 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)