What if this method were faster? Forecasting performance with dotTrace
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.
Subscribe to Blog updates
Thanks, we've got you!
Another Look into the Future with Rider’s Predictive Debugger
In the 2023.2 release cycle, we’ve introduced the Predictive Debugger in ReSharper, which gives you predictions about code paths and variables beyond the current execution pointer. We’ve written extensively about its advantages compared to alternative debugging strategies like thorough thinking, log…
Visualize Entity Framework Relationships and Additional Query Analysis in ReSharper 2023.3
A lot of teams are using Entity Framework or EF Core to work with their database. As an Object-Relational Mapper (ORM), it bridges objects in code to a relational database model, so that as a developer you don’t have to worry too much about the actual database. We all know: that’s not entirely tr…
Automatically Analyze ASP.NET Core Performance With Dynamic Program Analysis
Slow web pages may make your users or customers abandon your web application, even before they’ve had a proper look at it. You’ve likely also been frustrated working with a web application that is slow to load. The good news is that the latest versions of ReSharper and JetBrains Rider’s Dynamic P…
OSS Power-Ups: MassTransit – Webinar Recording
The recording of our webinar, OSS Power-Ups: MassTransit, with Chris Patterson, is available. This was the thirteenth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.…