summaryrefslogtreecommitdiff
path: root/src/bench.h
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-11-13 11:00:04 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-11-13 11:00:15 -0800
commit7861d82c6fcfb3f813e642c0f59318eb4f9f5332 (patch)
tree116269e4b4341222530c7acbde6b1b54d3138f4c /src/bench.h
parent3c9bdf645958a1c5b71cc9b96a5b711cca14224f (diff)
Added bench.h and inserted timing macros in main.
`make TIMER=1` to build with timings.
Diffstat (limited to 'src/bench.h')
-rw-r--r--src/bench.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bench.h b/src/bench.h
new file mode 100644
index 0000000..7308197
--- /dev/null
+++ b/src/bench.h
@@ -0,0 +1,22 @@
+#ifndef __BENCH_H__
+#define __BENCH_H__
+#include <stdio.h>
+#include <sys/time.h>
+
+#ifdef TIMER
+float _cmark_start_time;
+float _cmark_end_time;
+
+#define start_timer() \
+ _cmark_start_time = (float)clock()/CLOCKS_PER_SEC
+
+#define end_timer(M) \
+ _cmark_end_time = (float)clock()/CLOCKS_PER_SEC; \
+ fprintf(stderr, "[TIME] (%s:%d) %8.f ns " M "\n", __FILE__, \
+ __LINE__, (_cmark_end_time - _cmark_start_time) * 1000000)
+
+#else
+#define start_timer()
+#define end_timer(M)
+#endif
+#endif