diff options
Diffstat (limited to 'framework/printers')
-rw-r--r-- | framework/printers/JSONPrinter.cpp | 168 | ||||
-rw-r--r-- | framework/printers/JSONPrinter.h | 64 | ||||
-rw-r--r-- | framework/printers/PrettyPrinter.cpp | 140 | ||||
-rw-r--r-- | framework/printers/PrettyPrinter.h | 69 | ||||
-rw-r--r-- | framework/printers/Printer.cpp | 48 | ||||
-rw-r--r-- | framework/printers/Printer.h | 129 | ||||
-rw-r--r-- | framework/printers/Printers.cpp | 57 | ||||
-rw-r--r-- | framework/printers/Printers.h | 75 |
8 files changed, 0 insertions, 750 deletions
diff --git a/framework/printers/JSONPrinter.cpp b/framework/printers/JSONPrinter.cpp deleted file mode 100644 index 099734e72f..0000000000 --- a/framework/printers/JSONPrinter.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "JSONPrinter.h" - -#include "framework/Framework.h" - -#include <algorithm> - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -void JSONPrinter::print_separator(bool &flag) -{ - if(flag) - { - flag = false; - } - else - { - *_stream << ","; - } -} - -void JSONPrinter::print_entry(const std::string &name, const std::string &value) -{ - print_separator(_first_entry); - - *_stream << R"(")" << name << R"(" : ")" << value << R"(")"; -} - -void JSONPrinter::print_global_header() -{ - *_stream << "{"; -} - -void JSONPrinter::print_global_footer() -{ - *_stream << "}\n"; -} - -void JSONPrinter::print_run_header() -{ - print_separator(_first_entry); - - *_stream << R"("tests" : {)"; -} - -void JSONPrinter::print_run_footer() -{ - *_stream << "}"; -} - -void JSONPrinter::print_test_header(const TestInfo &info) -{ - print_separator(_first_test); - - _first_test_entry = true; - *_stream << R"(")" << info.name << R"(" : {)"; -} - -void JSONPrinter::print_test_footer() -{ - *_stream << "}"; -} - -void JSONPrinter::print_errors_header() -{ - print_separator(_first_test_entry); - - _first_error = true; - *_stream << R"("errors" : [)"; -} - -void JSONPrinter::print_errors_footer() -{ - *_stream << "]"; -} - -void JSONPrinter::print_error(const std::exception &error) -{ - std::stringstream error_log; - error_log.str(error.what()); - - for(std::string line; !std::getline(error_log, line).fail();) - { - print_separator(_first_error); - - *_stream << R"(")" << line << R"(")"; - } -} - -void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) -{ - print_separator(_first_test_entry); - - *_stream << R"("measurements" : {)"; - - for(auto i_it = measurements.cbegin(), i_end = measurements.cend(); i_it != i_end;) - { - *_stream << R"(")" << i_it->first << R"(" : {)"; - - auto add_measurements = [](double a, const Instrument::Measurement & b) - { - return a + b.value; - }; - - auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) - { - return a.value < b.value; - }; - - double sum_values = std::accumulate(i_it->second.cbegin(), i_it->second.cend(), 0., add_measurements); - int num_values = i_it->second.size(); - const auto minmax_values = std::minmax_element(i_it->second.begin(), i_it->second.end(), cmp_measurements); - - if(num_values > 2) - { - sum_values -= minmax_values.first->value + minmax_values.second->value; - num_values -= 2; - } - - auto measurement_to_string = [](const Instrument::Measurement & measurement) - { - return support::cpp11::to_string(measurement.value); - }; - - *_stream << R"("avg" : )" << (sum_values / num_values) << ","; - *_stream << R"("min" : )" << minmax_values.first->value << ","; - *_stream << R"("max" : )" << minmax_values.second->value << ","; - *_stream << R"("raw" : [)" << join(i_it->second.begin(), i_it->second.end(), ",", measurement_to_string) << "],"; - *_stream << R"("unit" : ")" << minmax_values.first->unit << R"(")"; - *_stream << "}"; - - if(++i_it != i_end) - { - *_stream << ","; - } - } - - *_stream << "}"; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/JSONPrinter.h b/framework/printers/JSONPrinter.h deleted file mode 100644 index 14c8b35cb9..0000000000 --- a/framework/printers/JSONPrinter.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_JSONPRINTER -#define ARM_COMPUTE_TEST_JSONPRINTER - -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of a @ref Printer that produces JSON output. */ -class JSONPrinter : public Printer -{ -public: - using Printer::Printer; - - void print_entry(const std::string &name, const std::string &value) override; - void print_global_header() override; - void print_global_footer() override; - void print_run_header() override; - void print_run_footer() override; - void print_test_header(const TestInfo &info) override; - void print_test_footer() override; - void print_errors_header() override; - void print_errors_footer() override; - void print_error(const std::exception &error) override; - void print_measurements(const Profiler::MeasurementsMap &measurements) override; - -private: - void print_separator(bool &flag); - - bool _first_entry{ true }; - bool _first_test{ true }; - bool _first_test_entry{ true }; - bool _first_error{ true }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_JSONPRINTER */ diff --git a/framework/printers/PrettyPrinter.cpp b/framework/printers/PrettyPrinter.cpp deleted file mode 100644 index 6f7174371a..0000000000 --- a/framework/printers/PrettyPrinter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "PrettyPrinter.h" - -#include "framework/Framework.h" - -#include <algorithm> - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -std::string PrettyPrinter::begin_color(const std::string &color) const -{ - if(!_color_output) - { - return ""; - } - - return "\033[0;3" + color + "m"; -} - -std::string PrettyPrinter::end_color() const -{ - if(!_color_output) - { - return ""; - } - - return "\033[m"; -} - -void PrettyPrinter::set_color_output(bool color_output) -{ - _color_output = color_output; -} - -void PrettyPrinter::print_entry(const std::string &name, const std::string &value) -{ - *_stream << begin_color("4") << name << " = " << value << end_color() << "\n"; -} - -void PrettyPrinter::print_global_header() -{ -} - -void PrettyPrinter::print_global_footer() -{ -} - -void PrettyPrinter::print_run_header() -{ -} - -void PrettyPrinter::print_run_footer() -{ -} - -void PrettyPrinter::print_test_header(const TestInfo &info) -{ - *_stream << begin_color("2") << "Running [" << info.id << "] '" << info.name << "'" << end_color() << "\n"; -} - -void PrettyPrinter::print_test_footer() -{ -} - -void PrettyPrinter::print_errors_header() -{ -} - -void PrettyPrinter::print_errors_footer() -{ -} - -void PrettyPrinter::print_error(const std::exception &error) -{ - *_stream << begin_color("1") << "ERROR: " << error.what() << end_color() << "\n"; -} - -void PrettyPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) -{ - for(const auto &instrument : measurements) - { - *_stream << begin_color("3") << " " << instrument.first << ":"; - - auto add_measurements = [](double a, const Instrument::Measurement & b) - { - return a + b.value; - }; - - auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) - { - return a.value < b.value; - }; - - double sum_values = std::accumulate(instrument.second.begin(), instrument.second.end(), 0., add_measurements); - int num_values = instrument.second.size(); - const auto minmax_values = std::minmax_element(instrument.second.begin(), instrument.second.end(), cmp_measurements); - - if(num_values > 2) - { - sum_values -= minmax_values.first->value + minmax_values.second->value; - num_values -= 2; - } - - Instrument::Measurement avg{ sum_values / num_values, minmax_values.first->unit }; - - *_stream << " "; - *_stream << "AVG=" << avg << ", "; - *_stream << "MIN=" << *minmax_values.first << ", "; - *_stream << "MAX=" << *minmax_values.second << end_color() << "\n"; - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/PrettyPrinter.h b/framework/printers/PrettyPrinter.h deleted file mode 100644 index fa7b7b2c59..0000000000 --- a/framework/printers/PrettyPrinter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRETTYPRINTER -#define ARM_COMPUTE_TEST_PRETTYPRINTER - -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of a @ref Printer that produces human readable output. */ -class PrettyPrinter : public Printer -{ -public: - using Printer::Printer; - - /** Set if the output is colored. - * - * @param[in] color_output True if the output is colored. - */ - void set_color_output(bool color_output); - - void print_entry(const std::string &name, const std::string &value) override; - void print_global_header() override; - void print_global_footer() override; - void print_run_header() override; - void print_run_footer() override; - void print_test_header(const TestInfo &info) override; - void print_test_footer() override; - void print_errors_header() override; - void print_errors_footer() override; - void print_error(const std::exception &error) override; - void print_measurements(const Profiler::MeasurementsMap &measurements) override; - -private: - std::string begin_color(const std::string &color) const; - std::string end_color() const; - - bool _color_output{ true }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute - -#endif /* ARM_COMPUTE_TEST_PRETTYPRINTER */ diff --git a/framework/printers/Printer.cpp b/framework/printers/Printer.cpp deleted file mode 100644 index e034c2ed43..0000000000 --- a/framework/printers/Printer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -Printer::Printer(std::ostream &stream) - : _stream{ &stream } -{ -} - -void Printer::print(const std::string &str) -{ - *_stream << str; -} - -void Printer::set_stream(std::ostream &stream) -{ - _stream = &stream; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/Printer.h b/framework/printers/Printer.h deleted file mode 100644 index 85b7a570c8..0000000000 --- a/framework/printers/Printer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRINTER -#define ARM_COMPUTE_TEST_PRINTER - -#include "framework/Profiler.h" - -#include <fstream> -#include <iostream> -#include <ostream> -#include <stdexcept> - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -struct TestInfo; - -/** Abstract printer class used by the @ref Framework to present output. */ -class Printer -{ -public: - /** Default constructor. - * - * Prints values to std::cout. - * */ - Printer() = default; - - /** Construct printer with given output stream. - * - * @param[out] stream Output stream. - */ - Printer(std::ostream &stream); - - Printer(const Printer &) = delete; - Printer &operator=(const Printer &) = delete; - Printer(Printer &&) = default; - Printer &operator=(Printer &&) = default; - - virtual ~Printer() = default; - - /** Print given string. - * - * @param[in] str String. - */ - void print(const std::string &str); - - /** Print an entry consisting of a (name, value) pair. - * - * @param[in] name Description of the value. - * @param[in] value Value. - */ - virtual void print_entry(const std::string &name, const std::string &value) = 0; - - /** Print global header. */ - virtual void print_global_header() = 0; - - /** Print global footer. */ - virtual void print_global_footer() = 0; - - /** Print header before running all tests. */ - virtual void print_run_header() = 0; - - /** Print footer after running all tests. */ - virtual void print_run_footer() = 0; - - /** Print header before a test. - * - * @param[in] info Test info. - */ - virtual void print_test_header(const TestInfo &info) = 0; - - /** Print footer after a test. */ - virtual void print_test_footer() = 0; - - /** Print header before errors. */ - virtual void print_errors_header() = 0; - - /** Print footer after errors. */ - virtual void print_errors_footer() = 0; - - /** Print test error. - * - * @param[in] error Description of the error. - */ - virtual void print_error(const std::exception &error) = 0; - - /** Print measurements for a test. - * - * @param[in] measurements Measurements as collected by a @ref Profiler. - */ - virtual void print_measurements(const Profiler::MeasurementsMap &measurements) = 0; - - /** Set the output stream. - * - * @param[out] stream Output stream. - */ - void set_stream(std::ostream &stream); - -protected: - std::ostream *_stream{ &std::cout }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PRINTER */ diff --git a/framework/printers/Printers.cpp b/framework/printers/Printers.cpp deleted file mode 100644 index 9ca5e317b3..0000000000 --- a/framework/printers/Printers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Printers.h" - -#include "framework/Utils.h" - -#include <map> -#include <stdexcept> - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -LogFormat log_format_from_name(const std::string &name) -{ - static const std::map<std::string, LogFormat> formats = - { - { "pretty", LogFormat::PRETTY }, - { "none", LogFormat::NONE }, - { "json", LogFormat::JSON }, - }; - - try - { - return formats.at(tolower(name)); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/Printers.h b/framework/printers/Printers.h deleted file mode 100644 index 53867e2dff..0000000000 --- a/framework/printers/Printers.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRINTERS -#define ARM_COMPUTE_TEST_PRINTERS - -#include "JSONPrinter.h" -#include "PrettyPrinter.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -enum class LogFormat -{ - NONE, - JSON, - PRETTY -}; - -LogFormat log_format_from_name(const std::string &name); - -inline ::std::stringstream &operator>>(::std::stringstream &stream, LogFormat &format) -{ - std::string value; - stream >> value; - format = log_format_from_name(value); - return stream; -} - -inline ::std::stringstream &operator<<(::std::stringstream &stream, LogFormat format) -{ - switch(format) - { - case LogFormat::PRETTY: - stream << "PRETTY"; - break; - case LogFormat::NONE: - stream << "NONE"; - break; - case LogFormat::JSON: - stream << "JSON"; - break; - default: - throw std::invalid_argument("Unsupported log format"); - } - - return stream; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PRINTERS */ |