Change in vdsm[master]: utils: add elapsed_time function

nsoffer at redhat.com nsoffer at redhat.com
Fri Nov 21 00:53:09 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: utils: add elapsed_time function
......................................................................


Patch Set 1:

(5 comments)

http://gerrit.ovirt.org/#/c/35350/1//COMMIT_MSG
Commit Message:

Line 8: 
Line 9: We currently use time.time() to get timestamp
Line 10: with (near) second precision.
Line 11: We we just need the difference between two instants
Line 12: in time, os.times() provide safer alternative
This is good only if we are ok with 10 millisecond resolution (depending on configuration of HZ in the kernel).
Line 13: because it can safely handle corner cases like
Line 14: a switch of timezone in between.
Line 15: 
Line 16: This function add a simple elapsed_time() function


Line 10: with (near) second precision.
Line 11: We we just need the difference between two instants
Line 12: in time, os.times() provide safer alternative
Line 13: because it can safely handle corner cases like
Line 14: a switch of timezone in between.
time.time() is not effected by timezone changes, it returns GMT time.

The only issue with time.time() is that it is effected by system time changes, typically tiny adjustments by ntp.
Line 15: 
Line 16: This function add a simple elapsed_time() function
Line 17: based on os.times().
Line 18: 


Line 13: because it can safely handle corner cases like
Line 14: a switch of timezone in between.
Line 15: 
Line 16: This function add a simple elapsed_time() function
Line 17: based on os.times().
elapsed_time is not a good name since it is not clear what is your reference point. In linux, the reference point is (unsigned long) -300 * HZ.

A better name would be monotonic_time.
Line 18: 
Line 19: Change-Id: I65c7d6041ed89fc8c497115b2d70341e82936b26


http://gerrit.ovirt.org/#/c/35350/1/lib/vdsm/utils.py
File lib/vdsm/utils.py:

Line 1203: 
Line 1204: def elapsed_time():
Line 1205:     """
Line 1206:     Return the amount of time, in secs, elapsed since a fixed
Line 1207:     point in the past. Can handle timezone switches, so it
timezone not relevant.
Line 1208:     is safer with a naive use of time.time() to record instants
Line 1209:     in time.
Line 1210:     """


Line 1205:     """
Line 1206:     Return the amount of time, in secs, elapsed since a fixed
Line 1207:     point in the past. Can handle timezone switches, so it
Line 1208:     is safer with a naive use of time.time() to record instants
Line 1209:     in time.
Should document the lower resolution.
Line 1210:     """


-- 
To view, visit http://gerrit.ovirt.org/35350
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I65c7d6041ed89fc8c497115b2d70341e82936b26
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list