Skip to content

Commit 0053579

Browse files
committed
Recreate table in benchmark
1 parent 53609ce commit 0053579

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

core/src/test/java/io/questdb/client/test/cutlass/line/tcp/v4/QwpAllocationTestClient.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
import io.questdb.client.Sender;
2828

2929
import java.io.IOException;
30+
import java.sql.Connection;
31+
import java.sql.DriverManager;
32+
import java.sql.Statement;
3033
import java.time.temporal.ChronoUnit;
34+
import java.util.Properties;
3135
import java.util.concurrent.TimeUnit;
3236

3337
/**
@@ -95,6 +99,7 @@ public class QwpAllocationTestClient {
9599
"AAPL", "GOOGL", "MSFT", "AMZN", "META", "NVDA", "TSLA", "BRK.A", "JPM", "JNJ",
96100
"V", "PG", "UNH", "HD", "MA", "DIS", "PYPL", "BAC", "ADBE", "CMCSA"
97101
};
102+
private static final String TABLE_NAME = "ilp_alloc_test";
98103

99104
public static void main(String[] args) {
100105
// Parse command-line options
@@ -173,6 +178,7 @@ public static void main(String[] args) {
173178
System.out.println();
174179

175180
try {
181+
recreateTable(host);
176182
runTest(protocol, host, port, totalRows, batchSize, flushBytes, flushIntervalMs,
177183
inFlightWindow, maxDatagramSize, warmupRows, reportInterval, targetThroughput);
178184
} catch (Exception e) {
@@ -286,6 +292,35 @@ private static void printUsage() {
286292
System.out.println(" QwpAllocationTestClient --protocol=ilp-tcp --rows=100000 --no-warmup");
287293
}
288294

295+
private static void recreateTable(String host) throws Exception {
296+
Properties properties = new Properties();
297+
properties.setProperty("user", "admin");
298+
properties.setProperty("password", "quest");
299+
properties.setProperty("sslmode", "disable");
300+
String url = "jdbc:postgresql://" + host + ":8812/qdb";
301+
try (Connection conn = DriverManager.getConnection(url, properties);
302+
Statement st = conn.createStatement()
303+
) {
304+
st.execute("DROP TABLE IF EXISTS " + TABLE_NAME);
305+
st.execute("CREATE TABLE " + TABLE_NAME + " ("
306+
+ " timestamp TIMESTAMP,"
307+
+ " exchange SYMBOL,"
308+
+ " currency SYMBOL,"
309+
+ " trade_id LONG,"
310+
+ " volume LONG,"
311+
+ " price DOUBLE,"
312+
+ " bid DOUBLE,"
313+
+ " ask DOUBLE,"
314+
+ " sequence LONG,"
315+
+ " spread DOUBLE,"
316+
+ " venue VARCHAR,"
317+
+ " is_buy BOOLEAN,"
318+
+ " event_time TIMESTAMP"
319+
+ ") TIMESTAMP(timestamp) PARTITION BY DAY WAL");
320+
}
321+
System.out.println("Recreated table " + TABLE_NAME);
322+
}
323+
289324
private static void runTest(String protocol, String host, int port, int totalRows,
290325
int batchSize, int flushBytes, long flushIntervalMs,
291326
int inFlightWindow, int maxDatagramSize,
@@ -345,9 +380,9 @@ private static void runTest(String protocol, String host, int port, int totalRow
345380
long now = System.nanoTime();
346381
long elapsedSinceReport = now - lastReportTime;
347382
int rowsSinceReport = (i + 1) - lastReportRows;
348-
double rowsPerSec = rowsSinceReport / (elapsedSinceReport / 1_000_000_000.0);
383+
int rowsPerSec = (int) (rowsSinceReport / (elapsedSinceReport / 1_000_000_000.0));
349384

350-
System.out.printf("Progress: %,d / %,d rows (%.1f%%) - %.0f rows/sec%n",
385+
System.out.printf("Progress: %,d / %,d rows (%.1f%%) - %,d rows/sec%n",
351386
i + 1, totalRows,
352387
(i + 1) * 100.0 / totalRows,
353388
rowsPerSec);
@@ -386,7 +421,7 @@ private static void sendRow(Sender sender, int rowIndex) {
386421
long baseTimestamp = 1704067200000000L; // 2024-01-01 00:00:00 UTC in micros
387422
long timestamp = baseTimestamp + (rowIndex * 1000L) + (rowIndex % 100);
388423

389-
sender.table("ilp_alloc_test")
424+
sender.table(TABLE_NAME)
390425
// Symbol columns
391426
.symbol("exchange", SYMBOLS[rowIndex % SYMBOLS.length])
392427
.symbol("currency", rowIndex % 2 == 0 ? "USD" : "EUR")

0 commit comments

Comments
 (0)