using System;
using System.Drawing;
using System.Collections;
public class ArrayListTiming {
public static void Main() {
ArrayList arrayImp = new ArrayList();
Point p = new Point(34, 156);
int time1, time2;
Object o;
time1 = Environment.TickCount;
for(int i = 0; i < 100000; i++)
arrayImp.Add(p);
time2 = Environment.TickCount;
Console.WriteLine("Time for 100,000 adds: " + (time2 - time1));
time1 = Environment.TickCount;
for(int i = 0; i < 1000; i++)
arrayImp.Insert(50, p);
time2 = Environment.TickCount;
Console.WriteLine("Time for 1,000 adds at position 50: " + (time2 - time1));
time1 = Environment.TickCount;
for(int i = 0; i < 10000000; i++)
o = arrayImp[50];
time2 = Environment.TickCount;
Console.WriteLine ("Time for 10,000,000 gets at position 50: " + (time2 - time1));
}
}
|