aboutsummaryrefslogtreecommitdiff
path: root/src/bench.h
blob: bbea2c67b034d94ef73c66e4b4faf9ec25c20e4c (plain)
  1. #ifndef CMARK_BENCH_H
  2. #define CMARK_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