joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef VisualLightweightBenchModule_DEFINED |
| 9 | #define VisualLightweightBenchModule_DEFINED |
| 10 | |
joshualitt | d0f0bce | 2015-10-14 07:49:28 -0700 | [diff] [blame] | 11 | #include "VisualStreamTimingModule.h" |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 12 | |
| 13 | #include "ResultsWriter.h" |
| 14 | #include "SkPicture.h" |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 15 | #include "VisualBench.h" |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 16 | |
| 17 | class SkCanvas; |
| 18 | |
| 19 | /* |
| 20 | * This module is designed to be a minimal overhead timing module for VisualBench |
| 21 | */ |
joshualitt | d0f0bce | 2015-10-14 07:49:28 -0700 | [diff] [blame] | 22 | class VisualLightweightBenchModule : public VisualStreamTimingModule { |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 23 | public: |
| 24 | // TODO get rid of backpointer |
| 25 | VisualLightweightBenchModule(VisualBench* owner); |
| 26 | |
jvanverth | f5d1b2d | 2015-09-15 07:40:56 -0700 | [diff] [blame] | 27 | bool onHandleChar(SkUnichar c) override; |
| 28 | |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 29 | private: |
joshualitt | d0f0bce | 2015-10-14 07:49:28 -0700 | [diff] [blame] | 30 | void renderFrame(SkCanvas*, Benchmark*, int loops) override; |
| 31 | bool timingFinished(Benchmark*, int loops, double measurement) override; |
| 32 | void printStats(Benchmark*, int loops); |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 33 | |
| 34 | struct Record { |
| 35 | SkTArray<double> fMeasurements; |
| 36 | }; |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 37 | int fCurrentSample; |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 38 | SkTArray<Record> fRecords; |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 39 | |
| 40 | // support framework |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 41 | SkAutoTDelete<ResultsWriter> fResults; |
| 42 | |
joshualitt | d0f0bce | 2015-10-14 07:49:28 -0700 | [diff] [blame] | 43 | typedef VisualStreamTimingModule INHERITED; |
joshualitt | 189aef7 | 2015-09-08 07:08:11 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | #endif |