45 lines
1.1 KiB
Plaintext
45 lines
1.1 KiB
Plaintext
#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!
|
|
private _rawCPS = _counter / (diag_frameNo - _frameNo);
|
|
player setVariable [QGVAR(player_raw_cps), _rawCPS, 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
|
|
private _playerCPS = _counter / (diag_frameNo - _frameNo);
|
|
player setVariable [QGVAR(player_cps), _playerCPS, true];
|
|
|
|
// log to RPT
|
|
[
|
|
|
|
{_this call EFUNC(common,log);},
|
|
[
|
|
LEVEL_INFO,
|
|
QUOTE(COMPONENT),
|
|
format ["Average Execution: %1 times per frame", _playerCPS],
|
|
[
|
|
["playerRawCPS", _rawCPS],
|
|
["playerCPS", _playerCPS]
|
|
]
|
|
]
|
|
] call CBA_fnc_directCall;
|
|
};
|
|
|
|
nil; |