blob: 7618ff2a11cc288c1917e16db84597c53ed4b3f4 [file] [log] [blame]
Tom Hudson2880df22015-10-29 09:55:42 -04001/*
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
17class SkCanvas;
18
19/*
20 * This module is designed to be a minimal overhead timing module for VisualBench
21 */
22class VisualLightweightBenchModule : public VisualStreamTimingModule {
23public:
24 // TODO get rid of backpointer
25 VisualLightweightBenchModule(VisualBench* owner);
26
27 bool onHandleChar(SkUnichar c) override;
28
29private:
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