timeHandler.h 631 B

12345678910111213141516171819202122232425262728
  1. #ifndef __TIMEHANDLER_H__
  2. #define __TIMEHANDLER_H__
  3. #include <ctime>
  4. /*
  5. * timeHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. class timeHandler
  14. {
  15. public:
  16. clock_t start, last, mem;
  17. timeHandler():start(clock()){last=clock();mem=0;};
  18. long getDif(){long ret=clock()-last;last=clock();return ret;};
  19. void update(){last=clock();};
  20. void remember(){mem=clock();};
  21. long memDif(){return clock()-mem;};
  22. };
  23. #endif // __TIMEHANDLER_H__