Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3013)

Unified Diff: bench/TimerData.cpp

Issue 304613002: Reland https://codereview.chromium.org/286903025 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Diagnostic patch: removed header from gyp entry Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/TimerData.h ('k') | gyp/bench.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « bench/TimerData.h ('k') | gyp/bench.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698