What are some resources I can use to learn profiling/optimizing?

后端 未结 11 1788
醉梦人生
醉梦人生 2020-12-24 10:03

I just inherited a C# project that runs way to slow and will have to start optimizing it. What I wanted to do first is learn a little more about profiling/optimizing since I

11条回答
  •  醉梦人生
    2020-12-24 10:33

    There are profilers and performance analysis tools, but while you're trying to find / buy / install / learn one, just try an old-timer's trick...

    Run the app under the IDE, and while it's being sluggish, hit the "Pause" button, and ask it what it is doing, and why. The best way to answer this is by reading the call stack.

    If it is several times slower than it should be, like 10 times, that means it is spending 90% of its time doing something unnecessary, and that is the probability you will catch it doing it. If you repeat this several times, you can confirm your suspicions with as much accuracy as you want.

    So you don't need an expensive / popular but fuzzy magnifying glass.

    So finding the reason for the slowness is not the hard part, and there are usually several.

    The hard part is, after you've fixed a few "low-hanging-fruits", you will probably have to face the fact that the main reason for the slowness is over-design.

    Good luck.

提交回复
热议问题