2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
29 profile_timer(int level, const char *module, const char *function, const char *fmt, ...)
32 static struct timeval last[10];
35 char buffer[strlen(module)+20];
43 gettimeofday(&curr, NULL);
44 msec=(curr.tv_usec-last[level].tv_usec)/1000+
45 (curr.tv_sec-last[level].tv_sec)*1000;
47 sprintf(buffer, "profile:%s", module);
48 debug_vprintf(1, buffer, strlen(buffer), function, strlen(function), 1, fmt, ap);
50 debug_printf(1, buffer, strlen(buffer), function, strlen(function), 0, " %d msec\n", msec);
52 usec=(curr.tv_usec-last[level].tv_usec)+(curr.tv_sec-last[level].tv_sec)*1000*1000;
53 debug_printf(1, buffer, strlen(buffer), function, strlen(function), 0, " %d.%d msec\n", usec/1000, usec%1000);
55 gettimeofday(&last[level], NULL);
57 gettimeofday(&curr, NULL);