2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TimerData_DEFINED
|
|
|
|
#define TimerData_DEFINED
|
|
|
|
|
|
|
|
#include "SkString.h"
|
2013-07-31 20:00:56 +00:00
|
|
|
#include "SkTemplates.h"
|
|
|
|
|
2014-05-29 17:10:24 +00:00
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4530)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "SkJSONCPP.h"
|
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
class BenchTimer;
|
|
|
|
|
|
|
|
class TimerData {
|
|
|
|
public:
|
2013-07-31 20:00:56 +00:00
|
|
|
/**
|
|
|
|
* Constructs a TimerData to hold at most maxNumTimings sets of elapsed timer values.
|
|
|
|
**/
|
|
|
|
explicit TimerData(int maxNumTimings);
|
2012-09-07 15:21:18 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-31 20:00:56 +00:00
|
|
|
* Collect times from the BenchTimer for an iteration. It will fail if called more often than
|
|
|
|
* indicated in the constructor.
|
|
|
|
*
|
2012-09-07 15:21:18 +00:00
|
|
|
* @param BenchTimer Must not be null.
|
|
|
|
*/
|
2013-07-31 20:00:56 +00:00
|
|
|
bool appendTimes(BenchTimer*);
|
|
|
|
|
|
|
|
enum Result {
|
|
|
|
kMin_Result,
|
|
|
|
kAvg_Result,
|
|
|
|
kPerIter_Result
|
|
|
|
};
|
|
|
|
|
|
|
|
enum TimerFlags {
|
|
|
|
kWall_Flag = 0x1,
|
|
|
|
kTruncatedWall_Flag = 0x2,
|
|
|
|
kCpu_Flag = 0x4,
|
|
|
|
kTruncatedCpu_Flag = 0x8,
|
|
|
|
kGpu_Flag = 0x10
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the timer data results as a string.
|
|
|
|
* @param doubleFormat printf-style format for doubles (e.g. "%02d")
|
|
|
|
* @param result the type of result desired
|
|
|
|
* @param the name of the config being timed (prepended to results string)
|
|
|
|
* @param timerFlags bitfield of TimerFlags values indicating which timers should be reported.
|
|
|
|
* @param itersPerTiming the number of test/bench iterations that correspond to each
|
|
|
|
* appendTimes() call, 1 when appendTimes is called for each iteration.
|
|
|
|
*/
|
|
|
|
SkString getResult(const char* doubleFormat,
|
|
|
|
Result result,
|
|
|
|
const char* configName,
|
|
|
|
uint32_t timerFlags,
|
|
|
|
int itersPerTiming = 1);
|
2014-05-29 17:10:24 +00:00
|
|
|
#ifdef SK_BUILD_JSON_WRITER
|
|
|
|
Json::Value getJSON(uint32_t timerFlags,
|
|
|
|
Result result,
|
|
|
|
int itersPerTiming = 1);
|
|
|
|
#endif // SK_BUILD_JSON_WRITER
|
2013-07-31 20:00:56 +00:00
|
|
|
|
2012-09-07 15:21:18 +00:00
|
|
|
private:
|
2013-07-31 20:00:56 +00:00
|
|
|
int fMaxNumTimings;
|
|
|
|
int fCurrTiming;
|
|
|
|
|
|
|
|
SkAutoTArray<double> fWallTimes;
|
|
|
|
SkAutoTArray<double> fTruncatedWallTimes;
|
|
|
|
SkAutoTArray<double> fCpuTimes;
|
|
|
|
SkAutoTArray<double> fTruncatedCpuTimes;
|
|
|
|
SkAutoTArray<double> fGpuTimes;
|
2012-09-07 15:21:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TimerData_DEFINED
|