4 | | == Enabling Profiler2 == |
5 | | By default, profiler2 is not activated. To see the results, you need to enable the HTTP server. You can do this by setting the following configuration in your user.cfg file: "profiler2.autoenable = true". Alternatively, you can press Ctrl+F11 (by default) to activate the HTTP profiler in-game. Currently, enabling Profiler2 in replay mode can only be done by recompiling the game with the following patch: |
| 4 | == Creating a Profiler2 file == |
| 5 | === non-visual replay (command line) === |
| 6 | You will need a replay file (command.txt) that you can create yourself or get from someone else, make sure it is compatible with your Alpha version. When you run the following command, a ''profiler2.jsonp'' file is automatically created in your working directory (~/0ad). |
| 7 | |
| 8 | {{{ |
| 9 | pyrogenesis -mod=public -replay=[PATH to a command.txt file] |
| 10 | }}} |
| 11 | Non-visual replay is also '''recommended''' if you want to compare two different states of your working copy with the same replay file. This ensures that your two ''.jsonp'' files are in sync and can be better compared using the ''source/tools/profiler2/profiler2.html'' file. |
| 12 | |
| 13 | === visual replay (game interface) === |
| 14 | By default, profiler2 is not enabled. To see the results, you need to enable the HTTP server. You can do this by setting the following configuration in your user.cfg file: "profiler2.autoenable = true". Alternatively, you can press Ctrl+F11 (by default) to activate the HTTP profiler in-game. Currently, enabling Profiler2 in replay mode can only be done by recompiling the game with the following patch: |
22 | | Once the HTTP server is activated, you simply need to open source/tools/profiler2/profiler2.html in a modern web browser. You should see the "Live" report being loaded. If you have not enabled the HTTP profiler, nothing will show up, otherwise, you should get a screen with a timeline of frames and events |
| 31 | Once the HTTP server is enabled, you simply need to open ''source/tools/profiler2/profiler2.html'' in a modern web browser. You should see that the " Live" report is loaded. If you don't have HTTP profiler enabled, nothing will be displayed, otherwise you should get a screen with a timeline of frames and events. You can save report sessions by clicking "Save Live Report to file". This will save the file to your log folder instead of your working directory as with non-visual replay. If you do this over a few runs, you can get several report files to compare. |
| 32 | |
| 33 | == Comparing reports == |
| 34 | You can easily compare multiple runs using the ''source/tools/profiler2/profiler2.html'' file by loading multiple profiling reports. Load them in the interface and click on some of the events. The graphs will then show you the event for all the reports so you can easily compare them. You will also get a table recapitulating some information to help you decide if an optimisation is worth it. |
| 35 | |
| 36 | [[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/compare-reports.PNG, 800px, border=2)]] |
| 37 | |
| 38 | == |
70 | | Sometimes, you don't really care about a certain event, unless it suddenly goes above a certain treshold and causes the game to hang. To profile such events, you can use the 'PROFILE2_IFSPIKE(name,minimal time in seconds)' macro. The events will only show up in the timeline if they are above this treshold. This can help you profile events over a long time if you were otherwise running in the buffer limit. |
71 | | Note that any "nested" profiler2 call inside a spiked region will be discarded if the spiked event does not hold, so you can get very finely grained profiling in case of spikes without cluttering your timeline by using this function. |
| 77 | Sometimes, you don't really care about a certain event, unless it suddenly goes above a certain treshold and causes the game to hang. To profile such events, you can use the 'PROFILE2_IFSPIKE(name,minimal time in seconds)' macro. The events will only show up in the timeline if they are above this treshold. This can help you profile events over a long time if you were otherwise running in the buffer limit. Note that any "nested" profiler2 call inside a spiked region will be discarded if the spiked event does not hold, so you can get very finely grained profiling in case of spikes without cluttering your timeline by using this function. |