C# 411 Launched! Software Senryu (Haiku)
Feb 28


Quick: How long does it take to construct one million C# objects?

Dr. Evil

1/4 second.

In the “old days,” a major knock against object-oriented programming (such as with C++) was the perceived overhead required to create and maintain objects in memory.  My how times have changed!

Given a simple three-property object as shown below:




class Person
{
    public string Name;
    public string Address;
    public DateTime Birthdate;
}

Amazingly, it takes an average of 0.25 seconds to create 1 million Person objects.  Of course times vary widely by PC, and most objects are much more complex and have initializers, but this simple test demonstrates how fast computers have become. 

For all you youngins out there, this story is equivalent to your grandparents walking to school uphill both ways.  You can roll your eyes now.




Copyright © 2007-8 Tiwebb Ltd. All rights reserved. This material may not be published, broadcast, rewritten or redistributed without explicit permission from Tiwebb Ltd.

One Response to “One Million Objects”

  1. Daily Find #37 | TechToolBlog Says:

    [...] One Million Objects in c# - How long do you thing it takes? Answer before clicking. [...]

Leave a Reply