Created
July 7, 2013 12:19
-
-
Save ashkrit/5943293 to your computer and use it in GitHub Desktop.
This file contains 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
private double x = Math.PI; | |
@GenerateMicroBenchmark | |
public void baseline() { | |
// do nothing, this is a baseline | |
} | |
@GenerateMicroBenchmark | |
public double measureWrong() { | |
// This is wrong: the result is provably the same, optimized out. | |
return Math.log(Math.PI); | |
} | |
@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