summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-25 22:24:53 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-29 02:19:51 (GMT)
commit6e4fff45e0f4e4db691da7ccb00d4932e9eb74a5 (patch)
tree36181795696b9f4cb91e4820517d89e17fe8625b
parentf838f2623d70d835a878a31f97cdc62833c7edd7 (diff)
Profiling code to estimate the time spent in StarObject::udpateCoords()
It doesn't look very good! Almost 4 microseconds (compiled in debug mode no optimizations) per call on my laptop!
-rw-r--r--kstars/skycomponents/deepstarcomponent.cpp9
-rw-r--r--kstars/skyobjects/starobject.cpp16
-rw-r--r--kstars/skyobjects/starobject.h8
3 files changed, 33 insertions, 0 deletions
diff --git a/kstars/skycomponents/deepstarcomponent.cpp b/kstars/skycomponents/deepstarcomponent.cpp
index 35a18c8..dfe6449 100644
--- a/kstars/skycomponents/deepstarcomponent.cpp
+++ b/kstars/skycomponents/deepstarcomponent.cpp
@@ -191,6 +191,11 @@ void DeepStarComponent::draw( SkyPainter *skyp ) {
long cachingdms_bad_uses = -CachingDms::cachingdms_bad_uses;
dms::seconds_in_trig = 0.;
#endif
+
+#ifdef PROFILE_UPDATECOORDS
+ StarObject::updateCoordsCpuTime = 0.;
+ StarObject::starsUpdated = 0;
+#endif
SkyMap *map = SkyMap::Instance();
KStarsData* data = KStarsData::Instance();
UpdateID updateID = data->updateID();
@@ -329,6 +334,10 @@ void DeepStarComponent::draw( SkyPainter *skyp ) {
qDebug() << "Caching has prevented " << CachingDms::cachingdms_delta << " redundant trig function calls";
qDebug() << "Bad cache uses in this draw: " << cachingdms_bad_uses;
#endif
+#ifdef PROFILE_UPDATECOORDS
+ qDebug() << "Spent " << StarObject::updateCoordsCpuTime << " seconds updating " << StarObject::starsUpdated << " stars' coordinates (StarObject::updateCoords) for an average of " << double( StarObject::updateCoordsCpuTime )/double( StarObject::starsUpdated ) * 1.e6 << " us per star.";
+#endif
+
#else
Q_UNUSED(skyp)
#endif
diff --git a/kstars/skyobjects/starobject.cpp b/kstars/skyobjects/starobject.cpp
index 3efa37d..8906ee4 100644
--- a/kstars/skyobjects/starobject.cpp
+++ b/kstars/skyobjects/starobject.cpp
@@ -36,6 +36,13 @@
#include "skymap.h"
#include "ksutils.h"
+#ifdef PROFILE_UPDATECOORDS
+double StarObject::updateCoordsCpuTime = 0.;
+unsigned int StarObject::starsUpdated = 0;
+#include <cstdlib>
+#include <ctime>
+#endif
+
// DEBUG EDIT. Uncomment for testing Proper Motion
//#include "skycomponents/skymesh.h"
// END DEBUG
@@ -263,6 +270,10 @@ void StarObject::updateCoords( const KSNumbers *num, bool , const CachingDms*, c
// Correction: The method below computes the proper motion before the
// precession. If we precessed first then the direction of the proper
// motion correction would depend on how far we've precessed. -jbb
+#ifdef PROFILE_UPDATECOORDS
+ std::clock_t start, stop;
+ start = std::clock();
+#endif
double saveRA = ra0().Hours();
double saveDec = dec0().Degrees();
@@ -288,6 +299,11 @@ void StarObject::updateCoords( const KSNumbers *num, bool , const CachingDms*, c
setRA0( saveRA );
setDec0( saveDec );
}
+#ifdef PROFILE_UPDATECOORDS
+ stop = std::clock();
+ updateCoordsCpuTime += double( stop - start )/double( CLOCKS_PER_SEC );
+ ++starsUpdated;
+#endif
}
bool StarObject::getIndexCoords( const KSNumbers *num, double *ra, double *dec )
diff --git a/kstars/skyobjects/starobject.h b/kstars/skyobjects/starobject.h
index f9c3721..56bd223 100644
--- a/kstars/skyobjects/starobject.h
+++ b/kstars/skyobjects/starobject.h
@@ -25,6 +25,8 @@
#include "stardata.h"
#include "deepstardata.h"
+#define PROFILE_UPDATECOORDS true
+
class KSPopupMenu;
/** @class StarObject
@@ -265,6 +267,12 @@ public:
quint64 updateID;
quint64 updateNumID;
+#ifdef PROFILE_UPDATECOORDS
+ static double updateCoordsCpuTime;
+ static unsigned int starsUpdated;
+#endif
+
+
protected:
// DEBUG EDIT. For testing proper motion, uncomment this, and related blocks
// See starobject.cpp for further info.