|
| 1 | +# Universal Windows Platform performance analysis |
| 2 | + |
| 3 | +## Tools |
| 4 | +1. [Windows Performance Analyzer](https://msdn.microsoft.com/en-us/windows/desktop/hh448170.aspx) - the only usable tool so far |
| 5 | +2. Standard profiler - doesn't give much information, but still could be useful |
| 6 | +3. [DotTrace](https://www.jetbrains.com/profiler/) profiler from JetBrains, gives the same level of info as Windows Performance Analyzer |
| 7 | +4. [Intel vTune](https://software.intel.com/en-us/vtune) - Does not support UWP or WPF-specific profiling, but gives low-level CPU and GPU breakdowns. |
| 8 | + |
| 9 | +## Windows Performance Analyzer |
| 10 | +You should have all the tools downloaded as part of UWP sdk, but in case you don't - download the latest version of the Windows Performance Tools Kit, and install it on your machine. (http://www.microsoft.com/whdc/system/sysperf/perftools.mspx : Windows Performance Tools Kit, v.4.1.1 (QFE)) |
| 11 | +To utilize this powerful tool you need to turn on application Tracing first. |
| 12 | + |
| 13 | +To do so you need to create an instance of Windows.Foundation.Diagnostic.FileLoggingSession class and add Tracer.Instance channel to this session: |
| 14 | + |
| 15 | +``` |
| 16 | + static Tracer() |
| 17 | + { |
| 18 | + loggingSession = new FileLoggingSession("performance"); |
| 19 | + loggingSession.AddLoggingChannel(Instance); |
| 20 | + } |
| 21 | +
|
| 22 | +``` |
| 23 | + |
| 24 | +This will enable application level tracing for react-native code. |
| 25 | +You could start and stop application level profiling dynamically by adding and removing the channel. |
| 26 | + |
| 27 | +I think it would make sence to hide tracing under define and add context menu for profiling features later. |
| 28 | + |
| 29 | +You would see the logs in following folder: |
| 30 | +~\AppData\Local\Application Data\Packages\%PACKAGE_UID%\LocalState\Logs\ |
| 31 | +log name would be: Log-performance-*.etl |
| 32 | +it rotates every 270Kb or so. |
| 33 | + |
| 34 | +I would recommend you to record additional system level information using xperf tool. |
| 35 | +TODO: find out how to scope tool results to specific process (ideally add to the same file session) |
| 36 | + |
| 37 | +To start event recording run: |
| 38 | +``` |
| 39 | +xperf start -on DiagEasy |
| 40 | +``` |
| 41 | +To stop recording run: |
| 42 | +``` |
| 43 | +xperf stop -d filename.etl |
| 44 | +``` |
| 45 | + |
| 46 | +Windows Performance Analyzer works with single file so you need to merge all your files: |
| 47 | + |
| 48 | +``` |
| 49 | +xperf merge *.etl merge.etl |
| 50 | +``` |
| 51 | + |
| 52 | +After that you could open the resulting merge.etl file in WPA tool and see what happens inside of react code. |
| 53 | + |
| 54 | + |
| 55 | +## More info |
| 56 | +1. https://blogs.msdn.microsoft.com/ntdebugging/2008/04/03/windows-performance-toolkit-xperf/ |
| 57 | +2. https://msdn.microsoft.com/en-us/library/windows/hardware/hh448170.aspx |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
0 commit comments