-
Notifications
You must be signed in to change notification settings - Fork 10
perf: recording performance optimizations #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6751620
d28f04c
875523b
81ac31a
b556fbc
5e42cc5
91b2a86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,9 +130,11 @@ GVAR(PFHObject) = [ | |
| }; | ||
| if (!_justInitialized && {!_isExcluded}) then { | ||
| private _unitRole = _x getVariable [QGVARMAIN(unitType), ""]; | ||
| if (GVAR(captureFrameNo) % 10 == 0 || _unitRole == "") then { | ||
| private _weapons = [primaryWeapon _x, secondaryWeapon _x]; | ||
| if (_weapons isNotEqualTo (_x getVariable [QGVAR(lastWeapons), []]) || _unitRole == "") then { | ||
| _unitRole = [_x] call FUNC(getUnitType); | ||
| _x setVariable [QGVARMAIN(unitType), _unitRole]; | ||
| _x setVariable [QGVAR(lastWeapons), _weapons]; | ||
| }; | ||
|
|
||
| private _lifeState = 0; | ||
|
|
@@ -147,6 +149,14 @@ GVAR(PFHObject) = [ | |
| _pos = getPosASL _x; | ||
| private _unitGroup = group _x; | ||
|
|
||
| private _scores = getPlayerScores _x; | ||
| private _scoresStr = _x getVariable [QGVAR(lastScoresStr), ""]; | ||
| if (_scores isNotEqualTo (_x getVariable [QGVAR(lastScores), []])) then { | ||
| _scoresStr = _scores joinString ","; | ||
| _x setVariable [QGVAR(lastScores), _scores]; | ||
| _x setVariable [QGVAR(lastScoresStr), _scoresStr]; | ||
| }; | ||
|
Comment on lines
+152
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| private _unitData = [ | ||
| (_x getVariable QGVARMAIN(id)), //1 | ||
| _pos, //2 | ||
|
|
@@ -156,20 +166,21 @@ GVAR(PFHObject) = [ | |
| if (alive _x) then {name _x} else {""}, //6 | ||
| BOOL(isPlayer _x), //7 | ||
| _unitRole, //8 | ||
| GVAR(captureFrameNo), // frame 9 | ||
| 0, // frame placeholder for comparison (set before sending) 9 | ||
| if (!isNil "ace_medical_status_fnc_hasStableVitals") then {BOOL([_x] call ace_medical_status_fnc_hasStableVitals)} else {true}, // 10 | ||
| if (!isNil "ace_medical_status_fnc_isBeingDragged") then {BOOL([_x] call ace_medical_status_fnc_isBeingDragged)} else {false}, // 11 | ||
| (getPlayerScores _x) joinString ",", // scores 12 | ||
| _scoresStr, // scores 12 | ||
| _x call CBA_fnc_vehicleRole, // vehicle role 13 | ||
| if (!isNull objectParent _x) then {(objectParent _x) getVariable [QGVARMAIN(id), -1]} else {-1}, // 14 | ||
| stance _x, // 15 | ||
| groupID _unitGroup, // 16 group name (dynamic) | ||
| str side _unitGroup // 17 side (dynamic) | ||
| ]; | ||
|
|
||
| if (_x getVariable ["unitData", []] isNotEqualTo _unitData) then { | ||
| if (_x getVariable [QGVARMAIN(unitData), []] isNotEqualTo _unitData) then { | ||
| _x setVariable [QGVARMAIN(unitData), +_unitData]; | ||
| _unitData set [8, GVAR(captureFrameNo)]; | ||
| [":SOLDIER:STATE:", _unitData] call EFUNC(extension,sendData); | ||
| _x setVariable [QGVARMAIN(unitData), _unitData]; | ||
| }; | ||
|
Comment on lines
+180
to
184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }; | ||
| false | ||
|
|
@@ -182,7 +193,7 @@ GVAR(PFHObject) = [ | |
| _class = _vehType call FUNC(getClass); | ||
| private _vic = _x; | ||
| private _toExcludeKind = false; | ||
| private _kindList = parseSimpleArray EGVAR(settings,excludeKindFromRecord); | ||
| private _kindList = GVAR(excludeKindList); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing References
|
||
| if (_kindList isNotEqualTo []) then { | ||
| { | ||
| if (_vic isKindOf _x) exitWith { | ||
|
|
@@ -191,7 +202,7 @@ GVAR(PFHObject) = [ | |
| } forEach _kindList; | ||
| }; | ||
| private _toExcludeClass = false; | ||
| private _classList = parseSimpleArray EGVAR(settings,excludeClassFromRecord); | ||
| private _classList = GVAR(excludeClassList); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the References
|
||
| if (_classList isNotEqualTo []) then { | ||
| { | ||
| if (typeOf _vic == _x) exitWith { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,6 +161,12 @@ EGVAR(listener,markers) = [QGVARMAIN(handleMarker), { | |
|
|
||
| // handle created markers | ||
| { | ||
| GVAR(excludeMarkerList) = if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| parseSimpleArray EGVAR(settings,excludeMarkerFromRecord) | ||
| } else { | ||
| [] | ||
| }; | ||
|
Comment on lines
+164
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caching the References
|
||
|
|
||
| /* | ||
| Event Handler: MarkerCreated | ||
| Description: | ||
|
|
@@ -181,13 +187,11 @@ EGVAR(listener,markers) = [QGVARMAIN(handleMarker), { | |
| // check for excluded values in marker name. if name contains at least one value, skip sending traffic to server | ||
| // if value is undefined, then skip | ||
| private _isExcluded = false; | ||
| if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| { | ||
| if ((str _marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach (parseSimpleArray EGVAR(settings,excludeMarkerFromRecord)); | ||
| }; | ||
| { | ||
| if ((str _marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach GVAR(excludeMarkerList); | ||
|
Comment on lines
+190
to
+194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By using the pre-cached References
|
||
| if (_isExcluded) exitWith {}; | ||
|
|
||
| private _event = _this; | ||
|
|
@@ -234,13 +238,11 @@ EGVAR(listener,markers) = [QGVARMAIN(handleMarker), { | |
| // check for excluded values in marker name. if name contains at least one value, skip sending traffic to server | ||
| // if value is undefined, then skip | ||
| private _isExcluded = false; | ||
| if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| { | ||
| if ((str _marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach (parseSimpleArray EGVAR(settings,excludeMarkerFromRecord)); | ||
| }; | ||
| { | ||
| if ((str _marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach GVAR(excludeMarkerList); | ||
|
Comment on lines
+241
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comment, using the cached References
|
||
| if (_isExcluded) exitWith {}; | ||
|
|
||
| private _pos = ATLToASL (markerPos [_marker, true]); | ||
|
|
@@ -269,13 +271,11 @@ EGVAR(listener,markers) = [QGVARMAIN(handleMarker), { | |
| // check for excluded values in marker name. if name contains at least one value, skip sending traffic to server | ||
| // if value is undefined, then skip | ||
| private _isExcluded = false; | ||
| if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| { | ||
| if ((str _marker) find _x > -1) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach (parseSimpleArray EGVAR(settings,excludeMarkerFromRecord)); | ||
| }; | ||
| { | ||
| if ((str _marker) find _x > -1) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach GVAR(excludeMarkerList); | ||
|
Comment on lines
+274
to
+278
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change to use References
|
||
| if (_isExcluded) exitWith {}; | ||
|
|
||
| [QGVARMAIN(handleMarker), ["DELETED", _marker, player]] call CBA_fnc_serverEvent; | ||
|
|
@@ -294,13 +294,11 @@ EGVAR(listener,markers) = [QGVARMAIN(handleMarker), { | |
| // check for excluded values in marker name. if name contains at least one value, skip sending traffic to server | ||
| // if value is undefined, then skip | ||
| private _isExcluded = false; | ||
| if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| { | ||
| if ((_marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach (parseSimpleArray EGVAR(settings,excludeMarkerFromRecord)); | ||
| }; | ||
| { | ||
| if ((_marker) find _x >= 0) exitWith { | ||
| _isExcluded = true; | ||
| }; | ||
| } forEach GVAR(excludeMarkerList); | ||
|
Comment on lines
+297
to
+301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change ensures that the initial marker collection also benefits from the cached exclusion list, preventing unnecessary parsing during mission initialization. References
|
||
| if (_isExcluded) then {continue}; | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,15 @@ GVAR(autoStart) = EGVAR(settings,autoStart); | |
| */ | ||
| GVAR(minMissionTime) = EGVAR(settings,minMissionTime); | ||
|
|
||
| GVAR(excludeKindList) = parseSimpleArray EGVAR(settings,excludeKindFromRecord); | ||
| GVAR(excludeClassList) = parseSimpleArray EGVAR(settings,excludeClassFromRecord); | ||
|
|
||
| GVAR(excludeMarkerList) = if (!isNil QEGVAR(settings,excludeMarkerFromRecord)) then { | ||
| parseSimpleArray EGVAR(settings,excludeMarkerFromRecord) | ||
| } else { | ||
| [] | ||
| }; | ||
|
Comment on lines
+82
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caching the exclusion lists ( References
|
||
|
|
||
| /* | ||
| VARIABLE: OCAP_version | ||
| Global variable that represents the version of OCAP addon being used [String] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,6 @@ Author: | |
| ---------------------------------------------------------------------------- */ | ||
| #include "script_component.hpp" | ||
|
|
||
| _bool = false; | ||
| { | ||
| if (_this isKindOf _x) exitWith {_bool = true;}; | ||
| false; | ||
| } count ["Wheeled_APC_F","Tracked_APC","APC_Wheeled_01_base_F","APC_Wheeled_02_base_F", | ||
| "APC_Wheeled_03_base_F","APC_Tracked_01_base_F","APC_Tracked_02_base_F","APC_Tracked_03_base_F"]; | ||
| _bool | ||
| ["Wheeled_APC_F","Tracked_APC","APC_Wheeled_01_base_F","APC_Wheeled_02_base_F", | ||
| "APC_Wheeled_03_base_F","APC_Tracked_01_base_F","APC_Tracked_02_base_F","APC_Tracked_03_base_F"] | ||
| findIf {_this isKindOf _x} != -1 | ||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing the References
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,25 +41,32 @@ Author: | |
| private _sideData = []; | ||
| { | ||
| private _s = _x; | ||
| private _sUnits = _allUnits select {side _x isEqualTo _s}; | ||
| private _sDead = _allDeadMen select {side _x isEqualTo _s}; | ||
| private _sGroups = _allGroups select {side _x isEqualTo _s}; | ||
| private _sVeh = _vehicles select {side _x isEqualTo _s}; | ||
|
|
||
| private _localUnits = _sUnits select {local _x}; | ||
| private _remoteUnits = _sUnits select {!local _x}; | ||
| private _localDead = _sDead select {local _x}; | ||
| private _remoteDead = _sDead select {!local _x}; | ||
| private _localGroups = _sGroups select {local _x}; | ||
| private _remoteGroups = _sGroups select {!local _x}; | ||
| private _localVeh = _sVeh select {local _x && !(_x isKindOf "WeaponHolderSimulated")}; | ||
| private _remoteVeh = _sVeh select {!local _x && !(_x isKindOf "WeaponHolderSimulated")}; | ||
| private _localWH = _sVeh select {local _x && _x isKindOf "WeaponHolderSimulated"}; | ||
| private _remoteWH = _sVeh select {!local _x && _x isKindOf "WeaponHolderSimulated"}; | ||
| private _localUnits = 0; private _localAlive = 0; private _remoteUnits = 0; private _remoteAlive = 0; | ||
| { if (side _x isEqualTo _s) then { | ||
| if (local _x) then { _localUnits = _localUnits + 1; if (alive _x) then { _localAlive = _localAlive + 1 } } | ||
| else { _remoteUnits = _remoteUnits + 1; if (alive _x) then { _remoteAlive = _remoteAlive + 1 } }; | ||
| }} forEach _allUnits; | ||
|
|
||
| private _localDead = 0; private _remoteDead = 0; | ||
| { if (side _x isEqualTo _s) then { | ||
| if (local _x) then { _localDead = _localDead + 1 } else { _remoteDead = _remoteDead + 1 }; | ||
| }} forEach _allDeadMen; | ||
|
|
||
| private _localGroups = 0; private _remoteGroups = 0; | ||
| { if (side _x isEqualTo _s) then { | ||
| if (local _x) then { _localGroups = _localGroups + 1 } else { _remoteGroups = _remoteGroups + 1 }; | ||
| }} forEach _allGroups; | ||
|
|
||
| private _localVeh = 0; private _remoteVeh = 0; private _localWH = 0; private _remoteWH = 0; | ||
| { if (side _x isEqualTo _s) then { | ||
| private _isWH = _x isKindOf "WeaponHolderSimulated"; | ||
| if (local _x) then { if (_isWH) then { _localWH = _localWH + 1 } else { _localVeh = _localVeh + 1 } } | ||
| else { if (_isWH) then { _remoteWH = _remoteWH + 1 } else { _remoteVeh = _remoteVeh + 1 } }; | ||
| }} forEach _vehicles; | ||
|
|
||
| _sideData pushBack [ | ||
| [count _localUnits, {alive _x} count _localUnits, count _localDead, count _localGroups, count _localVeh, count _localWH], | ||
| [count _remoteUnits, {alive _x} count _remoteUnits, count _remoteDead, count _remoteGroups, count _remoteVeh, count _remoteWH] | ||
| [_localUnits, _localAlive, _localDead, _localGroups, _localVeh, _localWH], | ||
| [_remoteUnits, _remoteAlive, _remoteDead, _remoteGroups, _remoteVeh, _remoteWH] | ||
| ]; | ||
|
Comment on lines
+44
to
70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The refactoring of the telemetry loop to use single-pass counting instead of chained References
|
||
| } forEach [east, west, independent, civilian]; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original condition
GVAR(captureFrameNo) % 10 == 0for recalculating_unitRolewas based on a fixed frame interval. The new condition_weapons isNotEqualTo (_x getVariable [QGVAR(lastWeapons), []])correctly triggers recalculation only when the unit's weapons change, which is a more accurate and efficient approach. This is a good optimization.