I'm searching for methods to boost up C#/.NET application. What I found so far is
Assembly.LoadFrom()
.What else tools/tips/good practices do you have to get the best performance out of C#/.NET program.
First be careful with ngen. It might actually end up hurting performance. See Jeff Richter's book "CLR via C#, Third Edition" for more details.
Personally I will use a profiler when I need to performance tune my application. The one I prefer is Red-Gate Ants, but there are plenty of good ones on the market. However using these can be a bit tricky because they will produce a lot of noise.
Most of the problems I have seen are usually caused by the developer or overall architecture rather than the .Net Framework. For example an Asp.Net web application that requires 30+ calls to the Database just for the home page to load.
Memoize expensive functions when possible.
public static class Expensive
{
private static readonly ConcurrentDictionary<int, int> _map =
new ConcurrentDictionary<int, int>();
public static int Calculate(int n)
{
return _map.AddOrUpdate(n, Add, (key, value) => value);
}
static int Add(int key)
{
return 0;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With