R3vo/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Main page changes)
mNo edit summary
 
(396 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Hide stuff -->
{{TOC|side}}
__NOTOC__
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.
__NOEDITSECTION__
The captured data can then be viewed and analysed.
__HIDDENCAT__
<!-- Hide page title "Main Page" -->
{{DISPLAYTITLE:<span style="position: absolute; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px);">{{FULLPAGENAME}}</span>}}


[[Image:Logo_BI_Black.png|center|256px|link=Bohemia Interactive Community:About]]
== Getting the correct Version ==
<div style="text-align: center; min-height: 75px">'''Welcome to the Bohemia Interactive Community Wiki.'''</div>
Profiling is enabled in the following {{arma3}} versions
<div style="text-align: center; min-height: 75px">'''In order to prevent vandalism and bot spam, self-creation of accounts has been disabled.<br> Therefore you need to ask''' '''''@Dwarden''''' '''for an account [http://discord.gg/arma at our discord], or on [https://forums.bohemia.net/profile/743078-dwarden/ BI Forums].'''</div>
* arma3profiling_x64.exe - '''Part of the Performance Profiling Build'''
<br>
* arma3diag_x64.exe - '''Part of the Development Build'''


<div style="display: flex; align-content: flex-start; align-items: flex-start; justify-content: center; flex-wrap: wrap"> <!-- flex container -->
Read [[Arma_3: Steam Branches]] for a guide on how to access these branches.


<!--- DAYZ --->
{{Feature|informative|It is recommended to use the '''Performance Profiling Build''' (arma3profiling_x64.exe) for performance profiling because:
<div class="floating-box">
* Has tools that might not make it into development build
== <div style="text-align: center; min-height: 75px">[[File:dayzlogoinv.png|150px|link=DayZ|About DayZ]]</div> ==
* Has all the profiling related commands that ''arma3diag_x64.exe'' has
:[[:Category:DayZ:Editing|Editing]]
* Its performance is closer to the default ''arma3_x64.exe''}}
:[[:Category:DayZ:Tools|Tools]]
:[[:Category:DayZ:Tutorials|Tutorials]]
:[[:Category:DayZ:Game Mechanics|Game mechanics]]
</div>


<!--- YLANDS --->
== Frame Capturing ==
<div class="floating-box">
There are several commands that allow you to capture a frame.
== <div style="text-align: center; min-height: 75px">[[Image:Ylands_3D_Logo.png|285px|link=Ylands|About Ylands]]</div> ==
* [[diag_captureFrame]]
:[[Ylands Visual Scripting|Visual Scripting]]
* [[diag_captureSlowFrame]]
:[[Ylands Editor|Editor]]
* [[diag_logSlowFrame]] - not available in Arma 3 :(
:[[Ylands Database|Database]]
* [[diag_captureFrameToFile]]
:[[Ylands Game Mechanics|Game mechanics]]
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.
</div>


<!--- A3 --->
== How to Use ==  
<div class="floating-box">
# Run a mission
== <div style="text-align: center; min-height: 75px">[[Image:Logo A3 black.png|150px|link=ArmA 3|About Arma 3]]</div> ==
# Execute a scripted command <sqf inline>diag_captureSlowFrame ["total", 0.3];</sqf> using any means ([[Arma 3: Debug Console|Debug Console]], mission radio trigger...)
:[[:Category:Arma 3: Editing|Editing]]
# Once a slow frame is detected, a window will open
:[[:Category:Scripting Commands Arma 3|Scripting commands]]
# In the window you will be able to browse a lot of performance-related data, which can be interesting
:[[:Category:Arma 3: Functions|Scripting functions]]
# To export the gathered information for sharing with others:
:[[Arma 3 Getting Started]]
## Select Main Thread (if not selected yet)
:[[Eden Editor]]
## Press the Copy button
</div>
## Open an external text editor
## Paste the text into a new file
## Save the file


<!--- A2 OA --->
== Capture Frame UI ==
<div class="floating-box">
[[File: arma3-capture frame ui overview.png]]
== <div style="text-align: center; min-height: 75px">[[Image:A2_OA_Logo.png|115px|link=:Category:ArmA 2: Operation Arrowhead|About Arma 2: Operation Arrowhead]]</div> ==
:[[ArmA 2: Editing|Editing]]
:[[ArmA II Hints and Tips|Hints and tips]]
:[[:Category:Scripting Commands ArmA2|Scripting commands]]
:[[:Category:Arma 2: Multiplayer|Multiplayer]]
</div>


<!--- A2 --->
# {{Wiki|TODO}}
<div class="floating-box">
# {{Wiki|TODO}}
== <div style="text-align: center; min-height: 75px">[[Image:Logo A2.png|150px|link=ArmA 2|About Arma 2]]</div> ==
# {{Wiki|TODO}}
:[[ArmA 2: Editing|Editing]]
# {{Wiki|TODO}}
:[[Arma2: Startup Parameters|Startup parameters]]
# {{Wiki|TODO}}
:[[:Category:Scripting Commands ArmA2|Scripting commands]]
# {{Wiki|TODO}}
:[[Mondkalb's Addon Tutorial|Creating Addons]]
# {{Wiki|TODO}}
</div>
# {{Wiki|TODO}}
# {{Wiki|TODO}}


<!--- A1 --->
== External Viewer ==
<div class="floating-box">
* chrome://tracing
== <div style="text-align: center; min-height: 75px">[[Image:Logo A1 black.png|150px|link=ArmA: The Game|About Arma: Armed Assault]]</div> ==
* https://ui.perfetto.dev/
:[[ArmA: Editing|Editing]]
:[[:Category:Scripting Commands ArmA|Scripting commands]]
:[[:ArmA: Mission Editing|Mission Editing]]
:[[ArmA: FAQ|FAQ]]
</div>


<!--- OFP --->
[[File:Performance_Profiling_04.png|thumb|diag_captureFrame sample output with custom subtree]]
<div class="floating-box">
== Creating Your Own Subtree ==
== <div style="text-align: center; min-height: 75px">[[Image:Logo A0.png|150px|link=:Category:Operation_Flashpoint|About Arma: Cold War Assault]]</div> ==
:[[:Category:Operation Flashpoint: Editing|Editing]]
:[[:Category:Operation Flashpoint: Startup Parameters|Startup parameters]]
:[[:Category:Operation Flashpoint: Addons|Addons]]
:[[:Category:Scripting Commands OFP 1.96|Scripting commands]]
</div>


<!--- TKOH --->
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>
<div class="floating-box">
You can create your own subtree inside siFEH by wrapping your function call inside a [[isNil]] CODE statement like this:<br>
== <div style="text-align: center; min-height: 75px">[[Image:Logo TakOH full.png|150px|link=Take On Helicopters|About Take On Helicopters]]</div> ==
Turn your old call which may look like this:
:[[:Category:Take On Helicopters: Editing| Editing]]
<sqf>
:[[:Category:Scripting Commands Take On Helicopters|Scripting commands]]
addMissionEventHandler ["EachFrame", {
:[[:Category:Take On Helicopters: Functions|Scripting functions]]
call myPFHFunction
:[[Functions Library 2.0]]
}];
</div>
</sqf>


<!--- TKOM --->
Into something like this:
<div class="floating-box">
<sqf>
== <div style="text-align: center; min-height: 75px">[[Image:tkom_logo.png|150px|link=Take On Mars|About Take On Mars]]</div> ==
addMissionEventHandler ["EachFrame", {
:[[:Take On Mars: Editor|Editor]]
isNil { call myPFHFunction } // isNil creates the subtree
:[[:Take On Mars: Equipment|Equipment]]
}];
</div>
</sqf>


<!--- CC --->
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>
<div class="floating-box">
It will only show a part of the first line of that code so you should put something descriptive into the [[isNil]] statement.<br>
== <div style="text-align: center">[[Image:CC_Logo.png|200px|link=:Carrier Command: Gaea Mission|About Carrier Command: Gaea Mission]]</div> ==
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>
:[[Carrier Command: Gaea Mission: Startup Parameters|Startup Parameters]]
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.
:[[Carrier Command: Gaea Mission: FAQ|FAQ]]
:[[:Category:Carrier Command: Official Tools|Official Tools]]
</div>


<!--- VBS
<div class="floating-box">
== <div style="text-align: center; min-height: 75px">[[:Category:Virtual Battlespace|About VBS1]]</div> ==
:[[Virtual Battlespace: Startup Parameters|Startup Parameters]]
:[[:Category:Scripting Commands VBS1|Scripting commands]]
:[[VBS1 Functions|Scripting functions]]
</div>
</div>--->


</div><!-- end of flex container -->
== Notes ==
<div style="display: flex; align-content: flex-start; align-items: flex-start; justify-content: center; flex-wrap: wrap"> <!-- flex container -->


<!--- EDITING (GENERAL) --->
* 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.
<div class="floating-box">
* 0.3 is definitely something you should not see in a normal game.
== <div style="text-align: center">Editing (General)</div> ==
* If you do not capture any frames with 0.3, try lowering it to 0.2 or 0.1.
:[[Addons]]
* If it triggers too early, before the main slowdown happens, increase it to a higher value, e.g. 1.0.
:[[Terrain Editing]]
:[[Modelling]]
:[[:Category:Scripting Topics|Scripting (general)]]
:[[:Category:Tools|Tools]]
:[[Public Data]]
</div>


<!--- CONTRIBUTE --->
<div class="floating-box">
== <div style="text-align: center">Contribute</div> ==
:[[Getting Started]]
:[[Cheatsheet|Formatting Help & Templates]]
:[[Bohemia Interactive Community:Guidelines|Guidelines]]
:[[Village Pump (todo)|To-do]]
</div>


<!--- GETTING HELP --->
== See Also ==
<div class="floating-box">
== <div style="text-align: center">Getting Help</div> ==
:[[Troubleshooting|Troubleshooting]]
:[https://forums.bohemia.net/ BIS Forums]
:[[:Category:Hints & Tips |Hints and Tips]]
:[https://discord.gg/Arma Discord]
</div>


</div><!-- end of flex container -->
* [[Code Optimisation]]
* [[Mission Optimisation]]




[[Category:Community Wiki]]
[[Category:Arma Scripting Tutorials]]

Latest revision as of 12:37, 26 October 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.


See Also