using System.Diagnostics;
using System.Collections.Generic;
private static void Benchmark(Action act, int iterations)
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
Console.WriteLine((sw.ElapsedMilliseconds).ToString());
public static void Main(string[] args)
var list2 = new int[1000000];
Benchmark(() => { var x = list.Count(); }, loops);
Benchmark(() => { var x = list2.Count(); }, loops);
Benchmark(() => { var x = list.Length; }, loops);
Benchmark(() => { var x = list2.Length; }, loops);