OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 * | 6 * |
7 * Classes for writing out bench results in various formats. | 7 * Classes for writing out bench results in various formats. |
8 */ | 8 */ |
9 #ifndef SkResultsWriter_DEFINED | 9 #ifndef SkResultsWriter_DEFINED |
10 #define SkResultsWriter_DEFINED | 10 #define SkResultsWriter_DEFINED |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 * { | 94 * { |
95 * "name" : "Xfermode_Luminosity_640_480", | 95 * "name" : "Xfermode_Luminosity_640_480", |
96 * "results" : [ | 96 * "results" : [ |
97 * { | 97 * { |
98 * "name": "565", | 98 * "name": "565", |
99 * "cmsecs" : 143.188128906250, | 99 * "cmsecs" : 143.188128906250, |
100 * "msecs" : 143.835957031250 | 100 * "msecs" : 143.835957031250 |
101 * }, | 101 * }, |
102 * ... | 102 * ... |
103 */ | 103 */ |
104 | |
105 Json::Value* find_named_node(Json::Value* root, const char name[]); | |
104 class JSONResultsWriter : public ResultsWriter { | 106 class JSONResultsWriter : public ResultsWriter { |
105 private: | |
106 Json::Value* find_named_node(Json::Value* root, const char name[]) { | |
107 Json::Value* search_results = NULL; | |
108 for(Json::Value::iterator iter = root->begin(); | |
109 iter!= root->end(); ++iter) { | |
110 if(SkString(name).equals((*iter)["name"].asCString())) { | |
111 search_results = &(*iter); | |
112 break; | |
113 } | |
114 } | |
115 | |
116 if(search_results != NULL) { | |
117 return search_results; | |
118 } else { | |
119 Json::Value* new_val = &(root->append(Json::Value())); | |
120 (*new_val)["name"] = name; | |
121 return new_val; | |
122 } | |
123 } | |
124 public: | 107 public: |
125 explicit JSONResultsWriter(const char filename[]) | 108 explicit JSONResultsWriter(const char filename[]) |
126 : fFilename(filename) | 109 : fFilename(filename) |
127 , fRoot() | 110 , fRoot() |
128 , fResults(fRoot["results"]) | 111 , fResults(fRoot["results"]) |
129 , fBench(NULL) | 112 , fBench(NULL) |
130 , fConfig(NULL) { | 113 , fConfig(NULL) { |
131 } | 114 } |
132 virtual void option(const char name[], const char value[]) { | 115 virtual void option(const char name[], const char value[]) { |
133 fRoot["options"][name] = value; | 116 fRoot["options"][name] = value; |
(...skipping 22 matching lines...) Expand all Loading... | |
156 } | 139 } |
157 private: | 140 private: |
158 | 141 |
159 SkString fFilename; | 142 SkString fFilename; |
160 Json::Value fRoot; | 143 Json::Value fRoot; |
161 Json::Value& fResults; | 144 Json::Value& fResults; |
162 Json::Value* fBench; | 145 Json::Value* fBench; |
163 Json::Value* fConfig; | 146 Json::Value* fConfig; |
164 }; | 147 }; |
165 | 148 |
149 | |
150 Json::Value* find_named_node(Json::Value* root, const char name[]) { | |
jcgregorio
2014/05/27 15:34:25
Should be moved to a CPP file. Also I believe the
kelvinly
2014/05/27 16:41:06
Ah, sorry. Any advice on what to name the CPP file
jcgregorio
2014/05/27 17:14:05
ResultsWriter.cpp
On 2014/05/27 16:41:06, kelvinl
kelvinly
2014/05/27 18:55:28
Done.
| |
151 Json::Value* search_results = NULL; | |
152 for(Json::Value::iterator iter = root->begin(); | |
153 iter!= root->end(); ++iter) { | |
154 if(SkString(name).equals((*iter)["name"].asCString())) { | |
155 search_results = &(*iter); | |
156 break; | |
157 } | |
158 } | |
159 | |
160 if(search_results != NULL) { | |
161 return search_results; | |
162 } else { | |
163 Json::Value* new_val = &(root->append(Json::Value())); | |
164 (*new_val)["name"] = name; | |
165 return new_val; | |
166 } | |
167 } | |
166 #endif // SK_BUILD_JSON_WRITER | 168 #endif // SK_BUILD_JSON_WRITER |
169 | |
167 /** | 170 /** |
168 * This ResultsWriter writes out to multiple ResultsWriters. | 171 * This ResultsWriter writes out to multiple ResultsWriters. |
169 */ | 172 */ |
170 class MultiResultsWriter : public ResultsWriter { | 173 class MultiResultsWriter : public ResultsWriter { |
171 public: | 174 public: |
172 MultiResultsWriter() : writers() { | 175 MultiResultsWriter() : writers() { |
173 }; | 176 }; |
174 void add(ResultsWriter* writer) { | 177 void add(ResultsWriter* writer) { |
175 writers.push_back(writer); | 178 writers.push_back(writer); |
176 } | 179 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 */ | 211 */ |
209 template <typename T> class CallEnd : SkNoncopyable { | 212 template <typename T> class CallEnd : SkNoncopyable { |
210 public: | 213 public: |
211 CallEnd(T& obj) : fObj(obj) {} | 214 CallEnd(T& obj) : fObj(obj) {} |
212 ~CallEnd() { fObj.end(); } | 215 ~CallEnd() { fObj.end(); } |
213 private: | 216 private: |
214 T& fObj; | 217 T& fObj; |
215 }; | 218 }; |
216 | 219 |
217 #endif | 220 #endif |
OLD | NEW |