title: Iterating HashSet of size 10 takes 7-8 seconds
body: <p>I have an JPA entity A which has a many to one relation with JPA entity B. In the A.java class I have a @OneToMany mapping to B and a private HashSet data member.
  When I fetch all entities A from the DB, and for each entity A I iterate over all Bs it has a relation with. The code is below.</p>
  <pre><code>List&lt;A&gt; allAs = getAllAs()
  for(A a : allAs)
  {
    HashSet&lt;B&gt; allBs = a.getAllBs()
    LOG.(X1)
    for(B b : allBs)
    {
      LOG.(X2)
      // doing something
    }
  }
  </code></pre>
  <p>For the first iteration for both the loops(when both are in their first iteration simultaneously ) the time diff between X1 and X2 is 7-8 seconds. The size of all Lists and Sets is less than 20. I have no idea what the CPU is doing between the Log X1 and X2. Anyone know if it takes some extra time for CPU to fetch iterator for HashSet(sounds ridiculous, I know). This is very puzzling for me, if anyone has any clues please let me know.</p>