version 3.0
This commit is contained in:
29
functions/client/fn_calculateClientStats.sqf
Normal file
29
functions/client/fn_calculateClientStats.sqf
Normal file
@@ -0,0 +1,29 @@
|
||||
[] 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!
|
||||
diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
player setVariable ["milsim_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
|
||||
diag_log text format ["[MILSIM] (client) Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)];
|
||||
player setVariable ["milsim_player_cps", _counter / (diag_frameNo - _frameNo), true];
|
||||
|
||||
};
|
||||
|
||||
nil;
|
||||
Reference in New Issue
Block a user