summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-24 05:25:15 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-28 22:16:20 (GMT)
commit0860ef61054d5ceee931aa90806e16d99ad12b9a (patch)
tree91d7ab2a450b74f5adbd486b73d8de6a7ec75a7e
parent25b07e4593ce0c0a41cdb3b706a16a2418fed826 (diff)
Profiling Code: Determine time spent in EquatorialToHorizontal
While this may as well be done in callgrind, this is simple and works, and is less of a hassle in running KStars (doesn't slow KStars down as much as callgrind would). Under some conditions, KStars output the following: [24 0:15:36 D] KStars::~KStars (182) - Spent 7.86563 seconds in 13906422 calls to SkyPoint::EquatorialToHorizontal, for an average of 0.000565611 ms per call The results seem to be somewhat consistent across runs: Spent 2.19932 seconds in 3988240 calls to SkyPoint::EquatorialToHorizontal, for an average of 0.000551452 ms per call Spent 2.02403 seconds in 3464395 calls to SkyPoint::EquatorialToHorizontal, for an average of 0.000584239 ms per call Spent 0.261255 seconds in 332259 calls to SkyPoint::EquatorialToHorizontal, for an average of 0.000786299 ms per call Spent 0.464544 seconds in 530146 calls to SkyPoint::EquatorialToHorizontal, for an average of 0.000876257 ms per call The variations seem to be tied to the number of stars in the field. The first three results are from the USNO NOMAD artifact patch in the Sagittarius milky way region. The latter are centered around regions of lower star density. The variation might be probably related to cache performance?
-rw-r--r--kstars/auxiliary/dms.h2
-rw-r--r--kstars/kstars.cpp5
-rw-r--r--kstars/skyobjects/skypoint.cpp14
-rw-r--r--kstars/skyobjects/skypoint.h7
4 files changed, 27 insertions, 1 deletions
diff --git a/kstars/auxiliary/dms.h b/kstars/auxiliary/dms.h
index 28ce633..65c2517 100644
--- a/kstars/auxiliary/dms.h
+++ b/kstars/auxiliary/dms.h
@@ -193,7 +193,7 @@ public:
void setH( const double &x );
/** @short Sets floating-point value of angle, in hours.
- *
+ *
* Converts argument values from hours to degrees, then
* sets floating-point value of angle, in degrees.
* This is an overloaded member function, provided for convenience. It
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index f4076f8..af32eda 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -44,6 +44,7 @@
// For profiling only
#include "auxiliary/dms.h"
+#include "skyobjects/skypoint.h"
#include "kstarsadaptor.h"
@@ -177,6 +178,10 @@ KStars::~KStars()
QSqlDatabase::removeDatabase("userdb");
QSqlDatabase::removeDatabase("skydb");
+#ifdef PROFILE_COORDINATE_CONVERSION
+ qDebug() << "Spent " << SkyPoint::cpuTime_EqToHz << " seconds in " << SkyPoint::eqToHzCalls << " calls to SkyPoint::EquatorialToHorizontal, for an average of " << 1000.*( SkyPoint::cpuTime_EqToHz / SkyPoint::eqToHzCalls ) << " ms per call";
+#endif
+
#ifdef COUNT_DMS_SINCOS_CALLS
qDebug() << "Constructed " << dms::dms_constructor_calls << " dms objects, of which " << dms::dms_with_sincos_called << " had trigonometric functions called on them = " << ( float( dms::dms_with_sincos_called ) / float( dms::dms_constructor_calls ) ) * 100. << "%";
qDebug() << "Of the " << dms::trig_function_calls << " calls to sin/cos/sincos on dms objects, " << dms::redundant_trig_function_calls << " were redundant = " << ( ( float( dms::redundant_trig_function_calls ) / float( dms::trig_function_calls ) ) * 100. ) << "%";
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index be4fdb8..65ab8ec 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -32,6 +32,12 @@
#include <QDebug>
+#ifdef PROFILE_COORDINATE_CONVERSION
+#include <ctime> // For profiling, remove if not profiling.
+long unsigned SkyPoint::eqToHzCalls = 0;
+double SkyPoint::cpuTime_EqToHz = 0.;
+#endif
+
KSSun *SkyPoint::m_Sun = 0;
const double SkyPoint::altCrit = -1.0;
@@ -54,6 +60,9 @@ SkyPoint::~SkyPoint(){
}
void SkyPoint::EquatorialToHorizontal( const dms *LST, const dms *lat ) {
+#ifdef PROFILE_COORDINATE_CONVERSION
+ std::clock_t start = std::clock();
+#endif
//Uncomment for spherical trig version
double AltRad, AzRad;
double sindec, cosdec, sinlat, coslat, sinHA, cosHA;
@@ -78,6 +87,11 @@ void SkyPoint::EquatorialToHorizontal( const dms *LST, const dms *lat ) {
Alt.setRadians( AltRad );
Az.setRadians( AzRad );
+#ifdef PROFILE_COORDINATE_CONVERSION
+ std::clock_t stop = std::clock();
+ cpuTime_EqToHz += double( stop - start )/double( CLOCKS_PER_SEC ); // Accumulate time in seconds
+ ++eqToHzCalls;
+#endif
// //Uncomment for XYZ version
// double xr, yr, zr, xr1, zr1, sa, ca;
diff --git a/kstars/skyobjects/skypoint.h b/kstars/skyobjects/skypoint.h
index a617be9..b48b673 100644
--- a/kstars/skyobjects/skypoint.h
+++ b/kstars/skyobjects/skypoint.h
@@ -26,6 +26,8 @@
#include "dms.h"
#include "kstarsdatetime.h"
+#define PROFILE_COORDINATE_CONVERSION true
+
class KSNumbers;
class KSSun;
class GeoLocation;
@@ -540,6 +542,11 @@ public:
*/
static const double altCrit;
+#ifdef PROFILE_COORDINATE_CONVERSION
+ static double cpuTime_EqToHz;
+ static long unsigned eqToHzCalls;
+#endif
+
protected:
/**
* Precess this SkyPoint's catalog coordinates to the epoch described by the