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

Unified Diff: bench/ResultsWriter.h

Issue 290903002: Changed JSON formatting to fit BigQuery requirements (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix for loop problem Created 6 years, 7 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 | no next file » | 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 12c968a5075d42b4c2890b0c540b8b6f3a2f83d7..b04c8ff53cff64079fed0890ada634053e285675 100644
--- a/bench/ResultsWriter.h
+++ b/bench/ResultsWriter.h
@@ -99,6 +99,23 @@ private:
* ...
*/
class JSONResultsWriter : public ResultsWriter {
+private:
+ Json::Value* find_named_node(Json::Value* root, const char name[]) {
+ Json::Value* search_results = NULL;
+ for(Json::Value::iterator iter = root->begin();
+ iter!= root->end(); ++iter) {
+ if(SkString(name).equals((*iter)["name"].asCString())) {
+ search_results = &(*iter);
+ break;
+ }
+ }
+
+ if(search_results != NULL) {
+ return search_results;
+ } else {
+ return &(root->append(Json::Value()));
+ }
+ }
public:
explicit JSONResultsWriter(const char filename[])
: fFilename(filename)
@@ -111,11 +128,15 @@ public:
fRoot["options"][name] = value;
}
virtual void bench(const char name[], int32_t x, int32_t y) {
- fBench = &fResults[SkStringPrintf( "%s_%d_%d", name, x, y).c_str()];
+ const char* full_name = SkStringPrintf( "%s_%d_%d", name, x, y).c_str();
+ Json::Value* bench_node = find_named_node(&fResults, full_name);
+ (*bench_node)["name"] = full_name;
+ fBench = &(*bench_node)["results"];
}
virtual void config(const char name[]) {
SkASSERT(NULL != fBench);
- fConfig = &(*fBench)[name];
+ fConfig = find_named_node(fBench, name);
+ (*fConfig)["name"] = name;
}
virtual void timer(const char name[], double ms) {
SkASSERT(NULL != fConfig);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698