12 #include "hebench/modules/general/include/hebench_math_utils.h"
13 #include "hebench/modules/general/include/hebench_utilities.h"
64 throw std::invalid_argument(
"");
66 p->
setHeader(new_header ? new_header :
"");
85 throw std::invalid_argument(
"");
87 p->
appendHeader(new_header ? new_header :
"", new_line != 0);
106 throw std::invalid_argument(
"");
108 p->
prependHeader(new_header ? new_header :
"", new_line != 0);
127 throw std::invalid_argument(
"");
146 throw std::invalid_argument(
"");
148 p->
setFooter(new_footer ? new_footer :
"");
167 throw std::invalid_argument(
"");
169 p->
appendFooter(new_footer ? new_footer :
"", new_line != 0);
188 throw std::invalid_argument(
"");
190 p->
prependFooter(new_footer ? new_footer :
"", new_line != 0);
209 throw std::invalid_argument(
"");
221 int32_t
addEventType(
void *p_report, uint32_t event_type_id,
const char *event_type_header)
228 throw std::invalid_argument(
"");
230 p->
newEventType(event_type_id, event_type_header ? event_type_header :
"",
false);
242 int32_t
addMainEventType(
void *p_report, uint32_t event_type_id,
const char *event_type_header)
249 throw std::invalid_argument(
"");
251 p->
newEventType(event_type_id, event_type_header ? event_type_header :
"",
true);
270 throw std::invalid_argument(
"");
272 retval = p->
getEventTypes().count(event_type_id) > 0 ? 1 : 0;
282 uint64_t
getEventTypeHeader(
void *p_report, uint32_t event_type_id,
char *event_type_header, uint64_t size)
289 throw std::invalid_argument(
"");
292 if (map_event_types.count(event_type_id) <= 0)
293 throw std::invalid_argument(
"ID not found.");
312 throw std::invalid_argument(
"");
326 uint32_t retval = std::numeric_limits<uint32_t>::max();
331 throw std::invalid_argument(
"");
337 retval = std::numeric_limits<uint32_t>::max();
349 if (!p || !p_event_type_id)
350 throw std::invalid_argument(
"");
373 throw std::invalid_argument(
"");
375 std::shared_ptr<TimingReportEventC> sp_event = std::make_shared<TimingReportEventC>();
377 throw std::bad_alloc();
378 *sp_event = *p_event;
397 if (!p || !p_event || index >= p->
getEvents().size())
398 throw std::invalid_argument(
"");
419 throw std::invalid_argument(
"");
438 throw std::invalid_argument(
"");
457 throw std::invalid_argument(
"");
478 throw std::invalid_argument(
"");
492 int32_t
save2CSV(
void *p_report,
const char *filename)
498 if (!p || !filename || filename[0] ==
'\0')
499 throw std::invalid_argument(
"");
502 fnum.open(filename, std::ios_base::out | std::ios_base::trunc);
504 throw std::ios_base::failure(
"Error opening file");
521 char *p_csv_content =
nullptr;
525 if (!p || !pp_csv_content)
526 throw std::invalid_argument(
"");
528 std::stringstream ss;
529 std::string s_csv_content;
532 s_csv_content = ss.str();
533 ss = std::stringstream();
535 p_csv_content =
new char[s_csv_content.length() + 1];
537 throw std::bad_alloc();
538 std::strcpy(p_csv_content, s_csv_content.c_str());
539 *pp_csv_content = p_csv_content;
546 delete[] p_csv_content;
556 delete[] p_csv_content;
566 catch (std::exception &ex)
593 if (!filename || filename[0] ==
'\0')
594 throw std::invalid_argument(
"Invalid empty filename.");
595 fnum.open(filename, std::ios_base::in);
597 throw std::ios_base::failure(
"Could not open file \"" + std::string(filename) +
"\"");
600 catch (std::exception &ex)
629 throw std::invalid_argument(
"p_prefix");
647 throw std::invalid_argument(
"p_prefix");
void appendHeader(const std::string &header, bool new_line)
void prependHeader(const std::string &header, bool new_line)
std::ostream & convert2CSV(std::ostream &os) const
static void setTimingPrefix(TimingPrefixedSeconds &prefix, double seconds, char ch_prefix)
void setHeader(const std::string &header)
void setFooter(const std::string &footer)
const std::vector< std::uint32_t > & getEventTypeIDs() const
const std::unordered_map< std::uint32_t, std::string > & getEventTypes() const
void prependFooter(const std::string &footer, bool new_line)
const std::vector< std::shared_ptr< TimingReportEventC > > & getEvents() const
void appendFooter(const std::string &footer, bool new_line)
const std::string & getHeader() const
void newEventType(std::uint32_t set_id, const std::string &set_header, bool is_main_event=false)
void reserveCapacityForEvents(std::size_t new_capacity)
static void computeTimingPrefix(TimingPrefixedSeconds &prefix, double seconds)
const std::string & getFooter() const
std::uint32_t getMainEventID() const
static TimingReportImpl loadCSV(std::istream &is)
void newEvent(std::shared_ptr< TimingReportEventC > p_event, const std::string &set_header=std::string())
#define MAX_DESCRIPTION_BUFFER_SIZE
uint32_t getEventType(void *p_report, uint64_t index)
Retrieve an event type ID.
void freeCSVContent(char *p_csv_content)
Releases resources allocated by functions that generate CSV formatted reports from a timing report.
int32_t setReportFooter(void *p_report, const char *new_footer)
int32_t addMainEventType(void *p_report, uint32_t event_type_id, const char *event_type_header)
Adds an event type and marks it as the main event.
void * loadReportFromCSVFile(const char *filename, char error_description[MAX_DESCRIPTION_BUFFER_SIZE])
int32_t appendReportHeader(void *p_report, const char *new_header, int32_t new_line)
Appends text to existing header.
int32_t prependReportHeader(void *p_report, const char *new_header, int32_t new_line)
Prepends text to existing header.
uint64_t getReportHeader(void *p_report, char *header, uint64_t size)
int32_t getMainEventType(void *p_report, uint32_t *p_event_type_id)
getMainEventType
int32_t hasEventType(void *p_report, uint32_t event_type_id)
hasEventType
int32_t addEvent(void *p_report, const TimingReportEventC *p_event)
addEvent
uint64_t getEventCapacity(void *p_report)
int32_t save2CSV(void *p_report, const char *filename)
uint64_t getEventTypeCount(void *p_report)
void freeReport(void *p_report)
int32_t addEventType(void *p_report, uint32_t event_type_id, const char *event_type_header)
addEventType
uint64_t getReportFooter(void *p_report, char *footer, uint64_t size)
void * loadReportFromCSV(const char *p_csv_content, char error_description[MAX_DESCRIPTION_BUFFER_SIZE])
int32_t setTimingPrefix(TimingPrefixedSeconds *p_prefix, double seconds, char prefix)
Computes the value for the time unit based on a specified prefix.
int32_t setReportHeader(void *p_report, const char *new_header)
int32_t appendReportFooter(void *p_report, const char *new_footer, int32_t new_line)
Appends text to existing footer.
uint64_t getEventTypeHeader(void *p_report, uint32_t event_type_id, char *event_type_header, uint64_t size)
uint64_t getEventCount(void *p_report)
int32_t getEvent(void *p_report, TimingReportEventC *p_event, uint64_t index)
getEvent
int32_t convert2CSV(void *p_report, char **pp_csv_content)
convert2CSV
int32_t setEventCapacity(void *p_report, uint64_t new_capacity)
setEventCapacity
int32_t clearEvents(void *p_report)
int32_t prependReportFooter(void *p_report, const char *new_footer, int32_t new_line)
Prepends text to existing footer.
int32_t computeTimingPrefix(TimingPrefixedSeconds *p_prefix, double seconds)
Retrieves the prefix for the time unit.
std::uint64_t copyString(char *dst, std::uint64_t size, const std::string &src)
Copies a C++ string object into a C-style string.