Wednesday, October 27, 2004 - Posts

Generics Performance Results

Microsoft is going to release new collection classes in .NET Framework 2.0 which is equivalent to exisiting collections in 1.0 but rewritten to use generics. All this collections are placed under System.collections.generic namespace. I have done a test to find out the performance difference in using Arraylist and List<T> collection(equivalent of Arrarylist in .NET 2.0 written using generics) . In this test 30,00,000 items of various data types has been added to both the collections and all the items are retrieved back from the collections. This test basically finds out the performance improvement by using generics. Performance results are mentioned in milliseconds. The performance difference is very value type when compared to reference type. But for reference type also performance difference during fetch is huge

Note: To learn about generics, refer this article

Collection Name

Integer

String

Date Time

Custom Object

Add

Fetch

Add

Fetch

Add

Fetch

Add

Fetch

Arraylist

3860

3508

1482

786

5769

4848

1916

1778

List<T>

511

1474

1477

132

1158

4166

1328

722

 

Test setup: Windows 2003 server, .NET Framework 2.0 Beta1.

If you want to do the performance testing on your own, you can use this generics sample to test the performance between  various collections

with 0 Comments