SharePoint world of ECM and Information Management

.NET Tips: Perfomance

back to content

INFO:

  • There is very small performance difference in reversing array between Array.Reverse and changing values manually (although several manuals declare than Array.Reverse is two times slower). Such rumors relates to foreach vs for for iterating - there is no difference too.

·       Members of BCL generic collection are non virtual due to performance.

·       P/Invoke takes ~10 instructions, COM interop takes ~50 instructions.

·       GC costs: gen0 - between 0 and 10ms; gen1 - between 10 and 30 ms.

·       A thread context switch costs 2,000–8,000 cycles. >>

·       The cost of lock() is about 243 CPU cycles, ReaderWriterLock - 1,130 cycles, and Mutex is 9,800 cycles. >>

·       The cost of creating a Windows thread is about 200,000 cycles, whereas the cost of destroying one is about 100,000 cycles. >>

·       Delegate invocation is about 4 time faster in .net 2.0 over .net 1.1.

·       The length of a CPU quantum varies based on the OS type and configuration, but it will generally be around 20ms for client platforms and 120ms for server platforms. >>

·       The static call is about 10ns faster because no needs to pass the "this" pointer. Actually the this pointer is not passed on the stack, managed code used the CLR calling convention when calling instance methods, here the this pointer and the first argument (if any) are passed in a register. (msnewsgroups)

·       New threads in ThreadPool are created with 500ms delay, if "minimum" number of threads was surpassed.

 

TIPS:

·       Using [ThreadStatic] with the Dictionary in 2 times faster than Thread.GetData/SetData.

·       When a strongly named assembly is loaded from a location other than the GAC the CLR hash of the file is performed each time when the assembly is loaded. This lead us to the performance hit .

·       NameValueCollection is about 2 times slower that Hashtable in lookup due to delegates the hash key lookups to an internal Hashtable; and about 8 time slower in index-based lookups. >>

 

back to content

Leave a Comment

(required) 

(required) 

(optional)

(required)