aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/ResultsWriter.h
diff options
context:
space:
mode:
Diffstat (limited to 'bench/ResultsWriter.h')
-rw-r--r--bench/ResultsWriter.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/bench/ResultsWriter.h b/bench/ResultsWriter.h
index c66593864f..a9eef802bd 100644
--- a/bench/ResultsWriter.h
+++ b/bench/ResultsWriter.h
@@ -101,9 +101,26 @@ private:
* },
* ...
*/
-
-Json::Value* SkFindNamedNode(Json::Value* root, const char name[]);
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 {
+ Json::Value* new_val = &(root->append(Json::Value()));
+ (*new_val)["name"] = name;
+ return new_val;
+ }
+ }
public:
explicit JSONResultsWriter(const char filename[])
: fFilename(filename)
@@ -121,12 +138,12 @@ public:
sk_name.appendS32(x);
sk_name.append("_");
sk_name.appendS32(y);
- Json::Value* bench_node = SkFindNamedNode(&fResults, sk_name.c_str());
+ Json::Value* bench_node = find_named_node(&fResults, sk_name.c_str());
fBench = &(*bench_node)["results"];
}
virtual void config(const char name[]) {
SkASSERT(NULL != fBench);
- fConfig = SkFindNamedNode(fBench, name);
+ fConfig = find_named_node(fBench, name);
}
virtual void timer(const char name[], double ms) {
SkASSERT(NULL != fConfig);
@@ -147,7 +164,6 @@ private:
};
#endif // SK_BUILD_JSON_WRITER
-
/**
* This ResultsWriter writes out to multiple ResultsWriters.
*/