Compute Library
 22.08
PrettyPrinter Class Reference

Implementation of a Printer that produces human readable output. More...

#include <PrettyPrinter.h>

Collaboration diagram for PrettyPrinter:
[legend]

Public Member Functions

void set_color_output (bool color_output)
 Set if the output is colored. More...
 
void print_entry (const std::string &name, const std::string &value) override
 Print an entry consisting of a (name, value) pair. More...
 
void print_global_header () override
 Print global header. More...
 
void print_global_footer () override
 Print global footer. More...
 
void print_run_header () override
 Print header before running all tests. More...
 
void print_run_footer () override
 Print footer after running all tests. More...
 
void print_test_header (const TestInfo &info) override
 Print header before a test. More...
 
void print_test_footer () override
 Print footer after a test. More...
 
void print_errors_header () override
 Print header before errors. More...
 
void print_errors_footer () override
 Print footer after errors. More...
 
void print_error (const std::exception &error, bool expected) override
 Print test error. More...
 
void print_info (const std::string &info) override
 Print test log info. More...
 
void print_profiler_header (const std::string &header_data) override
 Print header data. More...
 
void print_measurements (const Profiler::MeasurementsMap &measurements) override
 Print measurements for a test. More...
 
void print_list_tests (const std::vector< TestInfo > &infos) override
 Print the list of all the tests. More...
 
- Public Member Functions inherited from Printer
 Printer ()=default
 Default constructor. More...
 
 Printer (std::ostream &stream)
 Construct printer with given output stream. More...
 
 Printer (const Printer &)=delete
 Prevent instances of this class from being copy constructed. More...
 
Printeroperator= (const Printer &)=delete
 Prevent instances of this class from being copied. More...
 
 Printer (Printer &&)=default
 Allow instances of this class to be move constructed. More...
 
Printeroperator= (Printer &&)=default
 Allow instances of this class to be moved. More...
 
virtual ~Printer ()=default
 Default destructor. More...
 
void print (const std::string &str)
 Print given string. More...
 
void set_stream (std::ostream &stream)
 Set the output stream. More...
 

Detailed Description

Implementation of a Printer that produces human readable output.

Definition at line 36 of file PrettyPrinter.h.

Member Function Documentation

◆ print_entry()

void print_entry ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Print an entry consisting of a (name, value) pair.

Parameters
[in]nameDescription of the value.
[in]valueValue.

Implements Printer.

Definition at line 63 of file PrettyPrinter.cpp.

64 {
65  *_stream << begin_color("4") << name << " = " << value << end_color() << "\n";
66 }
const char * name

◆ print_error()

void print_error ( const std::exception &  error,
bool  expected 
)
overridevirtual

Print test error.

Parameters
[in]errorDescription of the error.
[in]expectedWhether the error was expected or not.

Implements Printer.

Definition at line 106 of file PrettyPrinter.cpp.

107 {
108  std::string prefix = expected ? "EXPECTED ERROR: " : "ERROR: ";
109  *_stream << begin_color("1") << prefix << error.what() << end_color() << "\n";
110 }

◆ print_errors_footer()

void print_errors_footer ( )
overridevirtual

Print footer after errors.

Implements Printer.

Definition at line 97 of file PrettyPrinter.cpp.

98 {
99 }

◆ print_errors_header()

void print_errors_header ( )
overridevirtual

Print header before errors.

Implements Printer.

Definition at line 93 of file PrettyPrinter.cpp.

94 {
95 }

◆ print_global_footer()

void print_global_footer ( )
overridevirtual

Print global footer.

Implements Printer.

Definition at line 72 of file PrettyPrinter.cpp.

73 {
74 }

◆ print_global_header()

void print_global_header ( )
overridevirtual

Print global header.

Implements Printer.

Definition at line 68 of file PrettyPrinter.cpp.

69 {
70 }

◆ print_info()

void print_info ( const std::string &  info)
overridevirtual

Print test log info.

Parameters
[in]infoDescription of the log.

Implements Printer.

Definition at line 101 of file PrettyPrinter.cpp.

102 {
103  *_stream << begin_color("1") << "INFO: " << info << end_color() << "\n";
104 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ print_list_tests()

void print_list_tests ( const std::vector< TestInfo > &  infos)
overridevirtual

Print the list of all the tests.

Parameters
[in]infosList of tests to print

Implements Printer.

Definition at line 112 of file PrettyPrinter.cpp.

References arm_compute::test::validation::info.

113 {
114  for(auto const &info : infos)
115  {
116  *_stream << "[" << info.id << ", " << info.mode << ", " << info.status << "] " << info.name << "\n";
117  }
118 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ print_measurements()

void print_measurements ( const Profiler::MeasurementsMap measurements)
overridevirtual

Print measurements for a test.

Parameters
[in]measurementsMeasurements as collected by a Profiler.

Implements Printer.

Definition at line 125 of file PrettyPrinter.cpp.

References arm_compute::test::arithmetic_to_string(), InstrumentsStats::max(), InstrumentsStats::mean(), InstrumentsStats::median(), InstrumentsStats::min(), InstrumentsStats::relative_standard_deviation(), Measurement::unit(), and Measurement::value().

126 {
127  for(const auto &instrument : measurements)
128  {
129  *_stream << begin_color("3") << " " << instrument.first << ":";
130 
131  InstrumentsStats stats(instrument.second);
132 
133  *_stream << " ";
134  *_stream << "AVG=" << stats.mean() << " " << stats.max().unit();
135  if(instrument.second.size() > 1)
136  {
137  *_stream << ", STDDEV=" << arithmetic_to_string(stats.relative_standard_deviation(), 2) << " %";
138  *_stream << ", MIN=" << stats.min();
139  *_stream << ", MAX=" << stats.max();
140  *_stream << ", MEDIAN=" << stats.median().value() << " " << stats.median().unit();
141  }
142  *_stream << end_color() << "\n";
143  }
144 }
std::string arithmetic_to_string(T val, int decimal_places=0)
Create a string with the arithmetic value in full precision.
Definition: Utils.h:164

◆ print_profiler_header()

void print_profiler_header ( const std::string &  header_data)
overridevirtual

Print header data.

Parameters
[in]header_dataJSON formmated header data.

Implements Printer.

Definition at line 120 of file PrettyPrinter.cpp.

References ARM_COMPUTE_UNUSED.

121 {
122  ARM_COMPUTE_UNUSED(header_data);
123 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ print_run_footer()

void print_run_footer ( )
overridevirtual

Print footer after running all tests.

Implements Printer.

Definition at line 80 of file PrettyPrinter.cpp.

81 {
82 }

◆ print_run_header()

void print_run_header ( )
overridevirtual

Print header before running all tests.

Implements Printer.

Definition at line 76 of file PrettyPrinter.cpp.

77 {
78 }

◆ print_test_footer()

void print_test_footer ( )
overridevirtual

Print footer after a test.

Implements Printer.

Definition at line 89 of file PrettyPrinter.cpp.

90 {
91 }

◆ print_test_header()

void print_test_header ( const TestInfo info)
overridevirtual

Print header before a test.

Parameters
[in]infoTest info.

Implements Printer.

Definition at line 84 of file PrettyPrinter.cpp.

References TestInfo::id, and TestInfo::name.

85 {
86  *_stream << begin_color("2") << "Running [" << info.id << "] '" << info.name << "'" << end_color() << "\n";
87 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ set_color_output()

void set_color_output ( bool  color_output)

Set if the output is colored.

Parameters
[in]color_outputTrue if the output is colored.

Definition at line 58 of file PrettyPrinter.cpp.

59 {
60  _color_output = color_output;
61 }

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