diff options
Diffstat (limited to 'apps/codecs/spc/spc_profiler.h')
-rw-r--r-- | apps/codecs/spc/spc_profiler.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/apps/codecs/spc/spc_profiler.h b/apps/codecs/spc/spc_profiler.h new file mode 100644 index 0000000000..99d3fdf16b --- /dev/null +++ b/apps/codecs/spc/spc_profiler.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2006-2007 Adam Gashlin (hcs) | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | /* a fun simple elapsed time profiler */ | ||
20 | |||
21 | #if defined(SPC_PROFILE) && defined(USEC_TIMER) | ||
22 | |||
23 | #define CREATE_TIMER(name) static uint32_t spc_timer_##name##_start,\ | ||
24 | spc_timer_##name##_total | ||
25 | #define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER | ||
26 | #define EXIT_TIMER(name) spc_timer_##name##_total+=\ | ||
27 | (USEC_TIMER-spc_timer_##name##_start) | ||
28 | #define READ_TIMER(name) (spc_timer_##name##_total) | ||
29 | #define RESET_TIMER(name) spc_timer_##name##_total=0 | ||
30 | |||
31 | #define PRINT_TIMER_PCT(bname,tname,nstr) ci->fdprintf( \ | ||
32 | logfd,"%10ld ",READ_TIMER(bname));\ | ||
33 | ci->fdprintf(logfd,"(%3d%%) " nstr "\t",\ | ||
34 | ((uint64_t)READ_TIMER(bname))*100/READ_TIMER(tname)) | ||
35 | |||
36 | CREATE_TIMER(total); | ||
37 | CREATE_TIMER(render); | ||
38 | #if 0 | ||
39 | CREATE_TIMER(cpu); | ||
40 | CREATE_TIMER(dsp); | ||
41 | CREATE_TIMER(dsp_pregen); | ||
42 | CREATE_TIMER(dsp_gen); | ||
43 | CREATE_TIMER(dsp_mix); | ||
44 | #endif | ||
45 | |||
46 | static void reset_profile_timers(void) { | ||
47 | RESET_TIMER(total); | ||
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 | |||
79 | #else | ||
80 | |||
81 | #define CREATE_TIMER(name) | ||
82 | #define ENTER_TIMER(name) | ||
83 | #define EXIT_TIMER(name) | ||
84 | #define READ_TIMER(name) | ||
85 | #define RESET_TIMER(name) | ||
86 | #define print_timers(path) | ||
87 | #define reset_profile_timers() | ||
88 | |||
89 | #endif | ||