[Evolution-hackers] profiling patch





Initial work-in-progress on a profiling patch for evolution.  Profiling events are emitted to a plugin, which can process them, or in this case, just dump them to stdout.  Disabling the plugin just disables the event logging; so it is easy to turn it off, and it can be compiled out completely when it isn't needed (or will be able to when i've finished it).

It shows that I was wrong about the folder loading, although it isn't that slow still.  And it shows that e-tree is the main slowness when changing messages, although the sample points aren't correct yet for the rendering stage.

The doprofile.pl script just scans the output dumped and presents each event in a more readable form.

Michael

Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.799
diff -u -p -r1.799 configure.in
--- configure.in	20 Apr 2005 03:42:13 -0000	1.799
+++ configure.in	27 Apr 2005 10:52:01 -0000
@@ -1361,6 +1361,15 @@ xexperimental)
 	msg_plugins="yes ($enable_plugins)"
 	;;
 esac
+
+AC_ARG_ENABLE(profiling, [  --enable-profiling=[no/yes]      Enable profiling plugin.],enable_profiling="$enableval",enable_profiling=no)
+case x"$enable_profiling" in
+x | xyes)
+	plugins_enabled="$plugins_base profiler"
+	msg_plugins="$msg_plugins (and profiling)"
+	;;
+esac
+
 AC_SUBST(plugins_enabled)
 AC_SUBST(plugins_base)
 AC_SUBST(plugins_standard)
@@ -1580,6 +1589,7 @@ plugins/save-calendar/Makefile
 plugins/select-one-source/Makefile
 plugins/mark-calendar-offline/Makefile
 plugins/prefer-plain/Makefile
+plugins/profiler/Makefile
 plugins/copy-tool/Makefile
 plugins/folder-unsubscribe/Makefile
 plugins/mailing-list-actions/Makefile
Index: e-util/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/e-util/Makefile.am,v
retrieving revision 1.123
diff -u -p -r1.123 Makefile.am
--- e-util/Makefile.am	23 Feb 2005 18:56:57 -0000	1.123
+++ e-util/Makefile.am	27 Apr 2005 10:52:02 -0000
@@ -45,6 +45,7 @@ eutilinclude_HEADERS = 				\
 	e-print.h				\
 	e-plugin.h				\
 	e-popup.h				\
+	e-profile-event.h			\
 	e-request.h				\
 	e-signature.h				\
 	e-signature-list.h			\
@@ -82,6 +83,7 @@ libeutil_la_SOURCES =				\
 	e-plugin.c				\
 	e-popup.c				\
 	e-print.c				\
+	e-profile-event.c			\
 	e-request.c				\
 	e-signature.c				\
 	e-signature-list.c			\
Index: e-util/e-event.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-event.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-event.c
--- e-util/e-event.c	26 Nov 2004 14:57:49 -0000	1.4
+++ e-util/e-event.c	27 Apr 2005 10:52:02 -0000
@@ -43,6 +43,7 @@
 #include <e-util/e-icon-factory.h>
 
 #include <libgnome/gnome-i18n.h>
+#include <libedataserver/e-msgport.h>
 
 #define d(x)
 
Index: e-util/e-event.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-event.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-event.h
--- e-util/e-event.h	3 Dec 2004 03:41:19 -0000	1.3
+++ e-util/e-event.h	27 Apr 2005 10:52:02 -0000
@@ -28,7 +28,6 @@
 #define __E_EVENT_H__
 
 #include <glib-object.h>
-#include "libedataserver/e-msgport.h"
 
 #ifdef __cplusplus
 extern "C" {
Index: e-util/e-profile-event.c
===================================================================
RCS file: e-util/e-profile-event.c
diff -N e-util/e-profile-event.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ e-util/e-profile-event.c	27 Apr 2005 10:52:02 -0000
@@ -0,0 +1,190 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Authors: Michael Zucchi <notzed ximian com>
+ *
+ *  Copyright 2004 Ximian, Inc. (www.ximian.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include "e-profile-event.h"
+#include "libedataserver/e-msgport.h"
+
+static GObjectClass *eme_parent;
+static EProfileEvent *e_profile_event;
+
+static void
+eme_init(GObject *o)
+{
+	/*EProfileEvent *eme = (EProfileEvent *)o; */
+}
+
+static void
+eme_finalise(GObject *o)
+{
+	((GObjectClass *)eme_parent)->finalize(o);
+}
+
+static void
+eme_target_free(EEvent *ep, EEventTarget *t)
+{
+	switch (t->type) {
+	case E_PROFILE_EVENT_TARGET: {
+		EProfileEventTarget *s = (EProfileEventTarget *)t;
+
+		g_free(s->id);
+		g_free(s->uid);
+		break; }
+	}
+
+	((EEventClass *)eme_parent)->target_free(ep, t);
+}
+
+static void
+eme_class_init(GObjectClass *klass)
+{
+	klass->finalize = eme_finalise;
+	((EEventClass *)klass)->target_free = eme_target_free;
+}
+
+GType
+e_profile_event_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		static const GTypeInfo info = {
+			sizeof(EProfileEventClass),
+			NULL, NULL,
+			(GClassInitFunc)eme_class_init,
+			NULL, NULL,
+			sizeof(EProfileEvent), 0,
+			(GInstanceInitFunc)eme_init
+		};
+		eme_parent = g_type_class_ref(e_event_get_type());
+		type = g_type_register_static(e_event_get_type(), "EProfileEvent", &info, 0);
+	}
+
+	return type;
+}
+
+/**
+ * e_profile_event_peek:
+ * @void: 
+ * 
+ * Get the singular instance of the profile event handler.
+ * 
+ * Return value: 
+ **/
+EProfileEvent *e_profile_event_peek(void)
+{
+	if (e_profile_event == NULL) {
+		e_profile_event = g_object_new(e_profile_event_get_type(), 0);
+		e_event_construct(&e_profile_event->popup, "org.gnome.evolution.profile.events");
+	}
+
+	return e_profile_event;
+}
+
+EProfileEventTarget *
+e_profile_event_target_new(EProfileEvent *eme, const char *id, const char *uid, guint32 flags)
+{
+	EProfileEventTarget *t = e_event_target_new(&eme->popup, E_PROFILE_EVENT_TARGET, sizeof(*t));
+
+	t->id = g_strdup(id);
+	t->uid = g_strdup(uid);
+	t->target.mask = ~flags;
+	gettimeofday(&t->tv, NULL);
+
+	return t;
+}
+
+#ifdef PROFILE_HOOKS
+void
+e_profile_event_emit(const char *id, const char *uid, guint32 flags)
+{
+	EProfileEvent *epe = e_profile_event_peek();
+	EProfileEventTarget *t = e_profile_event_target_new(epe, id, uid, flags);
+
+	e_event_emit((EEvent *)epe, "event", (EEventTarget *)t);
+}
+#endif
+
+/* ********************************************************************** */
+
+static void *emeh_parent_class;
+#define emeh ((EProfileEventHook *)eph)
+
+static const EEventHookTargetMask emeh_profile_masks[] = {
+	{ "start", E_PROFILE_EVENT_START },
+	{ "end", E_PROFILE_EVENT_END },
+	{ "cancel", E_PROFILE_EVENT_CANCEL },
+	{ 0 }
+};
+
+static const EEventHookTargetMap emeh_targets[] = {
+	{ "event", E_PROFILE_EVENT_TARGET, emeh_profile_masks },
+	{ 0 }
+};
+
+static void
+emeh_finalise(GObject *o)
+{
+	/*EPluginHook *eph = (EPluginHook *)o;*/
+
+	((GObjectClass *)emeh_parent_class)->finalize(o);
+}
+
+static void
+emeh_class_init(EPluginHookClass *klass)
+{
+	int i;
+
+	((GObjectClass *)klass)->finalize = emeh_finalise;
+	((EPluginHookClass *)klass)->id = "org.gnome.evolution.profile.events:1.0";
+
+	for (i=0;emeh_targets[i].type;i++)
+		e_event_hook_class_add_target_map((EEventHookClass *)klass, &emeh_targets[i]);
+
+	((EEventHookClass *)klass)->event = (EEvent *)e_profile_event_peek();
+}
+
+GType
+e_profile_event_hook_get_type(void)
+{
+	static GType type = 0;
+	
+	if (!type) {
+		static const GTypeInfo info = {
+			sizeof(EProfileEventHookClass), NULL, NULL, (GClassInitFunc) emeh_class_init, NULL, NULL,
+			sizeof(EProfileEventHook), 0, (GInstanceInitFunc) NULL,
+		};
+
+		emeh_parent_class = g_type_class_ref(e_event_hook_get_type());
+		type = g_type_register_static(e_event_hook_get_type(), "EProfileEventHook", &info, 0);
+	}
+	
+	return type;
+}
Index: e-util/e-profile-event.h
===================================================================
RCS file: e-util/e-profile-event.h
diff -N e-util/e-profile-event.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ e-util/e-profile-event.h	27 Apr 2005 10:52:02 -0000
@@ -0,0 +1,110 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ *  Authors: Michel Zucchi <notzed ximian com>
+ *
+ *  Copyright 2003 Ximian, Inc. (www.ximian.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __E_PROFILE_EVENT_H__
+#define __E_PROFILE_EVENT_H__
+
+#define PROFILE_HOOKS (1)
+
+#include <glib-object.h>
+#include <sys/time.h>
+
+#include "e-util/e-event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+struct _CamelFolder;
+struct _CamelMimeMessage;
+
+typedef struct _EProfileEvent EProfileEvent;
+typedef struct _EProfileEventClass EProfileEventClass;
+
+/* Current target description */
+enum _e_profile_event_target_t {
+	E_PROFILE_EVENT_TARGET,
+};
+
+/* Flags that qualify a target (UNIMPLEMENTED) */
+enum {
+	E_PROFILE_EVENT_START = 1<< 0,
+	E_PROFILE_EVENT_END = 1<< 1,
+	E_PROFILE_EVENT_CANCEL = 1<< 2,
+};
+
+typedef struct _EProfileEventTarget EProfileEventTarget;
+
+struct _EProfileEventTarget {
+	EEventTarget target;
+
+	struct timeval tv;
+	char *id;		/* id of event */
+	char *uid;		/* uid of event (folder/message, etc) */
+};
+
+typedef struct _EEventItem EProfileEventItem;
+
+/* The object */
+struct _EProfileEvent {
+	EEvent popup;
+
+	struct _EProfileEventPrivate *priv;
+};
+
+struct _EProfileEventClass {
+	EEventClass popup_class;
+};
+
+GType e_profile_event_get_type(void);
+
+EProfileEvent *e_profile_event_peek(void);
+
+EProfileEventTarget *e_profile_event_target_new(EProfileEvent *emp, const char *id, const char *uid, guint32 flags);
+
+#ifndef PROFILE_HOOKS
+#define e_profile_event_emit(id, uid, flags)
+#else
+void e_profile_event_emit(const char *id, const char *uid, guint32 flags);
+#endif
+
+/* ********************************************************************** */
+
+typedef struct _EProfileEventHook EProfileEventHook;
+typedef struct _EProfileEventHookClass EProfileEventHookClass;
+
+struct _EProfileEventHook {
+	EEventHook hook;
+};
+
+struct _EProfileEventHookClass {
+	EEventHookClass hook_class;
+};
+
+GType e_profile_event_hook_get_type(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __E_PROFILE_EVENT_H__ */
Index: mail/em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.114
diff -u -p -r1.114 em-folder-view.c
--- mail/em-folder-view.c	8 Apr 2005 04:34:25 -0000	1.114
+++ mail/em-folder-view.c	27 Apr 2005 10:52:02 -0000
@@ -69,6 +69,7 @@
 #include <e-util/e-dialog-utils.h>
 #include <e-util/e-icon-factory.h>
 #include <e-util/e-print.h>
+#include <e-util/e-profile-event.h>
 
 #include "em-format-html-display.h"
 #include "em-format-html-print.h"
@@ -608,18 +609,22 @@ emfv_got_folder(char *uri, CamelFolder *
 {
 	EMFolderView *emfv = data;
 	
+	e_profile_event_emit("folder.opened", uri?uri:"<none>", 0);
 	em_folder_view_set_folder(emfv, folder, uri);
 }
 
 static void
 emfv_set_folder_uri(EMFolderView *emfv, const char *uri)
 {
+	e_profile_event_emit("folder.open", uri?uri:"<none>", 0);
 	mail_get_folder(uri, 0, emfv_got_folder, emfv, mail_thread_queued);
 }
 
 static void
 emfv_set_message(EMFolderView *emfv, const char *uid, int nomarkseen)
 {
+	e_profile_event_emit("goto.uid", uid?uid:"<none>", 0);
+
 	/* This could possible race with other set messages, but likelyhood is small */
 	emfv->priv->nomarkseen = nomarkseen;
 	message_list_select_uid(emfv->list, uid);
@@ -1198,6 +1203,8 @@ emfv_mail_next(BonoboUIComponent *uid, v
 {
 	EMFolderView *emfv = data;
 
+	e_profile_event_emit("goto.next", "", 0);
+
 	message_list_select(emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0);
 }
 
@@ -2123,7 +2130,10 @@ emfv_list_done_message_selected(CamelFol
 		emfv_enable_menus(emfv);
 		g_object_unref (emfv);
 		return;
+
 	}
+
+	e_profile_event_emit("goto.loaded", emfv->displayed_uid, 0);
 		
 	/** @Event: message.reading
 	 * @Title: Viewing a message
@@ -2137,7 +2147,7 @@ emfv_list_done_message_selected(CamelFol
 	e_event_emit((EEvent *)eme, "message.reading", (EEventTarget *)target);
 
 	em_format_format((EMFormat *)emfv->preview, folder, uid, msg);
-	
+
 	if (emfv->priv->seen_id)
 		g_source_remove(emfv->priv->seen_id);
 	
@@ -2159,6 +2169,8 @@ emfv_list_done_message_selected(CamelFol
 	emfv->priv->nomarkseen = FALSE;
 	emfv_enable_menus(emfv);
 	g_object_unref (emfv);
+
+	e_profile_event_emit("goto.done", emfv->displayed_uid, 0);
 }
 
 static gboolean
@@ -2173,12 +2185,15 @@ emfv_message_selected_timeout(void *data
 			emfv->priv->selected_uid = NULL;
 			g_object_ref (emfv);
 			/* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */
+			e_profile_event_emit("goto.load", emfv->displayed_uid, 0);
 			mail_get_message(emfv->folder, emfv->displayed_uid, emfv_list_done_message_selected, emfv, mail_thread_queued);
 		} else {
+			e_profile_event_emit("goto.empty", "", 0);
 			g_free(emfv->priv->selected_uid);
 			emfv->priv->selected_uid = NULL;
 		}
 	} else {
+		e_profile_event_emit("goto.empty", "", 0);
 		g_free(emfv->displayed_uid);
 		emfv->displayed_uid = NULL;
 		em_format_format((EMFormat *)emfv->preview, NULL, NULL, NULL);
@@ -2193,6 +2208,8 @@ emfv_message_selected_timeout(void *data
 static void
 emfv_list_message_selected(MessageList *ml, const char *uid, EMFolderView *emfv)
 {
+	e_profile_event_emit("goto.listuid", uid, 0);
+
 	if (emfv->preview_active) {
 		if (emfv->priv->selected_id != 0)
 			g_source_remove(emfv->priv->selected_id);
Index: mail/message-list.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/message-list.c,v
retrieving revision 1.414
diff -u -p -r1.414 message-list.c
--- mail/message-list.c	1 Apr 2005 00:17:24 -0000	1.414
+++ mail/message-list.c	27 Apr 2005 10:52:04 -0000
@@ -71,6 +71,7 @@
 
 #include "em-utils.h"
 #include <e-util/e-icon-factory.h>
+#include <e-util/e-profile-event.h>
 
 #include "art/empty.xpm"
 
@@ -2796,7 +2797,7 @@ message_list_set_folder (MessageList *me
 		return;
 	
 	camel_exception_init (&ex);
-	
+
 	/* remove the cursor activate idle handler */
 	if (message_list->idle_id != 0) {
 		g_source_remove (message_list->idle_id);
@@ -3397,6 +3398,8 @@ regen_list_regen (struct _mail_msg *mm)
 	if (m->folder != m->ml->folder)
 		return;
 
+	e_profile_event_emit("list.getuids", m->folder->full_name, 0);
+
 	/* if we have hidedeleted on, use a search to find it out, merge with existing search if set */
 	if (!camel_folder_has_search_capability(m->folder)) {
 		/* if we have no search capability, dont let search or hide deleted work */
@@ -3515,6 +3518,8 @@ regen_list_regen (struct _mail_msg *mm)
 	}
 	
 	MESSAGE_LIST_UNLOCK(m->ml, hide_lock);
+
+	e_profile_event_emit("list.threaduids", m->folder->full_name, 0);
 	
 	if (!camel_operation_cancel_check(mm->cancel)) {
 		/* update/build a new tree */
@@ -3561,6 +3566,8 @@ regen_list_regened (struct _mail_msg *mm
 	if (m->ml->folder != m->folder)
 		return;
 
+	e_profile_event_emit("list.buildtree", m->folder->full_name, 0);
+
 	if (m->dotree) {
 		if (m->ml->just_set_folder)
 			m->ml->just_set_folder = FALSE;
@@ -3600,6 +3607,8 @@ regen_list_free (struct _mail_msg *mm)
 	struct _regen_list_msg *m = (struct _regen_list_msg *)mm;
 	int i;
 
+	e_profile_event_emit("list.regenerated", m->folder->full_name, 0);
+
 	if (m->summary) {
 		for (i = 0; i < m->summary->len; i++)
 			camel_folder_free_message_info (m->folder, m->summary->pdata[i]);
@@ -3632,6 +3641,8 @@ static struct _mail_msg_op regen_list_op
 static gboolean
 ml_regen_timeout(struct _regen_list_msg *m)
 {
+	e_profile_event_emit("list.regenerate", m->folder->full_name, 0);
+
 	m->ml->regen = g_list_prepend(m->ml->regen, m);
 	/* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */
 	e_thread_put (mail_thread_queued, (EMsg *)m);
@@ -3672,7 +3683,7 @@ mail_regen_list (MessageList *ml, const 
 {
 	struct _regen_list_msg *m;
 	GConfClient *gconf;
-	
+
 	if (ml->folder == NULL) {
 		if (ml->search != search) {
 			g_free(ml->search);
Index: plugins/profiler/ChangeLog
===================================================================
RCS file: plugins/profiler/ChangeLog
diff -N plugins/profiler/ChangeLog
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/profiler/ChangeLog	27 Apr 2005 10:52:04 -0000
@@ -0,0 +1,4 @@
+2005-04-26  Not Zed  <NotZed Ximian com>
+
+	* A profiler plugin.
+
Index: plugins/profiler/Makefile.am
===================================================================
RCS file: plugins/profiler/Makefile.am
diff -N plugins/profiler/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/profiler/Makefile.am	27 Apr 2005 10:52:04 -0000
@@ -0,0 +1,15 @@
+INCLUDES =						\
+	-I$(top_srcdir)					\
+	$(SHELL_CFLAGS)
+
+LIBS = $(SHELL_LIBS)
+
+ EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-evolution-profiler.eplug
+plugin_LTLIBRARIES = liborg-gnome-evolution-profiler.la
+
+liborg_gnome_evolution_profiler_la_SOURCES = profiler.c
+liborg_gnome_evolution_profiler_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = org-gnome-evolution-profiler.eplug.in
Index: plugins/profiler/org-gnome-evolution-profiler.eplug.in
===================================================================
RCS file: plugins/profiler/org-gnome-evolution-profiler.eplug.in
diff -N plugins/profiler/org-gnome-evolution-profiler.eplug.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/profiler/org-gnome-evolution-profiler.eplug.in	27 Apr 2005 10:52:04 -0000
@@ -0,0 +1,15 @@
+<e-plugin-list>
+	<e-plugin
+	id="org.gnome.evolution.profiler" 
+	type="shlib" 
+	name="Evolution Profiler" 
+	location="@PLUGINDIR@/liborg-gnome-evolution-profiler.so">
+
+		<description>Generates a D-BUS message when new mail arrives.</description>
+		<author name="Michael Zucchi" email="notzed novell com"/>
+
+		<hook class="org.gnome.evolution.profile.events:1.0">
+			<event id="event" handle="org_gnome_evolution_profiler_event" target="event"/>
+		</hook>
+	</e-plugin>
+</e-plugin-list>
Index: plugins/profiler/profiler.c
===================================================================
RCS file: plugins/profiler/profiler.c
diff -N plugins/profiler/profiler.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/profiler/profiler.c	27 Apr 2005 10:52:04 -0000
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Author: Michael Zucchi <notzed novell com>
+ *
+ *  Copyright 2005 Novell, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of version 2 of the GNU General Public
+ *  License as published by the Free Software Foundation.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+#include <e-util/e-profile-event.h>
+
+void
+org_gnome_evolution_profiler_event(EPlugin *ep, EProfileEventTarget *t)
+{
+	printf("%d.%d: %s,%s\n", t->tv.tv_sec, t->tv.tv_usec, t->id, t->uid);
+}
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.167
diff -u -p -r1.167 main.c
--- shell/main.c	21 Mar 2005 13:57:38 -0000	1.167
+++ shell/main.c	27 Apr 2005 10:52:04 -0000
@@ -30,6 +30,7 @@
 
 #include <e-util/e-icon-factory.h>
 #include "e-shell-constants.h"
+#include "e-util/e-profile-event.h"
 
 #include "e-shell.h"
 #include "es-menu.h"
@@ -593,6 +594,9 @@ main (int argc, char **argv)
 		e_plugin_register_type(e_plugin_lib_get_type());
 		e_plugin_hook_register_type(es_menu_hook_get_type());
 		e_plugin_hook_register_type(es_event_hook_get_type());
+#ifdef PROFILE_HOOKS
+		e_plugin_hook_register_type(e_profile_event_hook_get_type());
+#endif
 		e_plugin_load_plugins();
 	}
 
#!/usr/bin/perl

%events = (
	   "folder.open" => 1,
	   "folder.opened" => 99,
	   "list.regenerate" => 1,
	   "list.getuids", => 2,
	   "list.threaduids", => 3,
	   "list.buildtree", => 4,
	   "list.regenerated" => 99,
	   "goto.listuid", => 1,
	   "goto.uid", => 1,
	   "goto.next", => 1,
	   "goto.load", => 1,
	   "goto.loaded", => 3,
	   "goto.done", => 99,

 );

while (<STDIN>) {
    if (m/(\d+)\.(\d+): ([^\.]+)\.([^,]+),(.*)/) {
	$sec = $1;
	$usec = $2;
	$id = $3;
	$idsub = $4;
	$uid = $5;

	$time = $sec + ($usec/1000000.0);

	if ($state{$id} == 0) {
	    $log{$id} = "$id.$idsub\n";
	    $starts{$id} = $time;
	} else {
	    $diff = $time - $times{$id};
	    $log{$id} .= sprintf "%8.4f ".$lastid{$id}.": $uid\n", $diff;
	}
	$lastid{$id} = $idsub;
	$state{$id} = $events{"$id.$idsub"};
	if ($state{$id} == 99) {
	    $log{$id} .= sprintf "total: %8.4f\n", $time - $starts{$id};
	    print $log{$id};
	    $log{$id} = "";
	    $state{$id} = 0;
	}
	$times{$id} = $time;
    }

}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]