anjuta r3646 - in branches/anjuta-symbol-db: . libanjuta plugins/symbol-db/test



Author: jhs
Date: Tue Feb 12 20:26:46 2008
New Revision: 3646
URL: http://svn.gnome.org/viewvc/anjuta?rev=3646&view=rev

Log:
2008-02-12  Johannes Schmid <jhs gnome org>

	* configure.in:
	* plugins/symbol-db/test/Makefile.am:
	* plugins/symbol-db/test/benchmark.c: (on_single_file_scan_end),
	(get_files), (main):
	Added a test program for symbol-db. Usage ./benchmark <directory_to_scan>

	* libanjuta/anjuta-launcher.c: (anjuta_launcher_set_encoding),
	(anjuta_launcher_set_encoding_real), (anjuta_launcher_fork):
	* libanjuta/anjuta-launcher.h:
	Fixed Gtk-Warnings introduced yesterday

Added:
   branches/anjuta-symbol-db/plugins/symbol-db/test/benchmark.c
Modified:
   branches/anjuta-symbol-db/ChangeLog
   branches/anjuta-symbol-db/configure.in
   branches/anjuta-symbol-db/libanjuta/anjuta-launcher.c
   branches/anjuta-symbol-db/libanjuta/anjuta-launcher.h
   branches/anjuta-symbol-db/plugins/symbol-db/test/Makefile.am

Modified: branches/anjuta-symbol-db/configure.in
==============================================================================
--- branches/anjuta-symbol-db/configure.in	(original)
+++ branches/anjuta-symbol-db/configure.in	Tue Feb 12 20:26:46 2008
@@ -1148,6 +1148,7 @@
 plugins/symbol-browser/Makefile
 plugins/symbol-browser/images/Makefile
 plugins/symbol-db/Makefile
+plugins/symbol-db/test/Makefile
 plugins/cvs-plugin/Makefile
 plugins/project-wizard/Makefile
 plugins/macro/Makefile

Modified: branches/anjuta-symbol-db/libanjuta/anjuta-launcher.c
==============================================================================
--- branches/anjuta-symbol-db/libanjuta/anjuta-launcher.c	(original)
+++ branches/anjuta-symbol-db/libanjuta/anjuta-launcher.c	Tue Feb 12 20:26:46 2008
@@ -1053,13 +1053,10 @@
  *
  * Return value: TRUE if successful, otherwise FALSE.
  */
-gboolean
+void
 anjuta_launcher_set_encoding (AnjutaLauncher *launcher, const gchar *charset)
 {
-	GIOStatus s;
-	gboolean r = TRUE;
-
-	g_return_val_if_fail (launcher != NULL, FALSE);
+	g_return_if_fail (launcher != NULL);
 	// charset can be NULL
 
 	launcher->priv->custom_encoding = TRUE;
@@ -1067,7 +1064,14 @@
 	  launcher->priv->encoding = g_strdup(charset);
 	else
 	  launcher->priv->encoding = NULL;
-		
+}
+
+static gboolean
+anjuta_launcher_set_encoding_real (AnjutaLauncher *launcher, const gchar *charset)
+{
+	GIOStatus s;
+	gboolean r = TRUE;
+	
 	s = g_io_channel_set_encoding (launcher->priv->stderr_channel, charset, NULL);
 	if (s != G_IO_STATUS_NORMAL) r = FALSE;
 	s = g_io_channel_set_encoding (launcher->priv->stdout_channel, charset, NULL);
@@ -1162,7 +1166,7 @@
 
 	if (!launcher->priv->custom_encoding)
 	  g_get_charset ((const gchar**)&launcher->priv->encoding);
-	anjuta_launcher_set_encoding (launcher, launcher->priv->encoding);
+	anjuta_launcher_set_encoding_real (launcher, launcher->priv->encoding);
 	
 	tcgetattr(pty_master_fd, &termios_flags);
 	termios_flags.c_iflag &= ~(IGNPAR | INPCK | INLCR | IGNCR | ICRNL | IXON |

Modified: branches/anjuta-symbol-db/libanjuta/anjuta-launcher.h
==============================================================================
--- branches/anjuta-symbol-db/libanjuta/anjuta-launcher.h	(original)
+++ branches/anjuta-symbol-db/libanjuta/anjuta-launcher.h	Tue Feb 12 20:26:46 2008
@@ -87,7 +87,7 @@
 									gchar *const argv[],
 									AnjutaLauncherOutputCallback callback,
 									gpointer callback_data);
-gboolean anjuta_launcher_set_encoding (AnjutaLauncher *launcher,
+void anjuta_launcher_set_encoding (AnjutaLauncher *launcher,
 									   const gchar *charset);
 void anjuta_launcher_send_stdin (AnjutaLauncher *launcher,
 								 const gchar *input_str);

Modified: branches/anjuta-symbol-db/plugins/symbol-db/test/Makefile.am
==============================================================================
--- branches/anjuta-symbol-db/plugins/symbol-db/test/Makefile.am	(original)
+++ branches/anjuta-symbol-db/plugins/symbol-db/test/Makefile.am	Tue Feb 12 20:26:46 2008
@@ -1,6 +1,7 @@
 
 bin_PROGRAMS = \
-	test-symbol-db 
+	test-symbol-db \
+	benchmark
 
 AM_CPPFLAGS = \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
@@ -37,6 +38,24 @@
 	$(LIBANJUTA_LIBS) \
 	$(PLUGIN_SYMBOL_DB_LIBS)
 
+benchmark_SOURCES = \
+	benchmark.c       \
+	../readtags.c       \
+	../readtags.h       \
+	../symbol-db-engine.c       \
+	../symbol-db-engine.h       \
+	../symbol-db-engine-iterator.c       \
+	../symbol-db-engine-iterator.h \
+	../symbol-db-engine-iterator-node.c \
+	../symbol-db-engine-iterator-node.h \
+	../symbol-db-view.h \
+	../symbol-db-view.c
+ 
+
+benchmark_LDFLAGS = \
+	$(LIBANJUTA_LIBS) \
+	$(PLUGIN_SYMBOL_DB_LIBS)
+
 ## File created by the gnome-build tools
 
 

Added: branches/anjuta-symbol-db/plugins/symbol-db/test/benchmark.c
==============================================================================
--- (empty file)
+++ branches/anjuta-symbol-db/plugins/symbol-db/test/benchmark.c	Tue Feb 12 20:26:46 2008
@@ -0,0 +1,90 @@
+/* Symbol db performance stress test */
+
+
+#include <../symbol-db-engine.h>
+#include <gtk/gtk.h>
+#include <libgnomevfs/gnome-vfs.h>
+
+#define BASE_PATH "/home/jhs/devel/anjuta-symbol-db/plugins/symbol-db"
+
+static void on_single_file_scan_end (SymbolDBEngine* engine, GPtrArray* files)
+{
+	static int i = 0;
+	g_message ("Finished: %s", (gchar*)g_ptr_array_index (files, i++));
+}
+
+static GPtrArray* get_files (const gchar* dir)
+{
+	GList* list = NULL;
+	GList* node;
+	GPtrArray* files = g_ptr_array_new();
+	gchar* uri = gnome_vfs_get_uri_from_local_path (dir);
+	
+	if (gnome_vfs_directory_list_load (&list, uri, GNOME_VFS_FILE_INFO_GET_MIME_TYPE)
+			!= GNOME_VFS_OK)
+		return files;
+	
+	for (node = list; node != NULL; node = g_list_next (node))
+	{
+		GnomeVFSFileInfo* info = node->data;
+		
+		if (!info->mime_type)
+			continue;
+		if (g_str_equal (info->mime_type, "text/x-csrc") ||
+				g_str_equal (info->mime_type, "text/x-chdr"))
+		{
+			g_message ("File: %s", info->name);
+			g_ptr_array_add (files, g_build_filename (dir, info->name, NULL));
+		}
+	}
+	
+	g_free (uri);
+	return files;
+}	
+	
+int main (int argc, char** argv)
+{
+  SymbolDBEngine* engine;
+  GPtrArray* files;
+	GPtrArray* languages = g_ptr_array_new();
+	const gchar* root_dir;
+	int i;
+	
+  gtk_init(&argc, &argv);
+  g_thread_init (NULL);
+	gnome_vfs_init();
+	
+	if (argc != 2)
+	{
+		g_message ("Usage: benchmark <source_directory>");
+		return 1;
+	}
+	root_dir = argv[1];
+	
+  engine = symbol_db_engine_new ();
+	if (!symbol_db_engine_open_db (engine, root_dir))
+	{
+		g_message ("Could not open database: %s", root_dir);
+		return 1;
+	}
+	
+	symbol_db_engine_add_new_project (engine, NULL, root_dir);
+	if (!symbol_db_engine_open_project (engine, root_dir))
+	{
+		g_message ("Could not open project!");
+		return 1;
+	}
+			
+	files = get_files (root_dir);
+	for (i = 0; i < files->len; i++)
+		g_ptr_array_add (languages, "C");
+	
+	g_signal_connect (G_OBJECT (engine), "single-file-scan-end",
+		  G_CALLBACK (on_single_file_scan_end), files);
+	
+	symbol_db_engine_add_new_files (engine, root_dir, files, languages, TRUE);
+	
+	gtk_main();
+	
+	return 0;
+}



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