aboutsummaryrefslogtreecommitdiff
path: root/src/Timer.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Timer.hh')
-rw-r--r--src/Timer.hh39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Timer.hh b/src/Timer.hh
new file mode 100644
index 0000000..e801cf3
--- /dev/null
+++ b/src/Timer.hh
@@ -0,0 +1,39 @@
+#ifndef __TIMER_HH_
+#define __TIMER_HH_
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/times.h>
+#include <sys/time.h>
+
+class Timer {
+ int running;
+ double treal,tuser,tsystem;
+ tms tm;
+ timeval tv;
+public:
+ Timer() { reset(); }
+ void reset(){
+ treal=tuser=tsystem=0;
+ running=0;
+ }
+ int start();
+ int stop();
+ void elapsedTimeSeconds(double &system,double &user,double &real);
+ void elapsedTimeSeconds(float &system,float &user,float &real){
+ double s,u,r;
+ elapsedTimeSeconds(s,u,r);
+ system=s; user=u; real=r;
+ }
+ void print(char *preface="",FILE *f=stdout);
+};
+
+class Counter {
+ int count;
+public:
+ Counter():count(0){}
+ void reset() {count = 0;}
+ int incr(){ return count++;}
+ int nCount() { return count;}
+};
+
+#endif