Created
August 5, 2020 13:57
-
-
Save doom369/8680a3ce2c5b6cde8001896266da5559 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class StartsWith { | |
@Param({"http://facebook.com/loginMe", "Http://facebook.com/loginMe", "not url at all"}) | |
String url; | |
@Benchmark | |
public boolean regionMatches() { | |
return url.regionMatches(true, 0, "http", 0, "http".length()); | |
} | |
@Benchmark | |
public boolean toLowerCaseStartsWith() { | |
return url.toLowerCase().startsWith("http"); | |
} | |
@Benchmark | |
public boolean substringEqualsIgnoreCase() { | |
return url.substring(0, 4).equalsIgnoreCase("http"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment