< prev index next >

test/jdk/java/util/Collection/IteratorMicroBenchmark.java

Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2021-01
Reviewed-by: martin


 343             .filter(job ->
 344                 nameFilter == null || nameFilter.matcher(job.name()).find())
 345             .collect(toCollection(ArrayList::new));
 346 
 347         if (reverse) Collections.reverse(jobs);
 348         if (shuffle) Collections.shuffle(jobs);
 349 
 350         time(jobs);
 351     }
 352 
 353     @SafeVarargs @SuppressWarnings("varargs")
 354     private static <T> Stream<T> concatStreams(Stream<T> ... streams) {
 355         return Stream.of(streams).flatMap(s -> s);
 356     }
 357 
 358     boolean isMutable(Collection<Integer> x) {
 359         return !(x.getClass().getName().contains("ImmutableCollections$"));
 360     }
 361 
 362     Stream<Job> jobs(Collection<Integer> x) {
 363         final String klazz = goodClassName(x);
 364         return concatStreams(
 365             collectionJobs(x),
 366 
 367             (isMutable(x))
 368             ? mutableCollectionJobs(x)
 369             : Stream.empty(),
 370 
 371             (x instanceof Deque)
 372             ? dequeJobs((Deque<Integer>)x)
 373             : Stream.empty(),
 374 
 375             (x instanceof List)
 376             ? listJobs((List<Integer>)x)
 377             : Stream.empty(),
 378 
 379             (x instanceof List && isMutable(x))
 380             ? mutableListJobs((List<Integer>)x)
 381             : Stream.empty());
 382     }
 383 




 343             .filter(job ->
 344                 nameFilter == null || nameFilter.matcher(job.name()).find())
 345             .collect(toCollection(ArrayList::new));
 346 
 347         if (reverse) Collections.reverse(jobs);
 348         if (shuffle) Collections.shuffle(jobs);
 349 
 350         time(jobs);
 351     }
 352 
 353     @SafeVarargs @SuppressWarnings("varargs")
 354     private static <T> Stream<T> concatStreams(Stream<T> ... streams) {
 355         return Stream.of(streams).flatMap(s -> s);
 356     }
 357 
 358     boolean isMutable(Collection<Integer> x) {
 359         return !(x.getClass().getName().contains("ImmutableCollections$"));
 360     }
 361 
 362     Stream<Job> jobs(Collection<Integer> x) {

 363         return concatStreams(
 364             collectionJobs(x),
 365 
 366             (isMutable(x))
 367             ? mutableCollectionJobs(x)
 368             : Stream.empty(),
 369 
 370             (x instanceof Deque)
 371             ? dequeJobs((Deque<Integer>)x)
 372             : Stream.empty(),
 373 
 374             (x instanceof List)
 375             ? listJobs((List<Integer>)x)
 376             : Stream.empty(),
 377 
 378             (x instanceof List && isMutable(x))
 379             ? mutableListJobs((List<Integer>)x)
 380             : Stream.empty());
 381     }
 382 


< prev index next >