Skip to content

Instantly share code, notes, and snippets.

@ashkrit
Created July 6, 2013 19:06
Dead code sample sing JHM
@GenerateMicroBenchmark
public void baseline() {
// do nothing, this is a baseline
}
@GenerateMicroBenchmark
public void measureWrong() {
// This is wrong: result is not used, and the entire computation is optimized out.
Math.log(x);
}
@GenerateMicroBenchmark
public double measureRight() {
// This is correct: the result is being used.
return Math.log(x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment