[Libreoffice-commits] core.git: sc/qa

Markus Mohrhard markus.mohrhard at googlemail.com
Sat May 7 00:47:19 UTC 2016


 sc/qa/unit/ucalc.cxx |  325 ---------------------------------------------------
 sc/qa/unit/ucalc.hxx |   10 -
 2 files changed, 335 deletions(-)

New commits:
commit 52871b360c73efd59bfbc811b8b89a02b6375b29
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat May 7 01:34:12 2016 +0200

    nuke the old ucalc perf testing
    
    We now have the real perf tests and converting this test seems quite
    complicated as it uses a lot of private symbols. If we really need these
    tests again we need to write them through some exported symbols.
    
    Change-Id: Idfb568e026d63d6784400c08a82c9a7a40039e00
    Reviewed-on: https://gerrit.libreoffice.org/24711
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 228fafa..e92fd6f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -109,35 +109,6 @@ FormulaGrammarSwitch::~FormulaGrammarSwitch()
     mpDoc->SetGrammar(meOldGrammar);
 }
 
-class MeasureTimeSwitch
-{
-    double& mrDiff;
-    TimeValue maTimeBefore;
-public:
-    explicit MeasureTimeSwitch(double& rDiff) : mrDiff(rDiff)
-    {
-        mrDiff = 9999.0;
-        osl_getSystemTime(&maTimeBefore);
-    }
-
-    ~MeasureTimeSwitch()
-    {
-        TimeValue aTimeAfter;
-        osl_getSystemTime(&aTimeAfter);
-        mrDiff = getTimeDiff(aTimeAfter, maTimeBefore);
-    }
-
-    static 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;
-    }
-};
-
 Test::Test() :
     m_pImpl(new TestImpl),
     m_pDoc(nullptr)
@@ -174,302 +145,6 @@ void Test::tearDown()
     BootstrapFixture::tearDown();
 }
 
-#define PERF_ASSERT(df,scale,time,message) \
-    do { \
-        double dfscaled = df / scale; \
-        if ((dfscaled) >= (time)) \
-        { \
-            std::ostringstream os; \
-            os << message " took " << dfscaled << " pseudo-cycles (" << df << " real-time seconds), expected: " << time << " pseudo-cycles."; \
-            CPPUNIT_FAIL(os.str().c_str()); \
-        } \
-    } while (false)
-
-void Test::testPerf()
-{
-    CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
-
-    // First do a set of simple operations to try to work out
-    // how fast (or not) this particular machine is:
-    double scale;
-    {
-        MeasureTimeSwitch aTime(scale);
-        for (int i = 0; i < 10000000; ++i)
-        {
-            // Bang on the allocator
-            volatile ScRange *pRange = new ScRange (ScAddress (0,0,0));
-            // Calc does quite a bit of string conversion
-            volatile double it = OUString::number ((double)i/253.0).toDouble();
-            // Do we have floating point math ?
-            volatile double another = rtl::math::sin (it);
-            (void)another;
-            delete pRange;
-        }
-    }
-    printf("CPU scale factor %g\n", scale);
-
-    // FIXME: we should check if this already took too long
-    // and if so not run the perf. tests to have pity on some
-    // slow ARM machines - I think.
-
-    // to make the numbers more round and helpful,
-    // but the calculation of scale reasonably precise.
-    scale /= 100000.0;
-
-    double diff;
-
-    // Clearing an already empty sheet should finish in a fraction of a
-    // 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);
-        clearRange(m_pDoc, ScRange(0,0,0,99,MAXROW,0));
-    }
-    PERF_ASSERT(diff, scale, 1.0, "Clearing an empty sheet");
-
-    {
-        // Switch to R1C1 to make it easier to input relative references in multiple cells.
-        FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
-
-        // Insert formulas in B1:B100000. This shouldn't take long, but may take
-        // close to a second on a slower machine. We don't measure this yet, for
-        // now.
-        for (SCROW i = 0; i < 100000; ++i)
-            m_pDoc->SetString(ScAddress(1,i,0), "=RC[-1]");
-
-        // Now, Delete B2:B100000. This should complete in a fraction of a second
-        // (0.06 sec on my machine).
-        {
-            MeasureTimeSwitch aTime(diff);
-            clearRange(m_pDoc, ScRange(1,1,0,1,99999,0));
-        }
-        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.
-    CPPUNIT_ASSERT_MESSAGE("Column A shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,0));
-    CPPUNIT_ASSERT_MESSAGE("Column B shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,1));
-
-    {
-        // Measure the performance of repeat-pasting a single cell to a large
-        // cell range, undoing it, and redoing it.
-
-        ScAddress aPos(0,0,0);
-        m_pDoc->SetString(aPos, "test");
-        ScMarkData aMark;
-        aMark.SelectOneTable(0);
-
-        // Copy cell A1 to clipboard.
-        ScDocument aClipDoc(SCDOCMODE_CLIP);
-        ScClipParam aParam(aPos, false);
-        m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
-
-        ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
-        pUndoDoc->InitUndo(m_pDoc, 0, 0);
-        m_pDoc->CopyToDocument(ScRange(aPos), InsertDeleteFlags::CONTENTS, false, pUndoDoc, &aMark);
-
-        // Paste it to A2:A100000, and measure its duration.
-        ScRange aPasteRange(0,1,0,0,99999,0);
-        aMark.SetMarkArea(aPasteRange);
-
-        {
-            MeasureTimeSwitch aTime(diff);
-            m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::CONTENTS, pUndoDoc, &aClipDoc);
-        }
-        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);
-        m_pDoc->CopyToDocument(aPasteRange, InsertDeleteFlags::CONTENTS, false, pRedoDoc, &aMark);
-
-        // Create an undo object for this.
-        ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
-        ScUndoPaste aUndo(&getDocShell(), aPasteRange, aMark, pUndoDoc, pRedoDoc, InsertDeleteFlags::CONTENTS, pRefUndoData);
-
-        // Make sure it did what it's supposed to do.
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aEnd));
-
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Undo();
-        }
-        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));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aEnd));
-
-        // Now redo.
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Redo();
-        }
-        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));
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aEnd));
-    }
-
-    clearRange(m_pDoc, ScRange(0,0,0,1,MAXROW,0)); // Clear columns A:B.
-    CPPUNIT_ASSERT_MESSAGE("Column A shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,0));
-    CPPUNIT_ASSERT_MESSAGE("Column B shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,1));
-
-    {
-        // Measure the performance of repeat-pasting 2 adjacent cells to a
-        // large cell range, undoing it, and redoing it.  The bottom one of
-        // the two source cells is empty.
-
-        ScRange aSrcRange(0,0,0,0,1,0); // A1:A2
-
-        ScAddress aPos(0,0,0);
-        m_pDoc->SetValue(aPos, 12);
-        ScMarkData aMark;
-        aMark.SetMarkArea(aSrcRange);
-
-        // Copy to clipboard.
-        ScDocument aClipDoc(SCDOCMODE_CLIP);
-        ScClipParam aParam(aSrcRange, false);
-        m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
-
-        ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
-        pUndoDoc->InitUndo(m_pDoc, 0, 0);
-        m_pDoc->CopyToDocument(aSrcRange, InsertDeleteFlags::CONTENTS, false, pUndoDoc, &aMark);
-
-        // Paste it to A3:A100001, and measure its duration.
-        ScRange aPasteRange(0,2,0,0,100000,0);
-        aMark.SetMarkArea(aPasteRange);
-
-        {
-            MeasureTimeSwitch aTime(diff);
-            m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::CONTENTS, pUndoDoc, &aClipDoc);
-        }
-        PERF_ASSERT(diff, scale, 1000.0, "Pasting A1:A2 to A3:A100001");
-
-        ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
-        pRedoDoc->InitUndo(m_pDoc, 0, 0);
-        m_pDoc->CopyToDocument(aPasteRange, InsertDeleteFlags::CONTENTS, false, pRedoDoc, &aMark);
-
-        // Create an undo object for this.
-        ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
-        ScUndoPaste aUndo(&getDocShell(), aPasteRange, aMark, pUndoDoc, pRedoDoc, InsertDeleteFlags::CONTENTS, pRefUndoData);
-
-        // Make sure it did what it's supposed to do.
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aEnd));
-        ScAddress aTmp = aPasteRange.aStart;
-        aTmp.IncRow();
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aTmp));
-
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Undo();
-        }
-        PERF_ASSERT(diff, scale, 500.0, "Undoing");
-
-        // Make sure it's really undone.
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_VALUE, m_pDoc->GetCellType(aPos));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aEnd));
-
-        // Now redo.
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Redo();
-        }
-        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));
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), m_pDoc->GetString(aPasteRange.aEnd));
-    }
-
-    clearRange(m_pDoc, ScRange(0,0,0,1,MAXROW,0)); // Clear columns A:B.
-    CPPUNIT_ASSERT_MESSAGE("Column A shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,0));
-    CPPUNIT_ASSERT_MESSAGE("Column B shouldn't have any broadcasters.", !m_pDoc->HasBroadcaster(0,1));
-
-    {
-        // Measure the performance of repeat-pasting 2 adjacent cells to a
-        // large cell range, undoing it, and redoing it.  The bottom one of
-        // the two source cells is empty.  In this scenario, the non-empty
-        // cell is a formula cell referencing a cell to the right, which
-        // inserts a broadcaster to cell it references. So it has a higher
-        // overhead than the previous scenario.
-
-        ScRange aSrcRange(0,0,0,0,1,0); // A1:A2
-
-        ScAddress aPos(0,0,0);
-        m_pDoc->SetString(aPos, "=B1");
-        ScMarkData aMark;
-        aMark.SetMarkArea(aSrcRange);
-
-        // Copy to clipboard.
-        ScDocument aClipDoc(SCDOCMODE_CLIP);
-        ScClipParam aParam(aSrcRange, false);
-        m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark, false, false);
-        CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
-
-        ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
-        pUndoDoc->InitUndo(m_pDoc, 0, 0);
-        m_pDoc->CopyToDocument(aSrcRange, InsertDeleteFlags::CONTENTS, false, pUndoDoc, &aMark);
-
-        // Paste it to A3:A50001, and measure its duration.
-        ScRange aPasteRange(0,2,0,0,50000,0);
-        aMark.SetMarkArea(aPasteRange);
-
-        {
-            MeasureTimeSwitch aTime(diff);
-            m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::CONTENTS, pUndoDoc, &aClipDoc);
-        }
-        PERF_ASSERT(diff, scale, 2000.0, "Pasting");
-
-        ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
-        pRedoDoc->InitUndo(m_pDoc, 0, 0);
-        m_pDoc->CopyToDocument(aPasteRange, InsertDeleteFlags::CONTENTS, false, pRedoDoc, &aMark);
-
-        // Create an undo object for this.
-        ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
-        ScUndoPaste aUndo(&getDocShell(), aPasteRange, aMark, pUndoDoc, pRedoDoc, InsertDeleteFlags::CONTENTS, pRefUndoData);
-
-        // Make sure it did what it's supposed to do.
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPasteRange.aEnd));
-        ScAddress aTmp = aPasteRange.aStart;
-        aTmp.IncRow();
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aTmp));
-
-#if 0 // TODO: Undo and redo of this scenario is currently not fast enough to be tested reliably.
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Undo();
-        }
-        PERF_ASSERT(diff, scale, 1.0, "Undoing");
-
-        // Make sure it's really undone.
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPos));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, m_pDoc->GetCellType(aPasteRange.aEnd));
-
-        // Now redo.
-        {
-            MeasureTimeSwitch aTime(diff);
-            aUndo.Redo();
-        }
-        PERF_ASSERT(diff, scale, 1.0, "Redoing");
-
-        // Make sure it's really redone.
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPasteRange.aStart));
-        CPPUNIT_ASSERT_EQUAL(CELLTYPE_FORMULA, m_pDoc->GetCellType(aPasteRange.aEnd));
-#endif
-    }
-
-    m_pDoc->DeleteTab(0);
-}
-
 void Test::testCollator()
 {
     CollatorWrapper* p = ScGlobal::GetCollator();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 028c342..9ff01c0 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -99,13 +99,6 @@ public:
     virtual void setUp() override;
     virtual void tearDown() override;
 
-    /**
-     * Basic performance regression test. Pick some actions that *should* take
-     * only a fraction of a second to complete, and make sure they stay that
-     * way. We set the threshold to 1 second for each action which should be
-     * large enough to accommodate slower machines or machines with high load.
-     */
-    void testPerf();
     void testCollator();
     void testSharedStringPool();
     void testSharedStringPoolUndoDoc();
@@ -488,9 +481,6 @@ public:
     void testTdf97587();
 
     CPPUNIT_TEST_SUITE(Test);
-#if CALC_TEST_PERF
-    CPPUNIT_TEST(testPerf);
-#endif
     CPPUNIT_TEST(testCollator);
     CPPUNIT_TEST(testSharedStringPool);
     CPPUNIT_TEST(testSharedStringPoolUndoDoc);


More information about the Libreoffice-commits mailing list