Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package playground;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
@Fork(value = 2) //, jvmArgsAppend = "-XX:TieredStopAtLevel=1")
@Measurement(iterations = 5)
@Warmup(iterations = 5)
public class CapturingLambda {
private Integer param;
public void setup() throws Exception {
param = 3;
public Integer returnParam() {
return param;
public Integer returnViaClosure() {
return call(() -> param);
public Integer call(Supplier<Integer> supplier) {
return supplier.get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.