int nCmp = 0;System.Random rnd = new System.Random();
// measure the time required to sort a list of n integersvoid DoTest(int n){List<int> lst = new List<int>(n);for( int i=0; i<n; i++ )lst[i] = rnd.Next(0,1000);
// as we sort, keep track of the number of comparisons performed!nCmp = 0;lst.Sort( delegate( int a, int b ) { nCmp++; return (a<b)?-1:((a>b)?1:0)); }
System.Console.Writeline( "{0},{1}", n, nCmp );}
// Perform measurement for a variety of sample sizes.// It would be prudent to check multiple random samples of each size, but this is OK for a quick sanity checkfor( int n = 0; n<1000; n++ )DoTest(n);