HEBench
hebench_utilities_harness.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_Harness_Utilities_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_Utilities_H_0596d40a3cce4b108a81595c50eb286d
7 
8 #include <functional>
9 #include <ostream>
10 #include <random>
11 #include <string>
12 
14 #include "hebench/modules/timer/include/timer.h"
15 #include "hebench_report_cpp.h"
16 
17 namespace hebench {
18 namespace Utilities {
19 
41 std::string convertToDirectoryName(const std::string &s, bool to_lowercase = true);
42 
57 void printArraysAsColumns(std::ostream &os,
58  const hebench::APIBridge::NativeDataBuffer **p_buffers, std::size_t count,
60  bool output_row_index = false,
61  const char *separator = " ");
62 template <typename T>
77 void printArraysAsColumns(std::ostream &os,
78  const hebench::APIBridge::NativeDataBuffer **p_buffers, std::size_t count,
79  bool output_row_index = false,
80  const char *separator = " ");
81 
83 {
84 private:
85  static std::mt19937 m_rand;
86 
87 public:
88  static decltype(m_rand) &get() { return m_rand; }
89  static void setRandomSeed(std::uint64_t seed);
90  static void setRandomSeed();
91 };
92 
94 {
95 private:
97 
98 public:
99  TimingReportEx(const std::string &header = std::string()) :
100  TimingReport(header) {}
101  ~TimingReportEx() override {}
102 
103  using Base::addEvent;
104  template <class TimeInterval> // TimeInterval must be a std::ratio<num, den>
105  void addEvent(hebench::Common::TimingReportEvent::Ptr p_event);
106  template <class TimeInterval> // TimeInterval must be a std::ratio<num, den>
107  void addEvent(hebench::Common::TimingReportEvent::Ptr p_event,
108  const std::string &event_type_name);
109 
110  template <class TimeInterval> // TimeInterval must be a std::ratio<num, den>
111  static hebench::ReportGen::TimingReportEventC convert2C(const hebench::Common::TimingReportEvent &timing_event);
112 
113 private:
114  template <class TimeInterval> // TimeInterval must be a std::ratio<num, den>
115  void addEvent(hebench::Common::TimingReportEvent::Ptr p_event,
116  const char *event_type_name);
117 };
118 
119 } // namespace Utilities
120 } // namespace hebench
121 
123 
124 #endif // defined _HEBench_Harness_Utilities_H_0596d40a3cce4b108a81595c50eb286d
void addEvent(const TimingReportEventC &p_event)
TimingReport(const TimingReport &)=delete
TimingReportEx(const std::string &header=std::string())
static hebench::ReportGen::TimingReportEventC convert2C(const hebench::Common::TimingReportEvent &timing_event)
void addEvent(const TimingReportEventC &p_event)
DataType
Defines data types for a workload.
Definition: types.h:379
Structure to contain flexible data.
Definition: types.h:552
std::string convertToDirectoryName(const std::string &s, bool to_lowercase=true)
Converts a string to directory name friendly.
void printArraysAsColumns(std::ostream &os, const hebench::APIBridge::NativeDataBuffer **p_buffers, std::size_t count, hebench::APIBridge::DataType data_type, bool output_row_index=false, const char *separator=" ")
Writes the collection of NativeDataBuffer as columns to the specified output stream.