Changeset 1986 in kBuild
- Timestamp:
- Oct 28, 2008 1:59:10 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r1980 r1986 119 119 #ifdef CONFIG_WITH_MAKE_STATS 120 120 long make_stats_allocations = 0; 121 long make_stats_reallocations = 0; 121 122 unsigned long make_stats_allocated = 0; 122 unsigned long make_stats_allocated_sum = 0;123 123 unsigned long make_stats_ht_lookups = 0; 124 124 unsigned long make_stats_ht_collisions = 0; … … 4233 4233 { 4234 4234 # ifdef CONFIG_WITH_MAKE_STATS 4235 len = sprintf (buf, "alloc-cur: %5ld %6luKB (/%3luMB)hash: %5lu %2lu%%",4235 len = sprintf (buf, "alloc-cur: %5ld/%3ld %3luMB hash: %5lu %2lu%%", 4236 4236 make_stats_allocations, 4237 make_stats_ allocated / 1024,4238 make_stats_allocated _sum/ (1024*1024),4237 make_stats_reallocations, 4238 make_stats_allocated / (1024*1024), 4239 4239 make_stats_ht_lookups, 4240 4240 (make_stats_ht_collisions * 100) / make_stats_ht_lookups); … … 4256 4256 else if (!strcmp(argv[i], "allocations")) 4257 4257 val = make_stats_allocations; 4258 else if (!strcmp(argv[i], "reallocations")) 4259 val = make_stats_reallocations; 4258 4260 else if (!strcmp(argv[i], "allocated")) 4259 4261 val = make_stats_allocated; 4260 else if (!strcmp(argv[i], "allocated_sum"))4261 val = make_stats_allocated_sum;4262 4262 else if (!strcmp(argv[i], "ht_lookups")) 4263 4263 val = make_stats_ht_lookups; … … 4639 4639 { STRING_SIZE_TUPLE("libpath"), 1, 2, 1, func_os2_libpath}, 4640 4640 #endif 4641 #if def CONFIG_WITH_MAKE_STATS4641 #if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS) 4642 4642 { STRING_SIZE_TUPLE("make-stats"), 0, 0, 0, func_make_stats}, 4643 4643 #endif -
trunk/src/kmk/make.h
r1976 r1986 208 208 #ifdef CONFIG_WITH_MAKE_STATS 209 209 extern long make_stats_allocations; 210 extern long make_stats_reallocations; 210 211 extern unsigned long make_stats_allocated; 211 extern unsigned long make_stats_allocated_sum;212 212 extern unsigned long make_stats_ht_lookups; 213 213 extern unsigned long make_stats_ht_collisions; … … 215 215 # ifdef __APPLE__ 216 216 # include <malloc/malloc.h> 217 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_ size(ptr)217 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_good_size(ptr) 218 218 219 219 # elif defined(__linux__) /* glibc */ … … 228 228 # define SIZE_OF_HEAP_BLOCK(ptr) 0 229 229 #endif 230 231 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)232 # define free xfree233 extern void xfree (void *);234 # endif235 230 236 231 # define MAKE_STATS_3(expr) do { expr; } while (0) -
trunk/src/kmk/misc.c
r1971 r1986 398 398 if (result == 0) 399 399 fatal (NILF, _("virtual memory exhausted")); 400 400 401 #ifdef CONFIG_WITH_MAKE_STATS 401 402 make_stats_allocations++; 402 403 if (make_expensive_statistics) 403 { 404 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 405 make_stats_allocated += actual_size; 406 make_stats_allocated_sum += actual_size; 407 } 404 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 405 else 406 make_stats_allocated += size; 408 407 #endif 409 408 return result; … … 417 416 #ifdef CONFIG_WITH_MAKE_STATS 418 417 if (make_expensive_statistics && ptr != NULL) 419 {420 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (ptr);421 make_stats_allocated -= actual_size;422 make_stats_allocated_sum -= actual_size;423 }418 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr); 419 if (ptr) 420 make_stats_reallocations++; 421 else 422 make_stats_allocations++; 424 423 #endif 425 424 … … 430 429 if (result == 0) 431 430 fatal (NILF, _("virtual memory exhausted")); 431 432 432 #ifdef CONFIG_WITH_MAKE_STATS 433 if (!ptr)434 make_stats_allocations++;435 433 if (make_expensive_statistics) 436 { 437 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 438 make_stats_allocated += actual_size; 439 make_stats_allocated_sum += actual_size; 440 } 434 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 435 else 436 make_stats_allocated += size; 441 437 #endif 442 438 return result; … … 461 457 make_stats_allocations++; 462 458 if (make_expensive_statistics) 463 { 464 unsigned int actual_size = SIZE_OF_HEAP_BLOCK (result); 465 make_stats_allocated += actual_size; 466 make_stats_allocated_sum += actual_size; 467 } 459 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 460 else 461 make_stats_allocated += strlen (ptr) + 1; 468 462 #endif 469 463 #ifdef HAVE_STRDUP … … 1165 1159 } 1166 1160 1167 #if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)1168 #undef free1169 void xfree(void *ptr)1170 {1171 if (ptr)1172 {1173 make_stats_allocations--;1174 if (make_expensive_statistics)1175 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr);1176 free (ptr);1177 }1178 }1179 #endif1180 1181 1182 1161 #ifdef CONFIG_WITH_ALLOC_CACHES 1183 1162 … … 1403 1382 # endif /* __GLIBC__ */ 1404 1383 1384 # ifdef CONFIG_WITH_MAKE_STATS 1385 printf(_("# %lu malloc calls, %lu realloc calls\n"), 1386 make_stats_allocations, make_stats_reallocations); 1387 printf(_("# %lu MBs alloc sum, not counting freed, add pinch of salt\n"), /* XXX: better wording */ 1388 make_stats_allocated / (1024*1024)); 1389 # endif 1390 1405 1391 /* XXX: windows */ 1406 1392 }
Note:
See TracChangeset
for help on using the changeset viewer.