R3vo/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
 
(71 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="font-family: 'Consolas', serif; font-size:1.5em;height:auto;width:980px;margin:auto;overflow:auto;>
{{TOC|side}}
If you have ever wondered why you scenario is running so badly, performance profiling is the way to find it out. It allows you to find bottlenecks and slow code by capturing a "slow" frame.
The captured data can then be viewed and analysed.


* [[hmd]]
== Getting the correct Version ==
* [[ammo]]
Profiling is enabled in the following {{arma3}} versions
* [[load]]
* arma3profiling_x64.exe - '''Part of the Performance Profiling Build'''
* [[vest]]
* arma3diag_x64.exe - '''Part of the Development Build'''
* [[vest]]
 
* [[items]]
Read [[Arma_3: Steam Branches]] for a guide on how to access these branches.
* [[canAdd]]
 
* [[addItem]]
{{Feature|informative|It is recommended to use the '''Performance Profiling Build''' (arma3profiling_x64.exe) for performance profiling because:
* [[addVest]]
* Has tools that might not make it into development build
* [[goggles]]
* Has all the profiling related commands that ''arma3diag_x64.exe'' has
* [[loadAbs]]
* Its performance is closer to the default ''arma3_x64.exe''}}
* [[maxLoad]]
 
* [[setAmmo]]
== Frame Capturing ==
* [[uniform]]
There are several commands that allow you to capture a frame.
* [[weapons]]
* [[diag_captureFrame]]
* [[setAmmo]]
* [[diag_captureSlowFrame]]
* [[weapons]]
* [[diag_logSlowFrame]] - not available in Arma 3 :(
* [[uniform]]
* [[diag_captureFrameToFile]]
* [[headgear]]
In most cases you do not want to capture any or all frames, you just want to capture "slow" frames. A slow frame is a frame that takes longer than the average frame and slows down the game.
* [[linkItem]]
 
* [[loadVest]]
== How to Use ==
* [[someAmmo]]
# Run a mission
* [[backpack]]
# Execute a scripted command <sqf inline>diag_captureSlowFrame ["total", 0.3];</sqf> using any means ([[Arma 3: Debug Console|Debug Console]], mission radio trigger...)
* [[addWeapon]]
# Once a slow frame is detected, a window will open
* [[backpacks]]
# In the window you will be able to browse a lot of performance-related data, which can be interesting
* [[binocular]]
# To export the gathered information for sharing with others:
* [[getCorpse]]
## Select Main Thread (if not selected yet)
* [[hasWeapon]]
## Press the Copy button
* [[magazines]]
## Open an external text editor
* [[vestItems]]
## Paste the text into a new file
* [[addWeapon]]
## Save the file
* [[itemCargo]]
 
* [[magazines]]
== Capture Frame UI ==
* [[addGoggles]]
[[File: arma3-capture frame ui overview.png]]
* [[addUniform]]
 
* [[assignItem]]
# {{Wiki|TODO}}
* [[removeItem]]
# {{Wiki|TODO}}
* [[removeVest]]
# {{Wiki|TODO}}
* [[setMaxLoad]]
# {{Wiki|TODO}}
* [[unlinkItem]]
# {{Wiki|TODO}}
* [[removeVest]]
# {{Wiki|TODO}}
* [[addHeadgear]]
# {{Wiki|TODO}}
* [[addMagazine]]
# {{Wiki|TODO}}
* [[loadUniform]]
# {{Wiki|TODO}}
* [[removeItems]]
 
* [[weaponCargo]]
== External Viewer ==
* [[weaponCargo]]
* chrome://tracing
* [[addBackpack]]
* https://ui.perfetto.dev/
* [[weaponCargo]]
 
* [[addMagazines]]
[[File:Performance_Profiling_04.png|thumb|diag_captureFrame sample output with custom subtree]]
* [[gearSlotData]]
== Creating Your Own Subtree ==
* [[handgunItems]]
 
* [[removeWeapon]]
When Profiling Per-Frame Eventhandlers (PFH), [[diag_captureFrame]] only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.<br>
* [[unassignItem]]
You can create your own subtree inside siFEH by wrapping your function call inside a [[isNil]] CODE statement like this:<br>
* [[uniformItems]]
Turn your old call which may look like this:
* [[weaponsItems]]
<sqf>
* [[addItemCargo]]
addMissionEventHandler ["EachFrame", {
* [[getAmmoCargo]]
call myPFHFunction
* [[getFuelCargo]]
}];
* [[getItemCargo]]
</sqf>
* [[removeWeapon]]
 
* [[setAmmoCargo]]
Into something like this:
* [[setFuelCargo]]
<sqf>
* [[weaponsItems]]
addMissionEventHandler ["EachFrame", {
* [[loadBackpack]]
isNil { call myPFHFunction } // isNil creates the subtree
* [[unitBackpack]]
}];
* [[addItemToVest]]
</sqf>
* [[addWeaponItem]]
 
* [[assignedItems]]
Now when you run [[diag_captureFrame]] inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.<br>
* [[currentWeapon]]
It will only show a part of the first line of that code so you should put something descriptive into the [[isNil]] statement.<br>
* [[handgunWeapon]]
You can use the same to create a subtree for any function you like. This will also work inside [[Scheduler#Scheduled_Environment|Scheduled]] ([[spawn]]ed) scripts. <br>
* [[lockInventory]]
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.
* [[magazinesAmmo]]
 
* [[primaryWeapon]]
 
* [[removeGoggles]]
== Notes ==
* [[removeUniform]]
 
* [[vestContainer]]
* 0.3 is a time in second used to determine what duration of a frame you consider abnormal, and first such frame will be captured.
* [[vestMagazines]]
* 0.3 is definitely something you should not see in a normal game.
* [[magazineCargo]]
* If you do not capture any frames with 0.3, try lowering it to 0.2 or 0.1.
* [[magazinesAmmo]]
* If it triggers too early, before the main slowdown happens, increase it to a higher value, e.g. 1.0.
* [[backpackCargo]]
 
* [[backpackItems]]
== Scopes ==
* [[everyBackpack]]
{| class="wikitable sortable"
* [[firstBackpack]]
|-
* [[magazineCargo]]
! Technical Name !! Descriptive Name !! Description
* [[removeUniform]]
|-
* [[vestContainer]]
| Main
* [[addHandgunItem]]
|
* [[binocularItems]]
|
* [[getUnitLoadout]]
|-
* [[removeAllItems]]
| total
* [[removeClothing]]
|
* [[removeHeadgear]]
|
* [[removeMagazine]]
|-
* [[setUnitLoadout]]
| fsPHa
* [[everyContainer]]
|
* [[getRepairCargo]]
|
* [[getWeaponCargo]]
|-
* [[setRepairCargo]]
| winMs
* [[setVehicleAmmo]]
|
* [[addWeaponCargo]]
|
* [[clearItemCargo]]
|-
* [[getWeaponCargo]]
| dlcSim
* [[removeBackpack]]
|
* [[addWeaponGlobal]]
|
* [[currentMagazine]]
|-
* [[forceAddUniform]]
| steamCbk
* [[getSlotItemName]]
|
* [[handgunMagazine]]
|
* [[lockedInventory]]
|-
* [[magazinesDetail]]
| input
* [[removeMagazines]]
|
* [[secondaryWeapon]]
|
* [[uniqueUnitItems]]
|-
* [[addWeaponGlobal]]
| wSimu
* [[currentMagazine]]
|
* [[magazinesDetail]]
|
* [[forceAddUniform]]
|-
* [[addBinocularItem]]
| docSim
* [[addItemToUniform]]
|
* [[canAddItemToVest]]
|
* [[currentThrowable]]
|-
* [[gearIDCAmmoCount]]
| wSimDisp
* [[isUniformAllowed]]
|
* [[removeAllWeapons]]
|
* [[soldierMagazines]]
|-
* [[uniformContainer]]
| MFDManager
* [[uniformMagazines]]
|
* [[getMagazineCargo]]
|
* [[addBackpackCargo]]
|-
* [[addMagazineCargo]]
| wDisp
* [[backpackSpaceFor]]
|
* [[clearWeaponCargo]]
|
* [[getBackpackCargo]]
|-
* [[getMagazineCargo]]
| EventPrcs
* [[uniformContainer]]
|
* [[uniformMagazines]]
|
* [[addBackpackGlobal]]
|-
* [[addMagazineGlobal]]
| gsEva
* [[backpackMagazines]]
|
* [[binocularMagazine]]
|
* [[gearSlotAmmoCount]]
|-
* [[magazinesAmmoFull]]
| gbFrm
* [[removeHandgunItem]]
|
* [[setVehicleAmmoDef]]
|
* [[weaponAccessories]]
|-
* [[magazinesAmmoFull]]
| memLo
* [[removeWeaponCargo]]
|
* [[setVehicleAmmoDef]]
|
* [[weaponsItemsCargo]]
|-
* [[addItemToBackpack]]
| siScr
* [[backpackContainer]]
|
* [[backpackMagazines]]
|
* [[weaponsItemsCargo]]
|-
* [[itemsWithMagazines]]
| scrVM
* [[primaryWeaponItems]]
|
* [[removeItemFromVest]]
|
* [[removeWeaponGlobal]]
|-
* [[addItemCargoGlobal]]
| wsSet
* [[magazinesAmmoCargo]]
|
* [[removeWeaponGlobal]]
|
* [[clearBackpackCargo]]
|-
* [[clearMagazineCargo]]
| sLand
* [[canAddItemToUniform]]
|
* [[getContainerMaxLoad]]
|
* [[magazinesDetailVest]]
|-
* [[removeAllContainers]]
| simSW
* [[removeBinocularItem]]
|
* [[addPrimaryWeaponItem]]
|
* [[removeBackpackGlobal]]
|-
* [[removeMagazineGlobal]]
| cLWObj
* [[secondaryWeaponItems]]
|
* [[addMagazineAmmoCargo]]
|
* [[addWeaponCargoGlobal]]
|-
* [[canAddItemToBackpack]]
| oTemp
* [[clearItemCargoGlobal]]
|
* [[currentMagazineDetail]]
|
* [[primaryWeaponMagazine]]
|-
* [[removeAllHandgunItems]]
| FPres
* [[removeItemFromUniform]]
|
* [[currentMagazineDetail]]
|
* [[addSecondaryWeaponItem]]
|-
* [[magazinesDetailUniform]]
| waitSnd
* [[removeAllAssignedItems]]
|
* [[weaponAccessoriesCargo]]
|
* [[weaponAccessoriesCargo]]
|-
* [[addBackpackCargoGlobal]]
| job
* [[addMagazineCargoGlobal]]
|
* [[clearWeaponCargoGlobal]]
|
* [[removeItemFromBackpack]]
|-
* [[weaponAccessoriesCargo]]
| sound
* [[magazinesDetailBackpack]]
|
* [[removeAllBinocularItems]]
|
* [[removePrimaryWeaponItem]]
|-
* [[secondaryWeaponMagazine]]
| ssAdv
* [[clearBackpackCargoGlobal]]
|
* [[clearMagazineCargoGlobal]]
|
* [[removeSecondaryWeaponItem]]
|-
* [[clearAllItemsFromBackpack]]
| snCmt
* [[removeAllItemsWithMagazines]]
|
* [[removeAllPrimaryWeaponItems]]
|
* [[removeWeaponAttachmentCargo]]
|-
* [[removeAllItemsWithMagazines]]
| play
* [[removeAllSecondaryWeaponItems]]
|
* [[addWeaponWithAttachmentsCargo]]
|
* [[addWeaponWithAttachmentsCargoGlobal]]
|-
</div>
| ARTCpl
|
|
|-
| rendr
|
|
|-
| drwVi
|
|
|-
| txHLi
|
|
|-
| txPMM
|
|
|-
| dsr2t
|
|
|-
| wPrep
|
|
|-
| dPr
|
|
|-
| fmiRun
|
|
|-
| fmiWait
|
|
|-
| fmiMDrw
|
|
|-
| fmiSIns
|
|
|-
| wPrepFtr
|
|
|-
| clPrp
|
|
|-
| oPrep
|
|
|-
| sceAC
|
|
|-
| oSplt
|
|
|-
| sceACTA
|
|
|-
| sceACPrx
|
|
|-
| lodUL
|
|
|-
| PrxObj
|
|
|-
| manAn
|
|
|-
| ppdOT
|
|
|-
| flProx
|
|
|-
| PrxObjTransport
|
|
|-
| oSoSL
|
|
|-
| oSoJE
|
|
|-
| oSoJE1
|
|
|-
| oSoJE2
|
|
|-
| oSo1OFOv
|
|
|-
| oSo1ON
|
|
|-
| sceCLsHSH
|
|
|-
| prpAMCt
|
|
|-
| oSoJEw
|
|
|-
| pDrwFNP
|
|
|-
| oSoSLu
|
|
|-
| lPGCl
|
|
|-
| pdDrw
|
|
|-
| lDGnd
|
|
|-
| lGSMM
|
|
|-
| recCB
|
|
|-
| mtPmj
|
|
|-
| cuDrw
|
|
|-
| prepT
|
|
|-
| drwCB
|
|
|-
| oPasD
|
|
|-
| o1Drw
|
|
|-
| lckDnBf
|
|
|-
| prpTx
|
|
|-
| inst
|
|
|-
| stpSctnTL
|
|
|-
| o1ShV
|
|
|-
| scSVI
|
|
|-
| oPas3
|
|
|-
| sssmC
|
|
|-
| sbDrw
|
|
|-
| aniMt
|
|
|-
| ppSSSM
|
|
|-
| drwROM
|
|
|-
| drwIn
|
|
|-
| wDraw
|
|
|-
| lDPGT
|
|
|-
| oSDrw
|
|
|-
| oPasO
|
|
|-
| lDSky
|
|
|-
| swRdr
|
|
|-
| ppSWDD
|
|
|-
| swRdGeom
|
|
|-
| swRdGeomVB
|
|
|-
| swFillV
|
|
|-
| oPasA
|
|
|-
| ppShrpn
|
|
|-
| lDWat
|
|
|-
| oPas2
|
|
|-
| o2Drw
|
|
|-
| oPas5
|
|
|-
| o5Drw
|
|
|-
| EDraw3D
|
|
|-
| MEventPrcs
|
|
|-
| cLGSY
|
|
|-
| stpAll
|
|
|-
| stpCB
|
|
|-
| stpTxtCS
|
|
|-
| stpUAVsCS
|
|
|-
| ppHDRCL
|
|
|-
| ppGSB
|
|
|-
| ppDOF
|
|
|-
| ppGlwNw
|
|
|-
| ppGLu
|
|
|-
| stpCBUpd
|
|
|-
| ppQWt
|
|
|-
| ppCMAA
|
|
|-
| hudDr
|
|
|-
| 3DEN_UI_OnDraw
|
|
|-
| 3DEN_PrepareDraw
|
|
|-
| clObL
|
|
|-
| 3DEN_Drawing
|
|
|-
| stpTxtGS
|
|
|-
| txt2D
|
|
|-
| mapDr
|
|
|-
| mapSeaAndNormal
|
|
|-
| mapPM
|
|
|-
| lndPM
|
|
|-
| MapObjectsPrepTask
|
|
|-
| mapSeaAndNormalDraw
|
|
|-
| mapCntDraw
|
|
|-
| mapObjectsDraw
|
|
|-
| mapForestShape
|
|
|-
| mapGrid
|
|
|-
| drwFn
|
|
|-
| dtTot
|
|
|-
| wFram
|
|
|-
| 3dSwp
|
|
|-
| preLd
|
|
|-
| preLV
|
|
|-
| actObjPrld
|
|
|-
| hashChk
|
|
|-
| sSim
|
|
|-
| enfWorkShort
|
|
|-
| updAttPos
|
|
|-
| oSo1AN
|
|
|-
| prpAMCf
|
|
|-
| prpAMCSlt
|
|
|-
| prpSDM
|
|
|-
| locL
|
|
|-
| mapSeaAndNormalWork
|
|
|-
| mapObjectsPrepWork
|
|
|-
| drwIdxPrm
|
|
|-
| oSo3
|
|
|-
| lsCVB
|
|
|-
| oSo5
|
|
|-
| oSo2CL
|
|
|-
| oSo1AF
|
|
|-
| Visualize
|
|
|-
| visul
|
|
|-
| txMLo
|
|
|-
| oSo2Srt
|
|
|-
| oSoSdw
|
|
|-
| prpAMCbsi
|
|
|-
| prpAMCp
|
|
|-
| Render
|
|
|-
| bgD3D
|
|
|-
| stpTxtVS
|
|
|-
| ppHBAOPlus
|
|
|}
 
<sqf>
private _ctrlTV = ctrlparent (_this select 0) displayCtrl 101;
 
private _export = "{| class=""wikitable sortable"""  + endl + "|-" + endl;
_export = _export + "! Technical Name !! Descriptive Name !! Description";
 
private _fnc_logChilden =
{
    params ["_path"];
 
    for "_i" from 0 to ((_ctrlTV tvCount _path) - 1) do
    {
        private _text = _ctrlTV tvText (_path + [_i]);
        _text = _text splitString " " select 0;
 
        if !(_text in _export) then
        {
            _export = _export + endl + "|-" + endl + "| " + _text + endl + "| " + endl + "| ";
        };
 
        if (_ctrlTV tvCount (_path + [_i]) > 0 ) then
        {
            [_path + [_i]] call _fnc_logChilden;
        };
    };
};
 
[[]] call _fnc_logChilden;
 
copyToClipboard (_export + endl + "|}" + endl);
</sqf>
 
== See Also ==
 
* [[Code Optimisation]]
* [[Mission Optimisation]]
 
 
[[Category:Arma Scripting Tutorials]]

Latest revision as of 18:23, 4 November 2024

If you have ever wondered why you scenario is running so badly, performance profiling is the way to find it out. It allows you to find bottlenecks and slow code by capturing a "slow" frame. The captured data can then be viewed and analysed.

Getting the correct Version

Profiling is enabled in the following Arma 3 versions

  • arma3profiling_x64.exe - Part of the Performance Profiling Build
  • arma3diag_x64.exe - Part of the Development Build

Read Arma_3: Steam Branches for a guide on how to access these branches.

It is recommended to use the Performance Profiling Build (arma3profiling_x64.exe) for performance profiling because:
  • Has tools that might not make it into development build
  • Has all the profiling related commands that arma3diag_x64.exe has
  • Its performance is closer to the default arma3_x64.exe

Frame Capturing

There are several commands that allow you to capture a frame.

In most cases you do not want to capture any or all frames, you just want to capture "slow" frames. A slow frame is a frame that takes longer than the average frame and slows down the game.

How to Use

  1. Run a mission
  2. Execute a scripted command diag_captureSlowFrame ["total", 0.3]; using any means (Debug Console, mission radio trigger...)
  3. Once a slow frame is detected, a window will open
  4. In the window you will be able to browse a lot of performance-related data, which can be interesting
  5. To export the gathered information for sharing with others:
    1. Select Main Thread (if not selected yet)
    2. Press the Copy button
    3. Open an external text editor
    4. Paste the text into a new file
    5. Save the file

Capture Frame UI

arma3-capture frame ui overview.png

  1. 🚧
    TODO: this must be updated.
  2. 🚧
    TODO: this must be updated.
  3. 🚧
    TODO: this must be updated.
  4. 🚧
    TODO: this must be updated.
  5. 🚧
    TODO: this must be updated.
  6. 🚧
    TODO: this must be updated.
  7. 🚧
    TODO: this must be updated.
  8. 🚧
    TODO: this must be updated.
  9. 🚧
    TODO: this must be updated.

External Viewer

diag_captureFrame sample output with custom subtree

Creating Your Own Subtree

When Profiling Per-Frame Eventhandlers (PFH), diag_captureFrame only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.
You can create your own subtree inside siFEH by wrapping your function call inside a isNil CODE statement like this:
Turn your old call which may look like this:

addMissionEventHandler ["EachFrame", { call myPFHFunction }];

Into something like this:

addMissionEventHandler ["EachFrame", { isNil { call myPFHFunction } // isNil creates the subtree }];

Now when you run diag_captureFrame inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.
It will only show a part of the first line of that code so you should put something descriptive into the isNil statement.
You can use the same to create a subtree for any function you like. This will also work inside Scheduled (spawned) scripts.
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.


Notes

  • 0.3 is a time in second used to determine what duration of a frame you consider abnormal, and first such frame will be captured.
  • 0.3 is definitely something you should not see in a normal game.
  • If you do not capture any frames with 0.3, try lowering it to 0.2 or 0.1.
  • If it triggers too early, before the main slowdown happens, increase it to a higher value, e.g. 1.0.

Scopes

Technical Name Descriptive Name Description
Main
total
fsPHa
winMs
dlcSim
steamCbk
input
wSimu
docSim
wSimDisp
MFDManager
wDisp
EventPrcs
gsEva
gbFrm
memLo
siScr
scrVM
wsSet
sLand
simSW
cLWObj
oTemp
FPres
waitSnd
job
sound
ssAdv
snCmt
play
ARTCpl
rendr
drwVi
txHLi
txPMM
dsr2t
wPrep
dPr
fmiRun
fmiWait
fmiMDrw
fmiSIns
wPrepFtr
clPrp
oPrep
sceAC
oSplt
sceACTA
sceACPrx
lodUL
PrxObj
manAn
ppdOT
flProx
PrxObjTransport
oSoSL
oSoJE
oSoJE1
oSoJE2
oSo1OFOv
oSo1ON
sceCLsHSH
prpAMCt
oSoJEw
pDrwFNP
oSoSLu
lPGCl
pdDrw
lDGnd
lGSMM
recCB
mtPmj
cuDrw
prepT
drwCB
oPasD
o1Drw
lckDnBf
prpTx
inst
stpSctnTL
o1ShV
scSVI
oPas3
sssmC
sbDrw
aniMt
ppSSSM
drwROM
drwIn
wDraw
lDPGT
oSDrw
oPasO
lDSky
swRdr
ppSWDD
swRdGeom
swRdGeomVB
swFillV
oPasA
ppShrpn
lDWat
oPas2
o2Drw
oPas5
o5Drw
EDraw3D
MEventPrcs
cLGSY
stpAll
stpCB
stpTxtCS
stpUAVsCS
ppHDRCL
ppGSB
ppDOF
ppGlwNw
ppGLu
stpCBUpd
ppQWt
ppCMAA
hudDr
3DEN_UI_OnDraw
3DEN_PrepareDraw
clObL
3DEN_Drawing
stpTxtGS
txt2D
mapDr
mapSeaAndNormal
mapPM
lndPM
MapObjectsPrepTask
mapSeaAndNormalDraw
mapCntDraw
mapObjectsDraw
mapForestShape
mapGrid
drwFn
dtTot
wFram
3dSwp
preLd
preLV
actObjPrld
hashChk
sSim
enfWorkShort
updAttPos
oSo1AN
prpAMCf
prpAMCSlt
prpSDM
locL
mapSeaAndNormalWork
mapObjectsPrepWork
drwIdxPrm
oSo3
lsCVB
oSo5
oSo2CL
oSo1AF
Visualize
visul
txMLo
oSo2Srt
oSoSdw
prpAMCbsi
prpAMCp
Render
bgD3D
stpTxtVS
ppHBAOPlus

private _ctrlTV = ctrlparent (_this select 0) displayCtrl 101; private _export = "{| class=""wikitable sortable""" + endl + "|-" + endl; _export = _export + "! Technical Name !! Descriptive Name !! Description"; private _fnc_logChilden = { params ["_path"]; for "_i" from 0 to ((_ctrlTV tvCount _path) - 1) do { private _text = _ctrlTV tvText (_path + [_i]); _text = _text splitString " " select 0; if !(_text in _export) then { _export = _export + endl + "|-" + endl + "| " + _text + endl + "| " + endl + "| "; }; if (_ctrlTV tvCount (_path + [_i]) > 0 ) then { [_path + [_i]] call _fnc_logChilden; }; }; }; [[]] call _fnc_logChilden; copyToClipboard (_export + endl + "|}" + endl);

See Also