poldek: poldek/misc.c, poldek/misc.h - timethis

mis mis at pld-linux.org
Sun May 25 11:17:46 CEST 2008


Author: mis                          Date: Sun May 25 09:17:46 2008 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- timethis

---- Files affected:
poldek/poldek:
   misc.c (1.64 -> 1.65) , misc.h (1.38 -> 1.39) 

---- Diffs:

================================================================
Index: poldek/poldek/misc.c
diff -u poldek/poldek/misc.c:1.64 poldek/poldek/misc.c:1.65
--- poldek/poldek/misc.c:1.64	Tue May 13 17:55:33 2008
+++ poldek/poldek/misc.c	Sun May 25 11:17:40 2008
@@ -42,6 +42,7 @@
 #include <pwd.h>
 #include <sys/wait.h>
 #include <sys/utsname.h>
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <argp.h>
@@ -840,3 +841,29 @@
     p_st_destroy(&pst);
     return ec == 0;
 }
+
+void *timethis_begin(void)
+{
+    struct timeval *tv;
+
+    tv = n_malloc(sizeof(*tv));
+    gettimeofday(tv, NULL);
+    return tv;
+}
+
+void timethis_end(void *tvp, const char *prefix)
+{
+    struct timeval tv, *tv0 = (struct timeval *)tvp;
+
+    gettimeofday(&tv, NULL);
+
+    tv.tv_sec -= tv0->tv_sec;
+    tv.tv_usec -= tv0->tv_usec;
+    if (tv.tv_usec < 0) {
+        tv.tv_sec--;
+        tv.tv_usec = 1000000 + tv.tv_usec;
+    }
+
+    msgn(2, "time [%s] %ld.%ld\n", prefix, tv.tv_sec, tv.tv_usec);
+    free(tvp);
+}

================================================================
Index: poldek/poldek/misc.h
diff -u poldek/poldek/misc.h:1.38 poldek/poldek/misc.h:1.39
--- poldek/poldek/misc.h:1.38	Mon Jul  2 18:39:22 2007
+++ poldek/poldek/misc.h	Sun May 25 11:17:41 2008
@@ -58,4 +58,7 @@
 #include "poldek_util.h"
 const char *lc_messages_lang(void);
 
+void *timethis_begin(void);
+void timethis_end(void *tvp, const char *prefix);
+
 #endif /* POLDEK_MISC_H */
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/misc.c?r1=1.64&r2=1.65&f=u
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/misc.h?r1=1.38&r2=1.39&f=u



More information about the pld-cvs-commit mailing list