public static void checkEmptyListAddSpeed(int quantity) { LinkedList<Temp> testLL = new LinkedList<Temp>(); Console.WriteLine("Procesing (with LinkedList). Please wait... \n"); stopWatchLL.Restart(); for (int i = 0; i < quantity; i++) { var a = new Temp(i, i, i, i); testLL.AddLast(a); } stopWatchLL.Stop(); tsLL = stopWatchLL.Elapsed; string elapsedTimeLL = String.Format("{0:00}.{1:000}", tsLL.Seconds, tsLL.Milliseconds); LinkedListUtils.printReportLL(elapsedTimeLL); }
public static void checkEmptyListAddSpeed(int quantity) { ArrayList testAL = new ArrayList(); Console.WriteLine("Procesing (with ArrayList). Please wait... \n"); stopWatchAL.Restart(); for (int i = 0; i < quantity; i++) { var a = new Temp(i, i, i, i); testAL.Add(a); } stopWatchAL.Stop(); tsAL = stopWatchAL.Elapsed; string elapsedTimeAL = String.Format("{0:00}.{1:000}", tsAL.Seconds, tsAL.Milliseconds); ArrayListUtils.printReportAL(elapsedTimeAL); }
public static void checkListInsertAtBeginningSpeed(int quantity, int newQuantity) { LinkedList<Temp> testLL = createLinkedList(quantity); Console.WriteLine("Procesing (with LinkedList). Please wait... \n"); stopWatchLL.Restart(); var curNode = testLL.First; for (int i = 0; i < newQuantity; i++) { var a = new Temp(i, i, i, i); testLL.AddAfter(curNode, a); } stopWatchLL.Stop(); tsLL = stopWatchLL.Elapsed; string elapsedTimeLL = String.Format("{0:00}.{1:000}", tsLL.Seconds, tsLL.Milliseconds); LinkedListUtils.printReportLL(elapsedTimeLL); }
public static LinkedList<Temp> createLinkedList(int quantity) { LinkedList<Temp> testLL = new LinkedList<Temp>(); for (int i = 0; i < quantity; i++) { var a = new Temp(i, i, i, i); testLL.AddLast(a); } return testLL; }
public static ArrayList createArrayList(int quantity) { ArrayList testAL = new ArrayList(); for (int i = 0; i < quantity; i++) { var a = new Temp(i, i, i, i); testAL.Add(a); } return testAL; }
public static void checkListInsertAtMiddleSpeed(int quantity, int newQuantity) { int mid = quantity / 2; ArrayList testAL = createArrayList(quantity); Console.WriteLine("Procesing (with ArrayList). Please wait... \n"); stopWatchAL.Restart(); for (int i = 0; i < newQuantity; i++) { var a = new Temp(i, i, i, i); testAL.Insert(mid, a); } stopWatchAL.Stop(); tsAL = stopWatchAL.Elapsed; string elapsedTimeAL = String.Format("{0:00}.{1:000}", tsAL.Seconds, tsAL.Milliseconds); ArrayListUtils.printReportAL(elapsedTimeAL); }