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

Side by Side Diff: experimental/skpdiff/SkDiffContext.cpp

Issue 19826002: add --csv parameter to skpdiff to dump all scores in a csv file. We can run it with all skps, and h… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « experimental/skpdiff/SkDiffContext.h ('k') | experimental/skpdiff/main.cpp » ('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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
11 #include "SkStream.h" 11 #include "SkStream.h"
12 #include "SkTDict.h"
12 13
13 #include "SkDiffContext.h" 14 #include "SkDiffContext.h"
14 #include "SkImageDiffer.h" 15 #include "SkImageDiffer.h"
15 #include "skpdiff_util.h" 16 #include "skpdiff_util.h"
16 17
17 SkDiffContext::SkDiffContext() { 18 SkDiffContext::SkDiffContext() {
18 fRecords = NULL; 19 fRecords = NULL;
19 fDiffers = NULL; 20 fDiffers = NULL;
20 fDifferCount = 0; 21 fDifferCount = 0;
21 } 22 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 224 }
224 stream.writeText(" ]\n"); 225 stream.writeText(" ]\n");
225 if (useJSONP) { 226 if (useJSONP) {
226 stream.writeText("};\n"); 227 stream.writeText("};\n");
227 } 228 }
228 else 229 else
229 { 230 {
230 stream.writeText("}\n"); 231 stream.writeText("}\n");
231 } 232 }
232 } 233 }
234
235 void SkDiffContext::outputCsv(SkWStream& stream) {
236 SkTDict<int> columns(2);
237 int cntColumns = 0;
238
239 stream.writeText("key");
240
241 DiffRecord* currentRecord = fRecords;
242
243 // Write CSV header and create a dictionary of all columns.
244 while (NULL != currentRecord) {
245 for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI ndex++) {
246 DiffData& data = currentRecord->fDiffs[diffIndex];
247 if (!columns.find(data.fDiffName)) {
248 columns.set(data.fDiffName, cntColumns);
249 stream.writeText(", ");
250 stream.writeText(data.fDiffName);
251 cntColumns++;
252 }
253 }
254 currentRecord = currentRecord->fNext;
255 }
256 stream.writeText("\n");
257
258 double values[100];
259 SkASSERT(cntColumns < 100); // Make the array larger, we we ever have so ma ny diff types.
260
261 currentRecord = fRecords;
262 while (NULL != currentRecord) {
263 for (int i = 0; i < cntColumns; i++) {
264 values[i] = -1;
265 }
266
267 for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI ndex++) {
268 DiffData& data = currentRecord->fDiffs[diffIndex];
269 int index = -1;
270 SkAssertResult(columns.find(data.fDiffName, &index));
271 SkASSERT(index >= 0 && index < cntColumns);
272 values[index] = data.fResult;
273 }
274
275 const char* filename = currentRecord->fBaselinePath.c_str() +
276 strlen(currentRecord->fBaselinePath.c_str()) - 1;
277 while (filename > currentRecord->fBaselinePath.c_str() && *(filename - 1 ) != '/') {
278 filename--;
279 }
280
281 stream.writeText(filename);
282
283 for (int i = 0; i < cntColumns; i++) {
284 SkString str;
285 str.printf(", %f", values[i]);
286 stream.writeText(str.c_str());
287 }
288 stream.writeText("\n");
289
290 currentRecord = currentRecord->fNext;
291 }
292 }
OLDNEW
« no previous file with comments | « experimental/skpdiff/SkDiffContext.h ('k') | experimental/skpdiff/main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698