using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; namespace AlgorithmTest07_拆装箱 { class Program { static void Main(string[] args) { int n = 100000000; Stopwatch t1 = new Stopwatch(); Stopwatch t2 = new Stopwatch(); Console.WriteLine("测试值类型对象int"); t1.Start(); List<int> L = new List<int>(); for (int i = 0; i < n; i++) { L.Add(i); int x = L[i]; } t1.Stop(); Console.WriteLine(t1.ElapsedMilliseconds + "ms"); t2.Start(); ArrayList aL = new ArrayList(); for (int i = 0; i < n; i++) { aL.Add(i); int x = (int)aL[i]; } t2.Stop(); Console.WriteLine(t2.ElapsedMilliseconds + "ms"); Console.ReadKey(); } } }
|