@Benchmark public void parallel_lazy_jdk() { Map<Alphagram, List<String>> groupBy = this.jdkWords.parallelStream().collect(Collectors.groupingBy(Alphagram::new)); groupBy.entrySet() .parallelStream() .map(Map.Entry::getValue) .filter(list -> list.size() >= SIZE_THRESHOLD) .sorted(Comparator.<List<String>>comparingInt(List::size).reversed()) .map(list -> list.size() + ": " + list) .forEach(e -> Assert.assertFalse(e.isEmpty())); }
@Benchmark public Position maxByQuantity_parallel_lazy_direct_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().max( QUANTITY_COMPARATOR_METHODREF).get(); }
@Benchmark public Position minByQuantity_parallel_lazy_direct_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().min( QUANTITY_COMPARATOR_METHODREF).get(); }
@Benchmark public Position maxByMarketValue_parallel_lazy_direct_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().max( MARKET_VALUE_COMPARATOR_METHODREF).get(); }
@Benchmark public Position minByQuantity_parallel_lazy_direct_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().min( QUANTITY_COMPARATOR_LAMBDA).get(); }
@Benchmark public Position maxByMarketValue_parallel_lazy_direct_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().max( MARKET_VALUE_COMPARATOR_LAMBDA).get(); }
@Benchmark public Position maxByQuantity_parallel_lazy_direct_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().max( QUANTITY_COMPARATOR_LAMBDA).get(); }
@Benchmark public Position minByMarketValue_parallel_lazy_direct_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().min( MARKET_VALUE_COMPARATOR_METHODREF).get(); }
@Benchmark public Position maxByMarketValue_parallel_lazy_collect_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.maxBy(MARKET_VALUE_COMPARATOR_METHODREF)).get(); }
@Benchmark public Position maxByMarketValue_parallel_lazy_collect_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.maxBy(MARKET_VALUE_COMPARATOR_LAMBDA)).get(); }
@Benchmark public Position minByQuantity_parallel_lazy_collect_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.minBy(QUANTITY_COMPARATOR_LAMBDA)).get(); }
@Benchmark public Map<Product, DoubleSummaryStatistics> aggregateByProduct_parallel_lazy_jdk() { Map<Product, DoubleSummaryStatistics> result = this.jdkPositions.parallelStream().collect( Collectors.groupingBy( Position::getProduct, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result); return result; }
@Benchmark public Map<String, Double> sumByCategory_parallel_lazy_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.groupingBy( Position::getCategory, Collectors.summingDouble(Position::getMarketValue))); }
@Benchmark public Position maxByQuantity_parallel_lazy_collect_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.maxBy(QUANTITY_COMPARATOR_METHODREF)).get(); }
@Benchmark public Map<Account, Double> sumByAccount_parallel_lazy_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.groupingBy( Position::getAccount, Collectors.summingDouble(Position::getMarketValue))); }
@Benchmark public Position maxByQuantity_parallel_lazy_collect_lambda_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.maxBy(QUANTITY_COMPARATOR_LAMBDA)).get(); }
@Benchmark public Position minByQuantity_parallel_lazy_collect_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.minBy(QUANTITY_COMPARATOR_METHODREF)).get(); }
@Benchmark public Map<String, DoubleSummaryStatistics> aggregateByCategory_parallel_lazy_jdk() { Map<String, DoubleSummaryStatistics> result = this.jdkPositions.parallelStream().collect( Collectors.groupingBy(Position::getCategory, Collectors.summarizingDouble(Position::getMarketValue))); Assert.assertNotNull(result); return result; }
@Benchmark public Map<Product, Double> sumByProduct_parallel_lazy_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.groupingBy( Position::getProduct, Collectors.summingDouble(Position::getMarketValue))); }
@Benchmark public Position minByMarketValue_parallel_lazy_collect_methodref_jdk() { return this.positions.getJdkPositions().parallelStream().collect( Collectors.minBy(MARKET_VALUE_COMPARATOR_METHODREF)).get(); }