2 * This file is part of cparser.
3 * Copyright (C) 2012 Michael Beck <mm.beck@gmx.net>
8 * @brief timing for the Firm compiler
10 #include "firm_timing.h"
12 #include <libfirm/adt/xmalloc.h>
14 static int timers_inited;
16 typedef struct timer_info_t {
17 struct timer_info_t *next;
22 static timer_info_t *infos;
23 static timer_info_t *last_info;
25 void timer_register(ir_timer_t *timer, const char *description)
27 timer_info_t *info = XMALLOCZ(timer_info_t);
29 info->description = xstrdup(description);
32 if (last_info != NULL) {
33 last_info->next = info;
45 void timer_term(FILE *f)
50 for (info = infos; info != NULL; info = next) {
51 ir_timer_t *timer = info->timer;
53 double val = (double)ir_timer_elapsed_usec(timer) / 1000.0;
54 const char *description = info->description;
55 fprintf(f, "%-60s %10.3f msec\n", description, val);
59 xfree(info->description);
69 void timer_push(ir_timer_t *timer)
75 void timer_pop(ir_timer_t *timer)
81 void timer_start(ir_timer_t *timer)
84 ir_timer_start(timer);
87 void timer_stop(ir_timer_t *timer)