diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2016-02-26 19:11:00 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-23 19:09:59 +0000 |
commit | 19c5fb059b4c2bca88d37bafe4c0bada1f0f48a7 (patch) | |
tree | 79a89e4aa9651af5d9cd5973a05006cbb4b41d93 /sc/qa | |
parent | 59c1c5a4e84b18f9ccf20fb46903aa37b61cf957 (diff) |
sc - added fixed and variable array formula range perf tests
Change-Id: If1efa2340e4ed8acca6fde08dcd422f4bd5fd531
Reviewed-on: https://gerrit.libreoffice.org/22721
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/perf/scperfobj.cxx | 66 | ||||
-rw-r--r-- | sc/qa/perf/testdocuments/scMathFunctions3.ods | bin | 0 -> 55416 bytes |
2 files changed, 66 insertions, 0 deletions
diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx index 16e93cb5b9f6..74b2c6af5f25 100644 --- a/sc/qa/perf/scperfobj.cxx +++ b/sc/qa/perf/scperfobj.cxx @@ -72,6 +72,8 @@ public: CPPUNIT_TEST(testSubTotalWithFormulas); CPPUNIT_TEST(testSubTotalWithoutFormulas); CPPUNIT_TEST(testLoadingFileWithSingleBigSheet); + CPPUNIT_TEST(testFixedSum); + CPPUNIT_TEST(testVariableSum); CPPUNIT_TEST_SUITE_END(); private: @@ -94,6 +96,8 @@ private: void testSubTotalWithFormulas(); void testSubTotalWithoutFormulas(); void testLoadingFileWithSingleBigSheet(); + void testFixedSum(); + void testVariableSum(); }; sal_Int32 ScPerfObj::nTest = 0; @@ -562,6 +566,68 @@ void ScPerfObj::testLoadingFileWithSingleBigSheet() callgrindDump("sc:loadingFileWithSingleBigSheetdoSubTotal_2000lines"); } +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); + ASSERT_DOUBLES_EQUAL(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 Binary files differnew file mode 100644 index 000000000000..84023cf67b48 --- /dev/null +++ b/sc/qa/perf/testdocuments/scMathFunctions3.ods |