• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
6  */
7 
8 #ifndef VisualLightweightBenchModule_DEFINED
9 #define VisualLightweightBenchModule_DEFINED
10 
11 #include "VisualStreamTimingModule.h"
12 
13 #include "ResultsWriter.h"
14 #include "SkPicture.h"
15 #include "VisualBench.h"
16 
17 class SkCanvas;
18 
19 /*
20  * This module is designed to be a minimal overhead timing module for VisualBench
21  */
22 class VisualLightweightBenchModule : public VisualStreamTimingModule {
23 public:
24     // TODO get rid of backpointer
25     VisualLightweightBenchModule(VisualBench* owner);
26 
27     bool onHandleChar(SkUnichar c) override;
28 
29 private:
30     void renderFrame(SkCanvas*, Benchmark*, int loops) override;
31     bool timingFinished(Benchmark*, int loops, double measurement) override;
32     void printStats(Benchmark*, int loops);
33 
34     struct Record {
35         SkTArray<double> fMeasurements;
36     };
37     int fCurrentSample;
38     SkTArray<Record> fRecords;
39 
40     // support framework
41     SkAutoTDelete<ResultsWriter> fResults;
42 
43     typedef VisualStreamTimingModule INHERITED;
44 };
45 
46 #endif
47