blob: db7c78164d074d481e376cb4c3f6c74fb6546d86 [file] [log] [blame]
scroggo@google.com9a412522012-09-07 15:21:18 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef TimerData_DEFINED
10#define TimerData_DEFINED
11
12#include "SkString.h"
commit-bot@chromium.org47fad702013-07-25 20:01:20 +000013#include "SkTemplates.h"
14
scroggo@google.com9a412522012-09-07 15:21:18 +000015
16class BenchTimer;
17
18class TimerData {
19public:
commit-bot@chromium.org47fad702013-07-25 20:01:20 +000020 /**
21 * Constructs a TimerData to hold at most maxNumTimings sets of elapsed timer values.
22 **/
23 explicit TimerData(int maxNumTimings);
scroggo@google.com9a412522012-09-07 15:21:18 +000024
25 /**
commit-bot@chromium.org47fad702013-07-25 20:01:20 +000026 * Collect times from the BenchTimer for an iteration. It will fail if called more often than
27 * indicated in the constructor.
28 *
scroggo@google.com9a412522012-09-07 15:21:18 +000029 * @param BenchTimer Must not be null.
scroggo@google.com9a412522012-09-07 15:21:18 +000030 */
commit-bot@chromium.org47fad702013-07-25 20:01:20 +000031 bool appendTimes(BenchTimer*);
scroggo@google.com9a412522012-09-07 15:21:18 +000032
commit-bot@chromium.org47fad702013-07-25 20:01:20 +000033 enum Result {
34 kMin_Result,
35 kAvg_Result,
36 kPerIter_Result
37 };
38
39 enum TimerFlags {
40 kWall_Flag = 0x1,
41 kTruncatedWall_Flag = 0x2,
42 kCpu_Flag = 0x4,
43 kTruncatedCpu_Flag = 0x8,
44 kGpu_Flag = 0x10
45 };
46
47 SkString getResult(const char* doubleFormat,
48 Result result,
49 const char* configName,
50 uint32_t timerFlags,
51 int itersPerTiming = 1);
52private:
53 int fMaxNumTimings;
54 int fCurrTiming;
55
56 SkAutoTArray<double> fWallTimes;
57 SkAutoTArray<double> fTruncatedWallTimes;
58 SkAutoTArray<double> fCpuTimes;
59 SkAutoTArray<double> fTruncatedCpuTimes;
60 SkAutoTArray<double> fGpuTimes;
scroggo@google.com9a412522012-09-07 15:21:18 +000061};
62
63#endif // TimerData_DEFINED