Something NEW?.....Naaa...Not much.

↑ Grab this Headline Animator

Sunday 30 December 2007

Managed Code Performance, A Checklist - Part 3/3

String Operations
- Avoid inefficient string concatenation.
- Use + when the number of appends is known.
- Use StringBuilder when the number of appends is unknown.
- Treat StringBuilder as an accumulator
- Use the overloaded Compare method for case-insensitive string comparisons.

Arrays
- Prefer arrays to collections unless you need functionality
- Use strongly typed arrays.
- Use jagged arrays instead of multidimensional arrays

Collections
- Analyze your requirements before choosing the collection type.
- Intialize collections to the right size when you can.
- Consider enumerating overhead.
- Prefer to implement IEnumerable with optimistic concurrency.
- Consider boxing overhead.
- Consider for instead of foreach
- Implement strongly typed collections to prevent casting overhead.
-Be efficient with data in collections.

Reflection and LateBinding
- Prefer early binding and explicit types rather than reflection.
- Avoid late binding.
- Avoid using System.Object in performance critical code paths.
- Enable Option Explicit and Option Strict in VB.NET

Code Access Security
- Consider SupressUnManagedCodeSecurity for performance-critical, trusted scenarios.
- Prefer declarative demands rather than imperative demands.
- Consider using link demands rather than full demands for performance - critical, trusted scenarios.

Working Set Considerations
- Load only the assemblies you need.
- Consider assemblies that are being loaded as side effects.
- Reduce the number of application domains, and/or make assemblies shared assemblies.
- Reduce the number of threads.

Native Image Generator (Ngen.exe)
- Scenarios where startup time is paramount should consider Ngen.exe for their startup path.
- Scenarios that will benefit from the ability to share assemblies should adopt Ngen.exe
- Scenarios with limited or no sharing should not use Ngen.exe
- Do not use Ngen.exe for ASP.NET V1.0 and 1.1
- Consider Ngen.exe for ASP.NET V2.0
- Measure performance with and without Ngen.exe
- Regenerate your image when you ship new versions.
- Choose an appropriate base address

No comments: