NeoPZ
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RunStatsTable Class Reference

#include <run_stats_table.h>

Collaboration diagram for RunStatsTable:
[legend]

Public Member Functions

 RunStatsTable (const char *arg, const char *desc)
 
 ~RunStatsTable ()
 
void start ()
 
void lap ()
 
void stop ()
 
int flush_to_file ()
 
bool was_set () const
 

Private Member Functions

int read_from_file (CSVStringTable &table, string filename)
 
int write_to_file (const CSVStringTable &table, string filename)
 

Private Attributes

RunStatsRecorder stats
 
clarg::argString filename
 
bool stats_recorded
 

Detailed Description

Class to record execution statistics into tables. For performance reasons it should be declared globally in order to ensure it is only constructed and destructed once.

Typical usage

RunStatsTable dohrstruct_create_rst("-cre_rst", "Run statistics table for dohrstruct->Create()"za);

// Track statistics. Only measure if "-cre_rst" was set. dohrstruct_create_rst.start(); dohrstruct_create_rst.lap(); dohrstruct_create_rst.stop();

// Optional: Updates the table contents. Reads the file into the // table, add the statistics and writes the file back. Only performed // if the filename was provided. dohrstruct_create_rst.flush_to_file();

// Automatically calls flush_to_file(). ~dohrstruct_create_srt()

Definition at line 34 of file run_stats_table.h.

Constructor & Destructor Documentation

◆ RunStatsTable()

RunStatsTable::RunStatsTable ( const char *  arg,
const char *  desc 
)
inline

Constructor.

Definition at line 39 of file run_stats_table.h.

◆ ~RunStatsTable()

RunStatsTable::~RunStatsTable ( )
inline

Destructor. Update the file.

Definition at line 43 of file run_stats_table.h.

References filename, flush_to_file(), clarg::argT< T >::get_value(), and clarg::arg_base::was_set().

Member Function Documentation

◆ flush_to_file()

int RunStatsTable::flush_to_file ( )
inline

Optional: Updates the table contents. Reads the file into the table, add the statistics and writes the file back. Only performed if the filename was provided. Returns 0 if ok 1 if number of cells in one or more rows does not match the number of column headers when reading the file. 2 nothing to be flushed. -1 if could not read the table headers -2 could not open the file for read. -3 could not open the file for write. -4 error when appending statistics to the table.

Definition at line 84 of file run_stats_table.h.

References filename, clarg::argT< T >::get_value(), read_from_file(), stats_recorded, and write_to_file().

Referenced by ~RunStatsTable().

◆ lap()

void RunStatsTable::lap ( )
inline

Track statistics. Add lap.

Definition at line 68 of file run_stats_table.h.

References filename, stats_recorded, and clarg::arg_base::was_set().

◆ read_from_file()

int RunStatsTable::read_from_file ( CSVStringTable table,
string  filename 
)
inlineprivate

Reads the table contents from a file. Returns 0 if ok, 1 if number of cells in one or more rows does not match the number of column headers -1 if could not read the table headers -2 could not open the file.

Definition at line 121 of file run_stats_table.h.

References CSVTable< Tvar >::read().

Referenced by flush_to_file().

◆ start()

void RunStatsTable::start ( )
inline

◆ stop()

void RunStatsTable::stop ( )
inline

◆ was_set()

bool RunStatsTable::was_set ( ) const
inline

Definition at line 109 of file run_stats_table.h.

References filename, and clarg::arg_base::was_set().

Referenced by main().

◆ write_to_file()

int RunStatsTable::write_to_file ( const CSVStringTable table,
string  filename 
)
inlineprivate

Writes the table contents to a file. Returns 0 if ok. -3 could not open the file for write.

Definition at line 138 of file run_stats_table.h.

References CSVTable< Tvar >::write().

Referenced by flush_to_file().

Member Data Documentation

◆ filename

clarg::argString RunStatsTable::filename
private

Definition at line 153 of file run_stats_table.h.

Referenced by flush_to_file(), lap(), start(), stop(), was_set(), and ~RunStatsTable().

◆ stats

RunStatsRecorder RunStatsTable::stats
private

Definition at line 152 of file run_stats_table.h.

◆ stats_recorded

bool RunStatsTable::stats_recorded
private

Definition at line 154 of file run_stats_table.h.

Referenced by flush_to_file(), lap(), start(), and stop().


The documentation for this class was generated from the following file: