aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_wrappers.c
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2015-08-13 17:10:02 -0500
committerPeter Seebach <peter.seebach@windriver.com>2015-08-20 17:17:09 -0500
commit4377856c427d40d4d518263ff0b6effa00fd3636 (patch)
treed59095adf952060da6f6969fa792b3cf3f074c65 /pseudo_wrappers.c
parentdc631e69f8d189332c86a7dcae5b9f0badd52fd0 (diff)
downloadpseudo-4377856c427d40d4d518263ff0b6effa00fd3636.tar.gz
pseudo-4377856c427d40d4d518263ff0b6effa00fd3636.tar.bz2
pseudo-4377856c427d40d4d518263ff0b6effa00fd3636.zip
Initial profiling implementation.
A partially-implemented profiler for client time, which basically just inserts (optional) gettimeofday calls in various places and stashes data in a flat file containing one data block per pid. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
Diffstat (limited to 'pseudo_wrappers.c')
-rw-r--r--pseudo_wrappers.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index 4a40fed..b2e3810 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/wait.h>
#include <dlfcn.h>
@@ -70,6 +71,21 @@ static void _libpseudo_init(void) __attribute__ ((constructor));
static int _libpseudo_initted = 0;
+#ifdef PSEUDO_PROFILING
+extern struct timeval *pseudo_wrapper_time;
+/* profiling shared postamble */
+#define PROFILE_START \
+ struct timeval tv1, tv2; \
+ do { gettimeofday(&tv1, NULL); } while(0)
+#define PROFILE_DONE do { \
+ gettimeofday(&tv2, NULL); \
+ pseudo_wrapper_time->tv_sec += tv2.tv_sec - tv1.tv_sec; \
+ pseudo_wrapper_time->tv_usec += tv2.tv_usec - tv1.tv_usec; } while(0)
+#else
+#define PROFILE_START do {} while(0)
+#define PROFILE_DONE do {} while(0)
+#endif
+
static void
_libpseudo_init(void) {
pseudo_getlock();