aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-22 15:24:26 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-22 15:24:26 +0000
commitc93c8ac625a89c14f392d46620abaf6edfabe02e (patch)
treea7e23d8567da4cb480f51442786b42fd157b2423 /experimental
parent4b18f5767ab1df7fedf0ff2e3a9eac7f7c500c36 (diff)
Add --csv parameter to skpdiff to dump all scores in a csv file. We can run it with all skps, and have scores available to look at worst offenders progarmatically.
R=djsollen@google.com, zachr@google.com Review URL: https://codereview.chromium.org/19826002 git-svn-id: http://skia.googlecode.com/svn/trunk@10234 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skpdiff/SkDiffContext.cpp60
-rw-r--r--experimental/skpdiff/SkDiffContext.h6
-rw-r--r--experimental/skpdiff/main.cpp13
3 files changed, 79 insertions, 0 deletions
diff --git a/experimental/skpdiff/SkDiffContext.cpp b/experimental/skpdiff/SkDiffContext.cpp
index b5991273b5..519870397e 100644
--- a/experimental/skpdiff/SkDiffContext.cpp
+++ b/experimental/skpdiff/SkDiffContext.cpp
@@ -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 @@ void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) {
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, if 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;
+ }
+}
diff --git a/experimental/skpdiff/SkDiffContext.h b/experimental/skpdiff/SkDiffContext.h
index 141da09a4d..93354e8dec 100644
--- a/experimental/skpdiff/SkDiffContext.h
+++ b/experimental/skpdiff/SkDiffContext.h
@@ -90,6 +90,12 @@ public:
*/
void outputRecords(SkWStream& stream, bool useJSONP);
+ /**
+ * Output the records score in csv format.
+ */
+ void outputCsv(SkWStream& stream);
+
+
private:
struct DiffData {
const char* fDiffName;
diff --git a/experimental/skpdiff/main.cpp b/experimental/skpdiff/main.cpp
index d258c147c6..7ed0e4d90d 100644
--- a/experimental/skpdiff/main.cpp
+++ b/experimental/skpdiff/main.cpp
@@ -32,6 +32,7 @@ DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names
DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline> <test>");
DEFINE_string2(output, o, "skpdiff_output.json", "Writes the output of these diffs to output: <output>");
DEFINE_bool(jsonp, true, "Output JSON with padding");
+DEFINE_string(csv, "", "Writes the output of these diffs to a csv file");
#if SK_SUPPORT_OPENCL
/// A callback for any OpenCL errors
@@ -169,6 +170,13 @@ int main(int argc, char** argv) {
}
}
+ if (!FLAGS_csv.isEmpty()) {
+ if (1 != FLAGS_csv.count()) {
+ SkDebugf("csv flag expects one argument: <csv file>\n");
+ return 1;
+ }
+ }
+
SkDiffContext ctx;
ctx.setDiffers(chosenDiffers);
@@ -188,5 +196,10 @@ int main(int argc, char** argv) {
ctx.outputRecords(outputStream, FLAGS_jsonp);
}
+ if (!FLAGS_csv.isEmpty()) {
+ SkFILEWStream outputStream(FLAGS_csv[0]);
+ ctx.outputCsv(outputStream);
+ }
+
return 0;
}