summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 2c0a8d6..3cb1b4e 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -88,19 +88,23 @@ floatclock(_Py_clock_info_t *info)
}
#endif /* HAVE_CLOCK */
+static PyObject*
+perf_counter(_Py_clock_info_t *info)
+{
+ double t;
+ if (_PyTime_GetPerfCounterDoubleWithInfo(&t, info) < 0) {
+ return NULL;
+ }
+ return PyFloat_FromDouble(t);
+}
+
#if defined(MS_WINDOWS) || defined(HAVE_CLOCK)
#define PYCLOCK
static PyObject*
pyclock(_Py_clock_info_t *info)
{
#ifdef MS_WINDOWS
- /* Win32 has better clock replacement; we have our own version, due to Mark
- Hammond and Tim Peters */
- _PyTime_t t;
- if (_PyTime_GetWinPerfCounterWithInfo(&t, info) < 0) {
- return NULL;
- }
- return _PyFloat_FromPyTime(t);
+ return perf_counter(info);
#else
return floatclock(info);
#endif
@@ -936,16 +940,6 @@ PyDoc_STRVAR(monotonic_doc,
\n\
Monotonic clock, cannot go backward.");
-static PyObject*
-perf_counter(_Py_clock_info_t *info)
-{
- _PyTime_t t;
- if (_PyTime_GetPerfCounterWithInfo(&t, info) < 0) {
- return NULL;
- }
- return _PyFloat_FromPyTime(t);
-}
-
static PyObject *
time_perf_counter(PyObject *self, PyObject *unused)
{