src/debug.h
changeset 10383 7aee0e95303f
parent 9656 5a22c8e52f84
equal deleted inserted replaced
10382:5d680d4296e1 10383:7aee0e95303f
    82  *
    82  *
    83  * TIC() / TOC() creates it's own block, so make sure not the mangle
    83  * TIC() / TOC() creates it's own block, so make sure not the mangle
    84  *  it with an other block.
    84  *  it with an other block.
    85  **/
    85  **/
    86 #define TIC() {\
    86 #define TIC() {\
    87 	extern uint64 _rdtsc();\
    87 	extern uint64 ottd_rdtsc();\
    88 	uint64 _xxx_ = _rdtsc();\
    88 	uint64 _xxx_ = ottd_rdtsc();\
    89 	static uint64 __sum__ = 0;\
    89 	static uint64 __sum__ = 0;\
    90 	static uint32 __i__ = 0;
    90 	static uint32 __i__ = 0;
    91 
    91 
    92 #define TOC(str, count)\
    92 #define TOC(str, count)\
    93 	__sum__ += _rdtsc() - _xxx_;\
    93 	__sum__ += ottd_rdtsc() - _xxx_;\
    94 	if (++__i__ == count) {\
    94 	if (++__i__ == count) {\
    95 		DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\
    95 		DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\
    96 		__i__ = 0;\
    96 		__i__ = 0;\
    97 		__sum__ = 0;\
    97 		__sum__ = 0;\
    98 	}\
    98 	}\