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

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') | bench/nanobench.cpp » ('J')
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..676978e0505b9c98e87c05227fafd4c24d3172f9 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;
@@ -55,6 +59,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));
}
@@ -113,6 +120,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;
}
@@ -148,6 +157,79 @@ private:
};
/**
+ 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 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;
+ }
+ 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;
+};
+
+
+/**
* This ResultsWriter writes out to multiple ResultsWriters.
*/
class MultiResultsWriter : public ResultsWriter {
@@ -157,6 +239,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);
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | bench/nanobench.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698