Skip to content
Commit a6782b5a authored by Akarsh Simha's avatar Akarsh Simha
Browse files

Profiling Code: Count trigonometric calls on dms, and profile them.

Profiling code I: fraction of dms objects that have sin/cos called

This is profiling code to find out what fraction of dms objects hae
sin/cos called on them. This is useful to figure out if it makes sense
to cache sin/cos values in the constructor itself. It turns out that
this might not be a wise decision since the profiling results in at
least some context says that it can be as low as 25%:

[24 0:15:36 D] KStars::~KStars (186) - Constructed  68504224  dms
objects, of which  17021346  had trigonometric functions called on
them =  24.8471 %

In a different run, it was a bit higher, but still less than 50%.

This suggests that it might not be wise to compute and cache sin / cos
values upon construction

Profiling code II: determine how many trig calls on dms are redundant

The initial results of this profiling seem to be staggering! If the
simulation clock is running, so we are actually recomputing
coordinates, nearly 50% of trigonometric function calls seem to be
redundant! This might justify caching the values of sine and cosine
upon first computation within dms() itself. This will add a
conditional, which can lead to a potential branch mispredict, and some
extra stuff, so I'd guess ~ 20 CPU cycles; however, it would save an
expensive (~110 CPU cycles) trigonometric function computation almost
50% of the time. Given that a significant fraction (~27% under some
particular conditions) of KStars' time is spent on computing sine and
cosine, it might be well worth it to save these calls.

CCMAIL: kstars-devel@kde.org
parent 3a5a0a4c
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