[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kspread/storage
From:       Ariya Hidayat <ariya () kde ! org>
Date:       2007-01-07 12:18:47
Message-ID: 1168172327.994215.31666.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 620797 by ariya:

benchmark for different size


 M  +51 -30    TestPointStorage.cpp  


--- trunk/koffice/kspread/storage/TestPointStorage.cpp #620796:620797
@@ -440,46 +440,67 @@
 
 void PointStorageTest::testLookupPerformance()
 {
+    // row x column
+    const int scenarios[] = {
+        5, 5,          // very small
+        30, 20,        // fit to screen
+        100, 100,      // medium
+        1000, 1000,    // large
+        10000, 100,    // typical data: more rows
+        10000, 2000,   // and 20 times larger
+        100, 10000,    // not really typical: more columns
+        8000, 8000     // hopelessly large
+        };
+
     PointStorage<int> storage;
-    for ( int r = 0; r < 1000; ++r )
+    
+    for(int sc = 0; sc < sizeof(scenarios)/sizeof(scenarios[0])/2; sc++)
     {
-        for ( int c = 0; c < 1000; ++c )
+        int maxrow = scenarios[sc*2];
+        int maxcol = scenarios[sc*2+1];
+        
+        storage.clear();
+        for ( int r = 0; r < maxrow; ++r )
         {
-            storage.m_data << c;
-            storage.m_cols << ( c + 1 );
+            for ( int c = 0; c < maxcol; ++c )
+            {
+                storage.m_data << c;
+                storage.m_cols << ( c + 1 );
+            }
+            storage.m_rows << r*maxcol;
         }
-        storage.m_rows << r*1000;
-    }
-//     qDebug() << endl << qPrintable( storage.dump() );
-    qDebug() << "start measuring...";
+    //     qDebug() << endl << qPrintable( storage.dump() );
+        QString prefix = QString("%1 x %2").arg(maxrow).arg(maxcol);
+        qDebug() << "start measuring..." << prefix;
 
-    Time::tval start = 0;
-    Time::tval ticks = 0;
-    int v;
-    int col = 0;
-    int row = 0;
-    int cols = 0;
-    int rows = 0;
-    int counter = 0;
-    const int iterations = 100000;
-    while ( counter < iterations )
-    {
-        col = 1 + rand() % 1000;
-        row = 1 + rand() % 1000;
-        cols = col + 1 * ( rand() % 10 );
-        rows = row + rand() % 10;
-        start = Time::stamp();
-        for ( int r = row; r <= rows && counter < iterations; ++r )
+        Time::tval start = 0;
+        Time::tval ticks = 0;
+        int v;
+        int col = 0;
+        int row = 0;
+        int cols = 0;
+        int rows = 0;
+        int counter = 0;
+        const int iterations = 100000;
+        while ( counter < iterations )
         {
-            for ( int c = col; c <= cols && counter < iterations; c += 1 )
+            col = 1 + rand() % maxcol;
+            row = 1 + rand() % maxrow;
+            cols = col + 1 * ( rand() % 10 );
+            rows = row + rand() % 10;
+            start = Time::stamp();
+            for ( int r = row; r <= rows && counter < iterations; ++r )
             {
-                v = storage.lookup( c, r );
-                counter += 1;
+                for ( int c = col; c <= cols && counter < iterations; c += 1 )
+                {
+                    v = storage.lookup( c, r );
+                    counter += 1;
+                }
             }
+            ticks += Time::elapsed( start );
         }
-        ticks += Time::elapsed( start );
+        qDebug() << qPrintable( Time::printAverage( ticks, counter, prefix ) );
     }
-    qDebug() << qPrintable( Time::printAverage( ticks, counter ) );
 }
 
 void PointStorageTest::testInsertColumnsPerformance()
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic