X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_timing.c;h=7d6f9b7402ea1d260affdc77148faf8932184848;hb=cdf952d345ab4b4bd0867d8d1d8995db062b5263;hp=24994daef6e23cb5bddeea1b4adb0cc092ace0f4;hpb=d9f918c846087ee7fc1b97e83671181c1ecf2fff;p=cparser diff --git a/driver/firm_timing.c b/driver/firm_timing.c index 24994da..7d6f9b7 100644 --- a/driver/firm_timing.c +++ b/driver/firm_timing.c @@ -1,67 +1,88 @@ /** * @file firm_timing.c -- timing for the Firm compiler * - * (C) 2006 Michael Beck beck@ipd.info.uni-karlsruhe.de + * (C) 2006-2009 Michael Beck beck@ipd.info.uni-karlsruhe.de * * $Id$ */ -#include #include "firm_timing.h" -static const char *tv_names[] = { -#define DEFTIMEVAR(x, y, z) y, -#include "firm_timing.def" - NULL -#undef DEFTIMEVAR -}; - -static const char *tv_desc[] = { -#define DEFTIMEVAR(x, y, z) z, -#include "firm_timing.def" - NULL -#undef DEFTIMEVAR -}; - -static lc_timer_t *timers[TV_LAST]; +#include + static int timers_inited; -void timer_init(void) { - int i; +typedef struct timer_info_t { + struct timer_info_t *next; + char *description; + ir_timer_t *timer; +} timer_info_t; + +static timer_info_t *infos; +static timer_info_t *last_info; + +void timer_register(ir_timer_t *timer, const char *description) +{ + timer_info_t *info = XMALLOCZ(timer_info_t); - for (i = 0; i < TV_LAST; ++i) { - timers[i] = lc_timer_register(tv_names[i], tv_desc[i]); + info->description = xstrdup(description); + info->timer = timer; + + if (last_info != NULL) { + last_info->next = info; + } else { + infos = info; } + last_info = info; +} +void timer_init(void) +{ timers_inited = 1; } -void timer_term(FILE *f) { - int i; +void timer_term(FILE *f) +{ + timer_info_t *info; + timer_info_t *next; + + for (info = infos; info != NULL; info = next) { + ir_timer_t *timer = info->timer; + double val = (double)ir_timer_elapsed_usec(timer) / 1000.0; + const char *description = info->description; + fprintf(f, "%-45s %8.3f msec\n", description, val); - for (i = 0; i < TV_LAST; ++i) { - unsigned long val = lc_timer_elapsed_msec(timers[i]); - fprintf(f, "%-30s %8lu\n", tv_desc[i], val); + ir_timer_free(timer); + xfree(info->description); + next = info->next; + xfree(info); } + infos = NULL; + last_info = NULL; timers_inited = 0; } -void timer_push(int timer) { +void timer_push(ir_timer_t *timer) +{ if (timers_inited) - lc_timer_push(timers[timer]); + ir_timer_push(timer); } -void timer_pop(void) { +void timer_pop(ir_timer_t *timer) +{ + (void) timer; if (timers_inited) - lc_timer_pop(); + ir_timer_pop(); } -void timer_start(int timer) { +void timer_start(ir_timer_t *timer) +{ if (timers_inited) - lc_timer_start(timers[timer]); + ir_timer_start(timer); } -void timer_stop(int timer) { +void timer_stop(ir_timer_t *timer) +{ if (timers_inited) - lc_timer_stop(timers[timer]); + ir_timer_stop(timer); }