Skip to content

Instantly share code, notes, and snippets.

@shelajev
Created June 26, 2018 12:29
Show Gist options
  • Select an option

  • Save shelajev/5d30c6c82e48fbe8a401d1b74757267d to your computer and use it in GitHub Desktop.

Select an option

Save shelajev/5d30c6c82e48fbe8a401d1b74757267d to your computer and use it in GitHub Desktop.
Streams.java
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