Thursday, 21 May 2020

Running time of Java Iterator


Happy to see you after a long time. I have started working on Java collections and I have tried measuring retrieval time for each collection iterator types using 1000 records in Java 8 and found below time(in seconds) for iteration.

 List Name\Iterator types Iterator    Foreach For loop
 Array List 0.0856     0.044 0.0491
 Linked List 0.02867 0.0504 0.0467
 Vector 0.0342 0.0444 0.0584
 
I have also tried to use for-each lambda expression, this gives below time for each list collection:

Vector - 0.17455
Linked List - 0.17691
Array List - 0.18599

Retrieval time for binarySearch() in collection:

Vector - 0.00377
Linked List - 0.00377
Array List - 0.01069

No comments:

Post a Comment