Bug 1004416 - time does not show really consumed time
Summary: time does not show really consumed time
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: time
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Petr Pisar
QA Contact: BaseOS QE - Apps
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-04 15:07 UTC by Jan Ščotka
Modified: 2017-12-06 10:44 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
: 1005807 1412149 (view as bug list)
Environment:
Last Closed: 2017-12-06 10:44:27 UTC
Target Upstream Version:


Attachments (Terms of Use)
Test case (659 bytes, text/plain)
2013-09-09 12:24 UTC, Petr Pisar
no flags Details
Proposed fix (2.72 KB, patch)
2016-11-30 17:08 UTC, Petr Pisar
no flags Details | Diff
Proposed fix (9.85 KB, patch)
2017-01-11 14:27 UTC, Petr Pisar
no flags Details | Diff

Description Jan Ščotka 2013-09-04 15:07:15 UTC
Description of problem:
Hi, then problem is based on
https://bugzilla.redhat.com/show_bug.cgi?id=960570
I've tried to use time to measure problem, but time itself is not able to deal with time shift and show incorrent result



How reproducible:
100%

Steps to Reproduce:
# CONST=70
# W=3
# time sleep $CONST& 
# BPID=$!
# sleep $W
# DOLD=`date`
# date -s "now - 1 minute"
# wait $BPID
# date -s "now + 1 minute"
# DNEW=`date`
# let DIFF=(`date +%s -d "$DNEW"` - `date +%s -d "$DOLD"`)
# echo $(($DIFF+$W)) == $CONST

Actual results:
time difference is 70 sec 
but time show:
real	0m10.001s
user	0m0.000s
sys	0m0.001s


Expected results:
real	1m10.001s

   Thanks&Regards
   Honza

Comment 2 Petr Šabata 2013-09-04 15:20:13 UTC
Judging from the output, you seem to be using your shell's `time', not the `/usr/bin/time' binary.

Comment 3 Petr Pisar 2013-09-09 12:24:20 UTC
Despite you use built-in `time', there is the same problem with GNU time.

I also think that time should measure monotonic (-alike) time not to get influenced by shifts in system clock.

clock_gettime(2) offers:

CLOCK_MONOTONIC -- suffers from NTP time adjustment.
CLOCK_MONOTONIC_RAW -- uses real hardware clock, I worry about precision and access permission for non-root users.
CLOCK_BOOTTIME -- includes time elapsed in suspension but suffers from NTP time adjustment. Is it worth?

I guess the CLOCK_MONOTONIC_RAW is the most appropriate.

Comment 4 Petr Pisar 2013-09-09 12:24:52 UTC
Created attachment 795594 [details]
Test case

Comment 8 Petr Pisar 2014-10-21 13:15:50 UTC
Upstream agreed to use clock_gettime(CLOCK_MONOTONIC) for measuring the "real" value.

Comment 11 Petr Pisar 2016-11-30 17:08:10 UTC
Created attachment 1226439 [details]
Proposed fix

Comment 12 Petr Pisar 2017-01-11 10:17:18 UTC
Patches posted to upstream <http://lists.gnu.org/archive/html/bug-gnu-utils/2016-12/msg00000.html>, but upstream seems dead.

Comment 13 Petr Pisar 2017-01-11 14:27:03 UTC
Created attachment 1239457 [details]
Proposed fix

Comment 14 Jan Kurik 2017-12-06 10:44:27 UTC
Red Hat Enterprise Linux 6 is in the Production 3 Phase. During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not meet the inclusion criteria for the Production 3 Phase and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification. Note that a strong business justification will be required for re-evaluation. Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com/


Note You need to log in before you can comment on or make changes to this bug.