Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active December 18, 2015 20:48
Show Gist options
  • Save hagbarddenstore/5842290 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/5842290 to your computer and use it in GitHub Desktop.
It took 103 µs allocating an array with size 4000000
It took 37441 µs allocating an array with size 4000000
It took 43746 µs allocating an array with size 4000000
It took 42006 µs allocating an array with size 4000000
It took 41468 µs allocating an array with size 4000000
It took 42477 µs allocating an array with size 4000000
It took 43270 µs allocating an array with size 4000000
It took 41336 µs allocating an array with size 4000000
It took 42487 µs allocating an array with size 4000000
It took 41911 µs allocating an array with size 4000000
public static void Main(string[] args)
{
for (var i = 0; i < 10; i++)
{
var stopwatch = Stopwatch.StartNew();
var strings = new string[4000000];
stopwatch.Stop();
Debug.WriteLine("It took {0} µs allocating an array with size {1}", stopwatch.Elapsed.Ticks / (Stopwatch.Frequency / 1000000), strings.Length);
}
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment