Tuesday 24 February 2015

ASP.NET Tips #25 - Profile, don’t speculate!

Performance is something you should be concerned with from the start, by following best practices and general guidelines, rather than focusing on nitty gritty details. However, there often comes a time where you need to optimize your code to make it faster.

It's tempting to rely on your gut and focus on spots of code that you think are slow, but if you do that you run the risk of speeding up code that doesn't make much difference to overall performance. After all, even if you double the performance of code that only executes for 1% of overall time, the end result will be negligible.

Don’t speculate. Use code profilers to measure where time is being spent (either optimize for speed or for memory use), so you can focus your energy on the optimizations that will have the greatest impact on the overall performance of your system.

When in production, carefully consider what you need to log

Many people deploy to production without checking how logging is currently configured. It is always advisable to check whether your policy is to have logging on or off by default and, if on, what level you should be targeting. In addition, you should check which targets you are outputting to, what archiving strategy you have, and whether your logging infrastructure allows for async logging.

No comments :

Post a Comment