From: Ahmad on 2 Aug 2010 16:13 Hi, I am running a script that involves writing a log file. I use [clock clicks] at the start and end to get time stamps. Then, I use: run_time [expr {$end - $start}] But result is not human meaningful. How to convert it to a format like: hours : mins : seconds : milliseconds ? Thanks for help in advance, Ahmad
From: Aric Bills on 2 Aug 2010 16:33 On Aug 2, 2:13 pm, Ahmad <ahmad.abdulgh...(a)gmail.com> wrote: > Hi, > > I am running a script that involves writing a log file. > > I use [clock clicks] at the start and end to get time stamps. > > Then, I use: run_time [expr {$end - $start}] > > But result is not human meaningful. > > How to convert it to a format like: hours : mins : seconds : > milliseconds ? > > Thanks for help in advance, > Ahmad According to the clock man page, [clock clicks] is platform- dependent. If you want milliseconds instead, try [clock milliseconds]; if you want microseconds, try [clock microseconds].
From: phil on 6 Aug 2010 11:24 I prefer floating point. clicks-to-secs: set z [format %.05f [expr ($thenclicks - $nowclicks) / 1000000.0]] millis-to-secs: set z [format %.03f [expr ($thenmillis - $nowmillis) / 1000.0]] I've just recently started to use millis and like it. Precision isn't as high, but I'm sure the precision can't really be trusted anyway. Every so often it would go backwards too.
From: Uwe Klein on 6 Aug 2010 12:05 phil wrote: > I prefer floating point. > > clicks-to-secs: > set z [format %.05f [expr ($thenclicks - $nowclicks) / 1000000.0]] > > millis-to-secs: > set z [format %.03f [expr ($thenmillis - $nowmillis) / 1000.0]] > > I've just recently started to use millis and like it. > Precision isn't as high, but I'm sure the precision can't really be > trusted anyway. > Every so often it would go backwards too. roll over? I remember having to jump through hoops to get UTC time with fractional seconds resolution working. i.e. finding the relation (divisor, remainder) between [clock clicks] and [clock seconds]. What a hassle. The previous solution was much easier: just encode the DCF signal state and the utime value from the OS into the header of each data chunk. uwe
From: Alexandre Ferrieux on 7 Aug 2010 06:05 On Aug 6, 6:05 pm, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote: > phil wrote: > > I prefer floating point. > > > clicks-to-secs: > > set z [format %.05f [expr ($thenclicks - $nowclicks) / 1000000.0]] > > > millis-to-secs: > > set z [format %.03f [expr ($thenmillis - $nowmillis) / 1000.0]] > > > I've just recently started to use millis and like it. > > Precision isn't as high, but I'm sure the precision can't really be > > trusted anyway. > > Every so often it would go backwards too. > > roll over? > > I remember having to jump through hoops to get UTC time with fractional > seconds resolution working. i.e. finding the relation (divisor, remainder) > between [clock clicks] and [clock seconds]. What a hassle. > > The previous solution was much easier: just encode the DCF signal state > and the utime value from the OS into the header of each data chunk. > > uwe Then, use (the relatively recent) [clock milliseconds]. It is a bignum, hence doesn't wrap around, and has the remarkable property of being consistent with [clock seconds]: [clock milliseconds]/1000 == [clock seconds] [clock milliseconds]%1000 == remainder in milliseconds That makes it the silver bullet for full timestamps with date down to ms. (but of course the intrinsic accuracy is what the OS gives you ;-) -Alex
|
Pages: 1 Prev: THANKS GOD! I GOT $2000 FROM PAYPAL.... Next: Project announce: Porting gnocl to MacOSX |