开发者

Where can I find performance metrics (big-Oh notation) for different java containers?

When deciding to use a specific container (List/Set/Map), I like to consider the performance (big-Oh notation) metrics of operations such as insert, delete, get, etc. This is so I can select the best container for my needs.

The API docs always specify synchronized/unsynchronized, but not other performance metrics.

Is there a table of reference anywhere that I ca开发者_如何学Pythonn consult?


Java Generics and Collections contains such data for all collection implementations.


If you look at a specific implementation of one of the interfaces, it will give you performance information. Looking at ArrayList for example, you can read this:

The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜