HEBench
hebench_report_stats.h
Go to the documentation of this file.
1 
2 // Copyright (C) 2021 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef _HEBench_ReportStats_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_ReportStats_H_0596d40a3cce4b108a81595c50eb286d
7 
8 #include <cmath>
9 #include <iostream>
10 #include <memory>
11 #include <ratio>
12 #include <string>
13 #include <unordered_map>
14 #include <vector>
15 
16 #include "hebench_report_cpp.h"
17 #include "hebench_report_types.h"
18 
19 namespace hebench {
20 namespace ReportGen {
21 
23 {
24  double total; // total wall time for the all the events
25  double ave;
26  double variance;
27  double min;
28  double max;
29  double median;
30  double pct_1; // 1-th percentile
31  double pct_10; // 10-th percentile
32  double pct_90; // 90-th percentile
33  double pct_99; // 99-th percentile
34  double ave_trim; // trimmed by 10% on each side
35  double variance_trim;
36  double samples_per_unit; // = total / input_sample_count
37  double samples_per_unit_trim; // = total_trim / input_sample_count_trim
39 };
40 
42 {
49  uint32_t event_id;
50  double total_time; // total wall time for the all the events
51  double cpu_time_ave;
53  double cpu_time_min;
54  double cpu_time_max;
56  double cpu_time_1; // 1-th percentile
57  double cpu_time_10; // 10-th percentile
58  double cpu_time_90; // 90-th percentile
59  double cpu_time_99; // 99-th percentile
60  double cpu_time_ave_trim; // trimmed mean by 10% on each side
62  double wall_time_ave;
64  double wall_time_min;
65  double wall_time_max;
67  double wall_time_1; // 1-th percentile
68  double wall_time_10; // 10-th percentile
69  double wall_time_90; // 90-th percentile
70  double wall_time_99; // 99-th percentile
71  double wall_time_ave_trim; // trimmed mean by 10% on each side
73  double ops_per_sec;
74  double ops_per_sec_trim; // ops/sec based on trimmed mean
84  std::string name;
85  std::string description;
86 };
87 
89 {
90 public:
91  ReportStats(const cpp::TimingReport &report);
92 
93  const std::string &getHeader() const { return m_header; }
94  const std::string &getFooter() const { return m_footer; }
95 
96  std::uint64_t getEventTypeCount() const { return m_event_stats.size(); }
97  const ReportEventTypeStats &getEventTypeStats(std::uint64_t index) const;
98  const ReportEventTypeStats &getEventTypeStatsByID(std::uint32_t id) const;
99  std::uint64_t getMainEventTypeStatsIndex() const;
100  std::uint32_t getMainEventTypeID() const { return m_main_event_type_id; }
102 
108  void generateCSV(std::ostream &os, char ch_prefix);
116  void generateCSV(std::ostream &os, const ReportEventTypeStats &stats, char ch_prefix, bool new_line = true);
122  void generateSummaryCSV(std::ostream &os, char ch_prefix);
130  void generateSummaryCSV(std::ostream &os, const ReportEventTypeStats &stats, char ch_prefix, bool new_line = true);
131 
132 private:
133  std::string m_header;
134  std::string m_footer;
135  std::size_t m_main_event_type_id;
136  std::unordered_map<std::uint32_t, std::size_t> m_event_types_2_stat_idx; // maps event type id to index of stats in m_event_stats
137  std::vector<std::shared_ptr<ReportEventTypeStats>> m_event_stats;
138 };
139 
140 } // namespace ReportGen
141 } // namespace hebench
142 
143 #endif // defined _HEBench_ReportStats_H_0596d40a3cce4b108a81595c50eb286d
std::uint64_t getMainEventTypeStatsIndex() const
const std::string & getFooter() const
const ReportEventTypeStats & getEventTypeStats(std::uint64_t index) const
std::uint64_t getEventTypeCount() const
void generateCSV(std::ostream &os, char ch_prefix)
Generates complete CSV stats for this report.
std::uint32_t getMainEventTypeID() const
const ReportEventTypeStats & getEventTypeStatsByID(std::uint32_t id) const
void generateSummaryCSV(std::ostream &os, char ch_prefix)
Generates summary CSV for this report.
const std::string & getHeader() const
const ReportEventTypeStats & getMainEventTypeStats() const
ReportStats(const cpp::TimingReport &report)
uint64_t input_sample_count
Number of input samples used.
uint32_t event_id
ID specifying the event type.