Commits

stqn  committed 02189ec

Added README and LICENCE. Changed column values from UINT to INT.

  • Participants
  • Parent commits 7a7c3b3

Comments (0)

Files changed (4)

+The MIT License
+
+Copyright (c) 2011 Olivier Fabre
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+profileD
+========
+
+profileD is a GTK2 GUI to display dmd's profiling information in a sorted
+table with readable (demangled) function names.
+
+How to build:
+-------------
+
+* Install the needed tools and libraries:
+
+- Install dmd (v1) and libphobos (for D1)
+  - Under Arch Linux: sudo pacman -S dmd libphobos
+  - Or from http://www.digitalmars.com/d/download.html
+- Install Code::Blocks (optional)
+  - Under Arch Linux: sudo pacman -S codeblocks
+  - Or from http://www.codeblocks.org/
+- Install dsss
+  - Under Arch Linux: sudo pacman -S dsss
+  - Or from http://www.dsource.org/projects/dsss
+
+- Get GtkD from http://www.dsource.org/projects/gtkd
+- Open a terminal, unpack GtkD's archive and go inside the gtkd directory
+- Run "dsss install"
+  (note: this will build a bunch of libs I'm not using and copy them to
+  ~/d/lib/, but will also copy the includes profileD needs to ~/d/include/)
+  Alternatively, see http://www.dsource.org/projects/gtkd/wiki/BuildingWithDSSS
+- Run "make gtkd"
+- Copy libgtkd.a to your d libs directory (~/d/lib/)
+
+* To build without Code::Blocks:
+
+dmd -release -O -I/usr/lib/phobos -I~/d/include/d -c main.d
+gcc -o profiled -L~/d/lib main.o -ldl -lgtkd -lphobos -lpthread
+
+(Can probably be done with a one-liner and without gcc, too.)
+
+* To build with Code::Blocks:
+
+In Code::Blocks, Compiler Settings:
+- Select Global compiler settings, Digital Mars D Compiler
+- Linker settings:
+  - Link libraries:
+      phobos
+      pthread
+  - Other linker options:
+      -L/home/<your user name>/d/lib
+- Search directories
+  - Compiler
+      /usr/lib/phobos
+      ~/d/include/d
+  - Linker
+      /usr/lib
+      ~/d/lib
+- Toolchain executables
+  - Click "Auto-detect", I guess. Or type (in field order):
+    /usr
+    dmd
+    dmd
+    gcc
+    ar
+    gdb
+    (nothing)
+    make
+
+Now you are ready to open the profiled.cbp project in Code::Blocks and build it.
+
+Installing profileD:
+--------------------
+Copy profiled (from the bin/Release or bin/Debug directory if you used
+Code::Blocks) into your path (maybe /usr/local/bin/).
+
+How to use profileD:
+--------------------
+- Build your project with the -profile option.
+- Delete any old "trace.*" file.
+- Run your project, do stuff, and exit.
+- Run profiled from the directory containing the "trace.log" of your project,
+  or run "profiled /path/to/trace.log".
+- Click on a column header to sort the table by this column.
+
+Columns definitions:
+--------------------
+Num calls    : Number of times this function was called.
+Tree time    : Total time spent inside this function or in functions called by
+               it, recursively.
+%            : Tree time / tree time of main().
+Func time    : Time spent inside this function (but not in functions called by
+               it).
+%            : Func time / tree time of main().
+Avg Func time: Average time taken by one call of this function.
+
+Author:
+-------
+Olivier Fabre (off -at- free.fr)
+
+Web site:
+---------
+https://bitbucket.org/stqn/profiled/overview
+
+Licence:
+--------
+profileD is released under the MIT licence.
+(See LICENCE or http://www.opensource.org/licenses/mit-license)
 
 	// Create window
 	GtkWidget* window = gtk_window_new( GtkWindowType.TOPLEVEL /*GTK_WINDOW_TOPLEVEL*/ );
-	gtk_window_set_title( cast(GtkWindow*) window, std.string.toStringz("Profiled") );
+	gtk_window_set_title( cast(GtkWindow*) window, std.string.toStringz("profileD") );
 	gtk_widget_set_size_request( window, 800, 250 );
-	g_signal_connect( cast(void*) window, std.string.toStringz("delete_event"), cast(GCallback) gtk_main_quit, null ); /* dirty */ // Not sure why it is dirty...
+	//g_signal_connect( cast(void*) window, std.string.toStringz("delete_event"), cast(GCallback) gtk_main_quit, null );
+	g_signal_connect( cast(void*) window, std.string.toStringz("destroy"), cast(GCallback) gtk_main_quit, null );
 
 	GtkWidget* treeView = createViewAndModel();
 
 			sortColumn--;
 		}
 		gtk_tree_view_column_set_sort_column_id( treeViewColumn, sortColumn );
+		//gtk_tree_view_column_set_clickable( treeViewColumn, true );
+		//g_signal_connect/*_swapped*/( cast(void*) treeViewColumn, std.string.toStringz("clicked"), cast(GCallback) treeViewColumnClicked, null );
 		gtk_tree_view_append_column( cast(GtkTreeView*) view, treeViewColumn );
 	}
 
 
 
 extern(C) {
+	int treeViewColumnClicked( /*GtkTreeViewColumn* treeViewColumn,*/ void* data ) {
+		//gtk_tree_view_column_set_sort_order( treeViewColumn,
+		//gtk_tree_view_column_set_sort_column_id( treeViewColumn, *col );
+		return true;
+	}
+
 	/*gboolean*/int treeViewSearchEqualFunc( GtkTreeModel* model,
 		/*gint*/int column,
 		/*const*/ /*gchar*/char* key,
 
 GtkTreeModel* createAndFillModel() {
 	// Create ListStore
+	// Using INT and not UINT because sometimes trace.log contains negative
+	// values.
 	static GType[Column.SIZE] columnTypes = [
-		GType.UINT64,
-		GType.UINT64,
+		GType.INT64,
+		GType.INT64,
 		GType.STRING,
-		GType.UINT64,
+		GType.INT64,
 		GType.STRING,
-		GType.UINT64,
+		GType.INT64,
 		GType.STRING
 	];
 

File profiled.cbp

 			<Add library="dl" />
 			<Add library="gtkd" />
 		</Linker>
+		<Unit filename="README" />
 		<Unit filename="main.d" />
 		<Extensions>
 			<envvars />