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

Unified Diff: bench/ResultsWriter.h

Issue 392393002: Change JSON output of nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ResultsWriter.h
diff --git a/bench/ResultsWriter.h b/bench/ResultsWriter.h
index 1ee3616cebe212e87a5f7a6b75afcd36b4a93c26..dc45f192f5eecfba97ee21d7ca50d044f249313a 100644
--- a/bench/ResultsWriter.h
+++ b/bench/ResultsWriter.h
@@ -26,6 +26,10 @@ class ResultsWriter : SkNoncopyable {
public:
virtual ~ResultsWriter() {};
+ // Records one key value pair that makes up a unique identifier for this run.
+ // All keys must be set before calling bench().
+ virtual void key(const char name[], const char value[]) = 0;
+
// Records one option set for this run. All options must be set before
// calling bench().
virtual void option(const char name[], const char value[]) = 0;
@@ -37,6 +41,9 @@ public:
// Records the specific configuration a bench is run under, such as "8888".
virtual void config(const char name[]) = 0;
+ // Records the options for a configuration, such as "GL_RENDERER".
+ virtual void configOption(const char name[], const char* value) = 0;
+
// Records a single test metric.
virtual void timer(const char name[], double ms) = 0;
@@ -55,6 +62,9 @@ public:
, fTimeFormat(timeFormat) {
fLogger.logProgress("skia bench:");
}
+ virtual void key(const char name[], const char value[]) {
+ // Don't log keys to keep microbench output unchanged.
+ }
virtual void option(const char name[], const char value[]) {
fLogger.logProgress(SkStringPrintf(" %s=%s", name, value));
}
@@ -65,6 +75,9 @@ public:
virtual void config(const char name[]) {
fLogger.logProgress(SkStringPrintf(" %s:", name));
}
+ virtual void configOption(const char name[], const char* value) {
+ // Don't log configOptions to keep microbench output unchanged.
+ }
virtual void timer(const char name[], double ms) {
fLogger.logProgress(SkStringPrintf(" %s = ", name));
fLogger.logProgress(SkStringPrintf(fTimeFormat, ms));
@@ -113,6 +126,8 @@ public:
, fBench(NULL)
, fConfig(NULL) {
}
+ virtual void key(const char name[], const char value[]) {
+ }
virtual void option(const char name[], const char value[]) {
fRoot["options"][name] = value;
}
@@ -129,7 +144,84 @@ public:
SkASSERT(NULL != fBench);
fConfig = SkFindNamedNode(fBench, name);
}
+ virtual void configOption(const char name[], const char* value) {
+ }
+ virtual void timer(const char name[], double ms) {
+ SkASSERT(NULL != fConfig);
+ (*fConfig)[name] = ms;
+ }
+ virtual void end() {
+ SkFILEWStream stream(fFilename.c_str());
+ stream.writeText(Json::FastWriter().write(fRoot).c_str());
+ stream.flush();
+ }
+private:
+
+ SkString fFilename;
+ Json::Value fRoot;
+ Json::Value& fResults;
+ Json::Value* fBench;
+ Json::Value* fConfig;
+};
+
+/**
+ NanoJSONResultsWriter writes the test results out in the following
+ format:
+
+ {
+ "key": {
+ "arch": "Arm7",
+ "gpu": "SGX540",
+ "os": "Android",
+ "model": "GalaxyNexus",
+ }
+ "options": {
+ "GL_Version": "3.1",
+ ...
+ },
+ "gitHash": "d1830323662ae8ae06908b97f15180fd25808894",
+ "results" : {
+ "Xfermode_Luminosity_640_480" : {
+ "8888" : {
+ "median_ms" : 143.188128906250,
+ "min_ms" : 143.835957031250,
+ ...
+ },
+ ...
+*/
+class NanoJSONResultsWriter : public ResultsWriter {
+public:
+ explicit NanoJSONResultsWriter(const char filename[], const char gitHash[])
+ : fFilename(filename)
+ , fRoot()
+ , fResults(fRoot["results"])
+ , fBench(NULL)
+ , fConfig(NULL) {
+ fRoot["gitHash"] = gitHash;
+ }
+ virtual void key(const char name[], const char value[]) {
+ fRoot["key"][name] = value;
+ }
+ virtual void option(const char name[], const char value[]) {
+ fRoot["options"][name] = value;
+ }
+ virtual void bench(const char name[], int32_t x, int32_t y) {
+ SkString id = SkStringPrintf( "%s_%d_%d", name, x, y);
+ fResults[id.c_str()] = Json::Value(Json::objectValue);
+ fBench = &fResults[id.c_str()];
+ }
+ virtual void config(const char name[]) {
+ SkASSERT(NULL != fBench);
+ fConfig = &(*fBench)[name];
+ }
+ virtual void configOption(const char name[], const char* value) {
+ (*fConfig)["options"][name] = value;
+ }
virtual void timer(const char name[], double ms) {
+ // Don't record if nan, or -nan.
+ if (sk_double_isnan(ms)) {
+ return;
+ }
SkASSERT(NULL != fConfig);
(*fConfig)[name] = ms;
}
@@ -147,6 +239,7 @@ private:
Json::Value* fConfig;
};
+
/**
* This ResultsWriter writes out to multiple ResultsWriters.
*/
@@ -157,6 +250,11 @@ public:
void add(ResultsWriter* writer) {
writers.push_back(writer);
}
+ virtual void key(const char name[], const char value[]) {
+ for (int i = 0; i < writers.count(); ++i) {
+ writers[i]->key(name, value);
+ }
+ }
virtual void option(const char name[], const char value[]) {
for (int i = 0; i < writers.count(); ++i) {
writers[i]->option(name, value);
@@ -172,6 +270,11 @@ public:
writers[i]->config(name);
}
}
+ virtual void configOption(const char name[], const char* value) {
+ for (int i = 0; i < writers.count(); ++i) {
+ writers[i]->configOption(name, value);
+ }
+ }
virtual void timer(const char name[], double ms) {
for (int i = 0; i < writers.count(); ++i) {
writers[i]->timer(name, ms);
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698