Speeding up C # / application execution. NET

I am looking for methods to improve the performance of a C # / application. NET What I have found so far

  • Use ngen .
  • Caution when used as an operator
  • Caution when using the reflection API. It takes quite a while to load the dll with Assembly.LoadFrom().

What other tools / tips / good practices do you need to get in order to get the best performance from your C # /. NET program.

+5
source share
4 answers

ngen. . . "CLR #, ".

, . Red-Gate Ants, . , .

, , , .NET Framework. , - Asp.Net, 30 + .

+5

, .

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;
    }
}
+1

ngen, , DLL. , . , x86 x64. , JIT.

, . , -, db, . /, , XmlDocument Xml CLP ThreadPool , IDisposable, ...

+1
source

I once rewrote the code for several days to speed up the application, when in fact I discovered that CompareTothere was a bottleneck in my implementation that was called up thousands of times.

  • Use <a href = "> a profiler .
  • Do not waste time optimizing what does not matter (in your case).
  • Find out what does.
+1
source

All Articles