[Python-checkins] CVS: python/dist/src/Objects obmalloc.c,2.32,2.33

Tim Peters tim_one@users.sourceforge.net
Fri, 05 Apr 2002 17:45:37 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10226/python/Objects

Modified Files:
	obmalloc.c 
Log Message:
Minor improvements to the stats output dump, including adding commas to
the big numbers.


Index: obmalloc.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.32
retrieving revision 2.33
diff -C2 -d -r2.32 -r2.33
*** obmalloc.c	5 Apr 2002 06:24:54 -0000	2.32
--- obmalloc.c	6 Apr 2002 01:45:35 -0000	2.33
***************
*** 1198,1209 ****
  printone(const char* msg, ulong value)
  {
! 	const size_t len = strlen(msg);
! 	size_t i;
  
  	fputs(msg, stderr);
! 	for (i = len; i < 40; ++i)
  		fputc(' ', stderr);
! 	fprintf(stderr, "= %15lu\n", value);
! 	return value;
  }
  
--- 1198,1232 ----
  printone(const char* msg, ulong value)
  {
! 	int i, k;
! 	char buf[100];
! 	ulong origvalue = value;
  
  	fputs(msg, stderr);
! 	for (i = (int)strlen(msg); i < 35; ++i)
  		fputc(' ', stderr);
! 	fputc('=', stderr);
! 
! 	/* 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;
  }
  
***************
*** 1285,1290 ****
  
  	fputc('\n', stderr);
! 	fputs("class   num bytes   num pools   blocks in use  avail blocks\n"
! 	      "-----   ---------   ---------   -------------  ------------\n",
  		stderr);
  
--- 1308,1313 ----
  
  	fputc('\n', stderr);
! 	fputs("class   size   num pools   blocks in use  avail blocks\n"
! 	      "-----   ----   ---------   -------------  ------------\n",
  		stderr);
  
***************
*** 1298,1302 ****
  			continue;
  		}
! 		fprintf(stderr, "%5u %11u %11lu %15lu %13lu\n",
  			i, size, p, b, f);
  		allocated_bytes += b * size;
--- 1321,1325 ----
  			continue;
  		}
! 		fprintf(stderr, "%5u %6u %11lu %15lu %13lu\n",
  			i, size, p, b, f);
  		allocated_bytes += b * size;
***************
*** 1313,1321 ****
  	fputc('\n', stderr);
  
  	PyOS_snprintf(buf, sizeof(buf),
  		"%u unused pools * %d bytes", 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 lost to pool headers", pool_header_bytes);
--- 1336,1345 ----
  	fputc('\n', stderr);
  
+ 	total = printone("# bytes in allocated blocks", allocated_bytes);
+ 
  	PyOS_snprintf(buf, sizeof(buf),
  		"%u unused pools * %d bytes", numfreepools, POOL_SIZE);
! 	total += printone(buf, (ulong)numfreepools * POOL_SIZE);
  
  	total += printone("# bytes in available blocks", available_bytes);
  	total += printone("# bytes lost to pool headers", pool_header_bytes);