@@ -0,0 +1,2337 @@
+package org.postgresql.benchmark.core;%0A%0Aimport org.openjdk.jmh.annotations.*;%0Aimport org.openjdk.jmh.profile.GCProfiler;%0Aimport org.openjdk.jmh.runner.Runner;%0Aimport org.openjdk.jmh.runner.RunnerException;%0Aimport org.openjdk.jmh.runner.options.Options;%0Aimport org.openjdk.jmh.runner.options.OptionsBuilder;%0A%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * Tests the performance of %7B@link org.postgresql.core.Parser#unmarkDoubleQuestion%7D.%0A * This method is invoked at each query parse, so it might affect response times.%0A */%0A@Fork(value = 1, jvmArgsPrepend = %22-Xmx128m%22)%0A@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)%0A@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)%0A@State(Scope.Thread)%0A@Threads(1)%0A@BenchmarkMode(Mode.AverageTime)%0A@OutputTimeUnit(TimeUnit.NANOSECONDS)%0Apublic class Parser %7B%0A    @Param(%7B%221%22, %2210%22, %22100%22%7D)%0A    public int sqlSize;%0A%0A    @Param(%7B%22false%22, %22true%22%7D)%0A    public boolean withDoubleQuestionmark;%0A%0A    @Param(%2220%22)%0A    public int literalLength;%0A%0A    private String sql;%0A%0A    @Setup%0A    public void setup() %7B%0A        StringBuilder sb = new StringBuilder();%0A        sb.append(%22SELECT 1 where 1 ~?~%3E 2%22);%0A        for (int i = 0; i %3C sqlSize; i++) %7B%0A            // Double quotes%0A            sb.append(%22 %5C%22%22);%0A            for (int j = 0; j %3C literalLength; j++)%0A                sb.append('a');%0A            sb.append('%22');%0A%0A            sb.append(%22 '%22);%0A            for (int j = 0; j %3C literalLength/2; j++)%0A                sb.append('b');%0A            sb.append(%22''%22);%0A            for (int j = 0; j %3C literalLength/2; j++)%0A                sb.append('b');%0A            sb.append('%5C'');%0A%0A            sb.append(%22 /*%22);%0A            for (int j = 0; j %3C literalLength; j++)%0A                sb.append('c');%0A            sb.append(%22*/%22);%0A        %7D%0A%0A        if (withDoubleQuestionmark) sb.append(%22??%22);%0A        sql = sb.toString();%0A    %7D%0A%0A%0A    @Benchmark%0A    public String unmarkDoubleQuestion() %7B%0A        return org.postgresql.core.Parser.unmarkDoubleQuestion(sql, true);%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws RunnerException%0A    %7B%0A        Options opt = new OptionsBuilder()%0A                .include(Parser.class.getSimpleName())%0A                .addProfiler(GCProfiler.class)%0A                .detectJvmArgs()%0A                .build();%0A%0A        new Runner(opt).run();%0A    %7D%0A%7D%0A

add benchmark for Parser.unmarkDoubleQuestion