big refactor, WIP!
This commit is contained in:
40
framework/performance/functions/fn_calculateClientStats.sqf
Normal file
40
framework/performance/functions/fn_calculateClientStats.sqf
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
[] spawn {
|
||||
// warning: while loop without suspension executes multiple times per frame
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
// in an empty mission, the _counter may go well over 2000 times per frame!
|
||||
[
|
||||
LEVEL_INFO,
|
||||
QUOTE(COMPONENT),
|
||||
format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)],
|
||||
[["playerRawCPS", _counter / (diag_frameNo - _frameNo)]]
|
||||
] call EFUNC(common,log);
|
||||
player setVariable [QGVAR(player_raw_cps), _counter / (diag_frameNo - _frameNo), true];
|
||||
|
||||
// with suspension
|
||||
private _counter = 0;
|
||||
private _endTime = diag_tickTime + 5;
|
||||
private _frameNo = diag_frameNo;
|
||||
while { diag_tickTime < _endTime } do
|
||||
{
|
||||
_counter = _counter + 1;
|
||||
uiSleep 0.001; // waits at least 1 frame
|
||||
};
|
||||
// _counter says one per frame, as expected
|
||||
[
|
||||
LEVEL_INFO,
|
||||
QUOTE(COMPONENT),
|
||||
format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)],
|
||||
[["playerCPS", _counter / (diag_frameNo - _frameNo)]]
|
||||
] call EFUNC(common,log);
|
||||
player setVariable [QGVAR(player_cps), _counter / (diag_frameNo - _frameNo), true];
|
||||
};
|
||||
|
||||
nil;
|
||||
Reference in New Issue
Block a user