Performance Profiling: Difference between revisions
Lou Montana (talk | contribs) m (Some wiki formatting) |
(added link to branches page) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
== Versions with performance profiling == | == Versions with performance profiling == | ||
The Profiling build is provided by {{User|Dwarden}} in tandem with {{arma3}} Performance build. | The Profiling build is provided by {{User|Dwarden}} in tandem with {{arma3}} [[Arma_3:_Steam_Branches|Performance build]]. | ||
It can be found in the {{Link|https://forums.bistudio.com/forums/topic/160288-arma-3-stable-server-170-performance-binary-feedback/|BI | It can be found in the {{Link|https://forums.bistudio.com/forums/topic/160288-arma-3-stable-server-170-performance-binary-feedback/|BI Forums}} as well as in the {{hl|#perf_prof_branch}} channel in the {{Link|https://discordapp.com/invite/arma|official {{arma3}} Discord server}}. | ||
{{Feature|important| | {{Feature|important| | ||
Line 9: | Line 9: | ||
* This work also with [[Arma 3: Diagnostics Exe]]. | * This work also with [[Arma 3: Diagnostics Exe]]. | ||
}} | }} | ||
Line 19: | Line 18: | ||
* [[diag_captureFrame]] | * [[diag_captureFrame]] | ||
* [[diag_captureSlowFrame]] | * [[diag_captureSlowFrame]] | ||
* [[diag_logSlowFrame]] | * [[diag_logSlowFrame]] - not available in Arma 3 :( | ||
* [[diag_captureFrameToFile]] | |||
Line 25: | Line 25: | ||
# Run a mission | # Run a mission | ||
# Execute a scripted command | # Execute a scripted command <sqf inline>diag_captureSlowFrame ["total", 0.3];</sqf> using any means ([[Arma 3: Debug Console|Debug Console]], mission radio trigger...) | ||
# Once a slow frame is detected, a window will open | # Once a slow frame is detected, a window will open | ||
# In the window you will be able to browse a lot of | # In the window you will be able to browse a lot of performance-related data, which can be interesting | ||
# | # To export the gathered information for sharing with others: | ||
## Select Main Thread (if not selected yet) | ## Select Main Thread (if not selected yet) | ||
## Press Copy button | ## Press the Copy button | ||
## Open an external text editor | ## Open an external text editor | ||
## Paste the text into a new file | ## Paste the text into a new file | ||
Line 43: | Line 43: | ||
Turn your old call which may look like this: | Turn your old call which may look like this: | ||
<sqf> | <sqf> | ||
[" | addMissionEventHandler ["EachFrame", { | ||
call myPFHFunction | |||
}]; | |||
</sqf> | </sqf> | ||
Into something like this: | Into something like this: | ||
<sqf> | <sqf> | ||
[" | addMissionEventHandler ["EachFrame", { | ||
isNil { call myPFHFunction } | isNil { call myPFHFunction } // isNil creates the subtree | ||
}] | }]; | ||
</sqf> | </sqf> | ||
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> | 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> | ||
It will only show a part of the first line of that code so you should put something descriptive into the isNil statement.<br> | It will only show a part of the first line of that code so you should put something descriptive into the [[isNil]] statement.<br> | ||
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> | 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> | ||
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out. | But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out. |
Latest revision as of 17:18, 5 October 2024
Versions with performance profiling
The Profiling build is provided by Dwarden in tandem with Arma 3 Performance build. It can be found in the BI Forums as well as in the #perf_prof_branch channel in the official Arma 3 Discord server.
Scripting Commands
- diag_captureFrame
- diag_captureSlowFrame
- diag_logSlowFrame - not available in Arma 3 :(
- diag_captureFrameToFile
How to Use
- Run a mission
- Execute a scripted command diag_captureSlowFrame ["total", 0.3]; using any means (Debug Console, mission radio trigger...)
- Once a slow frame is detected, a window will open
- In the window you will be able to browse a lot of performance-related data, which can be interesting
- To export the gathered information for sharing with others:
- Select Main Thread (if not selected yet)
- Press the Copy button
- Open an external text editor
- Paste the text into a new file
- Save the file
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:
Into something like this:
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.