Simple On-the-fly performance metrics
Unreal comes with lot of tools for performance metrics like FPS, graphics card usage, shadder complexity and so on.
For quick test-and-try iterative approach, it also a good idea to define a self made set of simple tools to quickly understand what happen in the box.
As a consequence, the approch consists to define a set of macros callable in the critical part of the code, parametrizable to be displayed when relevant only (eg. when timelaps is above a predefined limit), containing only the useful information (eg. size of data tuple) and continuouly tracking the game behavior . My advice is to store the set of metric data in struture refered by the game instance singleton, so that it’s reachable during the whole game lifecycle; the point of attention is to choose a data structure good enough to avoid memory concerns. Typically:
struct [ method_name -> { - last call timelaps - number of calls - average timelaps }]
Wrapping this behind a code macro PERF_xxx, allows simple usage as :
void methodSample(...) { PERF_START() ... PERF_NEXT( some description's data) ... PERF_END() }
As a result, console monitoring appears as follow :
Perf UWorldmaker::createPMC_sync = 35.000000 ms having NB UV=32 Perf UWorldmaker::createPMC_sync = 32.000000 ms having NB UV=32 Perf UWorldmaker::createPMC_sync = 33.000000 ms having NB UV=32 #### #### Resume perf UWorldmaker::innerDrawFloor = 20 calls for 1640.000000 ms average #### Resume perf UCellmaker::innerDrawCell = 1 calls for 53.000000 ms average #### Resume perf UHexamaker::innerDrawHexa = 24 calls for 98.000000 ms average #### Resume perf UWorldmaker::createPMC_sync = 1222 calls for 33.000000 ms average #### Resume perf UCellmaker::createCell_sync = 4 calls for 150.000000 ms average #### Resume perf UHexamaker::updateISM_sync = 222 calls for 0.000000 ms average ####
By convention, only the *_sync method run on game thread.