📄 upshot.in
字号:
button .mainBtns.quit -text "Quit" -command \ exit pack append .mainBtns \ .mainBtns.load {left padx 10 pady 5} \ .mainBtns.logfile {left expand fillx padx 30 pady 5} \ .mainBtns.format {left padx 10 pady 5} \ .mainBtns.setup {left padx 10 pady 5} \ .mainBtns.options {left padx 10 pady 5} \ .mainBtns.quit {left padx 10 pady 5} pack append . .mainBtns {top fillx expand} # so the winfo return accurate values update wm minsize . [winfo reqwidth .mainBtns] [winfo reqheight .mainBtns] wm maxsize . 2000 [winfo height .]}proc SelectLogfile {file format} { global logFileFormat set logFileFormat $format .mainBtns.logfile delete 0 end .mainBtns.logfile insert 0 $file}proc OpenWin(options) {w} { global reqWidth blackWhite pageWidth pageHeight incDraw tk_version toplevel $w wm title $w "Options" frame $w.labels frame $w.entries if { $tk_version >= 4.0 } { set selectname "-selectcolor" } else { set selectname "-selector" } button $w.ok -text "OK" -command "CloseOption $w" label $w.labels.width -text "Initial screen width: " -relief raised entry $w.entries.width -relief sunken -width 10 label $w.labels.pageWidth -text "Printed width: " -relief raised entry $w.entries.pageWidth -relief sunken -width 10 label $w.labels.pageHeight -text "Printed height: " -relief raised entry $w.entries.pageHeight -relief sunken -width 10 set selectColor [expr "$blackWhite ? \"black\" : \"red\""] checkbutton $w.incDraw -text "Incremental time bar drawing" \ -variable incDraw \ -relief raised $selectname $selectColor $w.entries.width insert 0 $reqWidth $w.entries.pageWidth insert 0 $pageWidth $w.entries.pageHeight insert 0 $pageHeight pack append $w.labels \ $w.labels.width {padx 5 pady 10} \ $w.labels.pageWidth {padx 5 pady 10} \ $w.labels.pageHeight {padx 5 pady 10} pack append $w.entries \ $w.entries.width {padx 5 pady 10} \ $w.entries.pageWidth {padx 5 pady 10} \ $w.entries.pageHeight {padx 5 pady 10} pack append $w \ $w.ok {bottom expand pady 20 padx 5} \ $w.incDraw {bottom expand pady 20 padx 5} \ $w.labels {left} \ $w.entries {left}}proc CloseOption {w} { global reqWidth pageWidth pageHeight incDraw set reqWidth [$w.entries.width get] set pageWidth [$w.entries.pageWidth get] set pageHeight [$w.entries.pageHeight get] UpdateDefaults [list initial_timeline_window_width $reqWidth \ printed_width $pageWidth printed_height $pageHeight \ incremental_timeline_drawing $incDraw] destroy $w}proc OpenWin(timeline) {w logfilename logfileformat} { # pass in the name of the window to put the timelines in and the # name of the logfile global blackWhite reqWidth global procWidth global timelinebg setting global tk_version set timeLineCanvas $w.c set setting($w,tlc) $timeLineCanvas set btnFrame $w.btns set scale1 $w.scale1 set scale2 $w.scale2 set legend $w.legend set procNums $w.canvasFrame.procs set setting($w,pnc) $procNums set canvasWidth $reqWidth set setting($w,logfilename) $logfilename # make sure the logfile is readable if {![file readable $logfilename]} { # First, try the file with the default directory set filetest [ GetDefault logfiledirectory "." ] if { [file readable $filetest/$logfilename]} { cd $filetest } } if {![file readable $logfilename]} { toplevel $w wm title $w "Filename" message $w.m -text "\"$logfilename\" is not readable." \ -justify center -aspect 400 -relief raised -borderwidth 2 button $w.b -text "Cancel" -command "destroy $w" pack append $w $w.m {} $w.b {pady 10} return } UpdateDefaults "logfile $logfilename logfileformat $logfileformat" toplevel $w set status [PreprocessLog($logfileformat) $w $logfilename]# set status [QuickPreprocessLog_alog $w $logfilename] # read through the logfile if $status return # create process numbers, timeline canvas, and vertical scrollbar # set the default zooming point to the upper left set setting($w,mark,x) 0 set setting($w,mark,y) 0 $w config -cursor watch # frame for zoom, print buttons frame $btnFrame -relief raised -borderwidth 2 # create zoom buttons AddButtons $w $btnFrame # map zoom, print buttons # create legend canvas $legend -height 100 -width 100 CreateLegend $w $legend $canvasWidth # create frame for holding the canvas, process numbers, and vertical # scrollbar frame $w.canvasFrame set procLabelsWidth [TimeLineProcNums $w $procNums] if { $tk_version >= 4.0 } { scrollbar $w.canvasFrame.vscroll \ -orient vertical -relief sunken -command "Yscroll4 $timeLineCanvas \ $procNums" } else { scrollbar $w.canvasFrame.vscroll \ -orient vertical -relief sunken -command "Yscroll3 $timeLineCanvas \ $procNums" } canvas $timeLineCanvas -scrollregion [list 0 0 $canvasWidth \ [expr $setting($w,numProcs)*$procWidth]] -width $canvasWidth \ -height [expr $setting($w,numProcs)*$procWidth] -relief sunken \ -borderwidth 2 -bg $timelinebg StartDrawingTime $w ProcessLog($logfileformat) $w $logfilename# QuickProcessLog_alog $w $logfilename EndDrawingTime $w # set title and icon name wm title $w $logfilename wm iconname $w timelines pack append $w $btnFrame {top fillx} $legend {top fillx} # pack canvas and vertical scrollbar pack append $w.canvasFrame \ $w.canvasFrame.vscroll {right filly} \ $procNums {left filly} \ $timeLineCanvas {expand fill} # draw scale canvases TimeLineScales $w $scale1 $scale2 \ $canvasWidth [winfo reqwidth $w.canvasFrame.vscroll] \ $procLabelsWidth # create horizontal scrollbar scrollbar $w.hscroll -orient horiz -relief sunken \ -command "$timeLineCanvas xview" pack append $w $scale2 {bottom fillx} $w.hscroll {bottom fillx} \ $scale1 {bottom fillx} $w.canvasFrame {expand fill} # attach scroll bars to canvas if { $tk_version >= 4.0 } { $timeLineCanvas config -xscrollcommand "UpdateHScale4 $w $w.hscroll" \ -yscrollcommand "UpdateVScale4 $w.canvasFrame.vscroll $procNums" } else { $timeLineCanvas config -xscroll "UpdateHScale3 $w $w.hscroll" \ -yscroll "UpdateVScale3 $w.canvasFrame.vscroll $procNums" } # need update or the 'winfo' command will not return correct information ResizeLegend $w $legend $canvasWidth update set minwidth [expr [winfo reqwidth $btnFrame]] set minheight [expr "[winfo reqheight $btnFrame]+[winfo reqheight \ $scale1]+[winfo reqheight $scale2]+[winfo reqheight $w.hscroll]"] wm minsize $w $minwidth $minheight wm maxsize $w [expr ($minwidth>2000)?($minwidth*2):2000] \ [expr ($minheight>2000)?($minheight*2):2000] # set 2000 pixels as the absolute limit set stopDrawingStatesEvents 0 bind $w <Configure> "Resize $w $legend" bind $timeLineCanvas <3> " set setting($w,mark,x) \[$timeLineCanvas canvasx %x\] set setting($w,mark,y) \[$timeLineCanvas canvasy %y\] # puts \"Mark at %x %y\" " bind $timeLineCanvas <2> [format "CanvasDragMark %s %s %%x %%y" \ $timeLineCanvas $procNums] bind $timeLineCanvas <B2-Motion> [format "CanvasDrag %s %s %%x %%y" \ $timeLineCanvas $procNums] $w config -cursor top_left_arrow}proc U {lista listb} { if {[llength $lista]<[llength $listb]} { set n [llength $listb] for {set i 0} {$i<$n} {incr i} { set el [lindex $listb $i] if {[lsearch $lista $el]==-1} { lappend lista $el } } return $lista } else { set n [llength $lista] for {set i 0} {$i<$n} {incr i} { set el [lindex $lista $i] if {[lsearch $listb $el]==-1} { lappend listb $el } } return $listb }}proc N {lista listb} { set list {} if {[llength $lista]<[llength $listb]} { set n [llength $listb] for {set i 0} {$i<$n} {incr i} { set el [lindex $listb $i] if {[lsearch $lista $el]!=-1} { lappend list $el } } } else { set n [llength $lista] for {set i 0} {$i<$n} {incr i} { set el [lindex $lista $i] if {[lsearch $listb $el]!=-1} { lappend list $el } } } return $list}# If the value is found, returns the index of the value# in the list.# If within the range of the list, returns the index of the# greatest value in the list that is less than the value.# If below the range of the list, returns -1.# If above the range of the list, return the index of the# last element## pass-by-reference version -- should be faster; less latency timeproc refbsearch {listName val} { upvar $listName l set end [expr [llength $l]-1] set start 0 if $val<[lindex $l 0] {return -1} while {$start<$end} { set lookHere [expr ($end-$start+1)/2+$start] if {$val<[lindex $l $lookHere]} { set end [expr $lookHere-1] } else { set start $lookHere } } return $start}proc max {list} { if {[llength $list]==0} {return 0} set x [lindex $list 0] foreach element $list { if {$element>$x} { set x $element } } return $x}#Might as well document the Alog format, while we're here-#Each line:# type process task data cycle timestamp [comment]# type - nonnegative integer representing a user-defined event type# process - an integer representing the process in which the event occurred# task - an integer representing a different notion of task. Usually # ignored.# data - an integer representing user data for the event# cycle - an integer representing a time cycle, used to distinguish# between time returned by a timer that "rolls over" during# the run# timestamp - an integer representing (when considered in conjuction# with the cycle number) a time for the event. Upshot treats# the units as microseconds# comment - an optional character string representing user data. Currently# 12 character maximum, will soon hopefully be any length (really!)#Reserved types:# Type Proc Task Data cycle Timestamp Comment# ---- ---- ---- ---- ----- --------- -------#Creation data# -1 Creator and date#Number of events in the logfile# -2 #events#Number of processors in the run# -3 #procs#Number of tasks used in the run# -4 #tasks#Number of event types used# -5 #event types#Start time of the run# -6 start time#End time of the run# -7 end time#Number of timer cycles# -8 #timer cycles#Decription of event types# -9 event type Description#printf string for event types# -10 event type printf string#Rollover point# -11 rollover point#State definition# -13 start end color:bitmap State name#Send message# -14 size receiver tag#Receive message# -15 size sender tagset alog_process_vs_pre_ratio 6# for the percent-done widget: preprocessing takes about 1/6 the time# of processingproc PreprocessLog(alog) {id logfilename} { global blackWhite setting bitmaplist colorlist alog_process_vs_pre_ratio global colorNo bitmapNo set logFileHandle [open $logfilename r] set type -1 set lineNo 0 set bitmapNo 0 set colorNo 0 set setting($id,states,list) {} set setting($id,startEvents,list) {} set setting($id,endEvents,list) {} StartPctDone $id \ [expr [file size $logfilename]*($alog_process_vs_pre_ratio+1)] # set optional percent-done widget to 0 set setting($id,rolloverPt) 0 set nbytes [gets $logFileHandle string] # it is better to do an update of the display every 10 lines read set updatecnt 0 while {$nbytes>=0} { incr updatecnt if { $updatecnt > 10 } { AddPctDone $id [expr $nbytes+1] set updatecnt 0 } incr lineNo if {[scan $string "%d %d %d %d %d %lf" type proc task data cycle \ timestamp]!=6} { LogFormatError $logfilename $string $lineNo return -1 } else { case $type in { -3 {set setting($id,numProcs) $data} -6 {set setting($id,firstTime) $timestamp} -7 {set setting($id,lastTime) $timestamp} -11 {set setting($id,rolloverPt) $timestamp} -13 {Alog_StateDef $id $string $logfilename $lineNo} } if {[lsearch $setting($id,startEvents,list) $type] != -1} { set setting($id,states,$setting($id,startEvents,$type),used) 1 # puts "$setting($id,startEvents,$type) used" } # case $type } # else !format error
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -