gnome-games r8448 - trunk/libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8448 - trunk/libgames-support
- Date: Tue, 6 Jan 2009 18:18:59 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:18:59 2009
New Revision: 8448
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8448&view=rev
Log:
Add profiling, copied from gnome-settings-demon.
See http://www.gnome.org/~federico/news-2006-03.html#09 for how to use
it.
Added:
trunk/libgames-support/games-profile.c
trunk/libgames-support/games-profile.h
Modified:
trunk/libgames-support/Makefile.am
Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am (original)
+++ trunk/libgames-support/Makefile.am Tue Jan 6 18:18:59 2009
@@ -40,6 +40,8 @@
games-help.h \
games-pixbuf-utils.c \
games-pixbuf-utils.h \
+ games-profile.c \
+ games-profile.h \
games-runtime.c \
games-runtime.h \
games-sound.c \
Added: trunk/libgames-support/games-profile.c
==============================================================================
--- (empty file)
+++ trunk/libgames-support/games-profile.c Tue Jan 6 18:18:59 2009
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright  2005 William Jon McCann <mccann jhu edu>
+ *
+ * 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 Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors: William Jon McCann <mccann jhu edu>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "games-profile.h"
+
+void
+_games_profile_log (const char *func,
+ const char *note,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char *str;
+ char *formatted;
+
+ if (format == NULL) {
+ formatted = g_strdup ("");
+ } else {
+ va_start (args, format);
+ formatted = g_strdup_vprintf (format, args);
+ va_end (args);
+ }
+
+ if (func != NULL) {
+ str = g_strdup_printf ("MARK: %s %s: %s %s", g_get_prgname(), func, note ? note : "", formatted);
+ } else {
+ str = g_strdup_printf ("MARK: %s: %s %s", g_get_prgname(), note ? note : "", formatted);
+ }
+
+ g_free (formatted);
+
+ g_access (str, F_OK);
+ g_free (str);
+}
Added: trunk/libgames-support/games-profile.h
==============================================================================
--- (empty file)
+++ trunk/libgames-support/games-profile.h Tue Jan 6 18:18:59 2009
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright  2005 William Jon McCann <mccann jhu edu>
+ *
+ * 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 Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors: William Jon McCann <mccann jhu edu>
+ */
+
+#ifndef GAMES_PROFILE_H
+#define GAMES_PROFILE_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#ifdef ENABLE_PROFILING
+#ifdef G_HAVE_ISO_VARARGS
+#define _games_profile_start(...) _games_profile_log (G_STRFUNC, "start", __VA_ARGS__)
+#define _games_profile_end(...) _games_profile_log (G_STRFUNC, "end", __VA_ARGS__)
+#define _games_profile_msg(...) _games_profile_log (NULL, NULL, __VA_ARGS__)
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define _games_profile_start(format...) _games_profile_log (G_STRFUNC, "start", format)
+#define _games_profile_end(format...) _games_profile_log (G_STRFUNC, "end", format)
+#define _games_profile_msg(format...) _games_profile_log (NULL, NULL, format)
+#else
+#error Need either ISO or GNUC varargs macros!
+#endif
+#else
+#define _games_profile_start(...)
+#define _games_profile_end(...)
+#define _games_profile_msg(...)
+#endif
+
+void _games_profile_log (const char *func,
+ const char *note,
+ const char *format,
+ ...) G_GNUC_PRINTF (3, 4);
+
+G_END_DECLS
+
+#endif /* GAMES_PROFILE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]