~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/degas/degasmonitor/aglp-monitor.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 import AnnounceListenManager
  2 Class AGLPMonitor -superclass AnnounceListenManager
  3 
  4 AGLPMonitor instproc init { group } {
  5         $self instvar log_ total_ prev_total_ total_rate_ count_ first_ 
  6         $self next $group 4096
  7 
  8         set log_ [open "aglp-monitor.log" w]
  9         set total_ 0
 10         set prev_total_ 0
 11         set total_rate_ 0
 12         set count_ 0
 13         set first_ 0
 14 
 15         $self log
 16 }
 17 
 18 AGLPMonitor instproc recv_announcement { addr post msg length } {
 19         $self instvar total_ prev_total_ first_
 20         puts "$addr:$msg"
 21 
 22         global bps
 23         set prev_total_ $total_
 24         incr total_ $length
 25         set bps $total_
 26 
 27 #   Stop collecting after 5 minutes
 28         if {$first_ == 0} {
 29 
 30                 global bps
 31                 rate_variable bps 0.1
 32                 set bps 0
 33 
 34                 after [expr 10*60*1000] exit
 35 
 36                 set first_ 1
 37         }
 38 }
 39 
 40 AGLPMonitor instproc log { } {
 41         global bps
 42         $self instvar log_ total_ prev_total_ total_rate_ count_ first_
 43 
 44         after 5000 "$self log"
 45 
 46         if {$first_ == 0} {
 47                 return
 48         }
 49 
 50         incr count_
 51         set total_rate_ [expr $total_rate_ + $bps]
 52 
 53 
 54         if {$prev_total_ != $total_} {
 55                 puts $log_ "[expr [clock seconds] - 978535100] $bps $total_ [expr $total_rate_/$count_]"
 56                 flush $log_
 57         }
 58 }
 59 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.