Skip to content

Instantly share code, notes, and snippets.

@doom369
Last active August 5, 2020 12:29
Show Gist options
  • Save doom369/85fe46d6386d93f9b1f0ac3e154935c1 to your computer and use it in GitHub Desktop.
Save doom369/85fe46d6386d93f9b1f0ac3e154935c1 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 EqualsIgnoreCase {
@Param({"HELLO WORLD", "Hello World", "hello world", "otherParam"})
String strParams;
@Benchmark
public boolean equalsAndToLowerCase() {
return "hello world".equals(strParams.toLowerCase());
}
@Benchmark
public boolean equalsIgnoreCase() {
return "hello world".equalsIgnoreCase(strParams);
}
@Benchmark
public boolean equals() {
return "hello world".equals(strParams);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment