Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: site/dev/testing/tests.md

Issue 1696723002: Documantation: nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-02-12 (Friday) 09:38:04 EST Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: site/dev/testing/tests.md
diff --git a/site/dev/testing/tests.md b/site/dev/testing/tests.md
index 1b440ad7ac5f130aabf6a7e96d430c2772b25bce..f5559a9e1625ce666e3e4a1e9525ea064e2d24fe 100644
--- a/site/dev/testing/tests.md
+++ b/site/dev/testing/tests.md
@@ -1,5 +1,11 @@
-Writing Unit and Rendering Tests
-================================
+Writing Skia Tests
+==================
+
++ [Unit Tests](#test)
++ [Rendering Tests](#gm)
++ [Benchmark Tests](#bench)
+
+<span id="test"></span>
Writing a Unit Test
-------------------
@@ -29,6 +35,8 @@ Writing a Unit Test
ninja -C out/Debug dm
out/Debug/dm --match NewUnitTest
+<span id="gm"></span>
+
Writing a Rendering Test
------------------------
@@ -65,3 +73,45 @@ Writing a Rendering Test
On MacOS, try this:
out/Debug/SampleApp.app/Contents/MacOS/SampleApp --slide GM:newgmtest
+
+<span id="bench"></span>
+
+Writing a Benchmark Test
+------------------------
+
+1. Add a file `bench/FooBench.cpp`:
+
+ <!--?prettify lang=cc?-->
+
+ /*
+ * Copyright ........
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file.
+ */
+ #include "Benchmark.h"
+ #include "SkCanvas.h"
+ namespace {
+ class FooBench : public Benchmark {
+ public:
+ FooBench() {}
+ virtual ~FooBench() {}
+ protected:
+ const char* onGetName() override { return "Foo"; }
+ SkISize onGetSize() override { return SkISize{100, 100}; }
+ void onDraw(int loops, SkCanvas* canvas) override {
+ for (int i = 0; i < loops; i++) {
+ canvas->drawLine(10.0f + i % 17, 10.0f + i % 13,
mtklein 2016/02/12 15:22:34 This is probably not setting a good example. It's
hal.canary 2016/02/12 15:51:58 done and done.
+ 90.0f - i % 19, 90.0f - i % 5, SkPaint());
+ }
+ }
+ };
+ } // namespace
+ DEF_BENCH(return new FooBench;)
+
+
+2. Recompile and run nanobench:
+
+ python bin/sync-and-gyp
+ ninja -C out/Release nanobench
+ out/Release/nanobench --match Foo
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698