Commit 6e4fff45 authored by Akarsh Simha's avatar Akarsh Simha
Browse files

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!
parent f838f262
......@@ -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
......
......@@ -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 )
......
......@@ -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.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment