The result has the following attributes:
- - *adjusted*: ``True`` if the clock can be adjusted (e.g. by a NTP daemon),
- ``False`` otherwise
+ - *adjustable*: ``True`` if the clock can be changed automatically (e.g. by
+ a NTP daemon) or manually by the system administrator, ``False`` otherwise
- *implementation*: The name of the underlying C function used to get
the clock value
- *monotonic*: ``True`` if the clock cannot go backward,
typedef struct {
const char *implementation;
int monotonic;
- int adjusted;
+ int adjustable;
double resolution;
} _Py_clock_info_t;
info = time.get_clock_info('time')
self.assertFalse(info.monotonic)
if sys.platform != 'win32':
- self.assertTrue(info.adjusted)
+ self.assertTrue(info.adjustable)
def test_clock(self):
time.clock()
info = time.get_clock_info('clock')
self.assertTrue(info.monotonic)
- self.assertFalse(info.adjusted)
+ self.assertFalse(info.adjustable)
@unittest.skipUnless(hasattr(time, 'clock_gettime'),
'need time.clock_gettime()')
info = time.get_clock_info('monotonic')
self.assertTrue(info.monotonic)
if sys.platform == 'linux':
- self.assertTrue(info.adjusted)
+ self.assertTrue(info.adjustable)
else:
- self.assertFalse(info.adjusted)
+ self.assertFalse(info.adjustable)
def test_perf_counter(self):
time.perf_counter()
info = time.get_clock_info('process_time')
self.assertTrue(info.monotonic)
- self.assertFalse(info.adjusted)
+ self.assertFalse(info.adjustable)
@unittest.skipUnless(hasattr(time, 'monotonic'),
'need time.monotonic')
# 0.0 < resolution <= 1.0
self.assertGreater(info.resolution, 0.0)
self.assertLessEqual(info.resolution, 1.0)
- self.assertIsInstance(info.adjusted, bool)
+ self.assertIsInstance(info.adjustable, bool)
self.assertRaises(ValueError, time.get_clock_info, 'xxx')
Library
-------
+- Rename adjusted attribute to adjustable in time.get_clock_info() result.
+
- Issue #3518: Remove references to non-existent BaseManager.from_address()
method.
info->implementation = "clock()";
info->resolution = 1.0 / (double)CLOCKS_PER_SEC;
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
}
return PyFloat_FromDouble((double)value / CLOCKS_PER_SEC);
}
info->implementation = "QueryPerformanceCounter()";
info->resolution = 1.0 / (double)cpu_frequency;
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
}
*result = PyFloat_FromDouble(diff / (double)cpu_frequency);
return 0;
return NULL;
}
info->resolution = timeIncrement * 1e-7;
- info->adjusted = 0;
+ info->adjustable = 0;
}
return PyFloat_FromDouble(result);
info->implementation = "mach_absolute_time()";
info->resolution = (double)timebase.numer / timebase.denom * 1e-9;
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
}
return PyFloat_FromDouble(secs);
struct timespec res;
info->monotonic = 1;
info->implementation = function;
-#if (defined(linux) || defined(__linux) || defined(__linux__)) \
- && !defined(CLOCK_HIGHRES)
- /* CLOCK_MONOTONIC is adjusted on Linux */
- info->adjusted = 1;
-#else
- info->adjusted = 0;
-#endif
+ info->adjustable = 0;
if (clock_getres(clk_id, &res) == 0)
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
else
info->implementation = "GetProcessTimes()";
info->resolution = 1e-7;
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
}
return PyFloat_FromDouble(total * 1e-7);
#else
struct timespec res;
info->implementation = function;
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
if (clock_getres(clk_id, &res) == 0)
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
else
if (info) {
info->implementation = "getrusage(RUSAGE_SELF)";
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
info->resolution = 1e-6;
}
return PyFloat_FromDouble(total);
if (info) {
info->implementation = "times()";
info->monotonic = 1;
- info->adjusted = 0;
+ info->adjustable = 0;
info->resolution = 1.0 / ticks_per_second;
}
return PyFloat_FromDouble(total);
#ifdef Py_DEBUG
info.implementation = NULL;
info.monotonic = -1;
- info.adjusted = -1;
+ info.adjustable = -1;
info.resolution = -1.0;
#else
info.implementation = "";
info.monotonic = 0;
- info.adjusted = 0;
+ info.adjustable = 0;
info.resolution = 1.0;
#endif
goto error;
Py_CLEAR(obj);
- assert(info.adjusted != -1);
- obj = PyBool_FromLong(info.adjusted);
+ assert(info.adjustable != -1);
+ obj = PyBool_FromLong(info.adjustable);
if (obj == NULL)
goto error;
- if (PyDict_SetItemString(dict, "adjusted", obj) == -1)
+ if (PyDict_SetItemString(dict, "adjustable", obj) == -1)
goto error;
Py_CLEAR(obj);
struct timespec res;
info->implementation = "clock_gettime(CLOCK_REALTIME)";
info->monotonic = 0;
- info->adjusted = 1;
+ info->adjustable = 1;
if (clock_getres(CLOCK_REALTIME, &res) == 0)
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
else
(void) GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,
&isTimeAdjustmentDisabled);
info->resolution = timeIncrement * 1e-7;
- if (isTimeAdjustmentDisabled)
- info->adjusted = 0;
- else
- info->adjusted = 1;
+ info->adjustable = 1;
}
#else
/* There are three ways to get the time:
info->implementation = "gettimeofday()";
info->resolution = 1e-6;
info->monotonic = 0;
- info->adjusted = 1;
+ info->adjustable = 1;
}
return;
}
info->implementation = "ftime()";
info->resolution = 1e-3;
info->monotonic = 0;
- info->adjusted = 1;
+ info->adjustable = 1;
}
}
#else /* !HAVE_FTIME */
info->implementation = "time()";
info->resolution = 1.0;
info->monotonic = 0;
- info->adjusted = 1;
+ info->adjustable = 1;
}
#endif /* !HAVE_FTIME */