| Index: bench/TimerData.cpp
|
| diff --git a/bench/TimerData.cpp b/bench/TimerData.cpp
|
| index a86f29394f722146f183be555c4b45bf92a39424..ba682f0e2458255ddd619be58c5f6f37487e888c 100644
|
| --- a/bench/TimerData.cpp
|
| +++ b/bench/TimerData.cpp
|
| @@ -5,7 +5,6 @@
|
| * Use of this source code is governed by a BSD-style license that can be
|
| * found in the LICENSE file.
|
| */
|
| -
|
| #include "TimerData.h"
|
|
|
| #include "BenchTimer.h"
|
| @@ -140,3 +139,88 @@ SkString TimerData::getResult(const char* doubleFormat,
|
| }
|
| return str;
|
| }
|
| +
|
| +#ifdef SK_BUILD_JSON_WRITER
|
| +Json::Value TimerData::getJSON(uint32_t timerFlags,
|
| + Result result,
|
| + int itersPerTiming) {
|
| + SkASSERT(itersPerTiming >= 1);
|
| + Json::Value dataNode;
|
| + Json::Value wallNode, truncWall, cpuNode, truncCpu, gpuNode;
|
| + if (!fCurrTiming) {
|
| + return dataNode;
|
| + }
|
| +
|
| + int numTimings = fCurrTiming;
|
| +
|
| + double wallMin = std::numeric_limits<double>::max();
|
| + double truncWallMin = std::numeric_limits<double>::max();
|
| + double cpuMin = std::numeric_limits<double>::max();
|
| + double truncCpuMin = std::numeric_limits<double>::max();
|
| + double gpuMin = std::numeric_limits<double>::max();
|
| +
|
| + double wallSum = 0;
|
| + double truncWallSum = 0;
|
| + double cpuSum = 0;
|
| + double truncCpuSum = 0;
|
| + double gpuSum = 0;
|
| +
|
| + for (int i = 0; i < numTimings; ++i) {
|
| + if (kPerIter_Result == result) {
|
| + wallNode.append(fWallTimes[i] / itersPerTiming);
|
| + truncWall.append(fTruncatedWallTimes[i] / itersPerTiming);
|
| + cpuNode.append(fCpuTimes[i] / itersPerTiming);
|
| + truncCpu.append(fTruncatedCpuTimes[i] / itersPerTiming);
|
| + gpuNode.append(fGpuTimes[i] / itersPerTiming);
|
| + } else if (kMin_Result == result) {
|
| + wallMin = SkTMin(wallMin, fWallTimes[i]);
|
| + truncWallMin = SkTMin(truncWallMin, fTruncatedWallTimes[i]);
|
| + cpuMin = SkTMin(cpuMin, fCpuTimes[i]);
|
| + truncCpuMin = SkTMin(truncCpuMin, fTruncatedCpuTimes[i]);
|
| + gpuMin = SkTMin(gpuMin, fGpuTimes[i]);
|
| + } else {
|
| + SkASSERT(kAvg_Result == result);
|
| + wallSum += fWallTimes[i];
|
| + truncWallSum += fTruncatedWallTimes[i];
|
| + cpuSum += fCpuTimes[i];
|
| + truncCpuSum += fTruncatedCpuTimes[i];
|
| + }
|
| +
|
| + // We always track the GPU sum because whether it is non-zero indicates if valid gpu times
|
| + // were recorded at all.
|
| + gpuSum += fGpuTimes[i];
|
| + }
|
| +
|
| + if (kMin_Result == result) {
|
| + wallNode.append(wallMin / itersPerTiming);
|
| + truncWall.append(truncWallMin / itersPerTiming);
|
| + cpuNode.append(cpuMin / itersPerTiming);
|
| + truncCpu.append(truncCpuMin / itersPerTiming);
|
| + gpuNode.append(gpuMin / itersPerTiming);
|
| + } else if (kAvg_Result == result) {
|
| + int divisor = numTimings * itersPerTiming;
|
| + wallNode.append(wallSum / divisor);
|
| + truncWall.append(truncWallSum / divisor);
|
| + cpuNode.append(cpuSum / divisor);
|
| + truncCpu.append(truncCpuSum / divisor);
|
| + gpuNode.append(gpuSum / divisor);
|
| + }
|
| +
|
| + if (timerFlags & kWall_Flag) {
|
| + dataNode["wall"] = wallNode;
|
| + }
|
| + if (timerFlags & kTruncatedWall_Flag) {
|
| + dataNode["truncWall"] = truncWall;
|
| + }
|
| + if (timerFlags & kCpu_Flag) {
|
| + dataNode["cpu"] = cpuNode;
|
| + }
|
| + if (timerFlags & kTruncatedCpu_Flag) {
|
| + dataNode["trucCpu"] = truncCpu;
|
| + }
|
| + if ((timerFlags & kGpu_Flag) && gpuSum > 0) {
|
| + dataNode["gpu"] = gpuNode;
|
| + }
|
| + return dataNode;
|
| +}
|
| +#endif // SK_BUILD_JSON_WRITER
|
|
|