sc/qa/perf/scperfobj.cxx | 66 ++++++++++++++++++++++++++ sc/qa/perf/testdocuments/scMathFunctions3.ods |binary 2 files changed, 66 insertions(+)
New commits: commit 19c5fb059b4c2bca88d37bafe4c0bada1f0f48a7 Author: Marco Cecchetti <[email protected]> Date: Fri Feb 26 19:11:00 2016 +0100 sc - added fixed and variable array formula range perf tests Change-Id: If1efa2340e4ed8acca6fde08dcd422f4bd5fd531 Reviewed-on: https://gerrit.libreoffice.org/22721 Tested-by: Jenkins <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx index 16e93cb..74b2c6a 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 new file mode 100644 index 0000000..84023cf Binary files /dev/null and b/sc/qa/perf/testdocuments/scMathFunctions3.ods differ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
