You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
587 B

  1. #if !defined(DEF_TTIMING)
  2. #define DEF_TTIMING
  3. #include <sys/time.h>
  4. class TTiming
  5. {
  6. protected:
  7. struct timeval start;
  8. struct timeval stop;
  9. void getTime(timeval &tv);
  10. public:
  11. TTiming(void);
  12. void Begin(void);
  13. long End(void);
  14. };
  15. inline TTiming::TTiming(void)
  16. {
  17. }
  18. inline void TTiming::Begin(void)
  19. {
  20. getTime(start);
  21. }
  22. inline long TTiming::End(void)
  23. {
  24. getTime(stop);
  25. return ((stop.tv_sec-start.tv_sec) * 1000 + (stop.tv_usec-start.tv_usec)/1000.0) + 0.5;
  26. }
  27. inline void TTiming::getTime(timeval &tv)
  28. {
  29. gettimeofday(&tv,NULL);
  30. }
  31. #endif