This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年02月23日 23:09 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| monotonic.patch | nicholas.riley, 2012年03月12日 21:03 | review | ||
| monotonic-2.patch | nicholas.riley, 2012年03月12日 23:18 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg154095 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年02月23日 23:09 | |
time.monotonic() can use mach_absolute_time() on Mac OS X. mach_timebase_info() may be used to convert the result to a number of seconds. Examples: https://github.com/ThomasHabets/monotonic_clock/blob/master/src/monotonic_mach.c http://svn.boost.org/svn/boost/trunk/boost/chrono/detail/inlined/mac/chrono.hpp (search steady_clock) Another way is to use clock_get_time() with host_get_clock_service(SYSTEM_CLOCK). Example: https://github.com/gavinbeatty/python-monotonic-time/blob/master/darwin.c |
|||
| msg155478 - (view) | Author: Nicholas Riley (nicholas.riley) * | Date: 2012年03月12日 21:03 | |
Attached is a patch which implements time.monotonic() using mach_absolute_time() / mach_timebase_info(). This was recommended by Apple in their technical Q&A 1398: https://developer.apple.com/library/mac/#qa/qa1398/ |
|||
| msg155502 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月12日 22:42 | |
> Attached is a patch which implements time.monotonic() using > mach_absolute_time() / mach_timebase_info(). Is it possible that mach_timebase_info() fails? No according to the Technical Q&A QA1398. > time * timebase.numer / timebase.denom "time * timebase.numer" may overflow, you should maybe multiply using the double type to avoid the overflow. |
|||
| msg155507 - (view) | Author: Nicholas Riley (nicholas.riley) * | Date: 2012年03月12日 22:54 | |
timebase.numer and timebase.denom are always 1 in practice (see the "note" in the tech Q&A); I included them for completeness, but maybe it's just better to not bother? |
|||
| msg155511 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月12日 22:58 | |
> timebase.numer and timebase.denom are always 1 in practice In this case, you will not lose precision and it's safe to cast to double to multiply and divide ;-) |
|||
| msg155515 - (view) | Author: Nicholas Riley (nicholas.riley) * | Date: 2012年03月12日 23:18 | |
OK, you have a point :-) New patch attached. |
|||
| msg155520 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月12日 23:27 | |
New changeset 3c875719e46d by Victor Stinner in branch 'default': Issue #14104: Implement time.monotonic() on Mac OS X, http://hg.python.org/cpython/rev/3c875719e46d |
|||
| msg155521 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月12日 23:29 | |
Path commited, thanks for the patch Nicholas! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:27 | admin | set | github: 58312 |
| 2012年03月12日 23:29:14 | vstinner | set | messages: + msg155521 |
| 2012年03月12日 23:27:28 | vstinner | set | status: open -> closed resolution: fixed |
| 2012年03月12日 23:27:09 | python-dev | set | nosy:
+ python-dev messages: + msg155520 |
| 2012年03月12日 23:18:03 | nicholas.riley | set | files:
+ monotonic-2.patch messages: + msg155515 |
| 2012年03月12日 23:02:00 | ned.deily | set | stage: patch review |
| 2012年03月12日 22:58:37 | vstinner | set | messages: + msg155511 |
| 2012年03月12日 22:54:32 | nicholas.riley | set | messages: + msg155507 |
| 2012年03月12日 22:42:51 | vstinner | set | messages: + msg155502 |
| 2012年03月12日 21:03:54 | nicholas.riley | set | files:
+ monotonic.patch nosy: + nicholas.riley messages: + msg155478 keywords: + patch |
| 2012年02月23日 23:31:26 | pitrou | set | nosy:
+ ronaldoussoren, ned.deily |
| 2012年02月23日 23:09:14 | vstinner | create | |