Merge branch 'master' into jgrpp
Remove the viewport sign cache as this is now superseded by the kd tree implementation # Conflicts: # src/crashlog.cpp # src/lang/english.txt # src/misc.cpp # src/pathfinder/follow_track.hpp # src/pbs.cpp # src/rail_cmd.cpp # src/saveload/vehicle_sl.cpp # src/settings.cpp # src/settings_gui.cpp # src/ship_cmd.cpp # src/station.cpp # src/station_base.h # src/station_cmd.cpp # src/table/settings.ini # src/thread/thread_morphos.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/viewport.cpp # src/waypoint.cpp
This commit is contained in:
34
src/debug.h
34
src/debug.h
@@ -13,6 +13,7 @@
|
||||
#define DEBUG_H
|
||||
|
||||
#include "cpu.h"
|
||||
#include <chrono>
|
||||
|
||||
/* Debugging messages policy:
|
||||
* These should be the severities used for direct DEBUG() calls
|
||||
@@ -86,21 +87,40 @@ const char *GetDebugString();
|
||||
*
|
||||
* TIC() / TOC() creates its own block, so make sure not the mangle
|
||||
* it with another block.
|
||||
*
|
||||
* The output is counted in CPU cycles, and not comparable accross
|
||||
* machines. Mainly useful for local optimisations.
|
||||
**/
|
||||
#define TIC() {\
|
||||
uint64 _xxx_ = ottd_rdtsc();\
|
||||
static uint64 __sum__ = 0;\
|
||||
static uint32 __i__ = 0;
|
||||
static uint64 _sum_ = 0;\
|
||||
static uint32 _i_ = 0;
|
||||
|
||||
#define TOC(str, count)\
|
||||
__sum__ += ottd_rdtsc() - _xxx_;\
|
||||
if (++__i__ == count) {\
|
||||
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, __sum__, __sum__/(double)__i__);\
|
||||
__i__ = 0;\
|
||||
__sum__ = 0;\
|
||||
_sum_ += ottd_rdtsc() - _xxx_;\
|
||||
if (++_i_ == count) {\
|
||||
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, _sum_, _sum_/(double)_i_);\
|
||||
_i_ = 0;\
|
||||
_sum_ = 0;\
|
||||
}\
|
||||
}
|
||||
|
||||
/* Chrono based version. The output is in microseconds. */
|
||||
#define TICC() {\
|
||||
auto _start_ = std::chrono::high_resolution_clock::now();\
|
||||
static uint64 _sum_ = 0;\
|
||||
static uint32 _i_ = 0;
|
||||
|
||||
#define TOCC(str, _count_)\
|
||||
_sum_ += (std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - _start_)).count();\
|
||||
if (++_i_ == _count_) {\
|
||||
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " us [avg: %.1f us]", str, _sum_, _sum_/(double)_i_);\
|
||||
_i_ = 0;\
|
||||
_sum_ = 0;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
void ShowInfo(const char *str);
|
||||
void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2);
|
||||
|
||||
|
Reference in New Issue
Block a user