@@ -0,0 +1,2408 @@
+package org.postgresql.benchmark.statement;%0A%0Aimport org.openjdk.jmh.annotations.*;%0Aimport org.openjdk.jmh.infra.Blackhole;%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;%0Aimport org.postgresql.util.ConnectionUtil;%0A%0Aimport java.sql.*;%0Aimport java.util.Properties;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * Tests the performance of preparing, executing and performing a fetch out of a simple %22SELECT ?, ?, ... ?%22 statement.%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@BenchmarkMode(Mode.AverageTime)%0A@OutputTimeUnit(TimeUnit.MICROSECONDS)%0Apublic class ParseStatement %7B%0A    @Param(%7B%220%22, %221%22, %2210%22, %2220%22%7D)%0A    private int bindCount;%0A%0A    private Connection connection;%0A%0A    private String sql;%0A%0A    @Setup(Level.Trial)%0A    public void setUp() throws SQLException %7B%0A        Properties props = ConnectionUtil.getProperties();%0A%0A        connection = DriverManager.getConnection(ConnectionUtil.getURL(), props);%0A        StringBuilder sb = new StringBuilder();%0A        sb.append(%22SELECT %22);%0A        for (int i = 0; i %3C bindCount; i++) %7B%0A            if (i %3E 0) sb.append(',');%0A            sb.append('?');%0A        %7D%0A        sql = sb.toString();%0A    %7D%0A%0A    @TearDown(Level.Trial)%0A    public void tearDown() throws SQLException %7B%0A        connection.close();%0A    %7D%0A%0A    @Benchmark%0A    public Statement bindExecuteFetch(Blackhole b) throws SQLException %7B%0A        PreparedStatement ps = connection.prepareStatement(sql);%0A        for (int i = 1; i %3C= bindCount; i++) %7B%0A            ps.setInt(i, i);%0A        %7D%0A        ResultSet rs = ps.executeQuery();%0A        while (rs.next()) %7B%0A            for (int i = 1; i %3C= bindCount; i++) %7B%0A                b.consume(rs.getInt(i));%0A            %7D%0A        %7D%0A        rs.close();%0A        ps.close();%0A        return ps;%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws RunnerException %7B%0A        Options opt = new OptionsBuilder()%0A                .include(ParseStatement.class.getSimpleName())%0A                .addProfiler(GCProfiler.class)%0A                .detectJvmArgs()%0A                .build();%0A%0A        new Runner(opt).run();%0A    %7D%0A%7D%0A

add test for prepare-fetch-execute performance