snapshot of svn

This commit is contained in:
Uldis Locans
2016-10-10 14:49:32 +02:00
commit 4fa529aaea
122 changed files with 23153 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
SET (_SRCS
TimeStamp.cpp
DKSTimer.cpp
)
SET (_HDRS
TimeStamp.h
DKSTimer.h
)
#INCLUDE_DIRECTORIES (
# ${CMAKE_CURRENT_SOURCE_DIR}
#)
ADD_SOURCES (${_SRCS})
ADD_HEADERS (${_HDRS})
INSTALL(FILES ${_HDRS} DESTINATION include/Utility)
+53
View File
@@ -0,0 +1,53 @@
#include "DKSTimer.h"
//set initial values - running to false, timervalue to zero and name to empty string
DKSTimer::DKSTimer() {
running = false;
timervalue = 0.0;
name = "";
}
//destructor does nothing
DKSTimer::~DKSTimer() {
}
//init the timer by setting name and clearing timervalue, also sets running to false
void DKSTimer::init(std::string n) {
running = false;
timervalue = 0.0;
name = n;
}
//if timer is not running get the current time and save to timeStart, set the timer as running
void DKSTimer::start() {
if (!running) {
gettimeofday(&timeStart, NULL);
running = true;
}
}
//if the timer is running get the current time to timeEnd, calculate the elapsed time befor start
//and end, add elapsed time to timervalue, set the timer as not running
void DKSTimer::stop() {
if (running) {
gettimeofday(&timeEnd, NULL);
timervalue += ( (timeEnd.tv_sec - timeStart.tv_sec) * 1000000 +
(timeEnd.tv_usec - timeStart.tv_usec)) * 1e-6;
running = false;
}
}
void DKSTimer::reset() {
running = false;
timervalue = 0.0;
}
//return the accumulated value of timervalue
double DKSTimer::gettime() {
return timervalue;
}
void DKSTimer::print() {
std::cout << "DKSTimer " << name << " elapsed time\t" << timervalue << "s" << std::endl;
}
+59
View File
@@ -0,0 +1,59 @@
#ifndef H_DKSTIMER
#define H_DKSTIMER
#include <iostream>
#include <string>
#include <sys/time.h>
class DKSTimer {
private:
bool running;
double timervalue;
struct timeval timeStart;
struct timeval timeEnd;
std::string name;
public:
/** Init DKSTimer by seting timer to zero */
DKSTimer();
~DKSTimer();
/** Init the timer
* Set the name for timer and clear all values
*/
void init(std::string n);
/** Start the timer.
* Get the curret time with gettimeofday and save in timeStart
*/
void start();
/** Stop the timer
* Get the curretn time with gettimeofday and save in timeEnd
* Calculate elapsed time by timeEnd - timeStart and add to timervalue
*/
void stop();
/** Reset timervalue to zero.
* Set timervalue, timeStart and timeEnd to zero
*/
void reset();
/** Return elapsed time in seconds.
* Return the value of timervalue
*/
double gettime();
/** Print timer.
* Print the elapsed time of the timer
*/
void print();
};
#endif
+11
View File
@@ -0,0 +1,11 @@
#include "TimeStamp.h"
timestamp_t get_timestamp() {
struct timeval now;
gettimeofday (&now, NULL);
return now.tv_usec + (timestamp_t)now.tv_sec * 1000000;
}
double get_secs(timestamp_t t_start, timestamp_t t_end) {
return (t_end - t_start) / 1000000.0L;
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef H_TIMESTAMPE
#define H_TIMESTAMPE
#include <iostream>
#include <time.h>
#include <sys/time.h>
typedef unsigned long long timestamp_t;
timestamp_t get_timestamp();
double get_secs(timestamp_t t_start, timestamp_t t_end);
#endif