Performance numbers in the pub
Originally posted at 3/31/2011
I am currently sitting with 3 guys in the pub, and the discussion naturally turned to performance. I asked all three the following question: “How many CLR objects can you create in one second?”
I got the following replies:
- 2,000 objects per second
- 50,000 objects per second
- 100,000 objects per second
Then I sat down to check:
class Program { static void Main(string[] args) { var sp = Stopwatch.StartNew(); int i = 0; while(sp.ElapsedMilliseconds < 1000) { new MyClass(); i++; } sp.Stop(); Console.WriteLine("Created {0} in {1}", i, sp.Elapsed); } } public class MyClass { public string A; public int B; public DateTime C; }
The result?
Created 7,715,305 in 00:00:01

Comments
Comment preview