tech.clickhouse.benchmark.Basic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse-benchmark Show documentation
Show all versions of clickhouse-benchmark Show documentation
Benchmarks for ClickHouse clients
The newest version!
package tech.clickhouse.benchmark;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Collections;
import java.util.Random;
import org.openjdk.jmh.annotations.Benchmark;
public class Basic extends JdbcBenchmark {
@Benchmark
public int selectOneRandomNumber(ClientState state) throws Throwable {
final int num = new Random().nextInt(1000);
try (Statement stmt = executeQuery(state, "select ? as n", num)) {
ResultSet rs = stmt.getResultSet();
rs.next();
if (num != rs.getInt(1)) {
throw new IllegalStateException();
}
return num;
}
}
@Benchmark
public int insertOneRandomNumber(ClientState state) throws Throwable {
final int num = new Random().nextInt(1000);
return executeInsert(state, "insert into test_insert(i) values(?)",
Collections.enumeration(Collections.singletonList(new Object[] { num })));
}
}