Skip to content

Commit 513e226

Browse files
authored
feat: DH-19246 Added rolling formula benchmarks (#404)
1 parent f0024da commit 513e226

2 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Copyright (c) 2022-2026 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.updateby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the updateBy table operation. Defines a tick-based rolling formula. The result table contains
9+
* additional columns with windowed rolling formulas for each specified column in the source table.
10+
* <p>
11+
* Note: This test must contain benchmarks and <code>rev_ticks/fwd_ticks</code> that are comparable to
12+
* <code>RollingFormulaTimeTest</code>
13+
*/
14+
public class RollingFormulaTickTest {
15+
final StandardTestRunner runner = new StandardTestRunner(this);
16+
17+
void setup(int rowFactor, int staticFactor, int incFactor) {
18+
runner.setRowFactor(rowFactor);
19+
runner.setScaleFactors(staticFactor, incFactor);
20+
runner.tables("timed");
21+
var s = """
22+
from deephaven.updateby import rolling_formula_tick
23+
""";
24+
runner.addSetupQuery(s);
25+
}
26+
27+
@Test
28+
void rollingFormulaParamTick2Groups3Ops() {
29+
setup(2, 2, 1);
30+
runner.addSetupQuery("""
31+
contains = rolling_formula_tick(formula="avg(x)", formula_param="x", cols=["Contains=num1"],
32+
rev_ticks=20, fwd_ticks=30)
33+
""");
34+
var q = "timed.update_by(ops=[contains], by=['key1','key2'])";
35+
runner.test("RollingFormulaParamTick- 2 Groups 100K Unique Combos", q, "key1", "key2", "num1");
36+
}
37+
38+
@Test
39+
void rollingFormulaGeneralTick0Group3Ops() {
40+
setup(1, 1, 1);
41+
runner.addSetupQuery("""
42+
contains = rolling_formula_tick(formula="Contains=avg(num1)", rev_ticks=2000, fwd_ticks=3000)
43+
""");
44+
var q = "timed.update_by(ops=[contains])";
45+
runner.test("RollingFormulaGeneralTick- No Groups 1 Col", q, "num1");
46+
}
47+
48+
@Test
49+
void rollingFormulaGeneralTick1Group3Ops() {
50+
setup(3, 7, 2);
51+
runner.addSetupQuery("""
52+
contains = rolling_formula_tick(formula="Contains=avg(num1)", rev_ticks=20, fwd_ticks=30)
53+
""");
54+
var q = "timed.update_by(ops=[contains], by=['key1'])";
55+
runner.test("RollingFormulaGeneralTick- 1 Group 100 Unique Vals", q, "key1", "num1");
56+
}
57+
58+
@Test
59+
void rollingFormulaGeneralTick2Groups3Ops() {
60+
setup(2, 3, 1);
61+
runner.addSetupQuery("""
62+
contains = rolling_formula_tick(formula="Contains=avg(num1)", rev_ticks=20, fwd_ticks=30)
63+
""");
64+
var q = "timed.update_by(ops=[contains], by=['key1','key2'])";
65+
runner.test("RollingFormulaGeneralTick- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1");
66+
}
67+
68+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* Copyright (c) 2022-2025 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.updateby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the updateBy table operation. Defines a time-based rolling formula. The result table contains
9+
* additional columns with windowed rolling formulas for each specified column in the source table.
10+
* <p>
11+
* Note: This test must contain benchmarks and <code>rev_time/fwd_time</code> that are comparable to
12+
* <code>RollingFormulaTickTest</code>
13+
*/
14+
public class RollingFormulaTimeTest {
15+
final StandardTestRunner runner = new StandardTestRunner(this);
16+
final Setup setup = new Setup(runner);
17+
18+
void setup(int rowFactor, int staticFactor, int incFactor) {
19+
runner.setRowFactor(rowFactor);
20+
runner.setScaleFactors(staticFactor, incFactor);
21+
runner.tables("timed");
22+
var s = """
23+
from deephaven.updateby import rolling_formula_time
24+
""";
25+
runner.addSetupQuery(s);
26+
}
27+
28+
@Test
29+
void rollingFormulaParamTime2Groups3Ops() {
30+
setup(2, 2, 1);
31+
runner.addSetupQuery("""
32+
contains = rolling_formula_time(formula="avg(x)", formula_param="x", ts_col="timestamp",
33+
cols=["Contains=num1"], rev_time="PT4M", fwd_time="PT5M")
34+
""");
35+
var q = "timed.update_by(ops=[contains], by=['key1','key2'])";
36+
runner.test("RollingFormulaTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp");
37+
}
38+
39+
@Test
40+
void rollingFormulaGeneralTime0Group3Ops() {
41+
setup(1, 1, 1);
42+
runner.addSetupQuery("""
43+
contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT2S",
44+
fwd_time="PT3S")
45+
""");
46+
var q = "timed.update_by(ops=[contains])";
47+
runner.test("RollingFormulaGeneralTime- No Groups 1 Col", q, "num1", "timestamp");
48+
}
49+
50+
@Test
51+
void rollingFormulaGeneralTime1Group3Ops() {
52+
setup(3, 2, 1);
53+
runner.addSetupQuery("""
54+
contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT2S",
55+
fwd_time="PT3S")
56+
""");
57+
var q = "timed.update_by(ops=[contains], by=['key1'])";
58+
runner.test("RollingFormulaGeneralTime- 1 Group 100 Unique Vals", q, "key1", "num1", "timestamp");
59+
}
60+
61+
@Test
62+
void rollingFormulaGeneralTime2Groups3Ops() {
63+
setup(2, 2, 1);
64+
runner.addSetupQuery("""
65+
contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT4M",
66+
fwd_time="PT5M")
67+
""");
68+
var q = "timed.update_by(ops=[contains], by=['key1','key2'])";
69+
runner.test("RollingFormulaGeneralTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp");
70+
}
71+
72+
}

0 commit comments

Comments
 (0)