summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-02-26 18:16:37 +0100
committerMarco Cecchetti <marco.cecchetti@collabora.com>2016-02-26 18:16:37 +0100
commitfe57ffef468160757c7d598ebfa9f2d7ff2da8ef (patch)
tree72f09343a68c775242f87a57b1831b0113d7453a
parent3422b8804c2459fdd7f870ee300f2a81f3365d6c (diff)
sc - added fixed and variable array formula range perf testsprivate/mcecchetti/calc-perf-unit-test
Change-Id: Id81eee9f2258398831c86dfb57b2e0b4185e1d73
-rw-r--r--sc/qa/perf/scperfobj.cxx66
-rw-r--r--sc/qa/perf/testdocuments/scMathFunctions3.odsbin0 -> 55416 bytes
2 files changed, 65 insertions, 1 deletions
diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx
index 493072b9997f..1b7c4f1001dd 100644
--- a/sc/qa/perf/scperfobj.cxx
+++ b/sc/qa/perf/scperfobj.cxx
@@ -66,6 +66,8 @@ public:
CPPUNIT_TEST(testLcm);
CPPUNIT_TEST(testGcd);
CPPUNIT_TEST(testPearson);
+ CPPUNIT_TEST(testFixedSum);
+ CPPUNIT_TEST(testVariableSum);
CPPUNIT_TEST_SUITE_END();
private:
@@ -85,7 +87,8 @@ private:
void testLcm();
void testGcd();
void testPearson();
-
+ void testFixedSum();
+ void testVariableSum();
};
sal_Int32 ScPerfObj::nTest = 0;
@@ -471,6 +474,67 @@ void ScPerfObj::testPearson()
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong Pearson result" , 0.01255, xCell->getValue(), 10e-4);
}
+void ScPerfObj::testFixedSum()
+{
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("scMathFunctions3.ods"), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Problem in document loading" , xDoc.is());
+ uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
+
+ // get getSheets
+ uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_QUERY_THROW);
+
+ uno::Any rSheet = xSheets->getByName("FixedSumSheet");
+
+ // query for the XSpreadsheet interface
+ uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
+
+ // query for the XCellRange interface
+ uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
+ // query the cell range
+ uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("B1:B1000");
+
+ uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
+
+ callgrindStart();
+ xArrayFormulaRange->setArrayFormula("=SUM(A$1:A$1000)");
+ xCalculatable->calculate();
+ callgrindDump("sc:sum_with_fixed_array_formula");
+
+ for( sal_Int32 i = 0; i < 1000; ++i )
+ {
+ uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, i);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Sum" , 50206.0, xCell->getValue());
+ }
+}
+
+void ScPerfObj::testVariableSum()
+{
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("scMathFunctions3.ods"), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Problem in document loading" , xDoc.is());
+ uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
+
+ // get getSheets
+ uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_QUERY_THROW);
+
+ uno::Any rSheet = xSheets->getByName("VariableSumSheet");
+
+ // query for the XSpreadsheet interface
+ uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
+
+ // query for the XCellRange interface
+ uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
+ // query the cell range
+ uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("B1:B9000");
+
+ uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
+
+ callgrindStart();
+ xArrayFormulaRange->setArrayFormula("=SUM(A1:A1000)");
+ xCalculatable->calculate();
+ callgrindDump("sc:sum_with_variable_array_formula");
+}
CPPUNIT_TEST_SUITE_REGISTRATION(ScPerfObj);
diff --git a/sc/qa/perf/testdocuments/scMathFunctions3.ods b/sc/qa/perf/testdocuments/scMathFunctions3.ods
new file mode 100644
index 000000000000..84023cf67b48
--- /dev/null
+++ b/sc/qa/perf/testdocuments/scMathFunctions3.ods
Binary files differ