Changeset 4095 for libcaca/trunk


Ignore:
Timestamp:
Dec 7, 2009, 2:05:31 AM (10 years ago)
Author:
Sam Hocevar
Message:

Increase profiling timers' sliding mean accuracy.

Location:
libcaca/trunk/caca
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca_internals.h

    r4094 r4095  
    2525
    2626#if !defined(_DOXYGEN_SKIP_ME)
    27 #   define STAT_VALUES 20
     27#   define STAT_VALUES 32
    2828#   define EVENTBUF_LEN 10
    2929#   define MAX_DIRTY_COUNT 8
     
    149149struct caca_stat
    150150{
     151    int itable[STAT_VALUES];
     152    int64_t imean;
    151153    char *name;
    152     int imean, itable[STAT_VALUES];
    153154};
    154155
  • libcaca/trunk/caca/caca_prof.h

    r4094 r4095  
    2222#   define PROFILING_VARS
    2323
    24 #   define STAT_IADD(s, n) \
     24#   define STAT_IADD(_s, _n) \
    2525      do \
    2626      { \
    27         struct caca_stat *ss = s; \
    28         int ii, nn = n; \
    29         for (ii = STAT_VALUES - 1; ii > 0; ii--) \
    30             ss->itable[ii] = ss->itable[ii - 1]; \
    31         ss->itable[0] = nn; \
    32         ss->imean = ((int64_t)ss->imean * 15 + nn) / 16; \
     27        struct caca_stat *s = _s; \
     28        int i, n = _n; \
     29        for (i = STAT_VALUES - 1; i > 0; i--) \
     30            s->itable[i] = s->itable[i - 1]; \
     31        s->itable[0] = n; \
     32        s->imean = (s->imean * 63 + (int64_t)n * 64 + 32) / 64; \
    3333      } \
    3434      while(0)
     
    3939#else
    4040#   define PROFILING_VARS
    41 #   define STAT_IADD(s) do { } while(0)
     41#   define STAT_IADD(_s, _n) do { } while(0)
    4242#   define START_PROF(obj, fn) do { } while(0)
    4343#   define STOP_PROF(obj, fn) do { } while(0)
  • libcaca/trunk/caca/prof.c

    r4094 r4095  
    4646             total += stats[i]->itable[j];
    4747
    48          fprintf(stderr, " %s: last %i mean %i sliding mean %i\n",
     48         fprintf(stderr, " %s: last %i sliding mean %i smoothed mean %i\n",
    4949                 stats[i]->name, stats[i]->itable[0],
    5050                 (int)((total + STAT_VALUES / 2) / STAT_VALUES),
    51                  stats[i]->imean);
    52 /*fprintf(stderr, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i\n",
    53 stats[i]->itable[0], stats[i]->itable[1], stats[i]->itable[2],
    54 stats[i]->itable[3], stats[i]->itable[4], stats[i]->itable[5],
    55 stats[i]->itable[6], stats[i]->itable[7], stats[i]->itable[8],
    56 stats[i]->itable[9], stats[i]->itable[10], stats[i]->itable[11],
    57 stats[i]->itable[12], stats[i]->itable[13], stats[i]->itable[14],
    58 stats[i]->itable[15], stats[i]->itable[16], stats[i]->itable[17],
    59 stats[i]->itable[18], stats[i]->itable[19]);*/
     51                 (int)(stats[i]->imean / 64));
    6052    }
    6153
Note: See TracChangeset for help on using the changeset viewer.