| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,11 +168,11 @@ The module defines the following functions and data items: | |||
| 168 | 168 | ||
| 169 | 169 | The name of the underlying C function used to get the clock value. | |
| 170 | 170 | ||
| 171 | - .. attribute:: is_monotonic | ||
| 171 | + .. attribute:: monotonic | ||
| 172 | 172 | ||
| 173 | 173 | ``True`` if the clock cannot go backward, ``False`` otherwise. | |
| 174 | 174 | ||
| 175 | - .. attribute:: is_adjusted | ||
| 175 | + .. attribute:: adjusted | ||
| 176 | 176 | ||
| 177 | 177 | ``True`` if the clock can be adjusted (e.g. by a NTP daemon), ``False`` | |
| 178 | 178 | otherwise. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,8 +25,8 @@ typedef struct { | |||
| 25 | 25 | /* Structure used by time.get_clock_info() */ | |
| 26 | 26 | typedef struct { | |
| 27 | 27 | const char *implementation; | |
| 28 | - int is_monotonic; | ||
| 29 | - int is_adjusted; | ||
| 28 | + int monotonic; | ||
| 29 | + int adjusted; | ||
| 30 | 30 | double resolution; | |
| 31 | 31 | } _Py_clock_info_t; | |
| 32 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,16 +30,16 @@ def test_data_attributes(self): | |||
| 30 | 30 | def test_time(self): | |
| 31 | 31 | time.time() | |
| 32 | 32 | info = time.get_clock_info('time') | |
| 33 | - self.assertEqual(info.is_monotonic, False) | ||
| 33 | + self.assertEqual(info.monotonic, False) | ||
| 34 | 34 | if sys.platform != 'win32': | |
| 35 | - self.assertEqual(info.is_adjusted, True) | ||
| 35 | + self.assertEqual(info.adjusted, True) | ||
| 36 | 36 | ||
| 37 | 37 | def test_clock(self): | |
| 38 | 38 | time.clock() | |
| 39 | 39 | ||
| 40 | 40 | info = time.get_clock_info('clock') | |
| 41 | - self.assertEqual(info.is_monotonic, True) | ||
| 42 | - self.assertEqual(info.is_adjusted, False) | ||
| 41 | + self.assertEqual(info.monotonic, True) | ||
| 42 | + self.assertEqual(info.adjusted, False) | ||
| 43 | 43 | ||
| 44 | 44 | @unittest.skipUnless(hasattr(time, 'clock_gettime'), | |
| 45 | 45 | 'need time.clock_gettime()') | |
@@ -370,11 +370,11 @@ def test_monotonic(self): | |||
| 370 | 370 | self.assertAlmostEqual(dt, 0.1, delta=0.2) | |
| 371 | 371 | ||
| 372 | 372 | info = time.get_clock_info('monotonic') | |
| 373 | - self.assertEqual(info.is_monotonic, True) | ||
| 373 | + self.assertEqual(info.monotonic, True) | ||
| 374 | 374 | if sys.platform == 'linux': | |
| 375 | - self.assertEqual(info.is_adjusted, True) | ||
| 375 | + self.assertEqual(info.adjusted, True) | ||
| 376 | 376 | else: | |
| 377 | - self.assertEqual(info.is_adjusted, False) | ||
| 377 | + self.assertEqual(info.adjusted, False) | ||
| 378 | 378 | ||
| 379 | 379 | def test_perf_counter(self): | |
| 380 | 380 | time.perf_counter() | |
@@ -386,8 +386,8 @@ def test_process_time(self): | |||
| 386 | 386 | self.assertLess(stop - start, 0.01) | |
| 387 | 387 | ||
| 388 | 388 | info = time.get_clock_info('process_time') | |
| 389 | - self.assertEqual(info.is_monotonic, True) | ||
| 390 | - self.assertEqual(info.is_adjusted, False) | ||
| 389 | + self.assertEqual(info.monotonic, True) | ||
| 390 | + self.assertEqual(info.adjusted, False) | ||
| 391 | 391 | ||
| 392 | 392 | @unittest.skipUnless(hasattr(time, 'monotonic'), | |
| 393 | 393 | 'need time.monotonic') | |
@@ -433,12 +433,12 @@ def test_get_clock_info(self): | |||
| 433 | 433 | #self.assertIsInstance(info, dict) | |
| 434 | 434 | self.assertIsInstance(info.implementation, str) | |
| 435 | 435 | self.assertNotEqual(info.implementation, '') | |
| 436 | - self.assertIsInstance(info.is_monotonic, bool) | ||
| 436 | + self.assertIsInstance(info.monotonic, bool) | ||
| 437 | 437 | self.assertIsInstance(info.resolution, float) | |
| 438 | 438 | # 0.0 < resolution <= 1.0 | |
| 439 | 439 | self.assertGreater(info.resolution, 0.0) | |
| 440 | 440 | self.assertLessEqual(info.resolution, 1.0) | |
| 441 | - self.assertIsInstance(info.is_adjusted, bool) | ||
| 441 | + self.assertIsInstance(info.adjusted, bool) | ||
| 442 | 442 | ||
| 443 | 443 | self.assertRaises(ValueError, time.get_clock_info, 'xxx') | |
| 444 | 444 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,8 +95,8 @@ floatclock(_Py_clock_info_t *info) | |||
| 95 | 95 | if (info) { | |
| 96 | 96 | info->implementation = "clock()"; | |
| 97 | 97 | info->resolution = 1.0 / (double)CLOCKS_PER_SEC; | |
| 98 | - info->is_monotonic = 1; | ||
| 99 | - info->is_adjusted = 0; | ||
| 98 | + info->monotonic = 1; | ||
| 99 | + info->adjusted = 0; | ||
| 100 | 100 | } | |
| 101 | 101 | return PyFloat_FromDouble((double)value / CLOCKS_PER_SEC); | |
| 102 | 102 | } | |
@@ -131,8 +131,8 @@ win_perf_counter(_Py_clock_info_t *info, PyObject **result) | |||
| 131 | 131 | if (info) { | |
| 132 | 132 | info->implementation = "QueryPerformanceCounter()"; | |
| 133 | 133 | info->resolution = 1.0 / (double)cpu_frequency; | |
| 134 | - info->is_monotonic = 1; | ||
| 135 | - info->is_adjusted = 0; | ||
| 134 | + info->monotonic = 1; | ||
| 135 | + info->adjusted = 0; | ||
| 136 | 136 | } | |
| 137 | 137 | *result = PyFloat_FromDouble(diff / (double)cpu_frequency); | |
| 138 | 138 | return 0; | |
@@ -874,15 +874,15 @@ pymonotonic(_Py_clock_info_t *info) | |||
| 874 | 874 | info->implementation = "GetTickCount64()"; | |
| 875 | 875 | else | |
| 876 | 876 | info->implementation = "GetTickCount()"; | |
| 877 | - info->is_monotonic = 1; | ||
| 877 | + info->monotonic = 1; | ||
| 878 | 878 | ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement, | |
| 879 | 879 | &isTimeAdjustmentDisabled); | |
| 880 | 880 | if (!ok) { | |
| 881 | 881 | PyErr_SetFromWindowsErr(0); | |
| 882 | 882 | return NULL; | |
| 883 | 883 | } | |
| 884 | 884 | info->resolution = timeIncrement * 1e-7; | |
| 885 | - info->is_adjusted = 0; | ||
| 885 | + info->adjusted = 0; | ||
| 886 | 886 | } | |
| 887 | 887 | return PyFloat_FromDouble(result); | |
| 888 | 888 | ||
@@ -902,8 +902,8 @@ pymonotonic(_Py_clock_info_t *info) | |||
| 902 | 902 | if (info) { | |
| 903 | 903 | info->implementation = "mach_absolute_time()"; | |
| 904 | 904 | info->resolution = (double)timebase.numer / timebase.denom * 1e-9; | |
| 905 | - info->is_monotonic = 1; | ||
| 906 | - info->is_adjusted = 0; | ||
| 905 | + info->monotonic = 1; | ||
| 906 | + info->adjusted = 0; | ||
| 907 | 907 | } | |
| 908 | 908 | return PyFloat_FromDouble(secs); | |
| 909 | 909 | ||
@@ -924,14 +924,14 @@ pymonotonic(_Py_clock_info_t *info) | |||
| 924 | 924 | ||
| 925 | 925 | if (info) { | |
| 926 | 926 | struct timespec res; | |
| 927 | - info->is_monotonic = 1; | ||
| 927 | + info->monotonic = 1; | ||
| 928 | 928 | info->implementation = function; | |
| 929 | 929 | #if (defined(linux) || defined(__linux) || defined(__linux__)) \ | |
| 930 | 930 | && !defined(CLOCK_HIGHRES) | |
| 931 | 931 | /* CLOCK_MONOTONIC is adjusted on Linux */ | |
| 932 | - info->is_adjusted = 1; | ||
| 932 | + info->adjusted = 1; | ||
| 933 | 933 | #else | |
| 934 | - info->is_adjusted = 0; | ||
| 934 | + info->adjusted = 0; | ||
| 935 | 935 | #endif | |
| 936 | 936 | if (clock_getres(clk_id, &res) == 0) | |
| 937 | 937 | info->resolution = res.tv_sec + res.tv_nsec * 1e-9; | |
@@ -1023,8 +1023,8 @@ py_process_time(_Py_clock_info_t *info) | |||
| 1023 | 1023 | if (info) { | |
| 1024 | 1024 | info->implementation = "GetProcessTimes()"; | |
| 1025 | 1025 | info->resolution = 1e-7; | |
| 1026 | - info->is_monotonic = 1; | ||
| 1027 | - info->is_adjusted = 0; | ||
| 1026 | + info->monotonic = 1; | ||
| 1027 | + info->adjusted = 0; | ||
| 1028 | 1028 | } | |
| 1029 | 1029 | return PyFloat_FromDouble(total * 1e-7); | |
| 1030 | 1030 | #else | |
@@ -1052,8 +1052,8 @@ py_process_time(_Py_clock_info_t *info) | |||
| 1052 | 1052 | if (info) { | |
| 1053 | 1053 | struct timespec res; | |
| 1054 | 1054 | info->implementation = function; | |
| 1055 | - info->is_monotonic = 1; | ||
| 1056 | - info->is_adjusted = 0; | ||
| 1055 | + info->monotonic = 1; | ||
| 1056 | + info->adjusted = 0; | ||
| 1057 | 1057 | if (clock_getres(clk_id, &res) == 0) | |
| 1058 | 1058 | info->resolution = res.tv_sec + res.tv_nsec * 1e-9; | |
| 1059 | 1059 | else | |
@@ -1070,8 +1070,8 @@ py_process_time(_Py_clock_info_t *info) | |||
| 1070 | 1070 | total += ru.ru_stime.tv_sec + ru.ru_stime.tv_usec * 1e-6; | |
| 1071 | 1071 | if (info) { | |
| 1072 | 1072 | info->implementation = "getrusage(RUSAGE_SELF)"; | |
| 1073 | - info->is_monotonic = 1; | ||
| 1074 | - info->is_adjusted = 0; | ||
| 1073 | + info->monotonic = 1; | ||
| 1074 | + info->adjusted = 0; | ||
| 1075 | 1075 | info->resolution = 1e-6; | |
| 1076 | 1076 | } | |
| 1077 | 1077 | return PyFloat_FromDouble(total); | |
@@ -1099,8 +1099,8 @@ py_process_time(_Py_clock_info_t *info) | |||
| 1099 | 1099 | total += (double)t.tms_stime / ticks_per_second; | |
| 1100 | 1100 | if (info) { | |
| 1101 | 1101 | info->implementation = "times()"; | |
| 1102 | - info->is_monotonic = 1; | ||
| 1103 | - info->is_adjusted = 0; | ||
| 1102 | + info->monotonic = 1; | ||
| 1103 | + info->adjusted = 0; | ||
| 1104 | 1104 | info->resolution = 1.0 / ticks_per_second; | |
| 1105 | 1105 | } | |
| 1106 | 1106 | return PyFloat_FromDouble(total); | |
@@ -1132,8 +1132,8 @@ PyDoc_STRVAR(ClockInfo_docstring, | |||
| 1132 | 1132 | static PyStructSequence_Field ClockInfo_fields[] = { | |
| 1133 | 1133 | {"implementation", "name of the underlying C function " | |
| 1134 | 1134 | "used to get the clock value"}, | |
| 1135 | - {"is_monotonic", "True if the clock cannot go backward, False otherwise"}, | ||
| 1136 | - {"is_adjusted", "True if the clock can be adjusted " | ||
| 1135 | + {"monotonic", "True if the clock cannot go backward, False otherwise"}, | ||
| 1136 | + {"adjusted", "True if the clock can be adjusted " | ||
| 1137 | 1137 | "(e.g. by a NTP daemon), False otherwise"}, | |
| 1138 | 1138 | {"resolution", "resolution of the clock in seconds"}, | |
| 1139 | 1139 | {NULL, NULL} | |
@@ -1159,13 +1159,13 @@ time_get_clock_info(PyObject *self, PyObject *args) | |||
| 1159 | 1159 | ||
| 1160 | 1160 | #ifdef Py_DEBUG | |
| 1161 | 1161 | info.implementation = NULL; | |
| 1162 | - info.is_monotonic = -1; | ||
| 1163 | - info.is_adjusted = -1; | ||
| 1162 | + info.monotonic = -1; | ||
| 1163 | + info.adjusted = -1; | ||
| 1164 | 1164 | info.resolution = -1.0; | |
| 1165 | 1165 | #else | |
| 1166 | 1166 | info.implementation = ""; | |
| 1167 | - info.is_monotonic = 0; | ||
| 1168 | - info.is_adjusted = 0; | ||
| 1167 | + info.monotonic = 0; | ||
| 1168 | + info.adjusted = 0; | ||
| 1169 | 1169 | info.resolution = 1.0; | |
| 1170 | 1170 | #endif | |
| 1171 | 1171 | ||
@@ -1201,14 +1201,14 @@ time_get_clock_info(PyObject *self, PyObject *args) | |||
| 1201 | 1201 | goto error; | |
| 1202 | 1202 | PyStructSequence_SET_ITEM(result, 0, obj); | |
| 1203 | 1203 | ||
| 1204 | - assert(info.is_monotonic != -1); | ||
| 1205 | - obj = PyBool_FromLong(info.is_monotonic); | ||
| 1204 | + assert(info.monotonic != -1); | ||
| 1205 | + obj = PyBool_FromLong(info.monotonic); | ||
| 1206 | 1206 | if (obj == NULL) | |
| 1207 | 1207 | goto error; | |
| 1208 | 1208 | PyStructSequence_SET_ITEM(result, 1, obj); | |
| 1209 | 1209 | ||
| 1210 | - assert(info.is_adjusted != -1); | ||
| 1211 | - obj = PyBool_FromLong(info.is_adjusted); | ||
| 1210 | + assert(info.adjusted != -1); | ||
| 1211 | + obj = PyBool_FromLong(info.adjusted); | ||
| 1212 | 1212 | if (obj == NULL) | |
| 1213 | 1213 | goto error; | |
| 1214 | 1214 | PyStructSequence_SET_ITEM(result, 2, obj); | |
@@ -1487,8 +1487,8 @@ floattime(_Py_clock_info_t *info) | |||
| 1487 | 1487 | if (info) { | |
| 1488 | 1488 | struct timespec res; | |
| 1489 | 1489 | info->implementation = "clock_gettime(CLOCK_REALTIME)"; | |
| 1490 | - info->is_monotonic = 0; | ||
| 1491 | - info->is_adjusted = 1; | ||
| 1490 | + info->monotonic = 0; | ||
| 1491 | + info->adjusted = 1; | ||
| 1492 | 1492 | if (clock_getres(CLOCK_REALTIME, &res) == 0) | |
| 1493 | 1493 | info->resolution = res.tv_sec + res.tv_nsec * 1e-9; | |
| 1494 | 1494 | else | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,14 +40,14 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info) | |||
| 40 | 40 | BOOL isTimeAdjustmentDisabled; | |
| 41 | 41 | ||
| 42 | 42 | info->implementation = "GetSystemTimeAsFileTime()"; | |
| 43 | - info->is_monotonic = 0; | ||
| 43 | + info->monotonic = 0; | ||
| 44 | 44 | (void) GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement, | |
| 45 | 45 | &isTimeAdjustmentDisabled); | |
| 46 | 46 | info->resolution = timeIncrement * 1e-7; | |
| 47 | 47 | if (isTimeAdjustmentDisabled) | |
| 48 | - info->is_adjusted = 0; | ||
| 48 | + info->adjusted = 0; | ||
| 49 | 49 | else | |
| 50 | - info->is_adjusted = 1; | ||
| 50 | + info->adjusted = 1; | ||
| 51 | 51 | } | |
| 52 | 52 | #else | |
| 53 | 53 | /* There are three ways to get the time: | |
@@ -70,8 +70,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info) | |||
| 70 | 70 | if (info) { | |
| 71 | 71 | info->implementation = "gettimeofday()"; | |
| 72 | 72 | info->resolution = 1e-6; | |
| 73 | - info->is_monotonic = 0; | ||
| 74 | - info->is_adjusted = 1; | ||
| 73 | + info->monotonic = 0; | ||
| 74 | + info->adjusted = 1; | ||
| 75 | 75 | } | |
| 76 | 76 | return; | |
| 77 | 77 | } | |
@@ -86,8 +86,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info) | |||
| 86 | 86 | if (info) { | |
| 87 | 87 | info->implementation = "ftime()"; | |
| 88 | 88 | info->resolution = 1e-3; | |
| 89 | - info->is_monotonic = 0; | ||
| 90 | - info->is_adjusted = 1; | ||
| 89 | + info->monotonic = 0; | ||
| 90 | + info->adjusted = 1; | ||
| 91 | 91 | } | |
| 92 | 92 | } | |
| 93 | 93 | #else /* !HAVE_FTIME */ | |
@@ -96,8 +96,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info) | |||
| 96 | 96 | if (info) { | |
| 97 | 97 | info->implementation = "time()"; | |
| 98 | 98 | info->resolution = 1.0; | |
| 99 | - info->is_monotonic = 0; | ||
| 100 | - info->is_adjusted = 1; | ||
| 99 | + info->monotonic = 0; | ||
| 100 | + info->adjusted = 1; | ||
| 101 | 101 | } | |
| 102 | 102 | #endif /* !HAVE_FTIME */ | |
| 103 | 103 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments