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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « bench/TimerData.h ('k') | gyp/bench.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
9 #include "TimerData.h" 8 #include "TimerData.h"
10 9
11 #include "BenchTimer.h" 10 #include "BenchTimer.h"
12 #include <limits> 11 #include <limits>
13 12
14 using namespace std; 13 using namespace std;
15 14
16 TimerData::TimerData(int maxNumTimings) 15 TimerData::TimerData(int maxNumTimings)
17 : fMaxNumTimings(maxNumTimings) 16 : fMaxNumTimings(maxNumTimings)
18 , fCurrTiming(0) 17 , fCurrTiming(0)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 str += cpuStr; 132 str += cpuStr;
134 } 133 }
135 if (timerFlags & kTruncatedCpu_Flag) { 134 if (timerFlags & kTruncatedCpu_Flag) {
136 str += truncCpuStr; 135 str += truncCpuStr;
137 } 136 }
138 if ((timerFlags & kGpu_Flag) && gpuSum > 0) { 137 if ((timerFlags & kGpu_Flag) && gpuSum > 0) {
139 str += gpuStr; 138 str += gpuStr;
140 } 139 }
141 return str; 140 return str;
142 } 141 }
142
143 #ifdef SK_BUILD_JSON_WRITER
144 Json::Value TimerData::getJSON(uint32_t timerFlags,
145 Result result,
146 int itersPerTiming) {
147 SkASSERT(itersPerTiming >= 1);
148 Json::Value dataNode;
149 Json::Value wallNode, truncWall, cpuNode, truncCpu, gpuNode;
150 if (!fCurrTiming) {
151 return dataNode;
152 }
153
154 int numTimings = fCurrTiming;
155
156 double wallMin = std::numeric_limits<double>::max();
157 double truncWallMin = std::numeric_limits<double>::max();
158 double cpuMin = std::numeric_limits<double>::max();
159 double truncCpuMin = std::numeric_limits<double>::max();
160 double gpuMin = std::numeric_limits<double>::max();
161
162 double wallSum = 0;
163 double truncWallSum = 0;
164 double cpuSum = 0;
165 double truncCpuSum = 0;
166 double gpuSum = 0;
167
168 for (int i = 0; i < numTimings; ++i) {
169 if (kPerIter_Result == result) {
170 wallNode.append(fWallTimes[i] / itersPerTiming);
171 truncWall.append(fTruncatedWallTimes[i] / itersPerTiming);
172 cpuNode.append(fCpuTimes[i] / itersPerTiming);
173 truncCpu.append(fTruncatedCpuTimes[i] / itersPerTiming);
174 gpuNode.append(fGpuTimes[i] / itersPerTiming);
175 } else if (kMin_Result == result) {
176 wallMin = SkTMin(wallMin, fWallTimes[i]);
177 truncWallMin = SkTMin(truncWallMin, fTruncatedWallTimes[i]);
178 cpuMin = SkTMin(cpuMin, fCpuTimes[i]);
179 truncCpuMin = SkTMin(truncCpuMin, fTruncatedCpuTimes[i]);
180 gpuMin = SkTMin(gpuMin, fGpuTimes[i]);
181 } else {
182 SkASSERT(kAvg_Result == result);
183 wallSum += fWallTimes[i];
184 truncWallSum += fTruncatedWallTimes[i];
185 cpuSum += fCpuTimes[i];
186 truncCpuSum += fTruncatedCpuTimes[i];
187 }
188
189 // We always track the GPU sum because whether it is non-zero indicates if valid gpu times
190 // were recorded at all.
191 gpuSum += fGpuTimes[i];
192 }
193
194 if (kMin_Result == result) {
195 wallNode.append(wallMin / itersPerTiming);
196 truncWall.append(truncWallMin / itersPerTiming);
197 cpuNode.append(cpuMin / itersPerTiming);
198 truncCpu.append(truncCpuMin / itersPerTiming);
199 gpuNode.append(gpuMin / itersPerTiming);
200 } else if (kAvg_Result == result) {
201 int divisor = numTimings * itersPerTiming;
202 wallNode.append(wallSum / divisor);
203 truncWall.append(truncWallSum / divisor);
204 cpuNode.append(cpuSum / divisor);
205 truncCpu.append(truncCpuSum / divisor);
206 gpuNode.append(gpuSum / divisor);
207 }
208
209 if (timerFlags & kWall_Flag) {
210 dataNode["wall"] = wallNode;
211 }
212 if (timerFlags & kTruncatedWall_Flag) {
213 dataNode["truncWall"] = truncWall;
214 }
215 if (timerFlags & kCpu_Flag) {
216 dataNode["cpu"] = cpuNode;
217 }
218 if (timerFlags & kTruncatedCpu_Flag) {
219 dataNode["trucCpu"] = truncCpu;
220 }
221 if ((timerFlags & kGpu_Flag) && gpuSum > 0) {
222 dataNode["gpu"] = gpuNode;
223 }
224 return dataNode;
225 }
226 #endif // SK_BUILD_JSON_WRITER
OLDNEW
« 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