Tk Library Source Code

View Ticket
Login
Ticket UUID: 575376
Title: use execution traces for tcl8.4+
Type: Patch Version: None
Submitter: hemanglavana Created on: 2002-06-29 14:23:27
Subsystem: profiler Assigned To: andreas_kupries
Priority: 8 Severity:
Status: Closed Last Modified: 2003-04-14 14:25:42
Resolution: Accepted Closed By: andreas_kupries
    Closed on: 2003-04-14 07:25:42
Description:
Module: profiler

I am attaching a patch that makes use of [trace add execution ..] command
available in tcl8.4 version for profiling. The changes are as follows:

 o The current API is _not_ modified, only few internal procedures 
    have been changed.
 o "if [package vsatisifies [package provide Tcl] 8.4] .. else .." 
    construct is used to support both versions of tcl: 8.3 & 8.4
 o The code inside proc Handler is split into two new procs:
    enterHandler and leaveHandler which are called by Handler.
    Handler proc is used with tcl8.3 only
 o  A new proc TraceHandler, used with tcl8.4+, is invoked by
    enter/leave execution traces on commands
 o proc profProc either sets up execution traces or proc renames
    based on tcl version
 o profiler package version is incremented to 0.2.1
 o Added a test constraint called tcl8.3only in profiler.test file.
   5 tests are skipped for tcl8.4+ version because these tests
   work with internals of profiler package -- these rely on fact
   that procs are renamed to <name>ORIG in tcl8.3 version.

The following simple test shows some improvement in performance between
tcl8.3 and tcl8.4 versions. Note however that this improvement could be simply
because 8.4 version executes faster and not due to use of execution traces.

godel:35> tclsh test.tcl
tcl version = 8.3.4
time        = 602 microseconds per iteration
godel:36> /tmp/hlavana/tcltk/bin/tclsh8.4 test.tcl
tcl version = 8.4b1
time        = 472 microseconds per iteration
godel:37> cat test.tcl 

set auto_path [linsert $auto_path 0 /auto/vwsahr/cvs-sf/tcllib/modules/profiler]
package require profiler

::profiler::init
proc foo {} {}

puts "tcl version = [info patch]"
puts "time        = [time foo 10000]"
godel:38> 

In future, the profiler package can be updated to trace all commands as well.
Currently, it can only trace functions defined using proc command. This may
require some changes in APIs of profiling packages.
User Comments: andreas_kupries added on 2003-04-14 14:25:41:
Logged In: YES 
user_id=75003

Committed to head.

hemanglavana added on 2002-06-29 21:23:27:

File Added - 26034: profiler0.2.1.diff

Attachments: