mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
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()
This commit is contained in:
parent
c7c9b913c0
commit
aa61f8bfcf
10 changed files with 65 additions and 94 deletions
|
|
@ -121,7 +121,9 @@ call_timer(ProfilerObject *pObj)
|
|||
return CallExternalTimer(pObj);
|
||||
}
|
||||
else {
|
||||
return _PyTime_PerfCounterUnchecked();
|
||||
PyTime_t t;
|
||||
(void)PyTime_PerfCounterRaw(&t);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue