Skip to content

Instantly share code, notes, and snippets.

@doom369
Created September 1, 2020 09:11
Show Gist options
  • Save doom369/9bafb763e46d24b10fc988c7f3feff4b to your computer and use it in GitHub Desktop.
Save doom369/9bafb763e46d24b10fc988c7f3feff4b to your computer and use it in GitHub Desktop.

Revisions

  1. doom369 created this gist Sep 1, 2020.
    26 changes: 26 additions & 0 deletions RemoveChar.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    @BenchmarkMode(Mode.AverageTime)
    @Fork(1)
    @State(Scope.Thread)
    @Warmup(iterations = 5, time = 1)
    @OutputTimeUnit(TimeUnit.NANOSECONDS)
    @Measurement(iterations = 10, time = 1)
    public class RemoveChar {

    @Param({"", "somePathNoDoT", "some.Path.With.Dot"})
    String value;

    @Benchmark
    public String remove() {
    return value.replace(".", "");
    }

    @Benchmark
    public String removeApache() {
    return StringUtils.remove(value, '.');
    }

    @Benchmark
    public String removeSpring() {
    return springDelete(value, ".");
    }
    }