aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/VisualBench/VisualLightweightBenchModule.h
blob: 7618ff2a11cc288c1917e16db84597c53ed4b3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef VisualLightweightBenchModule_DEFINED
#define VisualLightweightBenchModule_DEFINED

#include "VisualStreamTimingModule.h"

#include "ResultsWriter.h"
#include "SkPicture.h"
#include "VisualBench.h"

class SkCanvas;

/*
 * This module is designed to be a minimal overhead timing module for VisualBench
 */
class VisualLightweightBenchModule : public VisualStreamTimingModule {
public:
    // TODO get rid of backpointer
    VisualLightweightBenchModule(VisualBench* owner);

    bool onHandleChar(SkUnichar c) override;

private:
    void renderFrame(SkCanvas*, Benchmark*, int loops) override;
    bool timingFinished(Benchmark*, int loops, double measurement) override;
    void printStats(Benchmark*, int loops);

    struct Record {
        SkTArray<double> fMeasurements;
    };
    int fCurrentSample;
    SkTArray<Record> fRecords;

    // support framework
    SkAutoTDelete<ResultsWriter> fResults;

    typedef VisualStreamTimingModule INHERITED;
};

#endif