Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
ResultsJSONWriter Class Reference

Classes

struct  Result
 
struct  SingleMeasurement
 

Public Member Functions

 ResultsJSONWriter (const char *path)
 
void addGitHash (std::string gitHash)
 
void addChangelistInfo (std::string issue, std::string patchset)
 
void addKey (std::map< std::string, std::string > key)
 
void addLinks (std::map< std::string, std::string > links)
 
void addResult (Result result)
 
void flush ()
 
 ~ResultsJSONWriter ()
 

Detailed Description

Definition at line 196 of file BazelBenchmarkTestRunner.cpp.

Constructor & Destructor Documentation

◆ ResultsJSONWriter()

ResultsJSONWriter::ResultsJSONWriter ( const char *  path)
inline

Definition at line 216 of file BazelBenchmarkTestRunner.cpp.

217 : fFileWStream(path)
218 , fJson(&fFileWStream, SkJSONWriter::Mode::kPretty)
219 , fAddingResults(false) {
220 fJson.beginObject(); // Root object.
221 fJson.appendS32("version", 1);
222 }
void appendS32(int32_t value)
void beginObject(const char *name=nullptr, bool multiline=true)

◆ ~ResultsJSONWriter()

ResultsJSONWriter::~ResultsJSONWriter ( )
inline

Definition at line 293 of file BazelBenchmarkTestRunner.cpp.

293 {
294 if (fAddingResults) {
295 fJson.endArray(); // "results" array;
296 }
297 fJson.endObject(); // Root object.
298 }

Member Function Documentation

◆ addChangelistInfo()

void ResultsJSONWriter::addChangelistInfo ( std::string  issue,
std::string  patchset 
)
inline

Definition at line 229 of file BazelBenchmarkTestRunner.cpp.

229 {
230 assertNotAddingResults();
231 fJson.appendCString("issue", issue.c_str());
232 fJson.appendCString("patchset", patchset.c_str());
233 }
void appendCString(const char *value)

◆ addGitHash()

void ResultsJSONWriter::addGitHash ( std::string  gitHash)
inline

Definition at line 224 of file BazelBenchmarkTestRunner.cpp.

224 {
225 assertNotAddingResults();
226 fJson.appendCString("git_hash", gitHash.c_str());
227 }

◆ addKey()

void ResultsJSONWriter::addKey ( std::map< std::string, std::string >  key)
inline

Definition at line 235 of file BazelBenchmarkTestRunner.cpp.

235 {
236 assertNotAddingResults();
237 fJson.beginObject("key");
238 for (auto const& [name, value] : key) {
239 fJson.appendCString(name.c_str(), value.c_str());
240 }
241 fJson.endObject();
242 }
uint8_t value
const char * name
Definition fuchsia.cc:50

◆ addLinks()

void ResultsJSONWriter::addLinks ( std::map< std::string, std::string >  links)
inline

Definition at line 244 of file BazelBenchmarkTestRunner.cpp.

244 {
245 assertNotAddingResults();
246 fJson.beginObject("links");
247 for (auto const& [key, value] : links) {
248 fJson.appendCString(key.c_str(), value.c_str());
249 }
250 fJson.endObject();
251 }

◆ addResult()

void ResultsJSONWriter::addResult ( Result  result)
inline

Definition at line 253 of file BazelBenchmarkTestRunner.cpp.

253 {
254 if (!fAddingResults) {
255 fAddingResults = true;
256 fJson.beginArray("results"); // "results" array.
257 }
258
259 fJson.beginObject(); // Result object.
260
261 // Key.
262 fJson.beginObject("key"); // "key" dictionary.
263 for (auto const& [name, value] : result.key) {
264 fJson.appendCString(name.c_str(), value.c_str());
265 }
266 fJson.endObject(); // "key" dictionary.
267
268 // Measurements.
269 fJson.beginObject("measurements"); // "measurements" dictionary.
270 for (auto const& [name, singleMeasurements] : result.measurements) {
271 fJson.beginArray(name.c_str()); // <name> array.
272 for (const SingleMeasurement& singleMeasurement : singleMeasurements) {
273 // Based on
274 // https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/ResultsWriter.h#51.
275 //
276 // Don't record if NaN or Inf.
277 if (SkIsFinite(singleMeasurement.measurement)) {
278 fJson.beginObject();
279 fJson.appendCString("value", singleMeasurement.value.c_str());
280 fJson.appendDoubleDigits("measurement", singleMeasurement.measurement, 16);
281 fJson.endObject();
282 }
283 }
284 fJson.endArray(); // <name> array.
285 }
286 fJson.endObject(); // "measurements" dictionary.
287
288 fJson.endObject(); // Result object.
289 }
static bool SkIsFinite(T x, Pack... values)
void beginArray(const char *name=nullptr, bool multiline=true)
void appendDoubleDigits(double value, int digits)
GAsyncResult * result

◆ flush()

void ResultsJSONWriter::flush ( )
inline

Definition at line 291 of file BazelBenchmarkTestRunner.cpp.

291{ fJson.flush(); }

The documentation for this class was generated from the following file: