summaryrefslogtreecommitdiff
path: root/navit/profile.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
commitca99b617483dd3b59fd42738e810309c4229a538 (patch)
treebe7bb1cb1020f4022e41c004e2fa9d561ea3580d /navit/profile.c
parent77ebd4f9df170e6211c5ace8d43c997d385d9ec9 (diff)
downloadnavit-svn-ca99b617483dd3b59fd42738e810309c4229a538.tar.gz
Fix:Core:Renamed src to navit for cleanup of includes
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1059 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/profile.c')
-rw-r--r--navit/profile.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/navit/profile.c b/navit/profile.c
new file mode 100644
index 00000000..677af4ba
--- /dev/null
+++ b/navit/profile.c
@@ -0,0 +1,43 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include "profile.h"
+#include "debug.h"
+
+void
+profile_timer(int level, const char *module, const char *function, const char *fmt, ...)
+{
+ va_list ap;
+ static struct timeval last[3];
+ struct timeval curr;
+ int msec,usec;
+ char buffer[strlen(module)+20];
+
+ va_start(ap, fmt);
+ if (level < 0)
+ level=0;
+ if (level > 2)
+ level=2;
+ if (fmt) {
+ gettimeofday(&curr, NULL);
+ msec=(curr.tv_usec-last[level].tv_usec)/1000+
+ (curr.tv_sec-last[level].tv_sec)*1000;
+
+ sprintf(buffer, "profile:%s", module);
+ debug_vprintf(1, buffer, strlen(buffer), function, strlen(function), 1, fmt, ap);
+ if (msec >= 100)
+ debug_printf(1, buffer, strlen(buffer), function, strlen(function), 0, " %d msec\n", msec);
+ else {
+ usec=(curr.tv_usec-last[level].tv_usec)+(curr.tv_sec-last[level].tv_sec)*1000*1000;
+ debug_printf(1, buffer, strlen(buffer), function, strlen(function), 0, " %d.%d msec\n", usec/1000, usec%1000);
+ }
+ gettimeofday(&last[level], NULL);
+ } else {
+ gettimeofday(&curr, NULL);
+ for (level = 0 ; level < 3 ; level++)
+ last[level]=curr;
+ }
+ va_end(ap);
+}