Created
June 26, 2018 12:29
-
-
Save shelajev/5d30c6c82e48fbe8a401d1b74757267d to your computer and use it in GitHub Desktop.
Streams.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.sample; | |
| import java.util.Arrays; | |
| import org.openjdk.jmh.annotations.*; | |
| @State(Scope.Benchmark) | |
| public class Streams { | |
| private double[] values = new double[2000000]; | |
| @Benchmark | |
| public double mapReduce() { | |
| return Arrays.stream(values) | |
| .map(x -> x + 1) | |
| .map(x -> x * 2) | |
| .map(x -> x + 5) | |
| .reduce(0, Double::sum); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment