TimeCounter.h 673 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef TIMECOUNTER_H__
  2. #define TIMECOUNTER_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #include "cmdlib.h"
  7. class TimeCounter
  8. {
  9. public:
  10. void start()
  11. {
  12. start = I_FloatTime();
  13. }
  14. void stop()
  15. {
  16. double stop = I_FloatTime();
  17. accum += stop - start;
  18. }
  19. double getTotal() const
  20. {
  21. return accum;
  22. }
  23. void reset()
  24. {
  25. memset(this, 0, sizeof(*this));
  26. }
  27. // Construction
  28. public:
  29. TimeCounter()
  30. {
  31. reset();
  32. }
  33. // Default Destructor ok
  34. // Default Copy Constructor ok
  35. // Default Copy Operator ok
  36. protected:
  37. double start;
  38. double accum;
  39. };
  40. #endif//TIMECOUNTER_H__