Skip to content

Instantly share code, notes, and snippets.

@doom369
Created August 19, 2020 16:03
Show Gist options
  • Save doom369/64a41df972b60a067f02a0ba1f11e739 to your computer and use it in GitHub Desktop.
Save doom369/64a41df972b60a067f02a0ba1f11e739 to your computer and use it in GitHub Desktop.
@BenchmarkMode(Mode.AverageTime)
@Fork(1)
@State(Scope.Thread)
@Warmup(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Measurement(iterations = 10, time = 1)
public class EnumValues {
@Benchmark
public void enumValuesMethod(Blackhole bh) {
for (WidgetProperty property : WidgetProperty.values()) {
bh.consume(property);
}
}
@Benchmark
public void enumValuesVariable(Blackhole bh) {
for (WidgetProperty property : WidgetProperty.values) {
bh.consume(property);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment