While .NET is an incredible platform, that doesn’t mean that development projects always run smoothly. Today’s applications incorporate a greater range of technologies and are distributed across a larger number of systems and geographic locations than ever before. The fact is that, in such a climate, performance issues are part and parcel of the process. On the plus side, if you experience performance issues, it means that you have a lot of users and your project is successful. However, the bigger the project gets, the more complicated optimisation and performance become.
Performance issues can be very difficult, especially if you don’t have full visibility and can’t easily detect them. After all, as many people in the industry like to quote, you don’t know what you don’t know. Fortunately, there are tools that can show metrics from production, method execution times and slow database queries. Moreover, there are plenty of tools that can help you fix performance issues both locally and in the cloud. .NET developers need to ensure that applications operate at peak efficiency, which makes these performance-related tools vital. Read on for six types of developer tools that can make all the difference to your application’s performance.
1. Performance Counters
Performance counters are a Windows feature that enables you to record and publish systems and application performance metrics. You can monitor and analyse processes, threads, events, mutexes, semaphores and features of your own running programs. As performance counters are free and easy to use, they are a vital tool for keeping on top of performance-related issues.
There are hundreds of different counters that can be monitored, enabling you to be incredibly specific. However, some of the key categories of performance counters include:
- CPU and memory usage
- ASP.NET application
- Web traffic
- Exception and error rate
- Garbage collection
2. Performance Profilers
Another versatile tool is performance profilers, which can record your .NET process over an extended period of time and deliver visibility to what’s going on inside. In terms of performance analytics, you get to see all methods that were executed, the amount of time spent on each method and how many times each method was called. Performance profilers offer a great way to pinpoint performance issues in an application and are fundamental to optimising application performance.
3. Performance Analysis Tools
Performance analysis tools are able to perform performance profiling, memory profiling and a huge range of diagnostics reports on your .NET process. One of the most common is PerfView, an open-source analysis tool from Microsoft that relies on Event Tracing for Windows (ETW) events. The tool is incredibly customisable, allowing you to decide how much information to capture, the frequency information is captured and the maximum file capture size. However, it’s worth noting that it has a huge amount of settings which can be complicated to manage and stand in the way of you extracting the right insights.
4. Application Performance Management Tools
Application performance management (APM) tools give an inside view of application performance and health in production, much like a black box in an aeroplane. With an APM tool, you can see request counts and duration, database query durations and more. Some APM tools can even show code-level performance profiling information.
APMs are vital for detecting performance problems in production and allow you to find and investigate the slowest of requests. They work by installing lean agents on your production machines to collect ETW logs of your .NET process. Some of the most popular APM tools for .NET developers include:
- Application Insights (part of Azure Monitor)
- New Relic
5. Benchmarking Tools
Benchmarking tools enable you to create reproducible benchmarks and then measure them before and after changes are made. This is a great help as it allows you to gauge what aspect of performance you’re trying to fix as well as whether attempts to fix it actually help or not. The most popular benchmarking tool for .NET is BenchmarkDotNet, a .NET library that enables you to measure execution times and create benchmarks. It’s an incredible tool for optimising a method locally and deciding which implementation works best. While attempting to get accurate benchmark measurements can be tricky due to the complexity of CPUs and the CLR, BenchmarkDotNet handles all that for you. What’s more, it takes care of the tricky statistical calculations required to compensate for random variations between different benchmark runs. With BenchmarkDotNet, you can transform methods into benchmarks, track their performance and share reproducible experiments, and it’s as simple as writing unit tests. Results are presented in a user-friendly format, highlighting all the important facts from your experiment and allowing you to quickly make measurable improvements.
6. Performance Logs
While not thought of as one of the more powerful tools, performance logs form a crucial part of application performance management. Ultimately, they are the best source of production information and far more reliable and granular than information provided by tools such as APMs. Logs enable you to use simple stopwatches to log the time a method takes to run or how long a database query takes. By placing stopwatches in performance-critical areas of your code, or areas where you know there is a performance problem, you can quickly and easily see if your optimisation efforts deliver a measurable impact.
While these six categories of tools all help to deal with performance issues, they have specific functions and use cases. Some run locally and measure or detect problems, while others run in the production environments to gather real-usage data. Some collect information like CPU usage and memory levels, while others collect specific method execution and database query time durations. And finally, while some require minimal effort, others take more developer time but deliver more reliable results. However, what they have in common is that they all can help improve your .NET performance, ensure your app is optimised, and drive business growth.