2009-04-16 14:14:13 +03:00
|
|
|
#ifndef __TIMEHANDLER_H__
|
|
|
|
#define __TIMEHANDLER_H__
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* timeHandler.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
class timeHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
clock_t start, last, mem;
|
|
|
|
timeHandler():start(clock()){last=clock();mem=0;};
|
2010-11-09 13:27:58 +02:00
|
|
|
long getDif(){long ret=clock()-last;last=clock();return ret/(CLOCKS_PER_SEC/1000);};//get diff in milliseconds
|
2009-04-16 14:14:13 +03:00
|
|
|
void update(){last=clock();};
|
|
|
|
void remember(){mem=clock();};
|
2009-08-11 10:50:29 +03:00
|
|
|
long memDif(){return clock()-mem;};
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __TIMEHANDLER_H__
|