-
Enhancement
-
Resolution: Fixed
-
P5
-
8, 9
-
b56
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084034 | emb-9 | Paul Sandoz | P5 | Resolved | Fixed | team |
This isn't very useful for self-contained use cases (why not just get the size directly?), but comes up when you pass Stream or Supplier<Stream> objects between methods.
My performance test (the timing numbers aren't very useful, but definitely grow with size):
---
import java.util.*;
import java.util.stream.*;
public class StreamOptimization {
public static void main(String... args) {
for (int i = 100; i < 200_000_000; i = (int) (i * 1.3)) {
testArrayCount(i);
testListCount(i);
}
}
public static void testListCount(int i) {
List<Object> objs = new ArrayList<>(i);
for (int j = 0; j < i; j++) objs.add(null);
long start = System.currentTimeMillis();
long count = objs.stream().count();
long delta = System.currentTimeMillis() - start;
System.out.println("list count=" + count + "; time=" + delta);
}
public static void testArrayCount(int i) {
Object[] objs = new Object[i];
long start = System.currentTimeMillis();
long count = Arrays.stream(objs).count();
long delta = System.currentTimeMillis() - start;
System.out.println("array count=" + count + "; time=" + delta);
}
}
- backported by
-
JDK-8084034 Optimize Stream.count for SIZED Streams
-
- Resolved
-
- duplicates
-
JDK-8172393 Calculating count from sized double stream does not perform well in parallel streams
-
- Closed
-
- relates to
-
JDK-8080817 clarify specification of Stream.count()
-
- Closed
-
-
JDK-8075307 Pipeline calculating inconsistent flag state for parallel stateful ops
-
- Closed
-
-
JDK-8075256 Fix for JDK-8067969 results in some failing tests across all platforms.
-
- Closed
-
-
JDK-8198356 Stream method peek() doesn't execute on JDK9
-
- Closed
-
-
JDK-8067971 Support optimizations for always-true and always-false Predicates
-
- Closed
-