Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 11
    @Viacheslav : very nice answer. Just wondering how Java8 apis are hindered, in your benchmark, by capturing lambdas... (e.g. long sum = 0; map.forEach( /* accumulate in variable sum*/); captures the sum long, which may be slower than say stream.mapToInt(/*whatever*/).sum for example. Of course you can not always avoid capturing state, but that may be a reasonnable addition to the bench. Commented May 12, 2016 at 11:53
  • 67
    @ZhekaKozlov: look at the mindblowingly large error values. Consider that a test result of x±e implies that there were result within the interval from x-e to x+e, so the fastest result (1184.767±332.968) ranges from 852 to 1518, whereas the second slowest (1706.676±436.867) runs between 1270 and 2144, so the results still overlap significantly. Now look at the slowest result, 3289.866±1445.564, which implies diverging between 1844 and 4735 and you know that these test results are meaningless. Commented Mar 17, 2017 at 18:28
  • 8
    What about comparing the 3 main implementations : HashMap, LinkedHashMap and TreeMap ? Commented Nov 7, 2017 at 23:37
  • 25
    #1 and #6 are exactly the same. Using while vs. a for loop is not a different technique for iterating. And I am surprised they have such variation between them in your tests—which suggests that the tests are not properly isolated from external factors unrelated to the things you intend to be testing. Commented Jul 14, 2018 at 19:04
  • 9
    #8 is a terrible example, because of the parallel there's now a race condition when adding to i. Commented Jan 2, 2019 at 13:00