From 6f96cf4bde38337724b492a00dd8e0857d84d5d6 Mon Sep 17 00:00:00 2001 From: halcanary Date: Fri, 12 Feb 2016 08:08:27 -0800 Subject: Documantation: nanobench DOCS_PREVIEW= https://skia.org/dev/testing/tests?cl=1696723002 https://skia.org/dev/testing/tests?cl=1696723002#bench GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1696723002 NOTRY=true Review URL: https://codereview.chromium.org/1696723002 --- site/dev/testing/tests.md | 53 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/site/dev/testing/tests.md b/site/dev/testing/tests.md index 1b440ad7ac..3b216e88af 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) + + Writing a Unit Test ------------------- @@ -29,6 +35,8 @@ Writing a Unit Test ninja -C out/Debug dm out/Debug/dm --match NewUnitTest + + Writing a Rendering Test ------------------------ @@ -65,3 +73,44 @@ Writing a Rendering Test On MacOS, try this: out/Debug/SampleApp.app/Contents/MacOS/SampleApp --slide GM:newgmtest + + + +Writing a Benchmark Test +------------------------ + +1. Add a file `bench/FooBench.cpp`: + + + + /* + * 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"; } + SkIPoint onGetSize() override { return SkIPoint{100, 100}; } + void onDraw(int loops, SkCanvas* canvas) override { + while (loops-- > 0) { + canvas->drawLine(0.0f, 0.0f, 100.0f, 100.0f, 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 -- cgit v1.2.3