51 static void tokenize(
const std::string& str,
52 std::vector<std::string>& tokens,
53 const std::string& delimiters =
" ");
63 static std::string
substring(
const std::string &str,
64 const char *start_delim,
65 const char *end_delim,
int order);
75 const char *delim,
int order);
83 static std::string&
ltrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r "){
84 str.erase(0, str.find_first_not_of(chars));
return str;
93 static std::string&
rtrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r "){
94 str.erase(str.find_last_not_of(chars) + 1);
return str;
103 static std::string&
trim(std::string& str,
const std::string& chars =
"\t\n\v\f\r "){
131 static void writeInt(
char *buffer,
int position,
int value);
139 static void writeLong(
char *buffer,
int position,
long value);
147 static void writeByte(
char *buffer,
int position, uint8_t value );
160 std::chrono::high_resolution_clock clock;
161 std::chrono::time_point<std::chrono::high_resolution_clock> first, second;
162 std::string benchmarkName;
166 int printoutFrequency;
175 benchmarkName = name;
176 running_time = 0;counter = 0; printoutFrequency = -1;
180 benchmark(){ running_time = 0;counter = 0; printoutFrequency = -1;}
186 benchmark(
int freq){ running_time = 0;counter = 0; printoutFrequency = freq;}
192 void reset(){ running_time = 0;counter = 0; printoutFrequency = -1;}
198 void setName(
const char *name){ benchmarkName = name;}
Simple timer for measuring code performance.
benchmark(const char *name)
Constructs a benchmark with the given name.
int getCounter()
Returns the number of resume/pause cycles recorded.
void resume()
Starts or resumes the timer.
void setName(const char *name)
Sets the display name of this benchmark.
void pause()
Pauses the timer and accumulates elapsed time.
benchmark(int freq)
Constructs a benchmark with automatic printout frequency.
double getTimeSec()
Returns the accumulated time in seconds.
void show()
Prints the benchmark name, accumulated time, and counter.
benchmark()
Default constructor.
void reset()
Resets accumulated time and counter to zero.
long getTime()
Returns the accumulated time in microseconds.
Utility functions for string manipulation, serialization, and HIPO file generation.
static std::string getFileHeader()
Returns the file header template string.
static void writeByte(char *buffer, int position, uint8_t value)
Writes a single byte into a byte buffer at the given position.
static std::string substring(const std::string &str, const char *start_delim, const char *end_delim, int order)
Extracts a substring between two delimiters.
static std::string getSConstruct()
Returns the SCons build configuration string.
static void writeLong(char *buffer, int position, long value)
Writes a 64-bit long into a byte buffer at the given position.
static std::string & ltrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
Trims leading whitespace characters from a string.
static std::string & rtrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
Trims trailing whitespace characters from a string.
utils()
Default constructor.
static std::string getFileTrailer(const char *code)
Returns the file trailer template string.
static std::string getHeader()
Returns the HIPO header string for code generation.
static void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Splits a string into tokens using the given delimiters.
static void printLogo()
Prints the HIPO library logo to standard output.
static int findposition(const std::string &str, const char *delim, int order)
Finds the position of the nth occurrence of a delimiter.
static void writeInt(char *buffer, int position, int value)
Writes a 32-bit integer into a byte buffer at the given position.
static std::string & trim(std::string &str, const std::string &chars="\t\n\v\f\r ")
Trims both leading and trailing whitespace from a string.