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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/skpdiff/SkDiffContext.h ('k') | experimental/skpdiff/main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/skpdiff/SkDiffContext.cpp
===================================================================
--- experimental/skpdiff/SkDiffContext.cpp (revision 10232)
+++ experimental/skpdiff/SkDiffContext.cpp (working copy)
@@ -9,6 +9,7 @@
#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkStream.h"
+#include "SkTDict.h"
#include "SkDiffContext.h"
#include "SkImageDiffer.h"
@@ -230,3 +231,62 @@
stream.writeText("}\n");
}
}
+
+void SkDiffContext::outputCsv(SkWStream& stream) {
+ SkTDict<int> columns(2);
+ int cntColumns = 0;
+
+ stream.writeText("key");
+
+ DiffRecord* currentRecord = fRecords;
+
+ // Write CSV header and create a dictionary of all columns.
+ while (NULL != currentRecord) {
+ for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffIndex++) {
+ DiffData& data = currentRecord->fDiffs[diffIndex];
+ if (!columns.find(data.fDiffName)) {
+ columns.set(data.fDiffName, cntColumns);
+ stream.writeText(", ");
+ stream.writeText(data.fDiffName);
+ cntColumns++;
+ }
+ }
+ currentRecord = currentRecord->fNext;
+ }
+ stream.writeText("\n");
+
+ double values[100];
+ SkASSERT(cntColumns < 100); // Make the array larger, we we ever have so many diff types.
+
+ currentRecord = fRecords;
+ while (NULL != currentRecord) {
+ for (int i = 0; i < cntColumns; i++) {
+ values[i] = -1;
+ }
+
+ for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffIndex++) {
+ DiffData& data = currentRecord->fDiffs[diffIndex];
+ int index = -1;
+ SkAssertResult(columns.find(data.fDiffName, &index));
+ SkASSERT(index >= 0 && index < cntColumns);
+ values[index] = data.fResult;
+ }
+
+ const char* filename = currentRecord->fBaselinePath.c_str() +
+ strlen(currentRecord->fBaselinePath.c_str()) - 1;
+ while (filename > currentRecord->fBaselinePath.c_str() && *(filename - 1) != '/') {
+ filename--;
+ }
+
+ stream.writeText(filename);
+
+ for (int i = 0; i < cntColumns; i++) {
+ SkString str;
+ str.printf(", %f", values[i]);
+ stream.writeText(str.c_str());
+ }
+ stream.writeText("\n");
+
+ currentRecord = currentRecord->fNext;
+ }
+}
« 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