[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - 2 commits - sc/qa sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Wed May 22 09:19:41 PDT 2013


 sc/qa/unit/ucalc.cxx           |   87 ++++++++++++++++++-----------------------
 sc/source/core/data/column.cxx |    2 
 2 files changed, 41 insertions(+), 48 deletions(-)

New commits:
commit 5cfb604159f0b73c94f528b5005da8734f2b2c2e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 22 12:14:24 2013 -0400

    Disable Calc perf test by default & output both pseudo-cycles and real time.
    
    Change-Id: I35120e576208640976cdda0a5628e355bbe2dc7c
    (cherry picked from commit 4fa7a0ce8131106a038ba441bcc230d0377690ac)

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 90da5f0..3f306d0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -77,6 +77,7 @@
 #include <vector>
 
 #define CALC_DEBUG_OUTPUT 0
+#define CALC_TEST_PERF 0
 
 #include "helper/debughelper.hxx"
 #include "helper/qahelper.hxx"
@@ -92,16 +93,6 @@ using ::std::vector;
 
 namespace {
 
-double getTimeDiff(const TimeValue& t1, const TimeValue& t2)
-{
-    double tv1 = t1.Seconds;
-    double tv2 = t2.Seconds;
-    tv1 += t1.Nanosec / 1000000000.0;
-    tv2 += t2.Nanosec / 1000000000.0;
-
-    return tv1 - tv2;
-}
-
 class Test : public test::BootstrapFixture {
 public:
     Test();
@@ -283,7 +274,7 @@ public:
     void testCondFormatINSDEL();
 
     CPPUNIT_TEST_SUITE(Test);
-#if !defined(DBG_UTIL) && !defined(_WIN32_WINNT)
+#if CALC_TEST_PERF
     CPPUNIT_TEST(testPerf);
 #endif
     CPPUNIT_TEST(testCollator);
@@ -447,20 +438,11 @@ public:
 class MeasureTimeSwitch
 {
     double& mrDiff;
-    double mnScale;
     TimeValue maTimeBefore;
 public:
     MeasureTimeSwitch(double& rDiff) : mrDiff(rDiff)
     {
         mrDiff = 9999.0;
-        mnScale = 1.0;
-        osl_getSystemTime(&maTimeBefore);
-    }
-    // Scaled pseudo-time
-    MeasureTimeSwitch(double& rDiff, const double nScale ) : mrDiff(rDiff)
-    {
-        mrDiff = 9999.0;
-        mnScale = nScale;
         osl_getSystemTime(&maTimeBefore);
     }
 
@@ -468,7 +450,17 @@ public:
     {
         TimeValue aTimeAfter;
         osl_getSystemTime(&aTimeAfter);
-        mrDiff = getTimeDiff(aTimeAfter, maTimeBefore) / mnScale;
+        mrDiff = getTimeDiff(aTimeAfter, maTimeBefore);
+    }
+
+    double getTimeDiff(const TimeValue& t1, const TimeValue& t2) const
+    {
+        double tv1 = t1.Seconds;
+        double tv2 = t2.Seconds;
+        tv1 += t1.Nanosec / 1000000000.0;
+        tv2 += t2.Nanosec / 1000000000.0;
+
+        return tv1 - tv2;
     }
 };
 
@@ -497,13 +489,13 @@ void Test::tearDown()
     BootstrapFixture::tearDown();
 }
 
-#define PERF_ASSERT(df,time,message) \
+#define PERF_ASSERT(df,scale,time,message) \
     do { \
-        if ((df) >= (time)) \
+        double dfscaled = df / scale; \
+        if ((dfscaled) >= (time)) \
         { \
             std::ostringstream os; \
-            os << message << " took " << diff << " psuedo-cycles, expected: " << time; \
-            /* debugging - fprintf (stderr, "'%s'\n", os.str().c_str()); */ \
+            os << message << " took " << dfscaled << " pseudo-cycles (" << df << " real-time seconds), expected: " << time << " pseudo-cycles."; \
             CPPUNIT_FAIL(os.str().c_str()); \
         } \
     } while (0)
@@ -545,10 +537,10 @@ void Test::testPerf()
     // second.  Flag failure if it takes more than one second.  Clearing 100
     // columns should be large enough to flag if something goes wrong.
     {
-        MeasureTimeSwitch aTime(diff, scale);
+        MeasureTimeSwitch aTime(diff);
         clearRange(m_pDoc, ScRange(0,0,0,99,MAXROW,0));
     }
-    PERF_ASSERT(diff, 1.0, "Clearing an empty sheet");
+    PERF_ASSERT(diff, scale, 1.0, "Clearing an empty sheet");
 
     {
         // Switch to R1C1 to make it easier to input relative references in multiple cells.
@@ -563,10 +555,10 @@ void Test::testPerf()
         // Now, Delete B2:B100000. This should complete in a fraction of a second
         // (0.06 sec on my machine).
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             clearRange(m_pDoc, ScRange(1,1,0,1,99999,0));
         }
-        PERF_ASSERT(diff, 3000, "Removal of a large array of formula cells");
+        PERF_ASSERT(diff, scale, 2000, "Removal of a large array of formula cells");
     }
 
     clearRange(m_pDoc, ScRange(0,0,0,1,MAXROW,0)); // Clear columns A:B.
@@ -597,10 +589,10 @@ void Test::testPerf()
         aMark.SetMarkArea(aPasteRange);
 
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             m_pDoc->CopyFromClip(aPasteRange, aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc);
         }
-        PERF_ASSERT(diff, 1500.0, "Pasting a single cell to A2:A100000");
+        PERF_ASSERT(diff, scale, 1500.0, "Pasting a single cell to A2:A100000");
 
         ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
         pRedoDoc->InitUndo(m_pDoc, 0, 0);
@@ -615,10 +607,10 @@ void Test::testPerf()
         CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aEnd));
 
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Undo();
         }
-        PERF_ASSERT(diff, 500.0, "Undoing a pasting of a cell to A2:A100000");
+        PERF_ASSERT(diff, scale, 500.0, "Undoing a pasting of a cell to A2:A100000");
 
         // Make sure it's really undone.
         CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, m_pDoc->GetCellType(aPos));
@@ -627,10 +619,10 @@ void Test::testPerf()
 
         // Now redo.
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Redo();
         }
-        PERF_ASSERT(diff, 1000.0, "Redoing a pasting of a cell to A2:A100000");
+        PERF_ASSERT(diff, scale, 1000.0, "Redoing a pasting of a cell to A2:A100000");
 
         // Make sure it's really redone.
         CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aStart));
@@ -668,10 +660,10 @@ void Test::testPerf()
         aMark.SetMarkArea(aPasteRange);
 
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             m_pDoc->CopyFromClip(aPasteRange, aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc);
         }
-        PERF_ASSERT(diff, 1000.0, "Pasting A1:A2 to A3:A100001");
+        PERF_ASSERT(diff, scale, 1000.0, "Pasting A1:A2 to A3:A100001");
 
         ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
         pRedoDoc->InitUndo(m_pDoc, 0, 0);
@@ -689,10 +681,10 @@ void Test::testPerf()
         CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aTmp));
 
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Undo();
         }
-        PERF_ASSERT(diff, 500.0, "Undoing");
+        PERF_ASSERT(diff, scale, 500.0, "Undoing");
 
         // Make sure it's really undone.
         CPPUNIT_ASSERT_EQUAL(CELLTYPE_VALUE, m_pDoc->GetCellType(aPos));
@@ -701,10 +693,10 @@ void Test::testPerf()
 
         // Now redo.
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Redo();
         }
-        PERF_ASSERT(diff, 800.0, "Redoing");
+        PERF_ASSERT(diff, scale, 800.0, "Redoing");
 
         // Make sure it's really redone.
         CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aStart));
@@ -745,10 +737,10 @@ void Test::testPerf()
         aMark.SetMarkArea(aPasteRange);
 
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             m_pDoc->CopyFromClip(aPasteRange, aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc);
         }
-        PERF_ASSERT(diff, 2000.0, "Pasting");
+        PERF_ASSERT(diff, scale, 2000.0, "Pasting");
 
         ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
         pRedoDoc->InitUndo(m_pDoc, 0, 0);
@@ -767,10 +759,10 @@ void Test::testPerf()
 
 #if 0 // TODO: Undo and redo of this scenario is currently not fast enough to be tested reliably.
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Undo();
         }
-        PERF_ASSERT(diff, 1.0, "Undoing");
+        PERF_ASSERT(diff, scale, 1.0, "Undoing");
 
         // Make sure it's really undone.
         CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPos));
@@ -779,10 +771,10 @@ void Test::testPerf()
 
         // Now redo.
         {
-            MeasureTimeSwitch aTime(diff, scale);
+            MeasureTimeSwitch aTime(diff);
             aUndo.Redo();
         }
-        PERF_ASSERT(diff, 1.0, "Redoing");
+        PERF_ASSERT(diff, scale, 1.0, "Redoing");
 
         // Make sure it's really redone.
         CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPasteRange.aStart));
commit 1c0e152adaba1b45d0e2cbe83d8f7834b1937eda
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed May 22 11:17:52 2013 -0400

    Use the block position of the destination, not of the source.
    
    And a test to catch this.
    
    Change-Id: Ia73be239b4be96cbe029390efbbec5f49e429652
    (cherry picked from commit 6958b6a3ce9f28bed2a529939e7740452929a5b3)

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 36a59fa..90da5f0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4494,6 +4494,7 @@ void Test::testPivotTableDocFunc()
 void Test::testSheetCopy()
 {
     m_pDoc->InsertTab(0, "TestTab");
+    m_pDoc->SetString(ScAddress(0,0,0), "copy me");
     CPPUNIT_ASSERT_MESSAGE("document should have one sheet to begin with.", m_pDoc->GetTableCount() == 1);
     SCROW nRow1, nRow2;
     bool bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 10d36b6..dfbc21d 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1444,7 +1444,7 @@ void ScColumn::CopyToColumn(
                     // Special case to allow removing of cell instances.  A
                     // string cell with empty content is used to indicate an
                     // empty cell.
-                    sc::ColumnBlockPosition* p = rCxt.getBlockPosition(nTab, nCol);
+                    sc::ColumnBlockPosition* p = rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol);
                     if (pNew->GetCellType() == CELLTYPE_STRING)
                     {
                         OUString aStr = static_cast<ScStringCell*>(pNew)->GetString();


More information about the Libreoffice-commits mailing list