aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/ResultsWriter.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-19 17:29:01 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-19 17:29:01 +0000
commit71e55762e686c8000367ea56a47c61e0c1e05402 (patch)
treef0ec6f674803ab8fcda859aa65abc1b2e5160b05 /bench/ResultsWriter.h
parent015c08e5ca44260b2f8edd6b70ae4eb05a05f2a9 (diff)
Changed JSON formatting to fit BigQuery requirements
BUG=skia: R=bensong@google.com, jcgregorio@google.com Author: kelvinly@google.com Review URL: https://codereview.chromium.org/290903002 git-svn-id: http://skia.googlecode.com/svn/trunk@14784 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/ResultsWriter.h')
-rw-r--r--bench/ResultsWriter.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/bench/ResultsWriter.h b/bench/ResultsWriter.h
index 12c968a507..b04c8ff53c 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);