MCPcopy Create free account
hub / github.com/questdb/questdb / PerformanceTest

Class PerformanceTest

core/src/test/java/io/questdb/test/PerformanceTest.java:46–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44import java.util.concurrent.TimeUnit;
45
46public class PerformanceTest extends AbstractCairoTest {
47
48 private static final Log LOG = LogFactory.getLog(PerformanceTest.class);
49 private static final int TEST_DATA_SIZE = 1_000_000;
50 private long timeoutResult;
51
52 @Test
53 public void testCairoPartitionedReaderReloadSpeed() throws Exception {
54 assertMemoryLeak(() -> {
55 int operations = 1_00_000 * 100;
56 double speed = measureReloadSpeed(1_00_000, operations, 100000);
57
58 // Add 10x slowdown for slow / busy build server.
59 Assert.assertTrue("Total reload should be around 300 ms", TimeUnit.NANOSECONDS.toMillis((long) (operations * speed)) < 30000);
60 });
61 }
62
63 @Test
64 public void testCairoPerformance() throws Exception {
65 assertMemoryLeak(() -> {
66 int count = 10;
67 long t = 0;
68 long result;
69
70 String[] symbols = {"AGK.L", "BP.L", "TLW.L", "ABF.L", "LLOY.L", "BT-A.L", "WTB.L", "RRS.L", "ADM.L", "GKN.L", "HSBA.L"};
71 TableModel model = new TableModel(configuration, "quote", PartitionBy.NONE)
72 .timestamp()
73 .col("sym", ColumnType.SYMBOL)
74 .col("bid", ColumnType.DOUBLE)
75 .col("ask", ColumnType.DOUBLE)
76 .col("bidSize", ColumnType.INT)
77 .col("askSize", ColumnType.INT)
78 .col("mode", ColumnType.SYMBOL).symbolCapacity(2)
79 .col("ex", ColumnType.SYMBOL).symbolCapacity(2);
80 AbstractCairoTest.create(model);
81
82 try (TableWriter writer = newOffPoolWriter(configuration, "quote")) {
83 for (int i = -count; i < count; i++) {
84 if (i == 0) {
85 t = System.nanoTime();
86 }
87 writer.truncate();
88 long timestamp = DateFormatUtils.parseUTCDate("2013-10-05T10:00:00.000Z");
89 Rnd r = new Rnd();
90 int n = symbols.length - 1;
91 for (int i1 = 0; i1 < TEST_DATA_SIZE; i1++) {
92 TableWriter.Row row = writer.newRow(timestamp);
93 row.putSym(1, symbols[Math.abs(r.nextInt() % n)]);
94 row.putDouble(2, Math.abs(r.nextDouble()));
95 row.putDouble(3, Math.abs(r.nextDouble()));
96 row.putInt(4, Math.abs(r.nextInt()));
97 row.putInt(5, Math.abs(r.nextInt()));
98 row.putSym(6, "LXE");
99 row.putSym(7, "Fast trading");
100 row.append();
101 timestamp += 1000;
102 }
103 writer.commit();

Callers

nothing calls this directly

Calls 1

getLogMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…