123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef BENCHMARK_REPORTER_H_
- #define BENCHMARK_REPORTER_H_
- #include <string>
- #include <utility>
- #include <vector>
- #include "benchmark_api.h"
- namespace benchmark {
- class BenchmarkReporter {
- public:
- struct Context {
- int num_cpus;
- double mhz_per_cpu;
- bool cpu_scaling_enabled;
-
- size_t name_field_width;
- };
- struct Run {
- Run() :
- iterations(1),
- real_accumulated_time(0),
- cpu_accumulated_time(0),
- bytes_per_second(0),
- items_per_second(0),
- max_heapbytes_used(0) {}
- std::string benchmark_name;
- std::string report_label;
- size_t iterations;
- double real_accumulated_time;
- double cpu_accumulated_time;
-
- double bytes_per_second;
- double items_per_second;
-
- double max_heapbytes_used;
- };
-
-
-
-
-
-
- virtual bool ReportContext(const Context& context) = 0;
-
-
-
-
- virtual void ReportRuns(const std::vector<Run>& report) = 0;
-
-
- virtual void Finalize();
- virtual ~BenchmarkReporter();
- protected:
- static void ComputeStats(std::vector<Run> const& reports, Run* mean, Run* stddev);
- };
- class ConsoleReporter : public BenchmarkReporter {
- public:
- virtual bool ReportContext(const Context& context);
- virtual void ReportRuns(const std::vector<Run>& reports);
- protected:
- virtual void PrintRunData(const Run& report);
- size_t name_field_width_;
- };
- class JSONReporter : public BenchmarkReporter {
- public:
- JSONReporter() : first_report_(true) {}
- virtual bool ReportContext(const Context& context);
- virtual void ReportRuns(const std::vector<Run>& reports);
- virtual void Finalize();
- private:
- void PrintRunData(const Run& report);
- bool first_report_;
- };
- class CSVReporter : public BenchmarkReporter {
- public:
- virtual bool ReportContext(const Context& context);
- virtual void ReportRuns(const std::vector<Run>& reports);
- private:
- void PrintRunData(const Run& report);
- };
- }
- #endif
|