Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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)
Definition: SkJSONWriter.h:237
void beginObject(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:114
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ ~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 }
void endObject()
Definition: SkJSONWriter.h:126
void endArray()
Definition: SkJSONWriter.h:158

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)
Definition: SkJSONWriter.h:224

◆ 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
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ 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)
Definition: SkJSONWriter.h:146
void appendDoubleDigits(double value, int digits)
Definition: SkJSONWriter.h:247
GAsyncResult * result

◆ flush()

void ResultsJSONWriter::flush ( )
inline

Definition at line 291 of file BazelBenchmarkTestRunner.cpp.

291{ fJson.flush(); }
void flush()
Definition: SkJSONWriter.h:78

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