Browse Source

Increase profiling timers' sliding mean accuracy.

tags/v0.99.beta17
Sam Hocevar sam 15 years ago
parent
commit
2e94c606b8
3 changed files with 13 additions and 20 deletions
  1. +3
    -2
      caca/caca_internals.h
  2. +8
    -8
      caca/caca_prof.h
  3. +2
    -10
      caca/prof.c

+ 3
- 2
caca/caca_internals.h View File

@@ -24,7 +24,7 @@ typedef struct caca_privevent caca_privevent_t;
typedef struct caca_figfont caca_figfont_t; typedef struct caca_figfont caca_figfont_t;


#if !defined(_DOXYGEN_SKIP_ME) #if !defined(_DOXYGEN_SKIP_ME)
# define STAT_VALUES 20
# define STAT_VALUES 32
# define EVENTBUF_LEN 10 # define EVENTBUF_LEN 10
# define MAX_DIRTY_COUNT 8 # define MAX_DIRTY_COUNT 8
#endif #endif
@@ -148,8 +148,9 @@ struct caca_timer
/* Statistic structure for profiling */ /* Statistic structure for profiling */
struct caca_stat struct caca_stat
{ {
int itable[STAT_VALUES];
int64_t imean;
char *name; char *name;
int imean, itable[STAT_VALUES];
}; };


/* Private event structure */ /* Private event structure */


+ 8
- 8
caca/caca_prof.h View File

@@ -21,15 +21,15 @@
#if defined PROF && !defined __KERNEL__ #if defined PROF && !defined __KERNEL__
# define PROFILING_VARS # define PROFILING_VARS


# define STAT_IADD(s, n) \
# define STAT_IADD(_s, _n) \
do \ do \
{ \ { \
struct caca_stat *ss = s; \
int ii, nn = n; \
for (ii = STAT_VALUES - 1; ii > 0; ii--) \
ss->itable[ii] = ss->itable[ii - 1]; \
ss->itable[0] = nn; \
ss->imean = ((int64_t)ss->imean * 15 + nn) / 16; \
struct caca_stat *s = _s; \
int i, n = _n; \
for (i = STAT_VALUES - 1; i > 0; i--) \
s->itable[i] = s->itable[i - 1]; \
s->itable[0] = n; \
s->imean = (s->imean * 63 + (int64_t)n * 64 + 32) / 64; \
} \ } \
while(0) while(0)


@@ -38,7 +38,7 @@


#else #else
# define PROFILING_VARS # define PROFILING_VARS
# define STAT_IADD(s) do { } while(0)
# define STAT_IADD(_s, _n) do { } while(0)
# define START_PROF(obj, fn) do { } while(0) # define START_PROF(obj, fn) do { } while(0)
# define STOP_PROF(obj, fn) do { } while(0) # define STOP_PROF(obj, fn) do { } while(0)
#endif #endif


+ 2
- 10
caca/prof.c View File

@@ -45,18 +45,10 @@ void _caca_dump_stats(void)
for (j = 0; j < STAT_VALUES; j++) for (j = 0; j < STAT_VALUES; j++)
total += stats[i]->itable[j]; total += stats[i]->itable[j];


fprintf(stderr, " %s: last %i mean %i sliding mean %i\n",
fprintf(stderr, " %s: last %i sliding mean %i smoothed mean %i\n",
stats[i]->name, stats[i]->itable[0], stats[i]->name, stats[i]->itable[0],
(int)((total + STAT_VALUES / 2) / STAT_VALUES), (int)((total + STAT_VALUES / 2) / STAT_VALUES),
stats[i]->imean);
/*fprintf(stderr, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i\n",
stats[i]->itable[0], stats[i]->itable[1], stats[i]->itable[2],
stats[i]->itable[3], stats[i]->itable[4], stats[i]->itable[5],
stats[i]->itable[6], stats[i]->itable[7], stats[i]->itable[8],
stats[i]->itable[9], stats[i]->itable[10], stats[i]->itable[11],
stats[i]->itable[12], stats[i]->itable[13], stats[i]->itable[14],
stats[i]->itable[15], stats[i]->itable[16], stats[i]->itable[17],
stats[i]->itable[18], stats[i]->itable[19]);*/
(int)(stats[i]->imean / 64));
} }


fprintf(stderr, "** %i counters dumped **\n", nstats); fprintf(stderr, "** %i counters dumped **\n", nstats);


Loading…
Cancel
Save