diff options
Diffstat (limited to 'apps/codecs/spc/spc_profiler.h')
-rw-r--r-- | apps/codecs/spc/spc_profiler.h | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/apps/codecs/spc/spc_profiler.h b/apps/codecs/spc/spc_profiler.h index 99d3fdf16b..330d95bca7 100644 --- a/apps/codecs/spc/spc_profiler.h +++ b/apps/codecs/spc/spc_profiler.h | |||
@@ -5,6 +5,7 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | ||
8 | * | 9 | * |
9 | * Copyright (C) 2006-2007 Adam Gashlin (hcs) | 10 | * Copyright (C) 2006-2007 Adam Gashlin (hcs) |
10 | * | 11 | * |
@@ -17,11 +18,19 @@ | |||
17 | ****************************************************************************/ | 18 | ****************************************************************************/ |
18 | 19 | ||
19 | /* a fun simple elapsed time profiler */ | 20 | /* a fun simple elapsed time profiler */ |
21 | #ifndef _SPC_PROFILER_H_ | ||
22 | #define _SPC_PROFILER_H_ | ||
20 | 23 | ||
21 | #if defined(SPC_PROFILE) && defined(USEC_TIMER) | 24 | #if defined(SPC_PROFILE) && defined(USEC_TIMER) |
22 | 25 | ||
23 | #define CREATE_TIMER(name) static uint32_t spc_timer_##name##_start,\ | 26 | #ifdef SPC_DEFINE_PROFILER_TIMERS |
27 | #define CREATE_TIMER(name) uint32_t spc_timer_##name##_start,\ | ||
24 | spc_timer_##name##_total | 28 | spc_timer_##name##_total |
29 | #else | ||
30 | #define CREATE_TIMER(name) extern uint32_t spc_timer_##name##_start,\ | ||
31 | spc_timer_##name##_total | ||
32 | #endif | ||
33 | |||
25 | #define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER | 34 | #define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER |
26 | #define EXIT_TIMER(name) spc_timer_##name##_total+=\ | 35 | #define EXIT_TIMER(name) spc_timer_##name##_total+=\ |
27 | (USEC_TIMER-spc_timer_##name##_start) | 36 | (USEC_TIMER-spc_timer_##name##_start) |
@@ -43,38 +52,8 @@ CREATE_TIMER(dsp_gen); | |||
43 | CREATE_TIMER(dsp_mix); | 52 | CREATE_TIMER(dsp_mix); |
44 | #endif | 53 | #endif |
45 | 54 | ||
46 | static void reset_profile_timers(void) { | 55 | void reset_profile_timers(void); |
47 | RESET_TIMER(total); | 56 | void print_timers(char * path); |
48 | RESET_TIMER(render); | ||
49 | #if 0 | ||
50 | RESET_TIMER(cpu); | ||
51 | RESET_TIMER(dsp); | ||
52 | RESET_TIMER(dsp_pregen); | ||
53 | RESET_TIMER(dsp_gen); | ||
54 | RESET_TIMER(dsp_mix); | ||
55 | #endif | ||
56 | } | ||
57 | |||
58 | static int logfd=-1; | ||
59 | |||
60 | static void print_timers(char * path) { | ||
61 | logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND); | ||
62 | ci->fdprintf(logfd,"%s:\t",path); | ||
63 | ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total)); | ||
64 | PRINT_TIMER_PCT(render,total,"render"); | ||
65 | #if 0 | ||
66 | PRINT_TIMER_PCT(cpu,total,"CPU"); | ||
67 | PRINT_TIMER_PCT(dsp,total,"DSP"); | ||
68 | ci->fdprintf(logfd,"("); | ||
69 | PRINT_TIMER_PCT(dsp_pregen,dsp,"pregen"); | ||
70 | PRINT_TIMER_PCT(dsp_gen,dsp,"gen"); | ||
71 | PRINT_TIMER_PCT(dsp_mix,dsp,"mix"); | ||
72 | #endif | ||
73 | ci->fdprintf(logfd,"\n"); | ||
74 | |||
75 | ci->close(logfd); | ||
76 | logfd=-1; | ||
77 | } | ||
78 | 57 | ||
79 | #else | 58 | #else |
80 | 59 | ||
@@ -87,3 +66,5 @@ static void print_timers(char * path) { | |||
87 | #define reset_profile_timers() | 66 | #define reset_profile_timers() |
88 | 67 | ||
89 | #endif | 68 | #endif |
69 | |||
70 | #endif /* _SPC_PROFILER_H_ */ | ||