JSON outputter. More...
#include <hayai_json_outputter.hpp>
Public Member Functions | |
virtual void | Begin (const std::size_t &enabledCount, const std::size_t &disabledCount) |
Begin benchmarking. | |
virtual void | BeginTest (const std::string &fixtureName, const std::string &testName, const TestParametersDescriptor ¶meters, const std::size_t &runsCount, const std::size_t &iterationsCount) |
Begin benchmark test run. | |
virtual void | End (const std::size_t &executedCount, const std::size_t &disabledCount) |
End benchmarking. | |
virtual void | EndTest (const std::string &fixtureName, const std::string &testName, const TestParametersDescriptor ¶meters, const TestResult &result) |
End benchmark test run. | |
JsonOutputter (std::ostream &stream) | |
Initialize JSON outputter. | |
virtual void | SkipDisabledTest (const std::string &fixtureName, const std::string &testName, const TestParametersDescriptor ¶meters, const std::size_t &runsCount, const std::size_t &iterationsCount) |
Skip disabled benchmark test run. | |
Private Member Functions | |
void | BeginTestObject (const std::string &fixtureName, const std::string &testName, const TestParametersDescriptor ¶meters, const std::size_t &runsCount, const std::size_t &iterationsCount, bool disabled) |
void | EndTestObject () |
void | WriteString (const std::string &str) |
Write an escaped string. | |
Private Attributes | |
bool | _firstTest |
std::ostream & | _stream |
JSON outputter.
Outputs the result of benchmarks in JSON format with the following structure:
{ "format_version": 1, "benchmarks": [{ "fixture": "DeliveryMan", "name": "DeliverPackage", "parameters": { "declaration": "std::size_t distance", "value": "1" }, "iterations_per_run": 10, "disabled": false, "runs": [{ "duration": 3801.889831 }, ..] }, { "fixture": "DeliveryMan", "name": "DisabledTest", "iterations_per_run": 10, "disabled": true }, ..] }
All durations are represented as milliseconds.
Definition at line 50 of file hayai_json_outputter.hpp.
hayai::JsonOutputter::JsonOutputter | ( | std::ostream & | stream | ) | [inline] |
Initialize JSON outputter.
stream | Output stream. Must exist for the entire duration of the outputter's use. |
Definition at line 58 of file hayai_json_outputter.hpp.
virtual void hayai::JsonOutputter::Begin | ( | const std::size_t & | enabledCount, |
const std::size_t & | disabledCount | ||
) | [inline, virtual] |
Begin benchmarking.
The total number of benchmarks registred is the sum of the two counts passed to the outputter.
enabledCount | Number of benchmarks to be executed. |
disabledCount | Number of disabled benchmarks to be skipped. |
Implements hayai::Outputter.
Definition at line 66 of file hayai_json_outputter.hpp.
virtual void hayai::JsonOutputter::BeginTest | ( | const std::string & | fixtureName, |
const std::string & | testName, | ||
const TestParametersDescriptor & | parameters, | ||
const std::size_t & | runsCount, | ||
const std::size_t & | iterationsCount | ||
) | [inline, virtual] |
Begin benchmark test run.
fixtureName | Fixture name. |
testName | Test name. |
parameters | Test parameter description. |
runsCount | Number of runs to be executed. |
iterationsCount | Number of iterations per run. |
Implements hayai::Outputter.
Definition at line 99 of file hayai_json_outputter.hpp.
void hayai::JsonOutputter::BeginTestObject | ( | const std::string & | fixtureName, |
const std::string & | testName, | ||
const TestParametersDescriptor & | parameters, | ||
const std::size_t & | runsCount, | ||
const std::size_t & | iterationsCount, | ||
bool | disabled | ||
) | [inline, private] |
Definition at line 173 of file hayai_json_outputter.hpp.
virtual void hayai::JsonOutputter::End | ( | const std::size_t & | executedCount, |
const std::size_t & | disabledCount | ||
) | [inline, virtual] |
End benchmarking.
executedCount | Number of benchmarks that have been executed. |
disabledCount | Number of benchmarks that have been skipped because they are disabled. |
Implements hayai::Outputter.
Definition at line 87 of file hayai_json_outputter.hpp.
virtual void hayai::JsonOutputter::EndTest | ( | const std::string & | fixtureName, |
const std::string & | testName, | ||
const TestParametersDescriptor & | parameters, | ||
const TestResult & | result | ||
) | [inline, virtual] |
End benchmark test run.
fixtureName | Fixture name. |
testName | Test name. |
parameters | Test parameter description. |
result | Test result. |
Implements hayai::Outputter.
Definition at line 130 of file hayai_json_outputter.hpp.
void hayai::JsonOutputter::EndTestObject | ( | ) | [inline, private] |
Definition at line 265 of file hayai_json_outputter.hpp.
virtual void hayai::JsonOutputter::SkipDisabledTest | ( | const std::string & | fixtureName, |
const std::string & | testName, | ||
const TestParametersDescriptor & | parameters, | ||
const std::size_t & | runsCount, | ||
const std::size_t & | iterationsCount | ||
) | [inline, virtual] |
Skip disabled benchmark test run.
fixtureName | Fixture name. |
testName | Test name. |
parameters | Test parameter description. |
runsCount | Number of runs to be executed. |
iterationsCount | Number of iterations per run. |
Implements hayai::Outputter.
Definition at line 114 of file hayai_json_outputter.hpp.
void hayai::JsonOutputter::WriteString | ( | const std::string & | str | ) | [inline, private] |
Write an escaped string.
The escaping is currently very rudimentary and assumes that names, parameters etc. are ASCII.
str | String to write. |
Definition at line 278 of file hayai_json_outputter.hpp.
bool hayai::JsonOutputter::_firstTest [private] |
Definition at line 327 of file hayai_json_outputter.hpp.
std::ostream& hayai::JsonOutputter::_stream [private] |
Definition at line 326 of file hayai_json_outputter.hpp.