/ Published in: TCL
Expand |
Embed | Plain Text
proc _elapsedTime { start end } { # Procedure to measure the time elapsed. # Arguments are two points in time measured in seconds. # Use as follows: # set start [clock seconds] # set end [clock seconds] # _elapsed_time $start $end set total_seconds [expr $end - $start] set _hours [expr int($total_seconds/3600)] set _minutes [expr int(($total_seconds % 3600)/60)] set _seconds [expr int(($total_seconds % 60))] if {$_hours == 1} {set htxt hour} else {set htxt hours} if {$_minutes == 1} {set mtxt minute} else {set mtxt minutes} if {$_seconds == 1} {set stxt second} else {set stxt seconds} if {$_hours == 0} { if {$_minutes == 0} { return "$_seconds $stxt" } else { return "$_minutes $mtxt $_seconds $stxt" } } else { return "$_hours $htxt $_minutes $mtxt $_seconds $stxt" } }
You need to login to post a comment.
