public static void ArrayListTest() { ArrayList list = new ArrayList(); ITiming tObj = new StopWatchTiming(); tObj.StartTime(); Utility.BuildList(list); tObj.StopTime(); Console.WriteLine(tObj.Result().TotalSeconds); }
public static void MyCollectionTest() { MyCollection list = new MyCollection(); ITiming tObj = new StopWatchTiming(); tObj.StartTime(); Utility.BuildList(list); tObj.StopTime(); Console.WriteLine(tObj.Result().TotalSeconds); }
public static void Main1() { var path = Utility.FilePath; var length = 5000000; Utility.CreateRandomIntFile(length); StreamReader sr = File.OpenText(path); int[] arr = new int[length]; for (int i = 0; i < length - 1; i++) { arr[i] = Convert.ToInt32(sr.ReadLine(), 10); } int searchNumber; while (true) { Console.WriteLine("Enter a number"); searchNumber = Convert.ToInt32(Console.ReadLine()); //ITiming timing = new StopWatchTiming(); //timing.StartTime(); //var index = Utility.SeqSearch(arr, searchNumber); //timing.StopTime(); //Console.WriteLine("SeqSearch use time:" + timing.Result().TotalSeconds.ToString()); ITiming timing = new StopWatchTiming(); int index = -1; timing.ShowResult(() => index = Utility.SeqSearch(arr, searchNumber)); if (index >= 0) { Console.WriteLine("Found index:" + index); } else { Console.WriteLine("Can not found"); } } }
public static void Main2() { var arr = Utility.BuildSortedArray(5000000); while (true) { Console.WriteLine("Enter a number"); var searchNumber = Convert.ToInt32(Console.ReadLine()); ITiming timing = new StopWatchTiming(); int index = -1; timing.ShowResult(() => index = Utility.BinSearch(arr, searchNumber)); if (index >= 0) { Console.WriteLine("Found index:" + index); } else { Console.WriteLine("Can not found"); } } }
public static void Main1() { ITiming timing = new StopWatchTiming(); timing.ShowResult(Main1Impl);//100000, 32s, no showPrimes }