Created
August 29, 2020 21:36
-
-
Save doom369/5563e5ca5532c9714e90ae3e89c3630c 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
@BenchmarkMode(Mode.AverageTime) | |
@Fork(1) | |
@State(Scope.Thread) | |
@Warmup(iterations = 5, time = 1) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@Measurement(iterations = 10, time = 1) | |
public class ReplaceAllPrecompiled { | |
@Param({"", "somePathNoDoT", "some.Path.With.Dot"}) | |
String value; | |
private static final Pattern DOT_PATTERN = Pattern.compile("\\."); | |
@Benchmark | |
public String replaceAllWithPrecompiled() { | |
return DOT_PATTERN.matcher(value).replaceAll("%2E"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment