aboutsummaryrefslogtreecommitdiff
path: root/src/bench.h
blob: 13d8aa40786e7c4cea3cb7379c703cf8b1cc5290 (plain)
  1. #ifndef __BENCH_H__
  2. #define __BENCH_H__
  3. #include <stdio.h>
  4. #include <time.h>
  5. #ifdef TIMER
  6. float _cmark_start_time;
  7. float _cmark_end_time;
  8. float _cmark_save_time;
  9. #define start_timer() \
  10. _cmark_save_time = _cmark_start_time; \
  11. _cmark_start_time = (float)clock()/CLOCKS_PER_SEC
  12. #define end_timer(M) \
  13. _cmark_end_time = (float)clock()/CLOCKS_PER_SEC; \
  14. fprintf(stderr, "[TIME] (%s:%d) %4.f ns " M "\n", __FILE__, \
  15. __LINE__, (_cmark_end_time - _cmark_start_time) * 1000000); \
  16. _cmark_start_time = _cmark_save_time;
  17. #else
  18. #define start_timer()
  19. #define end_timer(M)
  20. #endif
  21. #endif