home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
profiledia.tcl
< prev
next >
Wrap
Text File
|
1996-05-29
|
4KB
|
176 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)profiledia.tcl 1.6
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)profiledia.tcl 1.6 01 Feb 1996 Copyright 1996 Cadre Technologies Inc.
# Start user added include file section
require profilenod.tcl
require profrep.tcl
# End user added include file section
Class ProfileDialog : {TemplateDialog} {
constructor
method destructor
method processData
method readData
method buildTree
method addRoots
method removeRoots
method getChildren
method setChildren
method removeChildren
attribute tmpFile
attribute rootsSet
attribute children
}
global ProfileDialog::nodeCount
set ProfileDialog::nodeCount 0
constructor ProfileDialog {class this name} {
set this [TemplateDialog::constructor $class $this $name]
$this rootsSet [List new]
$this children [Dictionary new]
# Start constructor user section
interface DlgRow $this.r {
BrowsTree tree {
rowCount 24
}
DlgColumn c {
Label callsLabel {text "Calls:"}
SingleLineText callsText {editable 0}
Label realLabel {text "Real Time:"}
SingleLineText realText {editable 0}
Label cpuLabel {text "CPU Time:"}
SingleLineText cpuText {editable 0}
Label cpcLabel {text "CPU/Call:"}
SingleLineText cpcText {editable 0}
}
}
$this delCancelButton
$this config -okPressed {%this delete}
# End constructor user section
return $this
}
method ProfileDialog::destructor {this} {
# Start destructor user section
unlink [$this tmpFile]
# End destructor user section
}
method ProfileDialog::processData {this} {
$this readData
[$this rootsSet] foreach root {
$this buildTree $root ""
}
}
method ProfileDialog::readData {this} {
set fp [open [$this tmpFile]]
set roots [$this rootsSet]
set children [$this children]
# Skip header
gets $fp; gets $fp; gets $fp;
while {[gets $fp line] >= 0} {
set ncols [llength $line]
if {$ncols == 5} {
$roots append $line
} else {
set parent [lindex $line 1]
set childList [$children set $parent]
lappend childList \
[concat [lindex $line 0] [lrange $line 2 end]]
$children set $parent $childList
}
}
}
method ProfileDialog::buildTree {this spec parent} {
set node [lindex $spec 0]
set time [lindex $spec 2]
global ProfileDialog::nodeCount
incr ProfileDialog::nodeCount
if {$parent != ""} {
$parent hasChildren 1
}
set newNode [ProfileNode new $this.r.tree.n${ProfileDialog::nodeCount} \
-parent $parent \
-label "$time $node" \
-data [lrange $spec 1 end] \
-dialog $this]
set children [$this children]
set nodeChildren [$children set $node]
if {$nodeChildren == ""} {
return
}
global busy
foreach spec $nodeChildren {
if {[info exists busy($spec)]} {
incr ProfileDialog::nodeCount
$newNode hasChildren 1
ProfileNode new \
$this.r.tree.n${ProfileDialog::nodeCount} \
-label "<loop to [lindex $spec 0]>"\
-parent $newNode \
-data [lrange $spec 1 end] \
-dialog $this
} else {
set busy($spec) 1
$this buildTree $spec $newNode
unset busy($spec)
}
}
}
proc ProfileDialog::startProfile {} {
profile on
}
proc ProfileDialog::endProfile {} {
profile off ProfileDialog::data
if {[isCommand .main.profile]} {
error "profile dialog still active"
}
set tmp [args_file {}]
profrep ProfileDialog::data real 2 $tmp
ProfileDialog new .main.profile -tmpFile $tmp
.main.profile processData
.main.profile popUp
}
# Do not delete this line -- regeneration end marker
method ProfileDialog::addRoots {this newRoots} {
[$this rootsSet] append $newRoots
}
method ProfileDialog::removeRoots {this oldRoots} {
[$this rootsSet] removeValue $oldRoots
}
method ProfileDialog::getChildren {this node} {
return [[$this children] set $node]
}
method ProfileDialog::setChildren {this node newChildren} {
[$this children] set $node $newChildren
}
method ProfileDialog::removeChildren {this node} {
[$this children] unset $node
}