How to profile WPF 4.5 UI performance?

后端 未结 2 749
囚心锁ツ
囚心锁ツ 2020-12-03 04:57

I\'m developing a .NET 4.5 WPF app and having UI rendering performance issues.

After some googling, I came across WPF Performance Suite page which describes exactly

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 05:36

    Eventually, I've found a tool that I was looking for and that was really helpful for me.

    To get an idea of where exactly is the bottleneck in rendering your WPF layout, you want to:

    1. Install the Visual Studio 2015, if you don't have one yet :)
    2. Go to Debug -> Start Diagnostic Tools Without Debugging
      (NOTE: This seems to be changed to Debug -> Profiler -> Performance Profiler...).
    3. Check Application Timeline tool and hit Start in this view:

    1. When your app starts, do the actions causing issues you're interested in.
    2. Then hit Stop recording and you'll eventually get your elements tree with times spent for rendering every node. Then, you only need to sort it by Duration (total) and expand slowest nodes until you find the problem:

    In conclusion, it would much easier to correlate the nodes from tree above with your layout if you set names for your controls using the Name attribute like the following:

    
    

提交回复
热议问题