Close #19798: replace "maximum" term with "peak" in get_traced_memory()
documentation. Use also the term "current" for the current size.
This commit is contained in:
parent
cced076218
commit
3c0481d426
|
@ -276,8 +276,8 @@ Functions
|
|||
|
||||
.. function:: get_traced_memory()
|
||||
|
||||
Get the current size and maximum size of memory blocks traced by the
|
||||
:mod:`tracemalloc` module as a tuple: ``(size: int, max_size: int)``.
|
||||
Get the current size and peak size of memory blocks traced by the
|
||||
:mod:`tracemalloc` module as a tuple: ``(current: int, peak: int)``.
|
||||
|
||||
|
||||
.. function:: get_tracemalloc_memory()
|
||||
|
|
|
@ -182,19 +182,19 @@ class TestTracemallocEnabled(unittest.TestCase):
|
|||
obj_size = 1024 * 1024
|
||||
tracemalloc.clear_traces()
|
||||
obj, obj_traceback = allocate_bytes(obj_size)
|
||||
size, max_size = tracemalloc.get_traced_memory()
|
||||
size, peak_size = tracemalloc.get_traced_memory()
|
||||
self.assertGreaterEqual(size, obj_size)
|
||||
self.assertGreaterEqual(max_size, size)
|
||||
self.assertGreaterEqual(peak_size, size)
|
||||
|
||||
self.assertLessEqual(size - obj_size, max_error)
|
||||
self.assertLessEqual(max_size - size, max_error)
|
||||
self.assertLessEqual(peak_size - size, max_error)
|
||||
|
||||
# destroy the object
|
||||
obj = None
|
||||
size2, max_size2 = tracemalloc.get_traced_memory()
|
||||
size2, peak_size2 = tracemalloc.get_traced_memory()
|
||||
self.assertLess(size2, size)
|
||||
self.assertGreaterEqual(size - size2, obj_size - max_error)
|
||||
self.assertGreaterEqual(max_size2, max_size)
|
||||
self.assertGreaterEqual(peak_size2, peak_size)
|
||||
|
||||
# clear_traces() must reset traced memory counters
|
||||
tracemalloc.clear_traces()
|
||||
|
@ -202,8 +202,8 @@ class TestTracemallocEnabled(unittest.TestCase):
|
|||
|
||||
# allocate another object
|
||||
obj, obj_traceback = allocate_bytes(obj_size)
|
||||
size, max_size = tracemalloc.get_traced_memory()
|
||||
self.assertGreater(size, 0)
|
||||
size, peak_size = tracemalloc.get_traced_memory()
|
||||
self.assertGreaterEqual(size, obj_size)
|
||||
|
||||
# stop() also resets traced memory counters
|
||||
tracemalloc.stop()
|
||||
|
|
|
@ -106,9 +106,9 @@ typedef struct {
|
|||
Protected by TABLES_LOCK(). */
|
||||
static size_t tracemalloc_traced_memory = 0;
|
||||
|
||||
/* Maximum size in bytes of traced memory.
|
||||
/* Peak size in bytes of traced memory.
|
||||
Protected by TABLES_LOCK(). */
|
||||
static size_t tracemalloc_max_traced_memory = 0;
|
||||
static size_t tracemalloc_peak_traced_memory = 0;
|
||||
|
||||
/* Hash table used as a set to to intern filenames:
|
||||
PyObject* => PyObject*.
|
||||
|
@ -464,8 +464,8 @@ tracemalloc_log_alloc(void *ptr, size_t size)
|
|||
if (res == 0) {
|
||||
assert(tracemalloc_traced_memory <= PY_SIZE_MAX - size);
|
||||
tracemalloc_traced_memory += size;
|
||||
if (tracemalloc_traced_memory > tracemalloc_max_traced_memory)
|
||||
tracemalloc_max_traced_memory = tracemalloc_traced_memory;
|
||||
if (tracemalloc_traced_memory > tracemalloc_peak_traced_memory)
|
||||
tracemalloc_peak_traced_memory = tracemalloc_traced_memory;
|
||||
}
|
||||
TABLES_UNLOCK();
|
||||
|
||||
|
@ -674,7 +674,7 @@ tracemalloc_clear_traces(void)
|
|||
TABLES_LOCK();
|
||||
_Py_hashtable_clear(tracemalloc_traces);
|
||||
tracemalloc_traced_memory = 0;
|
||||
tracemalloc_max_traced_memory = 0;
|
||||
tracemalloc_peak_traced_memory = 0;
|
||||
TABLES_UNLOCK();
|
||||
|
||||
_Py_hashtable_foreach(tracemalloc_tracebacks, traceback_free_traceback, NULL);
|
||||
|
@ -1266,26 +1266,26 @@ tracemalloc_get_tracemalloc_memory(PyObject *self)
|
|||
PyDoc_STRVAR(tracemalloc_get_traced_memory_doc,
|
||||
"get_traced_memory() -> (int, int)\n"
|
||||
"\n"
|
||||
"Get the current size and maximum size of memory blocks traced\n"
|
||||
"by the tracemalloc module as a tuple: (size: int, max_size: int).");
|
||||
"Get the current size and peak size of memory blocks traced\n"
|
||||
"by the tracemalloc module as a tuple: (current: int, peak: int).");
|
||||
|
||||
static PyObject*
|
||||
tracemalloc_get_traced_memory(PyObject *self)
|
||||
{
|
||||
Py_ssize_t size, max_size;
|
||||
PyObject *size_obj, *max_size_obj;
|
||||
Py_ssize_t size, peak_size;
|
||||
PyObject *size_obj, *peak_size_obj;
|
||||
|
||||
if (!tracemalloc_config.tracing)
|
||||
return Py_BuildValue("ii", 0, 0);
|
||||
|
||||
TABLES_LOCK();
|
||||
size = tracemalloc_traced_memory;
|
||||
max_size = tracemalloc_max_traced_memory;
|
||||
peak_size = tracemalloc_peak_traced_memory;
|
||||
TABLES_UNLOCK();
|
||||
|
||||
size_obj = PyLong_FromSize_t(size);
|
||||
max_size_obj = PyLong_FromSize_t(max_size);
|
||||
return Py_BuildValue("NN", size_obj, max_size_obj);
|
||||
peak_size_obj = PyLong_FromSize_t(peak_size);
|
||||
return Py_BuildValue("NN", size_obj, peak_size_obj);
|
||||
}
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
|
|
Loading…
Reference in New Issue