summaryrefslogtreecommitdiffstats
path: root/Modules/_testinternalcapi
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-05-05 10:15:19 (GMT)
committerGitHub <noreply@github.com>2024-05-05 10:15:19 (GMT)
commitaa61f8bfcf2584dd8345f1f9a07e240100b79192 (patch)
treedb196e9316a20ff332290c56b60c38a6b533fae6 /Modules/_testinternalcapi
parentc7c9b913c01afb8d2ff4048f82155969f7ef75b1 (diff)
downloadcpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.zip
cpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.tar.gz
cpython-aa61f8bfcf2584dd8345f1f9a07e240100b79192.tar.bz2
gh-110850: Remove _PyTime_TimeUnchecked() function (#118552)
Use the new public Raw functions: * _PyTime_PerfCounterUnchecked() with PyTime_PerfCounterRaw() * _PyTime_TimeUnchecked() with PyTime_TimeRaw() * _PyTime_MonotonicUnchecked() with PyTime_MonotonicRaw() Remove internal functions: * _PyTime_PerfCounterUnchecked() * _PyTime_TimeUnchecked() * _PyTime_MonotonicUnchecked()
Diffstat (limited to 'Modules/_testinternalcapi')
-rw-r--r--Modules/_testinternalcapi/test_lock.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_testinternalcapi/test_lock.c b/Modules/_testinternalcapi/test_lock.c
index 1c50481..4900459 100644
--- a/Modules/_testinternalcapi/test_lock.c
+++ b/Modules/_testinternalcapi/test_lock.c
@@ -2,7 +2,6 @@
#include "parts.h"
#include "pycore_lock.h"
-#include "pycore_time.h" // _PyTime_MonotonicUnchecked()
#include "clinic/test_lock.c.h"
@@ -290,7 +289,10 @@ _testinternalcapi_benchmark_locks_impl(PyObject *module,
goto exit;
}
- PyTime_t start = _PyTime_MonotonicUnchecked();
+ PyTime_t start, end;
+ if (PyTime_PerfCounter(&start) < 0) {
+ goto exit;
+ }
for (Py_ssize_t i = 0; i < num_threads; i++) {
thread_data[i].bench_data = &bench_data;
@@ -307,7 +309,9 @@ _testinternalcapi_benchmark_locks_impl(PyObject *module,
}
Py_ssize_t total_iters = bench_data.total_iters;
- PyTime_t end = _PyTime_MonotonicUnchecked();
+ if (PyTime_PerfCounter(&end) < 0) {
+ goto exit;
+ }
// Return the total number of acquisitions and the number of acquisitions
// for each thread.
@@ -319,7 +323,8 @@ _testinternalcapi_benchmark_locks_impl(PyObject *module,
PyList_SET_ITEM(thread_iters, i, iter);
}
- double rate = total_iters * 1000000000.0 / (end - start);
+ assert(end != start);
+ double rate = total_iters * 1e9 / (end - start);
res = Py_BuildValue("(dO)", rate, thread_iters);
exit: