Commit 0860ef61 authored by Akarsh Simha's avatar Akarsh Simha
Browse files

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?
parent 25b07e45
......@@ -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
......
......@@ -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. ) << "%";
......
......@@ -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;
......
......@@ -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
......
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