| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 1 | |
| 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.org | 47fad70 | 2013-07-25 20:01:20 +0000 | [diff] [blame^] | 13 | #include "SkTemplates.h" |
| 14 | |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 15 | |
| 16 | class BenchTimer; |
| 17 | |
| 18 | class TimerData { |
| 19 | public: |
| commit-bot@chromium.org | 47fad70 | 2013-07-25 20:01:20 +0000 | [diff] [blame^] | 20 | /** |
| 21 | * Constructs a TimerData to hold at most maxNumTimings sets of elapsed timer values. |
| 22 | **/ |
| 23 | explicit TimerData(int maxNumTimings); |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 24 | |
| 25 | /** |
| commit-bot@chromium.org | 47fad70 | 2013-07-25 20:01:20 +0000 | [diff] [blame^] | 26 | * Collect times from the BenchTimer for an iteration. It will fail if called more often than |
| 27 | * indicated in the constructor. |
| 28 | * |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 29 | * @param BenchTimer Must not be null. |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 30 | */ |
| commit-bot@chromium.org | 47fad70 | 2013-07-25 20:01:20 +0000 | [diff] [blame^] | 31 | bool appendTimes(BenchTimer*); |
| scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 32 | |
| commit-bot@chromium.org | 47fad70 | 2013-07-25 20:01:20 +0000 | [diff] [blame^] | 33 | 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); |
| 52 | private: |
| 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.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | #endif // TimerData_DEFINED |