You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Chen (Jira)" <ji...@apache.org> on 2019/11/01 09:08:00 UTC
[jira] [Commented] (COLLECTIONS-722)
IteratorUtils.chainedIterator() Performance Degrades
[ https://issues.apache.org/jira/browse/COLLECTIONS-722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16964728#comment-16964728 ]
Chen commented on COLLECTIONS-722:
----------------------------------
hi [~dragonmacher], I think you misusing the API in testcase ,cause IteratorUtils.chainedIterator(iterator, next) will create a new object ,so if you create 50 times , that you will get a 50 deepth object .
below is a new test
{code:java}
//代码占位符
@Test
public void testIteratorUtils_ChainedIteartorPerformance() {
Map<Integer, List<Integer>> source = new HashMap<>();
for (int i = 0; i < 50; i++) {
source.put(i, Arrays.asList(1, 2, 3));
}
Iterator<Integer> iterator = IteratorUtils.emptyIterator();
IteratorChain iteratorChain = (IteratorChain)IteratorUtils.chainedIterator(iterator);
Set<Entry<Integer, List<Integer>>> entries = source.entrySet();
for (Entry<Integer, List<Integer>> entry : entries) {
Iterator<Integer> next = entry.getValue().iterator();
iteratorChain.addIterator(next);
}
while (iteratorChain.hasNext()) {
System.out.println(iteratorChain.next());
}
}
{code}
> IteratorUtils.chainedIterator() Performance Degrades
> ----------------------------------------------------
>
> Key: COLLECTIONS-722
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-722
> Project: Commons Collections
> Issue Type: Bug
> Affects Versions: 4.1
> Reporter: E P
> Priority: Major
> Attachments: IteratorUtilsTest.java
>
>
> IteratorUtils.chainedIterator() performance degrades when chaining iterators with chained iterators. The slowdown appears to be exponential, based upon the number of chains created. The attached test shows the issue.
> As a reference, the same test below works as expected using Google's Guava Iterator.concat() functionality. It is possible I am misusing the API, but the javadoc did not indicate as much.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)