Skip to content

Commit c2cf841

Browse files
author
Paultagoras
committed
Adding variant tests
1 parent 7cbf31f commit c2cf841

File tree

2 files changed

+84
-4
lines changed

2 files changed

+84
-4
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.clickhouse.client;
22

33
import com.clickhouse.client.http.ApacheHttpConnectionImplTest;
4-
import com.clickhouse.client.http.ClickHouseHttpClientTest;
54
import org.openjdk.jmh.annotations.*;
65
import org.slf4j.Logger;
76
import org.slf4j.LoggerFactory;

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

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package com.clickhouse.client;
22

3+
import com.clickhouse.client.api.Client;
4+
import com.clickhouse.client.api.enums.Protocol;
5+
import com.clickhouse.client.api.query.GenericRecord;
36
import com.clickhouse.client.insert.InsertTests;
47
import com.clickhouse.client.query.QueryTests;
58
import org.openjdk.jmh.annotations.*;
69
import org.slf4j.Logger;
710
import org.slf4j.LoggerFactory;
11+
import org.testng.Assert;
812

913
import java.util.concurrent.TimeUnit;
1014

15+
import static com.clickhouse.client.ClickHouseServerForTest.isCloud;
16+
1117
@BenchmarkMode(Mode.SampleTime)
1218
@OutputTimeUnit(TimeUnit.MILLISECONDS)
1319
@State(Scope.Benchmark)
@@ -19,19 +25,46 @@ public class ClientBenchmark {
1925
private static final int MEDIUM_SIZE = 1000000;
2026
private static final int LARGE_SIZE = 10000000;
2127

28+
private Client newClient;
29+
private Client oldClient;
30+
31+
public static void main(String[] args) throws Exception {
32+
org.openjdk.jmh.Main.main(args);
33+
}
34+
2235
@Setup
2336
public void setup() {
2437
BaseIntegrationTest.setupClickHouseContainer();
38+
39+
ClickHouseNode node = ClickHouseServerForTest.getClickHouseNode(ClickHouseProtocol.HTTP, isCloud(), ClickHouseNode.builder().build());
40+
oldClient = new Client.Builder()
41+
.addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), false)
42+
.setUsername("default")
43+
.setPassword("")
44+
.compressClientRequest(false)
45+
.compressServerResponse(false)
46+
.useHttpCompression(false)
47+
.useNewImplementation(false)
48+
.build();
49+
newClient = new Client.Builder()
50+
.addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), false)
51+
.setUsername("default")
52+
.setPassword("")
53+
.compressClientRequest(false)
54+
.compressServerResponse(false)
55+
.useHttpCompression(false)
56+
.useNewImplementation(true)
57+
.build();
2558
}
2659

2760
@TearDown
2861
public void tearDown() {
62+
oldClient.close();
63+
newClient.close();
2964
BaseIntegrationTest.teardownClickHouseContainer();
3065
}
3166

32-
public static void main(String[] args) throws Exception {
33-
org.openjdk.jmh.Main.main(args);
34-
}
67+
3568

3669
// Add benchmark methods here
3770
@Benchmark
@@ -68,6 +101,54 @@ public void queryBenchmarkLarge() throws Exception {
68101
queryTests.tearDown();
69102
}
70103

104+
@Threads(4)
105+
@Benchmark
106+
public void queryBenchmarkSmallParallelOldImpl() throws Exception {
107+
LOGGER.info("(V2) Query parallel benchmark");
108+
GenericRecord record = oldClient.queryAll("SELECT number FROM system.numbers LIMIT " + SMALL_SIZE).stream().findFirst().get();
109+
Assert.assertNotNull(record);
110+
}
111+
112+
@Threads(4)
113+
@Benchmark
114+
public void queryBenchmarkMediumParallelOldImpl() throws Exception {
115+
LOGGER.info("(V2) Query parallel benchmark");
116+
GenericRecord record = oldClient.queryAll("SELECT number FROM system.numbers LIMIT " + MEDIUM_SIZE).stream().findFirst().get();
117+
Assert.assertNotNull(record);
118+
}
119+
120+
@Threads(4)
121+
@Benchmark
122+
public void queryBenchmarkLargeParallelOldImpl() throws Exception {
123+
LOGGER.info("(V2) Query parallel benchmark");
124+
GenericRecord record = oldClient.queryAll("SELECT number FROM system.numbers LIMIT " + LARGE_SIZE).stream().findFirst().get();
125+
Assert.assertNotNull(record);
126+
}
127+
128+
@Threads(4)
129+
@Benchmark
130+
public void queryBenchmarkSmallParallelNewImpl() throws Exception {
131+
LOGGER.info("(V2) Query parallel benchmark");
132+
GenericRecord record = newClient.queryAll("SELECT number FROM system.numbers LIMIT " + SMALL_SIZE).stream().findFirst().get();
133+
Assert.assertNotNull(record);
134+
}
135+
136+
@Threads(4)
137+
@Benchmark
138+
public void queryBenchmarkMediumParallelNewImpl() throws Exception {
139+
LOGGER.info("(V2) Query parallel benchmark");
140+
GenericRecord record = newClient.queryAll("SELECT number FROM system.numbers LIMIT " + MEDIUM_SIZE).stream().findFirst().get();
141+
Assert.assertNotNull(record);
142+
}
143+
144+
@Threads(4)
145+
@Benchmark
146+
public void queryBenchmarkLargeParallelNewImpl() throws Exception {
147+
LOGGER.info("(V2) Query parallel benchmark");
148+
GenericRecord record = newClient.queryAll("SELECT number FROM system.numbers LIMIT " + LARGE_SIZE).stream().findFirst().get();
149+
Assert.assertNotNull(record);
150+
}
151+
71152
@Benchmark
72153
public void insertRawDataBenchmarkSmall() throws Exception {
73154
LOGGER.info("(V2) Insert raw data benchmark");

0 commit comments

Comments
 (0)