1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006-2007 Adam Gashlin (hcs)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /* a fun simple elapsed time profiler */
23 #ifndef _SPC_PROFILER_H_
24 #define _SPC_PROFILER_H_
26 #if defined(SPC_PROFILE) && defined(USEC_TIMER)
28 #ifdef SPC_DEFINE_PROFILER_TIMERS
29 #define CREATE_TIMER(name) uint32_t spc_timer_##name##_start,\
30 spc_timer_##name##_total
32 #define CREATE_TIMER(name) extern uint32_t spc_timer_##name##_start,\
33 spc_timer_##name##_total
36 #define ENTER_TIMER(name) spc_timer_##name##_start=USEC_TIMER
37 #define EXIT_TIMER(name) spc_timer_##name##_total+=\
38 (USEC_TIMER-spc_timer_##name##_start)
39 #define READ_TIMER(name) (spc_timer_##name##_total)
40 #define RESET_TIMER(name) spc_timer_##name##_total=0
42 #define PRINT_TIMER_PCT(bname,tname,nstr) ci->fdprintf( \
43 logfd,"%10ld ",READ_TIMER(bname));\
44 ci->fdprintf(logfd,"(%3d%%) " nstr "\t",\
45 ((uint64_t)READ_TIMER(bname))*100/READ_TIMER(tname))
52 CREATE_TIMER(dsp_pregen
);
53 CREATE_TIMER(dsp_gen
);
54 CREATE_TIMER(dsp_mix
);
57 void reset_profile_timers(void);
58 void print_timers(char * path
);
62 #define CREATE_TIMER(name)
63 #define ENTER_TIMER(name)
64 #define EXIT_TIMER(name)
65 #define READ_TIMER(name)
66 #define RESET_TIMER(name)
67 #define print_timers(path)
68 #define reset_profile_timers()
72 #endif /* _SPC_PROFILER_H_ */