User's Guide to the Profile Tcl Tool

This class provides a visual editor specialized for profiling the execution of tcl and tcl code. The profiler is derived from the EditForest class, and therefore inherits all of its features.

The Tycho Programmer's Manual includes a section on Performance in Tcl.

TclX profile command

The Profile Tcl tool uses the TclX profile command. TclX is an extension to Tcl. The TclX sources are available at ftp://ftp.neosoft.com/pub/tcl/tclx-distrib. To use the Profile Tcl tool, you must have the TclX profile command available at runtime.

When the Profiler is started, the Tycho Loader will look for the TclX shared library that contains the profile command and attempt to load it.

To use the Profiler, you must have the profile command. There are several different scenarios, pick the scenario that fits you situations best and follow the instructions below.

  • Use the default TclX profile command
  • Patch the TclX profile command and Reinstall TclX
  • Compile a standalone profile command
  • Use the default TclX profile command

    The profile command shipped with TclX7.6.0 has a bug that causes coredumps if used with Itcl. The file tclXprofile.c.patch is a patch to tclX7.6.0/tcl/generic/tclXprofile.c that fixes the bug.

    Patch the TclX profile command and Reinstall TclX

    To install this patch, you will need Larry Wall's patch program. (You can get patch from ftp://ptolemy.eecs.berkeley.edu/pub/gnu/src/patch-2.1.tar.gz). To install the patch

    1. Grab the TclX sources from ftp://ftp.neosoft.com/pub/tcl/tclx-distrib.
    2. cd to tclXversion/tcl/generic.
    3. Patch tclXprofile.c patch < $TYCHO/editors/visedit/doc/usersGuides/tclXprofile.c.patch.
    4. Install TclX by following the TclX instructions.

    Compile a standalone profile command

    The directory $TYCHO/lib/profile contains a standalone version of tclXprofile.c that can be configured and compiled to produced a shared object that can be loaded in to Tycho when profiling starts. The Tycho Loader facility will bring up a file browser if TclX cannot be found, and you can enter the pathname of the tclXprofile object.

    Compiling tclXprofile.c requires the tcl sources, since the .c file uses tclInt.h, which is not usually installed. If you are compiling tclXprofile.c from within Ptolemy, then you can use the default settings in $TYCHO/lib/profile/makefile. If you are not compiling from within Ptolemy, you will have to set the TCL_SRC_INCLUDE_DIR makefile variable.

    Compiling tclXprofile.c also requires tclConfig.sh, which is usually in the architecture dependent tcl lib directory. Again, if you are installing from within Ptolemy, then the makefile is probably fine. Otherwise you will have to adjust the TCLCONFIGSH makefile variable.

    There are two ways to adjust these variables:

    1. Edit $TYCHO/lib/profile/makefile After you have adjusted the makefile accordingly, configure and build the shared object:
       cd $TYCHO/lib/profile; make
      
    2. Or, Pass the new values as command line options:
      cd $TYCHO/lib/profile
      make TCL_SRC_INCLUDE_DIR=$PTOLEMY/src/tcltk/itcl2.1/tcl7.5/generic/ \
      	$PTOLEMY/tcltk/itcl.$PTARCH/lib/itcl/tclConfig.sh
      
    The tclXprofile shared object will be in $TYCHO/lib/profile/$PTARCH. Under solaris, the file will be named tclXprofile.so.

    Profiler Description

    The profiler consists of the usual tycho menu bar with a few buttons, a graphical forest editor, a few counters and a the tycho status bar. We describe each in turn.


    Profiler Buttons

  • Start Profiling - This button calls the TclX profile on command. To profile the execution of your code, hit the Start Profiling button, execute your code, and hit the Display Profile button.
  • Display Profile - This button stops the TclX profiler and processes the profiler output. For large runs, the processing of the data could take a moment, tcl is traversing large arrays.
  • Cancel Profile - This button stops the TclX profiler, but does not display the output.

  • Profiler Grapher

    The central area of the Profiler is a Forest editor. After generating a profile, the user can follow the execution of the tcl code by clicking on nodes in the graph. As the mouse moves over nodes in the graph, the counters at the bottom of the screen display statistics about that node.

    Profiler Counters

    At the bottom of the Profiler are a series of counters. These counters display statistics about the forest node that the mouse last passed over. As the mouse moves over a counter, the status window displays a short description about that counter.

    Tycho Home Page


    Copyright © 1996, The Regents of the University of California. All rights reserved.
    Last updated: 96/12/07, comments to: tycho@eecs.berkeley.edu