add tests/bench for dynamicwstream
BUG=skia:
Change-Id: I5a995b63b1a2975cce8101717777eaa6fc12af21
Reviewed-on: https://skia-review.googlesource.com/6035
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/StreamBench.cpp b/bench/StreamBench.cpp
new file mode 100644
index 0000000..0650a99
--- /dev/null
+++ b/bench/StreamBench.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Benchmark.h"
+#include "SkStream.h"
+
+class StreamBench : public Benchmark {
+ SkString fName;
+public:
+ StreamBench() {
+ fName.printf("wstream");
+ }
+
+ bool isSuitableFor(Backend backend) override {
+ return backend == kNonRendering_Backend;
+ }
+
+protected:
+ const char* onGetName() override { return fName.c_str(); }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ for (int i = 0; i < loops*100; ++i) {
+ SkDynamicMemoryWStream stream;
+ for (int j = 0; j < 100000; ++j) {
+ stream.write32(j);
+ stream.write32(j+j);
+ }
+ }
+ }
+
+private:
+ typedef Benchmark INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+DEF_BENCH(return new StreamBench;)