| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef TimerData_DEFINED | 9 #ifndef TimerData_DEFINED |
| 10 #define TimerData_DEFINED | 10 #define TimerData_DEFINED |
| 11 | 11 |
| 12 #include "SkString.h" | 12 #include "SkString.h" |
| 13 #include "SkTemplates.h" |
| 14 |
| 13 | 15 |
| 14 class BenchTimer; | 16 class BenchTimer; |
| 15 | 17 |
| 16 class TimerData { | 18 class TimerData { |
| 17 public: | 19 public: |
| 18 TimerData(const SkString& perIterTimeFormat, const SkString& normalTimeForma
t); | 20 /** |
| 21 * Constructs a TimerData to hold at most maxNumTimings sets of elapsed time
r values. |
| 22 **/ |
| 23 explicit TimerData(int maxNumTimings); |
| 19 | 24 |
| 20 /** | 25 /** |
| 21 * Append the value from each timer in BenchTimer to our various strings, an
d update the | 26 * Collect times from the BenchTimer for an iteration. It will fail if calle
d more often than |
| 22 * minimum and sum times. | 27 * indicated in the constructor. |
| 28 * |
| 23 * @param BenchTimer Must not be null. | 29 * @param BenchTimer Must not be null. |
| 24 * @param last True if this is the last set of times to add. | |
| 25 */ | 30 */ |
| 26 void appendTimes(BenchTimer*, bool last); | 31 bool appendTimes(BenchTimer*); |
| 27 SkString getResult(bool logPerIter, bool printMin, int repeatDraw, const cha
r* configName, | 32 |
| 28 bool showWallTime, bool showTruncatedWallTime, bool showC
puTime, | 33 enum Result { |
| 29 bool showTruncatedCpuTime, bool showGpuTime); | 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 /** |
| 48 * Gets the timer data results as a string. |
| 49 * @param doubleFormat printf-style format for doubles (e.g. "%02d") |
| 50 * @param result the type of result desired |
| 51 * @param the name of the config being timed (prepended to results string) |
| 52 * @param timerFlags bitfield of TimerFlags values indicating which timers s
hould be reported. |
| 53 * @param itersPerTiming the number of test/bench iterations that correspond
to each |
| 54 * appendTimes() call, 1 when appendTimes is called for each iteratio
n. |
| 55 */ |
| 56 SkString getResult(const char* doubleFormat, |
| 57 Result result, |
| 58 const char* configName, |
| 59 uint32_t timerFlags, |
| 60 int itersPerTiming = 1); |
| 61 |
| 30 private: | 62 private: |
| 31 SkString fWallStr; | 63 int fMaxNumTimings; |
| 32 SkString fTruncatedWallStr; | 64 int fCurrTiming; |
| 33 SkString fCpuStr; | |
| 34 SkString fTruncatedCpuStr; | |
| 35 SkString fGpuStr; | |
| 36 double fWallSum, fWallMin; | |
| 37 double fTruncatedWallSum, fTruncatedWallMin; | |
| 38 double fCpuSum, fCpuMin; | |
| 39 double fTruncatedCpuSum, fTruncatedCpuMin; | |
| 40 double fGpuSum, fGpuMin; | |
| 41 | 65 |
| 42 SkString fPerIterTimeFormat; | 66 SkAutoTArray<double> fWallTimes; |
| 43 SkString fNormalTimeFormat; | 67 SkAutoTArray<double> fTruncatedWallTimes; |
| 68 SkAutoTArray<double> fCpuTimes; |
| 69 SkAutoTArray<double> fTruncatedCpuTimes; |
| 70 SkAutoTArray<double> fGpuTimes; |
| 44 }; | 71 }; |
| 45 | 72 |
| 46 #endif // TimerData_DEFINED | 73 #endif // TimerData_DEFINED |
| OLD | NEW |