diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2016-07-05 20:26:38 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-07-05 21:03:28 +0000 |
commit | 6f0e3d508dea229e456e3b29abe2f2b3c77a2cf9 (patch) | |
tree | 61218fb98f046975c02a90f73f286b6f96fe8003 /sc/qa/perf | |
parent | adc3932dfc4fe763b7db0af8843b01614bdc6aa2 (diff) |
sc: re-factor perf-tests.
Reduce copy/paste coding.
Don't setup array (matrix) formulae - we don't accelerate those anyway.
Change-Id: I02f122ed03e90fe509c9764307aacf82ca7b4ba7
Reviewed-on: https://gerrit.libreoffice.org/26965
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc/qa/perf')
-rw-r--r-- | sc/qa/perf/scperfobj.cxx | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx index c08dcb1c0f80..eb9e888e85b5 100644 --- a/sc/qa/perf/scperfobj.cxx +++ b/sc/qa/perf/scperfobj.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/sheet/XArrayFormulaRange.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/sheet/XCellRangeFormula.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> #include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> @@ -57,6 +58,8 @@ public: CPPUNIT_TEST_SUITE(ScPerfObj); CPPUNIT_TEST(testSheetFindAll); + CPPUNIT_TEST(testFixedSum); + CPPUNIT_TEST(testVariableSum); CPPUNIT_TEST(testSheetNamedRanges); CPPUNIT_TEST(testSheets); CPPUNIT_TEST(testSum); @@ -70,8 +73,6 @@ public: CPPUNIT_TEST(testSubTotalWithFormulas); CPPUNIT_TEST(testSubTotalWithoutFormulas); CPPUNIT_TEST(testLoadingFileWithSingleBigSheet); - CPPUNIT_TEST(testFixedSum); - CPPUNIT_TEST(testVariableSum); CPPUNIT_TEST(testMatConcatSmall); CPPUNIT_TEST(testMatConcatLarge); CPPUNIT_TEST_SUITE_END(); @@ -557,33 +558,51 @@ void ScPerfObj::testLoadingFileWithSingleBigSheet() callgrindDump("sc:loadingFileWithSingleBigSheetdoSubTotal_2000lines"); } +namespace { + void setupBlockFormula( + const uno::Reference< sheet::XSpreadsheetDocument > & xDoc, + const OUString &rSheetName, + const OUString &rCellRange, + const OUString &rFormula) + { + uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_QUERY_THROW); + + uno::Any aSheet = xSheets->getByName(rSheetName); + uno::Reference< table::XCellRange > xSheetCellRange(aSheet, UNO_QUERY); + uno::Reference< sheet::XCellRangeFormula > xCellRange( + xSheetCellRange->getCellRangeByName(rCellRange), UNO_QUERY); + + uno::Sequence< uno::Sequence< OUString > > aFormulae(1000); + for (sal_Int32 i = 0; i < 1000; ++i) + { + uno::Sequence< OUString > aRow(1); + aRow[0] = rFormula; + aFormulae[i] = aRow; + } + + // NB. not set Array (matrix) formula + xCellRange->setFormulaArray(aFormulae); + } +} + 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::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW); - uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW); + setupBlockFormula(xDoc, "FixedSumSheet", "B1:B1000", "=SUM(A$1:A$1000)"); callgrindStart(); - xArrayFormulaRange->setArrayFormula("=SUM(A$1:A$1000)"); - xCalculatable->calculate(); + xCalculatable->calculateAll(); callgrindDump("sc:sum_with_fixed_array_formula"); + uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_QUERY_THROW); + uno::Any aSheet = xSheets->getByName("FixedSumSheet"); + uno::Reference< sheet::XSpreadsheet > xSheet (aSheet, UNO_QUERY); + for( sal_Int32 i = 0; i < 1000; ++i ) { uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, i); @@ -598,24 +617,10 @@ void ScPerfObj::testVariableSum() 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); + setupBlockFormula(xDoc, "VariableSumSheet", "B1:B1000", "=SUM(A1:A1000)"); callgrindStart(); - xArrayFormulaRange->setArrayFormula("=SUM(A1:A1000)"); - xCalculatable->calculate(); + xCalculatable->calculateAll(); callgrindDump("sc:sum_with_variable_array_formula"); } @@ -641,9 +646,9 @@ void ScPerfObj::testMatConcatSmall() uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW); - callgrindStart(); xArrayFormulaRange->setArrayFormula("=A1:A20&B1:B20"); - xCalculatable->calculate(); + callgrindStart(); + xCalculatable->calculateAll(); callgrindDump("sc:mat_concat_small"); } |