summaryrefslogtreecommitdiff
path: root/core/perftools.hpp
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
committerJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
commit420d2ef464d4a741028e132e662d5626806a41f5 (patch)
tree1aca6eb512e4ed0fb5f3c10c528cb998b6ffd695 /core/perftools.hpp
Initial commitHEADmaster
Diffstat (limited to 'core/perftools.hpp')
-rw-r--r--core/perftools.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/perftools.hpp b/core/perftools.hpp
new file mode 100644
index 0000000..91cf56e
--- /dev/null
+++ b/core/perftools.hpp
@@ -0,0 +1,40 @@
+#ifndef U6JSwQqqOviv7kQT0JaHQQr1VDI
+#define U6JSwQqqOviv7kQT0JaHQQr1VDI
+
+#include <sys/time.h>
+#include <stdio.h>
+
+////// THROUGHPUT
+
+void print_throughput(double time, double num, char * title) {
+ fprintf(stderr, "%s: %lfs\t%lf/s\n", title, time, num / time);
+}
+
+void print_throughput2(double time, double num, long base) {
+ fprintf(stderr, "%ld:\t%lfs\t%lf/s\n", base, time, num / time);
+}
+
+////// TIMER
+
+class Timer {
+public:
+ Timer();
+
+ double diff();
+
+ timeval start;
+};
+
+Timer::Timer() {
+ gettimeofday(&start,NULL);
+}
+
+double Timer::diff() {
+ timeval stop;
+
+ gettimeofday(&stop,NULL);
+
+ return (stop.tv_sec + stop.tv_usec/1000000.0) - (start.tv_sec + start.tv_usec/1000000.0);
+}
+
+#endif // U6JSwQqqOviv7kQT0JaHQQr1VDI
contact: Jan Huwald // Impressum