[Telepathy-commits] [telepathy-mission-control/master] Add timestamps
Alberto Mardegan
alberto.mardegan at nokia.com
Fri Nov 21 04:53:08 PST 2008
---
src/Makefile.am | 3 +-
src/mcd-connection.c | 2 +
src/mcd-dispatcher.c | 5 +++
src/timestamps.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 78 insertions(+), 1 deletions(-)
create mode 100644 src/timestamps.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 5cadb21..f05bd39 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,7 +80,8 @@ mission_control_include_HEADERS = \
mcd-account-config.h \
mcd-account-priv.h \
mcd-enum-types.h \
- mcd-misc.h
+ mcd-misc.h \
+ timestamps.h
BUILT_SOURCES = \
_gen/all.xml \
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index ecc29c6..581d691 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -56,6 +56,7 @@
#include "mcd-channel.h"
#include "mcd-provisioning-factory.h"
#include "mcd-misc.h"
+#include "timestamps.h"
#define MAX_REF_PRESENCE 4
#define LAST_MC_PRESENCE (TP_CONNECTION_PRESENCE_TYPE_BUSY + 1)
@@ -1084,6 +1085,7 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels,
channels))
return;
+ timestamp ("NewChannels received");
for (i = 0; i < channels->len; i++)
{
GValueArray *va;
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 2ca7cc2..69f2abb 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -56,6 +56,7 @@
#include <libmcclient/mc-errors.h>
#include <string.h>
+#include "timestamps.h"
#define MCD_DISPATCHER_PRIV(dispatcher) (MCD_DISPATCHER (dispatcher)->priv)
@@ -1120,6 +1121,7 @@ mcd_dispatcher_run_handlers (McdDispatcherContext *context)
const GList *channels;
GList *unhandled = NULL;
+ timestamp ("run handlers");
mcd_dispatcher_context_ref (context);
/* call mcd_dispatcher_run_handler until there are no unhandled channels */
@@ -1176,6 +1178,7 @@ mcd_dispatcher_run_observers (McdDispatcherContext *context)
GList *list;
GHashTable *observer_info;
+ timestamp ("run observers");
channels = context->channels;
observer_info = NULL;
@@ -1272,6 +1275,7 @@ mcd_dispatcher_run_approvers (McdDispatcherContext *context)
GList *list;
g_return_if_fail (context->operation != NULL);
+ timestamp ("run approvers");
/* we temporarily increment this count and decrement it at the end of the
* function, to make sure it won't become 0 while we are still invoking
@@ -1500,6 +1504,7 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher,
{
g_debug ("entering state machine for context %p", context);
+ timestamp ("invoke internal filters");
priv->state_machine_list =
g_slist_prepend (priv->state_machine_list, context);
mcd_dispatcher_context_process (context, TRUE);
diff --git a/src/timestamps.h b/src/timestamps.h
new file mode 100644
index 0000000..9bbe4cf
--- /dev/null
+++ b/src/timestamps.h
@@ -0,0 +1,69 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Contact: Alberto Mardegan <alberto.mardegan at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+/*
+ * Macro to add/mark "timestamps" to program in a way that can be found
+ * from LTT traces. This helps in pinpointing when something interesting
+ * starts or ends in the trace.
+ *
+ * Use like this:
+ * #include "timestamps.h"
+ * ...
+ * timestamp("something-interesting-start");
+ *
+ * To enable timestamping when building the code in Scratchbox,
+ * do this before build:
+ * export SBOX_EXTRA_COMPILER_ARGS="-DCREATE_TIMESTAMPS=1"
+ *
+ * If you don't have LTT, you can see the timestamps when running
+ * the software with:
+ * strace -f -tt -e open ./binary 2>&1 | grep /tmp/stamps|cut -d, -f1
+ * ir if program is already running, give "-p PID" for strace
+ * to attach to it instead.
+ *
+ * Although less useful due to bad granularity, if you (re-)create
+ * /tmp/stamps directory before the test:
+ * rm -r /tmp/tests/
+ * mkdir -p /tmp/tests
+ * you can afterwards see the timestamps with 1 sec granularity
+ * (and see their order):
+ * ls -clrt /tmp/stamps/|awk '{print $8, $9}'
+ */
+#ifndef TIMESTAMPS_H
+#define TIMESTAMPS_H
+
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifdef CREATE_TIMESTAMPS
+# define timestamp(step) { int _tmp_fd; \
+ _tmp_fd = open("/tmp/stamps/" __FILE__ ":" step, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); \
+ if (_tmp_fd >=0) close(_tmp_fd); }
+#else
+# define timestamp(step)
+#endif
+
+#endif /* TIMESTAMPS_H */
--
1.5.6.5
More information about the Telepathy-commits
mailing list