From 0af11f7e804c36c34d62fc8ea210d94864b66c12 Mon Sep 17 00:00:00 2001 From: Stan Brubaker <120737309+stanbrub@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:46:02 -0600 Subject: [PATCH] Select/Update/DateTime Bechmark Improvements (#185) --- .../standard/formula/DateTimeFormulaTest.java | 12 +- .../standard/formula/InlineFormulaTest.java | 107 ++++++++++++++++++ .../tests/standard/select/SelectTest.java | 33 ------ .../tests/standard/update/UpdateTest.java | 40 ------- .../tests/standard/update/UpdateViewTest.java | 41 ------- .../tests/standard/update/ViewTest.java | 40 ------- 6 files changed, 114 insertions(+), 159 deletions(-) create mode 100644 src/it/java/io/deephaven/benchmark/tests/standard/formula/InlineFormulaTest.java delete mode 100644 src/it/java/io/deephaven/benchmark/tests/standard/select/SelectTest.java delete mode 100644 src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateTest.java delete mode 100644 src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateViewTest.java delete mode 100644 src/it/java/io/deephaven/benchmark/tests/standard/update/ViewTest.java diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/formula/DateTimeFormulaTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/formula/DateTimeFormulaTest.java index bd4779ac..9239d9f3 100644 --- a/src/it/java/io/deephaven/benchmark/tests/standard/formula/DateTimeFormulaTest.java +++ b/src/it/java/io/deephaven/benchmark/tests/standard/formula/DateTimeFormulaTest.java @@ -13,7 +13,7 @@ public class DateTimeFormulaTest { @Test public void now() { - setup(6, 40, 5); + setup(6, 35, 15); var q = "source.update(formulas=['New1 = now()'])"; runner.test("Now- now()", q, "int250"); } @@ -27,22 +27,24 @@ public void parseInstant() { @Test public void parseDuration() { - setup(3, 10, 2); + setup(2, 9, 1); var q = "source.update(formulas=['New1 = parseDuration(`PT4H52M14S`)'])"; runner.test("ParseDuration- PT Duration String", q, "int250"); } @Test public void parseLocalTime() { - setup(3, 10, 1); + setup(2, 7, 1); var q = "source.update(formulas=['New1 = parseLocalTime(`04:52:14.001`)'])"; runner.test("ParseLocalTime- Time String)", q, "int250"); } @Test public void epochNanosToZonedDateTime() { - setup(3, 8, 5); - var q = "source.update(formulas=['New1 = epochNanosToZonedDateTime(1000000, java.time.ZoneId.systemDefault())'])"; + setup(2, 11, 10); + var q = """ + source.update(formulas=['New1=epochNanosToZonedDateTime(1697240421926014741L,java.time.ZoneOffset.UTC)']) + """; runner.test("EpochNanosToZonedDateTime- Nanos Long and ZoneId", q, "int250"); } diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/formula/InlineFormulaTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/formula/InlineFormulaTest.java new file mode 100644 index 00000000..5152fd80 --- /dev/null +++ b/src/it/java/io/deephaven/benchmark/tests/standard/formula/InlineFormulaTest.java @@ -0,0 +1,107 @@ +/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ +package io.deephaven.benchmark.tests.standard.formula; + +import org.junit.jupiter.api.*; +import io.deephaven.benchmark.tests.standard.StandardTestRunner; + +/** + * Standard tests for running basic formulas (not functions) inline for select, update, view, update_view, etc. These + * tests aggregate the resulting values to make sure the formulas are actually run (as in the case of views). These + * tests are meant to be compared, and so use the same data. + */ +public class InlineFormulaTest { + final StandardTestRunner runner = new StandardTestRunner(this); + final String calc1col1 = "'New1 = (float)((int640 + int640) / 2)'"; + final String calc1cols2 = "'New1 = (float)((int640 + int250) / 2)'"; + final String calc2cols2 = "'New1 = (float)((int640 + int250) / 2)', 'New2 = int640 - int250'"; + + @BeforeEach + public void setup() { + runner.tables("source"); + } + + @Test + public void select1Calc1ColFormula() { + runner.setScaleFactors(160, 60); + var q = "source.select(['int640',${calcs}]).sum_by()".replace("${calcs}", calc1col1); + runner.test("Select-Sum- 1 Calc Using 1 Col", 1, q, "int640"); + } + + @Test + public void select1Calc2ColsFormula() { + runner.setScaleFactors(120, 50); + var q = "source.select(['int250','int640',${calcs}]).sum_by()".replace("${calcs}", calc1cols2); + runner.test("Select-Sum- 1 Calc Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void select2Calcs2ColsFormula() { + runner.setScaleFactors(120, 50); + var q = "source.select(['int250','int640',${calcs}]).sum_by()".replace("${calcs}", calc2cols2); + runner.test("Select-Sum- 2 Calcs Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void update1Calc1ColsFormula() { + runner.setScaleFactors(160, 130); + var q = "source.update([${calcs}]).sum_by()".replace("${calcs}", calc1col1); + runner.test("Update-Sum- 1 Calc Using 1 Col", 1, q, "int640"); + } + + @Test + public void update1Calc2ColsFormula() { + runner.setScaleFactors(140, 100); + var q = "source.update([${calcs}]).sum_by()".replace("${calcs}", calc1cols2); + runner.test("Update-Sum- 1 Calc Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void update2Calcs2ColsFormula() { + runner.setScaleFactors(110, 80); + var q = "source.update([${calcs}]).sum_by()".replace("${calcs}", calc2cols2); + runner.test("Update-Sum- 2 Calcs Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void view1Calc1ColFormula() { + runner.setScaleFactors(130, 120); + var q = "source.view(['int640',${calcs}]).sum_by()".replace("${calcs}", calc1col1); + runner.test("View-Sum- 1 Calc Using 1 Col", 1, q, "int640"); + } + + @Test + public void view1Calc2ColsFormula() { + runner.setScaleFactors(120, 120); + var q = "source.view(['int250','int640',${calcs}]).sum_by()".replace("${calcs}", calc1cols2); + runner.test("View-Sum- 1 Calc Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void view2Calcs2ColsFormula() { + runner.setScaleFactors(120, 100); + var q = "source.view(['int250','int640',${calcs}]).sum_by()".replace("${calcs}", calc2cols2); + runner.test("View-Sum- 2 Calcs Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void updateView1Calc1ColFormula() { + runner.setScaleFactors(140, 140); + var q = "source.update_view([${calcs}]).sum_by()".replace("${calcs}", calc1col1); + runner.test("UpdateView-Sum- 1 Calc Using 1 Col", 1, q, "int640"); + } + + @Test + public void updateView1Calc2ColsFormula() { + runner.setScaleFactors(120, 120); + var q = "source.update_view([${calcs}]).sum_by()".replace("${calcs}", calc1cols2); + runner.test("UpdateView-Sum- 1 Calc Using 2 Cols", 1, q, "int250", "int640"); + } + + @Test + public void updateView2Calcs2ColsFormula() { + runner.setScaleFactors(120, 120); + var q = "source.update_view([${calcs}]).sum_by()".replace("${calcs}", calc2cols2); + runner.test("UpdateView-Sum- 2 Calcs Using 2 Cols", 1, q, "int250", "int640"); + } + +} diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/select/SelectTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/select/SelectTest.java deleted file mode 100644 index 477451df..00000000 --- a/src/it/java/io/deephaven/benchmark/tests/standard/select/SelectTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ -package io.deephaven.benchmark.tests.standard.select; - -import org.junit.jupiter.api.*; -import io.deephaven.benchmark.tests.standard.StandardTestRunner; - -/** - * Standard tests for the select table operation. Creates a new in-memory table that includes one column for each - * argument - */ -public class SelectTest { - final StandardTestRunner runner = new StandardTestRunner(this); - - @BeforeEach - public void setup() { - runner.tables("source"); - } - - @Test - public void select1CalcUsing2Cols() { - runner.setScaleFactors(200, 40); - var q = "source.select(formulas=['New1 = (float)((int640 + int250) / 2)'])"; - runner.test("Select- 1 Calc Using 2 Cols", q, "int250", "int640"); - } - - @Test - public void select2CalcsUsing2Cols() { - runner.setScaleFactors(100, 20); - var q = "source.select(formulas=['New1 = (float)((int640 + int250) / 2)', 'New2 = int640 - int250'])"; - runner.test("Select- 2 Cals Using 2 Cols", q, "int250", "int640"); - } - -} diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateTest.java deleted file mode 100644 index 9f1fdc97..00000000 --- a/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ -package io.deephaven.benchmark.tests.standard.update; - -import org.junit.jupiter.api.*; -import io.deephaven.benchmark.tests.standard.StandardTestRunner; - -/** - * Standard tests for the update table operation. Creates a new table containing a new, in-memory column for each - * argument - */ -public class UpdateTest { - final StandardTestRunner runner = new StandardTestRunner(this); - - @BeforeEach - public void setup() { - runner.tables("source"); - } - - @Test - public void update1CalcUsing2Cols() { - runner.setScaleFactors(200, 40); - var q = "source.update(formulas=['New1 = (float)((int640 + int250) / 2)'])"; - runner.test("Update- 1 Calc Using 2 Cols", q, "int250", "int640"); - } - - @Test - public void update2CalcsInt() { - runner.setScaleFactors(100, 20); - var q = "source.update(formulas=['New1 = (float)((int640 + int250) / 2)', 'New2 = int640 - int250'])"; - runner.test("Update- 2 Calcs Using Int", q, "int250", "int640"); - } - - @Test - public void update2CalcsFloat() { - runner.setScaleFactors(100, 20); - var q = "source.update(formulas=['New1 = (float)((float5 + int250) / 2)', 'New2 = float5 - int250'])"; - runner.test("Update- 2 Calcs Using Float", q, "int250", "float5"); - } - -} diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateViewTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateViewTest.java deleted file mode 100644 index a0737bb8..00000000 --- a/src/it/java/io/deephaven/benchmark/tests/standard/update/UpdateViewTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ -package io.deephaven.benchmark.tests.standard.update; - -import org.junit.jupiter.api.*; -import io.deephaven.benchmark.tests.standard.StandardTestRunner; - -/** - * Standard tests for the update_view table operation. Creates a new table containing a new formula column for each - * argument - */ -public class UpdateViewTest { - final StandardTestRunner runner = new StandardTestRunner(this); - - @BeforeEach - public void setup() { - runner.setRowFactor(6); - runner.tables("source"); - } - - @Test - public void updateView1CalcUsing2Cols() { - runner.setScaleFactors(200, 40); - var q = "source.update_view(formulas=['New1 = (int640 + int250) / 2'])"; - runner.test("UpdateView- 1 Calc Using 2 Cols", q, "str250", "int250", "int640", "int1M"); - } - - @Test - public void updateView2CalcsInt() { - runner.setScaleFactors(100, 20); - var q = "source.update_view(formulas=['New1 = (int640 + int250) / 2', 'New2 = int1M - int640'])"; - runner.test("UpdateView- 2 Cals Using Int", q, "str250", "int250", "int640", "int1M"); - } - - @Test - public void updateView2CalcsFloat() { - runner.setScaleFactors(100, 20); - var q = "source.update_view(formulas=['New1 = (float5 + int250) / 2', 'New2 = int1M - float5'])"; - runner.test("UpdateView- 2 Calcs Using Float", q, "str250", "int250", "float5", "int1M"); - } - -} diff --git a/src/it/java/io/deephaven/benchmark/tests/standard/update/ViewTest.java b/src/it/java/io/deephaven/benchmark/tests/standard/update/ViewTest.java deleted file mode 100644 index ab6838c3..00000000 --- a/src/it/java/io/deephaven/benchmark/tests/standard/update/ViewTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ -package io.deephaven.benchmark.tests.standard.update; - -import org.junit.jupiter.api.*; -import io.deephaven.benchmark.tests.standard.StandardTestRunner; - -/** - * Standard tests for the view table operation. Creates a new formula table that includes one column for each argument - */ -public class ViewTest { - final StandardTestRunner runner = new StandardTestRunner(this); - - @BeforeEach - public void setup() { - runner.setRowFactor(6); - runner.tables("source"); - } - - @Test - public void view1CalcUsing2Cols() { - runner.setScaleFactors(200, 40); - var q = "source.view(formulas=['New1 = (int640 + int250) / 2'])"; - runner.test("View- 1 Calc Using 2 Cols", q, "str250", "int250", "int640", "int1M"); - } - - @Test - public void view2CalcsInt() { - runner.setScaleFactors(100, 20); - var q = "source.view(formulas=['New1 = (int640 + int250) / 2', 'New2 = int1M - int640'])"; - runner.test("View- 2 Cals Using 2 Cols", q, "str250", "int250", "int640", "int1M"); - } - - @Test - public void view2CalcsFloat() { - runner.setScaleFactors(100, 20); - var q = "source.view(formulas=['New1 = (float5 + int250) / 2', 'New2 = int1M - float5'])"; - runner.test("View- 2 Calcs Using Float", q, "str250", "int250", "float5", "int1M"); - } - -}