Skip to content

Instantly share code, notes, and snippets.

@doom369
Created August 29, 2020 21:36
Show Gist options
  • Save doom369/5563e5ca5532c9714e90ae3e89c3630c to your computer and use it in GitHub Desktop.
Save doom369/5563e5ca5532c9714e90ae3e89c3630c 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 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