Charles-François Natali neolo...@free.fr added the comment:
I'm closing again this issue.
@neologix: Please open a new issue if you disagree with me on the definition
of seconds for time.process_time().
I won't reopen, but I still disagree with your definition.
process_time() returns
Antoine Pitrou pit...@free.fr added the comment:
I don't know what you two are arguing about, since the process_time() doc says
Return the value (in fractional seconds) of the sum of the system and user CPU
time of the current process.
(while I'm not sure what fractional seconds are, they are
STINNER Victor victor.stin...@gmail.com added the comment:
I'm closing again this issue.
@neologix: Please open a new issue if you disagree with me on the definition of
seconds for time.process_time().
--
status: open - closed
___
Python tracker
STINNER Victor victor.stin...@gmail.com added the comment:
It really looks like seconds to me, definitely not jiffies ;-)
time.process_time() uses maybe seconds on Linux, but it doesn't include time
elapsed during sleep. See the test:
def test_process_time(self):
start =
Charles-François Natali neolo...@free.fr added the comment:
Yes, dt is not a number of seconds in the following example:
t1=time.process_time(); (...); t2=time.process_time(); dt=t2-t1
OK, so what is it then?
It's not written anywhere - neither in the PEP nor in the
documentation - and it
Charles-François Natali neolo...@free.fr added the comment:
test_process_time_threads is failing on one of the buildbots:
==
FAIL: test_process_time_threads (test.test_time.TimeTestCase)
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 1255cac63dfc by Victor Stinner in branch 'default':
Issue #14428: Rewrite test_process_time_threads() test
http://hg.python.org/cpython/rev/1255cac63dfc
--
___
Python
STINNER Victor victor.stin...@gmail.com added the comment:
The test is a bit too optimistic: a thread is looping for 0.2s, and the test
checks that the process time (user + system) increased of at least 0.1s. If the
thread is preempted, there's a high chance you won't get even as low as 0.1s.
Charles-François Natali neolo...@free.fr added the comment:
Hum, the problem is maybe that the thread is preempted, but the first
problem is that the test considers that time.process_time() uses seconds.
Hum, what?
You mean that process_time() doesn't return seconds?
--
Antoine Pitrou pit...@free.fr added the comment:
There are many sporadic failures on the buildbots:
==
FAIL: test_process_time_threads (test.test_time.TimeTestCase)
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 0bdf0727ee29 by Victor Stinner in branch 'default':
Issue #14428: Make test_process_time_threads() less strict
http://hg.python.org/cpython/rev/0bdf0727ee29
--
___
Python
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset ad3d6010379b by Victor Stinner in branch 'default':
Issue #14428: Remove test_process_time_threads() from test_time
http://hg.python.org/cpython/rev/ad3d6010379b
--
___
STINNER Victor victor.stin...@gmail.com added the comment:
You mean that process_time() doesn't return seconds?
Yes, dt is not a number of seconds in the following example:
t1=time.process_time(); (...); t2=time.process_time(); dt=t2-t1
I see two options: either increase the total running
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25393/4ba64ca9abcf.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25393/4ba64ca9abcf.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25395/9a93348e98e7.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25395/9a93348e98e7.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25254/384190bb0bd5.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25396/667541bb315c.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
STINNER Victor victor.stin...@gmail.com added the comment:
667541bb315c.diff: Updated patch, last change: is_adjusted key of
time.get_clock_info() is now mandatory.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25397/4255e3c4daf2.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 76d2e0761d18 by Victor Stinner in branch 'default':
Issue #14428, #14397: Implement the PEP 418
http://hg.python.org/cpython/rev/76d2e0761d18
--
nosy: +python-dev
___
STINNER Victor victor.stin...@gmail.com added the comment:
Guido van Rossum accepted the PEP, let's commit the implementation.
--
resolution: - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset bd195749c0a2 by Victor Stinner in branch 'default':
Issue #14428: Use the new time.perf_counter() and time.process_time() functions
http://hg.python.org/cpython/rev/bd195749c0a2
--
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Marc-Andre Lemburg m...@egenix.com added the comment:
STINNER Victor wrote:
STINNER Victor victor.stin...@gmail.com added the comment:
Please leave the pybench default timers unchanged in case the
new APIs are not available.
Ok, done in the new patch: perf_counter_process_time-2.patch.
Marc-Andre Lemburg m...@egenix.com added the comment:
Please leave the pybench default timers unchanged in case the
new APIs are not available.
The perf_counter_process_time.patch currently changes them, even
though the new APIs are not available on older Python releases,
thus breaking pybench
STINNER Victor victor.stin...@gmail.com added the comment:
Please leave the pybench default timers unchanged in case the
new APIs are not available.
Ok, done in the new patch: perf_counter_process_time-2.patch.
--
Added file:
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25202/perf_counter_process_time.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25210/pep418-9.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
STINNER Victor victor.stin...@gmail.com added the comment:
FreeBSD doesn't provide CLOCK_PROCESS_CPUTIME_ID, but CLOCK_PROF. CLOCK_PROF
can be used instead of getrusage(), its precision can be read using
clock_getres(). Something like #if defined(CLOCK_PROF)
defined(__FreeBSD__) can be
Charles-François Natali neolo...@free.fr added the comment:
Victor, can you let us know when you think the patch is ready for
review?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
Changes by STINNER Victor victor.stin...@gmail.com:
--
hgrepos: +118
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
___
Python-bugs-list
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25253/aac59a3c11ef.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Added file: http://bugs.python.org/file25254/384190bb0bd5.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25253/aac59a3c11ef.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
STINNER Victor victor.stin...@gmail.com added the comment:
can you let us know when you think the patch is ready for review?
Now!
I created a repository for the PEP. I integrated my own last comments. I tested
the PEP on Linux 3.3, FreeBSD 8, OpenBSD 5, OpenSolaris and Windows Seven.
The
STINNER Victor victor.stin...@gmail.com added the comment:
The precision of mach_absolute_time() is known: it is timebase.numer /
timebase.denom * 1e-9.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
Marc-Andre Lemburg m...@egenix.com added the comment:
STINNER Victor wrote:
STINNER Victor victor.stin...@gmail.com added the comment:
perf_counter_process_time.patch: replace time.clock if windows else
time.time with time.perf_counter, and getrusage/clock with time.process_time.
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 8: time.process_time() uses times() if available. Rename also
function key of time.get_clock_info() with implementation.
--
Added file: http://bugs.python.org/file25209/pep418-8.patch
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 9: fixes for Windows (fix compilation and fix to code checking if
GetTickCount64 is present).
--
Added file: http://bugs.python.org/file25210/pep418-9.patch
___
Python tracker
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25126/pep418-6.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25201/pep418-7.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25209/pep418-8.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 7:
- Add time.perf_counter() and time.process_time()
- Replace accuracy key with precision in time.get_clock_info() result
--
Added file: http://bugs.python.org/file25201/pep418-7.patch
STINNER Victor victor.stin...@gmail.com added the comment:
perf_counter_process_time.patch: replace time.clock if windows else time.time
with time.perf_counter, and getrusage/clock with time.process_time.
pybench and timeit now use time.perf_counter() by default. profile uses
STINNER Victor victor.stin...@gmail.com added the comment:
+if (has_getickcount64) {
+ULONGLONG ticks;
+ticks = Py_GetTickCount64();
+result = (double)ticks * 1e-3
+}
; is missing after 1e-3, it does not compile on Windows because of this.
--
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 5, updated to the last version of the PEP:
- drop time.highres()
- time.monotonic() is always monotonic but it not always available
- add a test on time.monotonic() setting the system clock (jump backward wtih
a delta
STINNER Victor victor.stin...@gmail.com added the comment:
+#if defined(linux) || defined(__linux) || defined(__linux__)
Hum, a better check should be done in configure and/or a macro like MS_WINDOWS
should be added.
--
___
Python tracker
STINNER Victor victor.stin...@gmail.com added the comment:
Version 6: simplify the code handling GetTickCounter() integer overflow. We
don't need a has_last_ticks variable.
--
Added file: http://bugs.python.org/file25126/pep418-6.patch
___
Python
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25115/pep418-5.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25108/pep418-4.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by R. David Murray rdmur...@bitdance.com:
--
type: - enhancement
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
___
Marc-Andre Lemburg m...@egenix.com added the comment:
Hi Victor,
I think you need to reconsider the time.steady() name you're using
in the PEP. For practical purposes, it's better to call it
time.monotonic() and only make the function available if the OS provides
a monotonic clock.
The
STINNER Victor victor.stin...@gmail.com added the comment:
I think you need to reconsider the time.steady() name you're using
in the PEP. For practical purposes, it's better to call it
time.monotonic()
I opened a new thread on python-dev to discuss this topic.
and only make the function
Marc-Andre Lemburg m...@egenix.com added the comment:
STINNER Victor wrote:
STINNER Victor victor.stin...@gmail.com added the comment:
I think you need to reconsider the time.steady() name you're using
in the PEP. For practical purposes, it's better to call it
time.monotonic()
I
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 4:
- Rename time.monotonic() to time.steady()
- Don't use CLOCK_MONOTONIC_RAW but CLOCK_MONOTONIC for time.highres() and
time.steady()
- Use CLOCK_HIGHRES, useful on Solaris
- Rewrite time.highres() and time.steady()
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25053/pep418.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25101/pep418-2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
Changes by STINNER Victor victor.stin...@gmail.com:
Removed file: http://bugs.python.org/file25103/pep418-3.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
___
STINNER Victor victor.stin...@gmail.com added the comment:
BTW: Are aware of the existing systimes.py module in pybench,
which already provides interfaces to high resolution timers usable
for benchmarking in a portable way ? Perhaps worth mentioning in
the PEP.
Nope, I didn't know it. It
STINNER Victor victor.stin...@gmail.com added the comment:
Updated patch:
- Implement time.get_clock_info()
- time.monotonic() never fails: fallback to time.time() if needed
TODO: time.monotonic() must use GetTickCount64() or GetTickCount() on Windows,
with a detection of integer overflow on
STINNER Victor victor.stin...@gmail.com added the comment:
Patch version 3:
- fix compilation on non-Linux (e.g. on FreeBSD and OpenBSD)
- time.monotonic() uses GetTickCount/GetTickCount64 on Windows
- clock_getres() fills the accuracy field instead of the resolution field of
STINNER Victor victor.stin...@gmail.com added the comment:
Solaris on x86_64:
pprint.pprint(time.get_clock_info('clock'))
{'accuracy': 1e-06,
'function': 'clock()',
'is_adjusted': False,
'is_monotonic': True,
'resolution': 1e-06}
pprint.pprint(time.get_clock_info('highres'))
{'accuracy':
STINNER Victor victor.stin...@gmail.com added the comment:
TODO (pep418-3.patch):
- Use CLOCK_HIGHRES on Solaris
- Maybe implement gethrtime() for Solaris
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14428
Charles-François Natali neolo...@free.fr added the comment:
Tiny review.
Two more details:
- since it's relatively straightforward to cache the last value returned using
a static variable, it might be interesting to use this to make sure that the
values returned are indeed monotonic
- I'm not
New submission from STINNER Victor victor.stin...@gmail.com:
Attached patch implements the PEP 418: add time.monotonic() and time.hires().
In practice, it replaces time.steady() by time.hires() and
time.steady(strict=True) by time.monotonic().
--
components: Library (Lib)
files:
67 matches
Mail list logo