22
33import com .clickhouse .client .api .Client ;
44import com .clickhouse .client .api .enums .Protocol ;
5+ import com .clickhouse .client .api .insert .InsertResponse ;
6+ import com .clickhouse .client .api .metrics .OperationMetrics ;
57import com .clickhouse .client .api .query .GenericRecord ;
68import com .clickhouse .client .insert .InsertTests ;
79import com .clickhouse .client .query .QueryTests ;
10+ import com .clickhouse .data .ClickHouseFormat ;
811import org .openjdk .jmh .annotations .*;
912import org .slf4j .Logger ;
1013import org .slf4j .LoggerFactory ;
1114import org .testng .Assert ;
1215
16+ import java .io .ByteArrayInputStream ;
17+ import java .io .ByteArrayOutputStream ;
18+ import java .io .IOException ;
19+ import java .io .PrintWriter ;
1320import java .util .concurrent .TimeUnit ;
1421
1522import static com .clickhouse .client .ClickHouseServerForTest .isCloud ;
23+ import static org .testng .Assert .assertEquals ;
1624
1725@ BenchmarkMode (Mode .SampleTime )
1826@ OutputTimeUnit (TimeUnit .MILLISECONDS )
@@ -28,12 +36,15 @@ public class ClientBenchmark {
2836 private Client newClient ;
2937 private Client oldClient ;
3038
39+ private InsertTests insertTests ;
40+ private QueryTests queryTests ;
41+
3142 public static void main (String [] args ) throws Exception {
3243 org .openjdk .jmh .Main .main (args );
3344 }
3445
3546 @ Setup
36- public void setup () {
47+ public void setup () throws IOException {
3748 BaseIntegrationTest .setupClickHouseContainer ();
3849
3950 ClickHouseNode node = ClickHouseServerForTest .getClickHouseNode (ClickHouseProtocol .HTTP , isCloud (), ClickHouseNode .builder ().build ());
@@ -55,12 +66,20 @@ public void setup() {
5566 .useHttpCompression (false )
5667 .useNewImplementation (true )
5768 .build ();
69+
70+ queryTests = new QueryTests (false , false );
71+ queryTests .setUp ();
72+
73+ insertTests = new InsertTests (false , false );
74+ insertTests .setUp ();
5875 }
5976
6077 @ TearDown
6178 public void tearDown () {
6279 oldClient .close ();
6380 newClient .close ();
81+ insertTests .tearDown ();
82+ queryTests .tearDown ();
6483 BaseIntegrationTest .teardownClickHouseContainer ();
6584 }
6685
@@ -77,28 +96,19 @@ public void pingBenchmark() {
7796 @ Benchmark
7897 public void queryBenchmarkSmall () throws Exception {
7998 LOGGER .info ("(V2) Query benchmark" );
80- QueryTests queryTests = new QueryTests (false , false );
81- queryTests .setUp ();
8299 queryTests .testQueryAllSimple (SMALL_SIZE );
83- queryTests .tearDown ();
84100 }
85101
86102 @ Benchmark
87103 public void queryBenchmarkMedium () throws Exception {
88104 LOGGER .info ("(V2) Query benchmark" );
89- QueryTests queryTests = new QueryTests (false , false );
90- queryTests .setUp ();
91105 queryTests .testQueryAllSimple (MEDIUM_SIZE );
92- queryTests .tearDown ();
93106 }
94107
95108 @ Benchmark
96109 public void queryBenchmarkLarge () throws Exception {
97110 LOGGER .info ("(V2) Query benchmark" );
98- QueryTests queryTests = new QueryTests (false , false );
99- queryTests .setUp ();
100111 queryTests .testQueryAllSimple (LARGE_SIZE );
101- queryTests .tearDown ();
102112 }
103113
104114 @ Threads (4 )
@@ -152,36 +162,45 @@ public void queryBenchmarkLargeParallelNewImpl() throws Exception {
152162 @ Benchmark
153163 public void insertRawDataBenchmarkSmall () throws Exception {
154164 LOGGER .info ("(V2) Insert raw data benchmark" );
155- InsertTests insertTests = new InsertTests (false , false );
156- insertTests .setUp ();
157165 insertTests .insertRawDataSimple (SMALL_SIZE );
158- insertTests .tearDown ();
159166 }
160167
161168 @ Benchmark
162169 public void insertRawDataBenchmarkMedium () throws Exception {
163170 LOGGER .info ("(V2) Insert raw data benchmark" );
164- InsertTests insertTests = new InsertTests (false , false );
165- insertTests .setUp ();
166171 insertTests .insertRawDataSimple (MEDIUM_SIZE );
167- insertTests .tearDown ();
168172 }
169173
170174 @ Benchmark
171175 public void insertRawDataBenchmarkLarge () throws Exception {
172176 LOGGER .info ("(V2) Insert raw data benchmark" );
173- InsertTests insertTests = new InsertTests (false , false );
174- insertTests .setUp ();
175177 insertTests .insertRawDataSimple (LARGE_SIZE );
176- insertTests .tearDown ();
178+ }
179+
180+ @ Threads (4 )
181+ @ Benchmark
182+ public void insertRawDataBenchmarkSmallParallel () throws Exception {
183+ LOGGER .info ("(V2) Insert raw data parallel benchmark" );
184+ insertTests .insertRawDataSimple (SMALL_SIZE );
185+ }
186+
187+ @ Threads (4 )
188+ @ Benchmark
189+ public void insertRawDataBenchmarkMediumParallel () throws Exception {
190+ LOGGER .info ("(V2) Insert raw data parallel benchmark" );
191+ insertTests .insertRawDataSimple (MEDIUM_SIZE );
192+ }
193+
194+ @ Threads (4 )
195+ @ Benchmark
196+ public void insertRawDataBenchmarkLargeParallel () throws Exception {
197+ LOGGER .info ("(V2) Insert raw data parallel benchmark" );
198+ insertTests .insertRawDataSimple (LARGE_SIZE );
177199 }
178200
179201 @ Benchmark
180202 public void insertSimplePojoBenchmark () throws Exception {
181203 LOGGER .info ("(V2) Insert simple pojo benchmark" );
182- InsertTests insertTests = new InsertTests (false , false );
183- insertTests .setUp ();
184204 insertTests .insertSimplePOJOs ();
185- insertTests .tearDown ();
186205 }
187206}
0 commit comments