1834465 Members
3295 Online
110067 Solutions
New Discussion

change time man page

 
Brem Belguebli
Regular Advisor

change time man page

Hi,

The time utility (buitin and /bin/time) outputs the time command results with the format xx:yy.zz (where xx is in minutes, yy seconds, and zz in tenth of seconds) where its man pages says its output is in seconds.

It may be time to change the man page, or to change the time utility:

/bin/time sleep 75

real 1:15.0
user 0.0
sys 0.0

/bin/time -p sleep 75

real 1:15.0
user 0.0
sys 0.0






12 REPLIES 12
SKR_1
Trusted Contributor

Re: change time man page

Here the least unit for time is in seconds, that's why in man pages you will find seconds only.

Let for example if you do

time bdf

real 0.1 ( seconds )
user 0.0
sys 0.0

you can't say 0.1 minute to this.

Thanks

SKR
Brem Belguebli
Regular Advisor

Re: change time man page

Hi SKR,

and how do you pronounce 1:15.0 ?

regards
SKR_1
Trusted Contributor

Re: change time man page

1 minute and 15 seconds

SKR
Venkatesh BL
Honored Contributor

Re: change time man page

>/bin/time sleep 75
> real 1:15.0
> user 0.0
> sys 0.0

1:15 => 1min:15 sec => 75 sec ... what is the problem?
SKR_1
Trusted Contributor

Re: change time man page

Yes...........now its confusing me also.

If we given

time sleep 75
Then output should be like this 75.0 seconds but its coming 1:15.0

SKR

Venkatesh BL
Honored Contributor

Re: change time man page

I think its clear. Any thing above 60 secs should be indicated by increment to 'minute'.

# time sleep 55
real 55.0
user 0.0
sys 0.0

# time sleep 62
real 1:02.0
user 0.0
sys 0.0

Pete Randall
Outstanding Contributor

Re: change time man page

Slow day at the office, guys???

This sounds a lot like arguing over the pronunciation of potato . . . . or of tomato.


Pete

Pete
TTr
Honored Contributor

Re: change time man page

Don't let the deciaml point at the end confuse you. The word "seconds" that is mentioned in the man page is telling you what the precision is in the time format.
Suppose you are looking at this string
1:15.0
How would you know if it is for "1 hour 15 minutes" or for " 1 minute 15 seconds"? Since you know that the precision is in seconds, you must treat 1:15.0 as 1m15s. If you wanted to write "1hour 15minutes" you would write "1:15:0.0".
Brem Belguebli
Regular Advisor

Re: change time man page

Hi,

My point was that my understanding of the man page (extract : Times are reported in seconds.) was supposed to give 75.0 instead of 1:15.0.

Not a major issue, but, I need to parse the result and transform it to seconds.

TTr
Honored Contributor

Re: change time man page

I see. You want to count seconds using base 10, where the time format uses base 60. Well you have to convert ot base 10 as you mentioned.
Bill Hassell
Honored Contributor

Re: change time man page

While the man page says seconds, if you saw some time output like this:

real 45296.7
user 5678.9
sys 1744.0

would it be more useful? By common convention, the ":" character separates hours, minutes and seconds. Of course, there may be a different method used in a different country or language (see man environ, specifically LC_TIME). The time program always shows seconds until 59.9, then shows mins:secs until 59:59.9 and then shows hrs:mins:secs. Computers are quite happy with 45296.7 but humans are more comfortable with 12:34:56.7


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: change time man page

Hi Brem:

To add to Bill's discussion, here's a little Perl snippet to convert a time format of H:M:S.f to seconds:

# TIME=12:34:56.7
# echo ${TIME} | perl -nle '@t=reverse split /:/;for (1,60,3600) {$sec+=$t[$i]*$_;$i++};END{print $sec}'
45296.7

This works equally well for only minutes and seconds, too, like:

# TIME=3:11.8
# echo ${TIME} | perl ...
191.8

Regards!

...JRF...
Regards!

...JRF...