When profiling and analyzing performance of an application, we sometimes ask ourselves questions like, “What if this method were faster?”, “What would be the performance gain if we made this specific call 50% more efficient?”, and “Is it worth doing?”
One way to tell that would be to optimize that method and profile the application again – a time-consuming task that could involve changing the program structure without knowing if it makes sense to do so. The other option would be to ask dotTrace to reduce the method’s execution time and then recalculate function timings “as if” that method were optimized.
In the below snapshot, we can see the ExecuteRequest method takes up 4,90% of execution time and hence the entire thread’s call tree takes a good 6% of execution time. What if we modified this method to take 60% of its original time, simulating a 40% performance gain?
The execution time of our entire thread is now down to 4% of total execution time. Improving the ExecuteRequest method would clearly make a difference!
In the Adjust Time window, we can specify the target measure that should be optimized. In the example above, we optimized the total time this method takes to execute, including its children. Other options are to adjust timing for just the method itself. On a good day, we could also opt to optimize the total execution time of all methods in the selected class – good times!
Now what if we would optimize the daylight out of this method? In the Adjust Time context menu, we can opt to Optimize Current Instance (Del) or Optimize All Instances (Shift + Del), essentially setting the execution time of our method to zero.
That looks pretty slick! If we optimized the ExecuteRequest method to perform really fast, the execution time of our entire thread would go down to 2.59%!
Of course, all of that is based on assumptions. Now comes the tedious job of actually making it perform that fast. Still, dotTrace’s Adjust Time functionality lets us simulate performance optimizations and inspect their potential effect on the overall application, making it easier to decide which methods to optimize.