Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / perf / scperfobj.cxx
blob2cb0f6a3175d12c2c5714924a05b21719f24150c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
12 #include <string_view>
14 #include <test/unoapi_test.hxx>
16 #include <rtl/ustring.hxx>
17 #include <cppunit/extensions/HelperMacros.h>
18 #include <comphelper/processfactory.hxx>
20 #include <com/sun/star/frame/Desktop.hpp>
21 #include <com/sun/star/frame/XModel2.hpp>
23 #include <com/sun/star/util/XSearchable.hpp>
24 #include <com/sun/star/util/XSearchDescriptor.hpp>
25 #include <com/sun/star/container/XIndexAccess.hpp>
26 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
27 #include <com/sun/star/sheet/XSpreadsheet.hpp>
28 #include <com/sun/star/sheet/XSpreadsheets.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/sheet/XArrayFormulaRange.hpp>
32 #include <com/sun/star/sheet/XCalculatable.hpp>
33 #include <com/sun/star/table/XCellRange.hpp>
34 #include <com/sun/star/sheet/XCellRangeFormula.hpp>
35 #include <com/sun/star/sheet/XNamedRanges.hpp>
36 #include <com/sun/star/table/XCell.hpp>
37 #include <com/sun/star/table/CellAddress.hpp>
38 #include <com/sun/star/table/CellRangeAddress.hpp>
39 #include <com/sun/star/sheet/Border.hpp>
40 #include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
41 #include <com/sun/star/sheet/SubTotalColumn.hpp>
42 #include <com/sun/star/sheet/GeneralFunction.hpp>
44 #include <test/callgrind.hxx>
46 #include <calcconfig.hxx>
47 #include <docsh.hxx>
48 #include <tabvwsh.hxx>
50 using namespace css;
51 using namespace css::uno;
53 namespace sc_apitest {
55 class ScPerfObj : public UnoApiTest
57 public:
59 ScPerfObj();
61 CPPUNIT_TEST_SUITE(ScPerfObj);
62 CPPUNIT_TEST(testSheetFindAll);
63 CPPUNIT_TEST(testFixedSum);
64 CPPUNIT_TEST(testSheetNamedRanges);
65 CPPUNIT_TEST(testSheets);
66 CPPUNIT_TEST(testSum);
67 CPPUNIT_TEST(testFTest);
68 CPPUNIT_TEST(testChiTest);
69 CPPUNIT_TEST(testSumX2PY2Test);
70 CPPUNIT_TEST(testTTest);
71 CPPUNIT_TEST(testLcm);
72 CPPUNIT_TEST(testGcd);
73 CPPUNIT_TEST(testPearson);
74 CPPUNIT_TEST(testSubTotalWithFormulas);
75 CPPUNIT_TEST(testSubTotalWithoutFormulas);
76 CPPUNIT_TEST(testLoadingFileWithSingleBigSheet);
77 CPPUNIT_TEST(testMatConcatSmall);
78 CPPUNIT_TEST(testMatConcatLarge);
79 CPPUNIT_TEST_SUITE_END();
81 private:
82 // tests
83 void testSheetFindAll();
84 void testSheetNamedRanges();
85 void testSheets();
86 void testSum();
87 void testFTest();
88 void testChiTest();
89 void testSumX2PY2Test();
90 void testTTest();
91 void testLcm();
92 void testGcd();
93 void testPearson();
94 void testSubTotalWithFormulas();
95 void testSubTotalWithoutFormulas();
96 void testLoadingFileWithSingleBigSheet();
97 void testFixedSum();
98 void testMatConcatSmall();
99 void testMatConcatLarge();
102 ScPerfObj::ScPerfObj()
103 : UnoApiTest("sc/qa/perf/testdocuments/")
107 void ScPerfObj::testSheetFindAll()
109 loadFromFile(u"scBigFile.ods");
110 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
112 // get sheet
113 uno::Reference< container::XIndexAccess > xSheetIndex (xDoc->getSheets(), UNO_QUERY_THROW);
115 uno::Reference< sheet::XSpreadsheet > xSheet( xSheetIndex->getByIndex(0), UNO_QUERY_THROW);
117 // create descriptor
118 uno::Reference< util::XSearchable > xSearchable(xSheet, UNO_QUERY_THROW);
119 uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
121 // search for a value
122 xSearchDescr->setSearchString("value_1");
124 callgrindStart();
126 uno::Reference< container::XIndexAccess > xIndex = xSearchable->findAll(xSearchDescr);
128 callgrindDump("sc:search_all_sheets_by_value");
130 CPPUNIT_ASSERT(xIndex.is());
132 int nCount = xIndex->getCount();
134 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Count" , 20000, nCount);
136 // search for style
137 uno::Reference< sheet::XSpreadsheet > xSheet2( xSheetIndex->getByIndex(2), UNO_QUERY_THROW);
138 uno::Reference< util::XSearchable > xSearchableStyle(xSheet2, UNO_QUERY_THROW);
139 xSearchDescr = xSearchableStyle->createSearchDescriptor();
141 uno::Reference< beans::XPropertySet > xSearchProp(xSearchDescr,UNO_QUERY_THROW);
142 xSearchProp->setPropertyValue("SearchStyles", Any(true));
144 xSearchDescr->setSearchString("aCellStyle");
146 callgrindStart();
148 uno::Reference< container::XIndexAccess > xIndex2 = xSearchableStyle->findAll(xSearchDescr);
150 callgrindDump("sc:search_all_sheets_by_style");
152 CPPUNIT_ASSERT(xIndex2.is());
154 nCount = xIndex2->getCount();
156 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Count" , 160, nCount);
160 void ScPerfObj::testSheetNamedRanges()
163 loadFromFile(u"scBigFile.ods");
164 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
166 // get NamedRanges
167 uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
168 uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue("NamedRanges"), UNO_QUERY_THROW);
169 uno::Reference< container::XIndexAccess > xIndexNamedRanges(xNamedRanges, UNO_QUERY_THROW);
171 // get sheet - named ranges are defined in sheet #1
172 uno::Reference< container::XIndexAccess > xSheetIndex (xDoc->getSheets(), UNO_QUERY_THROW);
173 uno::Reference< sheet::XSpreadsheet > xSheet( xSheetIndex->getByIndex(1), UNO_QUERY_THROW);
175 // test removeByName
176 OUString maNameToRemove("namedRange_4999");
177 bool bHasIt = xNamedRanges->hasByName(maNameToRemove);
178 CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 does not exist, can't remove it", bHasIt);
180 if (bHasIt)
182 callgrindStart();
183 xNamedRanges->removeByName(maNameToRemove);
184 callgrindDump("sc:remove_named_range_by_name");
187 // test addNewByName
188 table::CellAddress aBaseAddress(0, 0, 0);
190 sal_Int32 nType = 0;
191 callgrindStart();
192 xNamedRanges->addNewByName("single_added", "B4999", aBaseAddress, nType);
193 callgrindDump("sc:add_named_range_by_name");
195 //test AddNewFromTitles with some 1000 new named ranges
196 table::CellRangeAddress aCellRangeAddress(0, 1, 0, 2, 999);
197 callgrindStart();
198 xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT);
199 callgrindDump("sc:add_named_range_from_titles");
203 void ScPerfObj::testSheets()
205 loadFromFile(u"scBigFile.ods");
206 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
208 // get getSheets
209 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
211 OUString aSheetName = "NewSheet";
213 callgrindStart();
214 xSheets->insertNewByName(aSheetName, 80);
215 callgrindDump("sc:insert_new_sheet_by_name");
217 callgrindStart();
218 xSheets->copyByName("aSheet_2", "aCopiedSheet", 70);
219 callgrindDump("sc:copy_sheet_by_name");
221 uno::Reference< sheet::XSpreadsheets > xSheetsNameContainer (xSheets, UNO_SET_THROW);
223 callgrindStart();
224 xSheetsNameContainer->removeByName(aSheetName);
225 callgrindDump("sc:remove_sheet_by_name");
229 void ScPerfObj::testSum()
231 loadFromFile(u"scMathFunctions.ods");
232 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
234 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
236 // get getSheets
237 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
239 uno::Any rSheet = xSheets->getByName("SumSheet");
241 // query for the XSpreadsheet interface
242 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
243 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, 0);
246 callgrindStart();
247 xCell->setFormula("=SUM(A1:A10000)");
248 xCalculatable->calculate();
249 callgrindDump("sc:sum_numbers_column");
251 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Sum" , 504178.0, xCell->getValue());
253 // query for the XCellRange interface
254 uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
255 // query the cell range
256 uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("B1");
258 uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
260 callgrindStart();
261 xArrayFormulaRange->setArrayFormula("=SUM(A1:A10000=30)");
262 xCalculatable->calculate();
263 callgrindDump("sc:sum_with_array_formula_condition");
265 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Sum - number of elements equal 30" , 99.0, xCell->getValue());
268 void ScPerfObj::testFTest()
270 loadFromFile(u"scMathFunctions.ods");
271 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
273 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
275 // get getSheets
276 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
278 uno::Any rSheet = xSheets->getByName("FTestSheet");
280 // query for the XSpreadsheet interface
281 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
282 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(0, 0);
284 callgrindStart();
285 xCell->setFormula("=FTEST(B1:K10;L1:U10)");
286 xCalculatable->calculate();
287 callgrindDump("sc:ftest");
289 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong FTest result" , 0.8909, xCell->getValue(), 10e-4);
292 void ScPerfObj::testChiTest()
294 loadFromFile(u"scMathFunctions.ods");
295 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
297 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
299 // get getSheets
300 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
302 uno::Any rSheet = xSheets->getByName("ChiTestSheet");
304 // query for the XSpreadsheet interface
305 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
306 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(0, 0);
308 callgrindStart();
309 xCell->setFormula("=CHITEST(B1:CV100;CW1:GQ100)");
310 xCalculatable->calculate();
311 callgrindDump("sc:chitest");
313 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong ChiTest result" , 0.0, xCell->getValue(), 10e-4);
316 void ScPerfObj::testSumX2PY2Test()
318 loadFromFile(u"scMathFunctions2.ods");
319 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
321 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
323 // get getSheets
324 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
326 uno::Any rSheet = xSheets->getByName("SumX2PY2Sheet");
328 // query for the XSpreadsheet interface
329 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
330 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(2, 0);
332 callgrindStart();
333 xCell->setFormula("=SUMX2PY2(A1:A10000;B1:B10000)");
334 xCalculatable->calculate();
335 callgrindDump("sc:sumx2py2");
337 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SumX2PY2 result" , 574539.0, xCell->getValue());
340 void ScPerfObj::testTTest()
342 loadFromFile(u"scMathFunctions2.ods");
343 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
345 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
347 // get getSheets
348 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
350 uno::Any rSheet = xSheets->getByName("TTestSheet");
352 // query for the XSpreadsheet interface
353 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
354 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(0, 0);
356 callgrindStart();
357 xCell->setFormula("=T.TEST(B1:CV100;CW1:GQ100;2;1)");
358 xCalculatable->calculate();
359 callgrindDump("sc:ttest");
361 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong TTest result" , 0.0, xCell->getValue());
364 void ScPerfObj::testLcm()
366 loadFromFile(u"scMathFunctions2.ods");
367 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
369 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
371 // get getSheets
372 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
374 uno::Any rSheet = xSheets->getByName("LCMSheet");
376 // query for the XSpreadsheet interface
377 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
378 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, 0);
380 callgrindStart();
381 xCell->setFormula("=LCM(A1:A10000)");
382 xCalculatable->calculate();
383 callgrindDump("sc:lcm");
385 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong LCM" , 2520.0, xCell->getValue());
388 void ScPerfObj::testGcd()
390 loadFromFile(u"scMathFunctions2.ods");
391 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
393 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
395 // get getSheets
396 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
398 uno::Any rSheet = xSheets->getByName("GCDSheet");
400 // query for the XSpreadsheet interface
401 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
402 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, 0);
404 callgrindStart();
405 xCell->setFormula("=GCD(A1:A10000)");
406 xCalculatable->calculate();
407 callgrindDump("sc:gcd");
409 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong GCD", 3.0, xCell->getValue());
412 void ScPerfObj::testPearson()
414 loadFromFile(u"scMathFunctions2.ods");
415 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
417 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
419 // get getSheets
420 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
422 uno::Any rSheet = xSheets->getByName("PearsonSheet");
424 // query for the XSpreadsheet interface
425 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
426 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(0, 0);
428 callgrindStart();
429 xCell->setFormula("=PEARSON(B1:CV100;CW1:GQ100)");
430 xCalculatable->calculate();
431 callgrindDump("sc:pearson");
433 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong Pearson result" , 0.01255, xCell->getValue(), 10e-4);
436 void ScPerfObj::testSubTotalWithFormulas()
438 loadFromFile(u"scBigSingleSheet200.ods");
439 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
441 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
443 // get getSheets
444 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
445 uno::Any rSheet = xSheets->getByName("scBigSingleSheet");
447 // query for the XCellRange interface
448 uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
450 // query the cell range
451 uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByPosition(0,0,1023,1000000);
453 // Create the subtotal interface
454 uno::Reference< sheet::XSubTotalCalculatable > xSub(xCellRange, UNO_QUERY_THROW);
455 uno::Reference< sheet::XSubTotalDescriptor > xSubDesc = xSub->createSubTotalDescriptor(true);
457 // Create the column used for subtotal
458 uno::Sequence < sheet::SubTotalColumn > xSubTotalColumns { { 1, sheet::GeneralFunction_SUM } };
460 xSubDesc->addNew(xSubTotalColumns, 0);
462 // Run the subtotal function
463 callgrindStart();
464 xSub->applySubTotals(xSubDesc, true);
465 callgrindDump("sc:doSubTotal_on_large_sheet_with_formulas");
468 void ScPerfObj::testSubTotalWithoutFormulas()
470 loadFromFile(u"scBigSingleSheet200.ods");
471 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
473 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
475 // get getSheets
476 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
477 uno::Any rSheet = xSheets->getByName("scBigSingleSheet");
479 // query for the XCellRange interface
480 uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
482 // query the cell range
483 uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByPosition(0,0,10,1000000);
485 // Create the subtotal interface
486 uno::Reference< sheet::XSubTotalCalculatable > xSub(xCellRange, UNO_QUERY_THROW);
487 uno::Reference< sheet::XSubTotalDescriptor > xSubDesc = xSub->createSubTotalDescriptor(true);
489 // Create the column used for subtotal
490 uno::Sequence < sheet::SubTotalColumn> xSubTotalColumns { { 1, sheet::GeneralFunction_SUM } };
492 xSubDesc->addNew(xSubTotalColumns, 0);
494 // Run the subtotal function
495 callgrindStart();
496 xSub->applySubTotals(xSubDesc, true);
497 callgrindDump("sc:doSubTotal_on_large_sheet_without_formulas");
500 void ScPerfObj::testLoadingFileWithSingleBigSheet()
502 callgrindStart();
503 loadFromFile(u"scBigSingleSheet2000.ods");
504 uno::Reference< sheet::XSpreadsheetDocument > xDoc1(mxComponent, UNO_QUERY_THROW);
505 uno::Reference< sheet::XCalculatable > xCalculatable1(xDoc1, UNO_QUERY_THROW);
506 callgrindDump("sc:loadingFileWithSingleBigSheetdoSubTotal_2000lines");
509 namespace {
510 void setupBlockFormula(
511 const uno::Reference< sheet::XSpreadsheetDocument > & xDoc,
512 const OUString &rSheetName,
513 const OUString &rCellRange,
514 const OUString &rFormula)
516 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
518 uno::Any aSheet = xSheets->getByName(rSheetName);
519 uno::Reference< table::XCellRange > xSheetCellRange(aSheet, UNO_QUERY);
520 uno::Reference< sheet::XCellRangeFormula > xCellRange(
521 xSheetCellRange->getCellRangeByName(rCellRange), UNO_QUERY);
523 uno::Sequence< uno::Sequence< OUString > > aFormulae(1000);
524 auto pFormulae = aFormulae.getArray();
525 for (sal_Int32 i = 0; i < 1000; ++i)
527 pFormulae[i] = { rFormula };
530 // NB. not set Array (matrix) formula
531 xCellRange->setFormulaArray(aFormulae);
535 void ScPerfObj::testFixedSum()
537 loadFromFile(u"scMathFunctions3.ods");
538 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
540 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
542 setupBlockFormula(xDoc, "FixedSumSheet", "B1:B1000", "=SUM(A$1:A$1000)");
544 callgrindStart();
545 xCalculatable->calculateAll();
546 callgrindDump("sc:sum_with_fixed_array_formula");
548 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
549 uno::Any aSheet = xSheets->getByName("FixedSumSheet");
550 uno::Reference< sheet::XSpreadsheet > xSheet (aSheet, UNO_QUERY);
552 for( sal_Int32 i = 0; i < 1000; ++i )
554 uno::Reference< table::XCell > xCell = xSheet->getCellByPosition(1, i);
555 CPPUNIT_ASSERT_DOUBLES_EQUAL(50206.0, xCell->getValue(), 1e-12);
559 void ScPerfObj::testMatConcatSmall()
561 loadFromFile(u"empty.ods");
562 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
564 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
566 // get getSheets
567 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
569 uno::Any rSheet = xSheets->getByName("Sheet1");
571 // query for the XSpreadsheet interface
572 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
574 // query for the XCellRange interface
575 uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
576 // query the cell range
577 uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("C1");
579 uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
581 xArrayFormulaRange->setArrayFormula("=A1:A20&B1:B20");
582 callgrindStart();
583 xCalculatable->calculateAll();
584 callgrindDump("sc:mat_concat_small");
587 void ScPerfObj::testMatConcatLarge()
589 loadFromFile(u"empty.ods");
590 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
592 uno::Reference< sheet::XCalculatable > xCalculatable(xDoc, UNO_QUERY_THROW);
594 // get getSheets
595 uno::Reference< sheet::XSpreadsheets > xSheets (xDoc->getSheets(), UNO_SET_THROW);
597 uno::Any rSheet = xSheets->getByName("Sheet1");
599 // query for the XSpreadsheet interface
600 uno::Reference< sheet::XSpreadsheet > xSheet (rSheet, UNO_QUERY);
602 // query for the XCellRange interface
603 uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
604 // query the cell range
605 uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("C1");
607 uno::Reference< sheet::XArrayFormulaRange > xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
609 callgrindStart();
610 xArrayFormulaRange->setArrayFormula("=A1:A30000&B1:B30000");
611 xCalculatable->calculate();
612 callgrindDump("sc:mat_concat");
615 CPPUNIT_TEST_SUITE_REGISTRATION(ScPerfObj);
619 CPPUNIT_PLUGIN_IMPLEMENT();
621 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */