Skip to content
  • Akarsh Simha's avatar
    Profiling Code: Count trigonometric calls on dms, and profile them. · 25b07e45
    Akarsh Simha authored
    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
    25b07e45