mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Minor improvements to the stats output dump, including adding commas to
the big numbers.
This commit is contained in:
parent
8ace1ab53a
commit
49f26817eb
1 changed files with 34 additions and 10 deletions
|
@ -1197,14 +1197,37 @@ _PyMalloc_DebugDumpAddress(const void *p)
|
||||||
static ulong
|
static ulong
|
||||||
printone(const char* msg, ulong value)
|
printone(const char* msg, ulong value)
|
||||||
{
|
{
|
||||||
const size_t len = strlen(msg);
|
int i, k;
|
||||||
size_t i;
|
char buf[100];
|
||||||
|
ulong origvalue = value;
|
||||||
|
|
||||||
fputs(msg, stderr);
|
fputs(msg, stderr);
|
||||||
for (i = len; i < 40; ++i)
|
for (i = (int)strlen(msg); i < 35; ++i)
|
||||||
fputc(' ', stderr);
|
fputc(' ', stderr);
|
||||||
fprintf(stderr, "= %15lu\n", value);
|
fputc('=', stderr);
|
||||||
return value;
|
|
||||||
|
/* Write the value with commas. */
|
||||||
|
i = 22;
|
||||||
|
buf[i--] = '\0';
|
||||||
|
buf[i--] = '\n';
|
||||||
|
k = 3;
|
||||||
|
do {
|
||||||
|
ulong nextvalue = value / 10UL;
|
||||||
|
uint digit = value - nextvalue * 10UL;
|
||||||
|
value = nextvalue;
|
||||||
|
buf[i--] = (char)(digit + '0');
|
||||||
|
--k;
|
||||||
|
if (k == 0 && value && i >= 0) {
|
||||||
|
k = 3;
|
||||||
|
buf[i--] = ',';
|
||||||
|
}
|
||||||
|
} while (value && i >= 0);
|
||||||
|
|
||||||
|
while (i >= 0)
|
||||||
|
buf[i--] = ' ';
|
||||||
|
fputs(buf, stderr);
|
||||||
|
|
||||||
|
return origvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print summary info to stderr about the state of pymalloc's structures. */
|
/* Print summary info to stderr about the state of pymalloc's structures. */
|
||||||
|
@ -1284,8 +1307,8 @@ _PyMalloc_DebugDumpStats(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
fputs("class num bytes num pools blocks in use avail blocks\n"
|
fputs("class size num pools blocks in use avail blocks\n"
|
||||||
"----- --------- --------- ------------- ------------\n",
|
"----- ---- --------- ------------- ------------\n",
|
||||||
stderr);
|
stderr);
|
||||||
|
|
||||||
for (i = 0; i < numclasses; ++i) {
|
for (i = 0; i < numclasses; ++i) {
|
||||||
|
@ -1297,7 +1320,7 @@ _PyMalloc_DebugDumpStats(void)
|
||||||
assert(b == 0 && f == 0);
|
assert(b == 0 && f == 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%5u %11u %11lu %15lu %13lu\n",
|
fprintf(stderr, "%5u %6u %11lu %15lu %13lu\n",
|
||||||
i, size, p, b, f);
|
i, size, p, b, f);
|
||||||
allocated_bytes += b * size;
|
allocated_bytes += b * size;
|
||||||
available_bytes += f * size;
|
available_bytes += f * size;
|
||||||
|
@ -1312,11 +1335,12 @@ _PyMalloc_DebugDumpStats(void)
|
||||||
|
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
|
total = printone("# bytes in allocated blocks", allocated_bytes);
|
||||||
|
|
||||||
PyOS_snprintf(buf, sizeof(buf),
|
PyOS_snprintf(buf, sizeof(buf),
|
||||||
"%u unused pools * %d bytes", numfreepools, POOL_SIZE);
|
"%u unused pools * %d bytes", numfreepools, POOL_SIZE);
|
||||||
total = printone(buf, (ulong)numfreepools * POOL_SIZE);
|
total += printone(buf, (ulong)numfreepools * POOL_SIZE);
|
||||||
|
|
||||||
total += printone("# bytes in allocated blocks", allocated_bytes);
|
|
||||||
total += printone("# bytes in available blocks", available_bytes);
|
total += printone("# bytes in available blocks", available_bytes);
|
||||||
total += printone("# bytes lost to pool headers", pool_header_bytes);
|
total += printone("# bytes lost to pool headers", pool_header_bytes);
|
||||||
total += printone("# bytes lost to quantization", quantization);
|
total += printone("# bytes lost to quantization", quantization);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue