Skip to content

Commit 7cbf31f

Browse files
author
Paultagoras
committed
Adjusting V1 benchmarks
1 parent 3218361 commit 7cbf31f

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

clickhouse-client/src/test/java/com/clickhouse/client/ClientIntegrationTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,33 @@ public void testInsertWithCustomFormat() throws ClickHouseException {
19751975
}
19761976
}
19771977

1978+
@Test(groups = { "integration" })
1979+
public void testInsertRawDataSimple() throws Exception {
1980+
testInsertRawDataSimple(1000);
1981+
}
1982+
public void testInsertRawDataSimple(int numberOfRecords) throws Exception {
1983+
String tableName = "test_insert_raw_data_simple";
1984+
ClickHouseNode server = getServer();
1985+
sendAndWait(server, "DROP TABLE IF EXISTS " + tableName,
1986+
"CREATE TABLE IF NOT EXISTS "+ tableName + " (i Int16, f String) engine=MergeTree ORDER BY i");
1987+
try (ClickHouseClient client = getClient()) {
1988+
ClickHouseRequest.Mutation request = client.read(server).write().table(tableName).format(ClickHouseFormat.JSONEachRow);
1989+
ClickHouseConfig config = request.getConfig();
1990+
CompletableFuture<ClickHouseResponse> future;
1991+
try (ClickHousePipedOutputStream stream = ClickHouseDataStreamFactory.getInstance().createPipedOutputStream(config)) {
1992+
// start the worker thread which transfer data from the input into ClickHouse
1993+
future = request.data(stream.getInputStream()).execute();
1994+
for (int i = 0; i < numberOfRecords; i++) {
1995+
BinaryStreamUtils.writeBytes(stream, String.format("{\"i\": %s, \"\": \"JSON\"}", i).getBytes(StandardCharsets.UTF_8));
1996+
}
1997+
}
1998+
1999+
ClickHouseResponseSummary summary = future.get().getSummary();
2000+
Assert.assertEquals(summary.getWrittenRows(), numberOfRecords);
2001+
}
2002+
}
2003+
2004+
19782005
@Test(groups = { "integration" })
19792006
public void testInsertWithInputFunction() throws ClickHouseException {
19802007
ClickHouseNode server = getServer();

clickhouse-http-client/src/test/perf/com/clickhouse/client/ClientBenchmark.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
@Threads(1)
1616
public class ClientBenchmark {
1717
private static final Logger LOGGER = LoggerFactory.getLogger(ClientBenchmark.class);
18+
private static final int SMALL_SIZE = 1000;
19+
private static final int MEDIUM_SIZE = 1000000;
20+
private static final int LARGE_SIZE = 10000000;
1821

1922
@Setup
2023
public void setup() {
@@ -42,27 +45,41 @@ public void pingBenchmark() {
4245
public void queryBenchmarkSmall() throws Exception {
4346
LOGGER.info("(V1) Query benchmark");
4447
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
45-
apacheHttpConnectionImplTest.testQuery(1000);
48+
apacheHttpConnectionImplTest.testQuery(SMALL_SIZE);
4649
}
4750

4851
@Benchmark
4952
public void queryBenchmarkMedium() throws Exception {
5053
LOGGER.info("(V1) Query benchmark");
5154
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
52-
apacheHttpConnectionImplTest.testQuery(1000000);
55+
apacheHttpConnectionImplTest.testQuery(MEDIUM_SIZE);
5356
}
5457

5558
@Benchmark
5659
public void queryBenchmarkLarge() throws Exception {
5760
LOGGER.info("(V1) Query benchmark");
5861
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
59-
apacheHttpConnectionImplTest.testQuery(1000000000);
62+
apacheHttpConnectionImplTest.testQuery(LARGE_SIZE);
6063
}
6164

6265
@Benchmark
63-
public void insertRawDataBenchmark() throws Exception {
66+
public void insertRawDataBenchmarkSmall() throws Exception {
6467
LOGGER.info("(V1) Insert raw data benchmark");
6568
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
66-
apacheHttpConnectionImplTest.testInsertWithCustomFormat();
69+
apacheHttpConnectionImplTest.testInsertRawDataSimple(SMALL_SIZE);
70+
}
71+
72+
@Benchmark
73+
public void insertRawDataBenchmarkMedium() throws Exception {
74+
LOGGER.info("(V1) Insert raw data benchmark");
75+
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
76+
apacheHttpConnectionImplTest.testInsertRawDataSimple(MEDIUM_SIZE);
77+
}
78+
79+
@Benchmark
80+
public void insertRawDataBenchmarkLarge() throws Exception {
81+
LOGGER.info("(V1) Insert raw data benchmark");
82+
ApacheHttpConnectionImplTest apacheHttpConnectionImplTest = new ApacheHttpConnectionImplTest();
83+
apacheHttpConnectionImplTest.testInsertRawDataSimple(LARGE_SIZE);
6784
}
6885
}

0 commit comments

Comments
 (0)