Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Foo
- {
- int x;
- public Foo(int x)
- {
- this.x = x;
- }
- }
- public class Test
- {
- static void Main(string[] args)
- {
- int length = int.Parse(args[0]);
- Foo x = new Foo(0);
- Foo[] array = new Foo[length];
- // Make sure that JITting the string constructor doesn't
- // change things
- long start = GC.GetTotalMemory(true);
- for (int i=0; i < length; i++)
- {
- array[i] = new Foo(i);
- }
- long end = GC.GetTotalMemory(true);
- GC.KeepAlive(array);
- GC.KeepAlive(x);
- decimal totalDecimal = end-start;
- Console.WriteLine(totalDecimal / length);
- }
- }
Add Comment
Please, Sign In to add comment