FTimeCount.h 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (C) =USTC= Fu Li
  3. *
  4. * Author : Fu Li
  5. * Create : 2005-3-3
  6. * Home : http://www.crazy-bit.com/
  7. * Mail : crazybit@263.net
  8. * History :
  9. */
  10. #ifndef __FOO_TIME_COUNT__2005_03_03__H__
  11. #define __FOO_TIME_COUNT__2005_03_03__H__
  12. #include <time.h>
  13. //=============================================================================
  14. /**
  15. * Calculate time interval between two time stamper.
  16. */
  17. class FCTimeCount
  18. {
  19. clock_t m_nTick ;
  20. public:
  21. /// Constructor (will set start time stamper).
  22. FCTimeCount() {SetStartTag();}
  23. /// Set start time stamper.
  24. void SetStartTag() {m_nTick = ::clock();}
  25. /// Get passed millisecond from start time stamper.
  26. int GetPassMillisecond() const {return (int)tick_to_ms(::clock() - m_nTick);}
  27. static clock_t tick_to_ms (clock_t nTick)
  28. {
  29. return (nTick * 1000 / CLOCKS_PER_SEC) ;
  30. }
  31. };
  32. #endif