Skip to content

Instantly share code, notes, and snippets.

@ConnorAU
Created April 24, 2020 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConnorAU/c371e1db90c1ed3ab777759bb02df95e to your computer and use it in GitHub Desktop.
Save ConnorAU/c371e1db90c1ed3ab777759bb02df95e to your computer and use it in GitHub Desktop.
private _serverQuery = {
params ["_clientQuery","_serverQueryReturn","_clientReturn"];
// hopefully unique temporary variable
private _variable = format["serv_fps_query_%1",diag_tickTime];
// create array for players to insert their fps into
private _players = call BIS_fnc_listPlayers;
private _returns = [];
_returns resize (count _players + 1);
_returns = _returns apply {0};
_returns set [0,[2,diag_fps]];
missionNameSpace setVariable [_variable,_returns];
// query players
[[_serverQueryReturn,_variable],_clientQuery] remoteExec ["call",_players];
// wait for all players to respond or proceed anyway after defined time (seconds)
private _tick = diag_tickTime + 15;
waitUntil {
uiSleep 1;
_returns = missionNameSpace getVariable [_variable,[0]];
!(0 in _returns) || diag_tickTime > _tick
};
[[_returns - [0]],_clientReturn] remoteExec ["call",remoteExecutedOwner];
missionNameSpace setVariable [_variable,nil];
};
private _clientQuery = {
[[_this#1,diag_fps],_this#0] remoteExec ["call",2];
};
private _serverQueryReturn = {
params ["_variable","_return"];
if (isNil _variable) exitWith {};
private _returns = missionNameSpace getVariable [_variable,[]];
_returns set [_returns find 0,[remoteExecutedOwner,_return]];
missionNameSpace setVariable [_variable,_returns];
};
private _clientReturn = {
params ["_returns"];
_returns sort true;
{
diag_log format[
"%1%2 FPS: %3",
["Player ","Server "] select (_forEachIndex == 0),
[_x#0,""] select (_forEachIndex == 0),
_x#1
];
} forEach _returns;
private _serverReturn = _returns deleteAt 0;
private _clientFPSOnly = _returns apply {_x#1};
private _clientFPSMin = selectMin _clientFPSOnly;
private _clientFPSMax = selectMax _clientFPSOnly;
private _clientFPSAvg = 0;
{_clientFPSAvg = _clientFPSAvg + _x} forEach _clientFPSOnly;
_clientFPSAvg = _clientFPSAvg/count _clientFPSOnly;
systemchat format["Server fps: %1, Player fps (min,avg,max): %2, %3, %4",_serverReturn#1,_clientFPSMin,_clientFPSAvg,_clientFPSMax];
};
for "_i" from 0 to 1 step 0 do {
uiSleep 60;
[[_clientQuery,_serverQueryReturn,_clientReturn],_serverQuery] remoteExec ["spawn",2];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment