[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Mon Jun 16 23:04:53 CEST 2008


SVN commit 821213 by asimha:

Binding key 'B' to print useful debug information about unnamed star
memory allocation.

CCMAIL: kstars-devel at kde.org



 M  +1 -0      skycomponents/skymapcomposite.h  
 M  +7 -0      skycomponents/starblockfactory.h  
 M  +41 -1     skycomponents/starcomponent.cpp  
 M  +7 -1      skycomponents/starcomponent.h  
 M  +4 -2      skymapevents.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/skymapcomposite.h #821212:821213
@@ -172,6 +172,7 @@
     int starColorMode() const;
     void setStarColorIntensity( int newIntensity );
     int starColorIntensity() const;
+    inline StarComponent *getStarComponent() const { return m_Stars; }
 
     virtual void emitProgressText( const QString &message );
     virtual QHash<int, QStringList>& objectNames();
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starblockfactory.h #821212:821213
@@ -83,6 +83,13 @@
      */
     bool markNext( StarBlock *after, StarBlock *block );
 
+    /**
+     *@short  Returns the number of StarBlocks currently produced
+     *
+     *@return Number of StarBlocks currently allocated
+     */
+    inline int getBlockCount() { return nBlocks; }
+
     quint32 drawID;            // A number identifying the current draw cycle
 
  private:
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #821212:821213
@@ -235,7 +235,8 @@
     //Loop for drawing star images
 
     MeshIterator region(m_skyMesh, DRAW_BUF);
-
+    // TODO: Debug code. May not be useful in production. Remove if required.
+    magLim = maglim;
     while ( region.hasNext() ) {
         Trixel currentRegion = region.next();
         StarList* starList = m_starIndex->at( currentRegion );
@@ -638,3 +639,42 @@
 }
 */
 
+void StarComponent::printDebugInfo() {
+
+    int nTrixels = 0;
+    int nBlocks = 0;
+    long int nStars = 0;
+    float faintMag = -5.0;
+
+    MeshIterator trixels( m_skyMesh, DRAW_BUF );
+    Trixel trixel;
+
+    while( trixels.hasNext() ) {
+        trixel = trixels.next();
+        nTrixels++;
+        for(int i = 0; i < m_starBlockList[ trixel ]->getBlockCount(); ++i) {
+            nBlocks++;
+            StarBlock *block = m_starBlockList[ trixel ]->block( i );
+            for(int j = 0; j < block->getStarCount(); ++j) {
+                nStars++;
+            }
+            if( block->getFaintMag() > faintMag ) {
+                faintMag = block->getFaintMag();
+            }
+        }
+    }
+
+    kDebug() << "========== UNNAMED STAR MEMORY ALLOCATION INFORMATION ==========";
+    kDebug() << "Number of visible trixels               = " << nTrixels << endl;
+    kDebug() << "Number of visible StarBlocks            = " << nBlocks << endl;
+    kDebug() << "Number of StarBlocks allocated via SBF  = " << m_StarBlockFactory.getBlockCount() << endl;
+    kDebug() << "Number of visible unnamed stars         = " << nStars << endl;
+    kDebug() << "Magnitude of the faintest star          = " << faintMag << endl;
+    kDebug() << "Target magnitude limit                  = " << magLim << endl;
+    kDebug() << "Size of each StarBlock                  = " << sizeof( StarBlock ) << endl;
+    kDebug() << "Size of each StarObject                 = " << sizeof( StarObject ) << endl;
+    kDebug() << "Memory use due to visible unnamed stars = " << ( sizeof( StarObject ) * nStars / 1048576.0 ) << "MB" << endl;
+    kDebug() << "Memory use due to visible StarBlocks    = " << sizeof( StarBlock ) * nBlocks << endl;
+    kDebug() << "Memory use due to StarBlocks in SBF     = " << sizeof( StarBlock ) * m_StarBlockFactory.getBlockCount() << endl;
+    kDebug() << "================================================================";
+}
--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.h #821212:821213
@@ -126,6 +126,11 @@
 
     SkyObject* findByName( const QString &name );
 
+    /**
+     *@short Prints some useful debug info about memory allocation for stars
+     */
+    void printDebugInfo();
+
     // TODO: Find the right place for this method
     static void byteSwap( starData *stardata );
 
@@ -150,6 +155,7 @@
     float          m_FaintMagnitude;
     bool           starsLoaded;
     float          m_zoomMagLimit;
+    float          magLim;
 
     KStarsSplash*  m_reloadSplash;
     KStarsSplash*  m_reindexSplash;
@@ -192,7 +198,7 @@
         /**
          *Constructor
          *
-         *@param parent Pointer to the parent StarComponent class
+         *@param par    Pointer to the parent StarComponent class
          *@param trixel Trixel for which this Iterator should work
          */
         TrixelIterator( StarComponent *par, Trixel trixel );
--- branches/kstars/summer/kdeedu/kstars/kstars/skymapevents.cpp #821212:821213
@@ -45,7 +45,9 @@
 #include "kspopupmenu.h"
 #include "ksmoon.h"
 
+// TODO: Remove if debug key binding is removed
 #include "skycomponents/skylabeler.h"
+#include "skycomponents/starcomponent.h"
 
 void SkyMap::resizeEvent( QResizeEvent * )
 {
@@ -418,8 +420,8 @@
         << sl.point(1)->ra()->toHMSString() << endl;
             break;
         **/
-    case Qt::Key_B:  // print labeler info
-        SkyLabeler::Instance()->printInfo();
+    case Qt::Key_B:  // print useful debug info about memory allocation for stars
+        data->skyComposite()->getStarComponent()->printDebugInfo();
         break;
     case Qt::Key_F:  // print labeler info
         SkyLabeler::Instance()->decDensity();


More information about the Kstars-devel mailing list