Changeset 1438 in kBuild
- Timestamp:
- Mar 29, 2008 1:49:27 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.am
r1409 r1438 125 125 -DCONFIG_WITH_WHICH \ 126 126 -DCONFIG_WITH_EVALCTX \ 127 -DCONFIG_WITH_MAKE_STATS \ 127 128 -DCONFIG_PRETTY_COMMAND_PRINTING \ 128 129 \ -
trunk/src/kmk/Makefile.kmk
r1422 r1438 125 125 CONFIG_WITH_WHICH \ 126 126 CONFIG_WITH_EVALCTX \ 127 CONFIG_WITH_MAKE_STATS \ 127 128 CONFIG_PRETTY_COMMAND_PRINTING \ 128 129 \ -
trunk/src/kmk/function.c
r1409 r1438 116 116 117 117 static struct hash_table function_table; 118 119 #ifdef CONFIG_WITH_MAKE_STATS 120 unsigned long make_stats_allocations = 0; 121 unsigned long make_stats_allocated = 0; 122 unsigned long make_stats_allocated_sum = 0; 123 unsigned long make_stats_ht_lookups = 0; 124 unsigned long make_stats_ht_collisions = 0; 125 #endif 118 126 119 127 … … 3460 3468 #endif /* CONFIG_WITH_OS2_LIBPATH */ 3461 3469 3470 #ifdef CONFIG_WITH_MAKE_STATS 3471 /* Retrieve make statistics. */ 3472 static char * 3473 func_make_stats (char *o, char **argv, const char *funcname) 3474 { 3475 char buf[512]; 3476 int len; 3477 3478 if (!argv[0] || (!argv[0][0] && !argv[1])) 3479 { 3480 len = sprintf (buf, "alloc-cur: %5lu %6luKB (/%3luMB) hash: %5lu %2lu%%", 3481 make_stats_allocations, 3482 make_stats_allocated / 1024, 3483 make_stats_allocated_sum / (1024*1024), 3484 make_stats_ht_lookups, 3485 (make_stats_ht_collisions * 100) / make_stats_ht_lookups); 3486 o = variable_buffer_output (o, buf, len); 3487 } 3488 else 3489 { 3490 /* selective */ 3491 int i; 3492 for (i = 0; argv[i]; i++) 3493 { 3494 unsigned long val; 3495 if (i != 0) 3496 o = variable_buffer_output (o, " ", 1); 3497 if (!strcmp(argv[i], "allocations")) 3498 val = make_stats_allocations; 3499 else if (!strcmp(argv[i], "allocated")) 3500 val = make_stats_allocated; 3501 else if (!strcmp(argv[i], "allocated_sum")) 3502 val = make_stats_allocated_sum; 3503 else if (!strcmp(argv[i], "ht_lookups")) 3504 val = make_stats_ht_lookups; 3505 else if (!strcmp(argv[i], "ht_collisions")) 3506 val = make_stats_ht_collisions; 3507 else if (!strcmp(argv[i], "ht_collisions_pct")) 3508 val = (make_stats_ht_collisions * 100) / make_stats_ht_lookups; 3509 else 3510 { 3511 o = variable_buffer_output (o, argv[i], strlen (argv[i])); 3512 continue; 3513 } 3514 3515 len = sprintf (buf, "%ld", val); 3516 o = variable_buffer_output (o, buf, len); 3517 } 3518 } 3519 return o; 3520 } 3521 #endif 3522 3462 3523 /* Lookup table for builtin functions. 3463 3524 … … 3576 3637 { STRING_SIZE_TUPLE("libpath"), 1, 2, 1, func_os2_libpath}, 3577 3638 #endif 3639 #ifdef CONFIG_WITH_MAKE_STATS 3640 { STRING_SIZE_TUPLE("make-stats"), 0, ~0, 0, func_make_stats}, 3641 #endif 3578 3642 #ifdef KMK_HELPERS 3579 3643 { STRING_SIZE_TUPLE("kb-src-tool"), 1, 1, 0, func_kbuild_source_tool}, -
trunk/src/kmk/hash.c
r503 r1438 92 92 93 93 ht->ht_lookups++; 94 #ifdef CONFIG_WITH_MAKE_STATS 95 make_stats_ht_lookups++; 96 #endif 94 97 for (;;) 95 98 { … … 111 114 return slot; 112 115 ht->ht_collisions++; 116 #ifdef CONFIG_WITH_MAKE_STATS 117 make_stats_ht_collisions++; 118 #endif 113 119 } 114 120 if (!hash_2) -
trunk/src/kmk/make.h
r903 r1438 690 690 691 691 #endif /* __EMX__ (bird) */ 692 693 #ifdef CONFIG_WITH_MAKE_STATS 694 extern unsigned long make_stats_allocations; 695 extern unsigned long make_stats_allocated; 696 extern unsigned long make_stats_allocated_sum; 697 extern unsigned long make_stats_ht_lookups; 698 extern unsigned long make_stats_ht_collisions; 699 700 # ifdef __APPLE__ 701 # include <malloc/malloc.h> 702 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_size(ptr) 703 704 # elif defined(__linux__) /* glibc */ 705 # include <malloc.h> 706 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_usable_size(ptr) 707 708 # elif defined(_MSC_VER) || defined(__OS2__) 709 # define SIZE_OF_HEAP_BLOCK(ptr) _msize(ptr) 710 711 # else 712 # include <stdlib.h> 713 # define SIZE_OF_HEAP_BLOCK(ptr) 0 714 #endif 715 716 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP) 717 # define free xfree 718 extern void xfree (void *); 719 # endif 720 721 #endif 722 -
trunk/src/kmk/misc.c
r909 r1438 361 361 if (result == 0) 362 362 fatal (NILF, _("virtual memory exhausted")); 363 #ifdef CONFIG_WITH_MAKE_STATS 364 make_stats_allocations++; 365 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 366 make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result); 367 #endif 363 368 return result; 364 369 } … … 369 374 { 370 375 void *result; 376 #ifdef CONFIG_WITH_MAKE_STATS 377 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr); 378 make_stats_allocated_sum -= SIZE_OF_HEAP_BLOCK (ptr); 379 #endif 371 380 372 381 /* Some older implementations of realloc() don't conform to ANSI. */ … … 376 385 if (result == 0) 377 386 fatal (NILF, _("virtual memory exhausted")); 387 #ifdef CONFIG_WITH_MAKE_STATS 388 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 389 make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result); 390 #endif 378 391 return result; 379 392 } … … 394 407 fatal (NILF, _("virtual memory exhausted")); 395 408 409 #ifdef CONFIG_WITH_MAKE_STATS 410 make_stats_allocations++; 411 make_stats_allocated += SIZE_OF_HEAP_BLOCK (result); 412 make_stats_allocated_sum += SIZE_OF_HEAP_BLOCK (result); 413 #endif 396 414 #ifdef HAVE_STRDUP 397 415 return result; … … 924 942 } 925 943 } 944 945 #if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP) 946 #undef free 947 void xfree(void *ptr) 948 { 949 if (ptr) 950 { 951 make_stats_allocations--; 952 make_stats_allocated -= SIZE_OF_HEAP_BLOCK (ptr); 953 free (ptr); 954 } 955 } 956 #endif 957 -
trunk/src/kmk/variable.c
r1408 r1438 1042 1042 && defined (CONFIG_WITH_FILE_SIZE) \ 1043 1043 && defined (CONFIG_WITH_WHICH) \ 1044 && defined (CONFIG_WITH_EVALCTX) \ 1045 && defined (CONFIG_WITH_MAKE_STATS) \ 1044 1046 && defined (KMK_HELPERS) 1045 1047 (void) define_variable ("KMK_FEATURES", 12, … … 1058 1060 " file-size" 1059 1061 " which" 1062 " evalctx" 1063 " make-stats" 1060 1064 " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one " 1061 1065 , o_default, 0); … … 1102 1106 strcat (buf, " which"); 1103 1107 # endif 1108 # if defined (CONFIG_WITH_EVALCTX) 1109 strcat (buf, " evalctx"); 1110 # endif 1111 # if defined (CONFIG_WITH_MAKE_STATS) 1112 strcat (buf, " make-stats"); 1113 # endif 1104 1114 # if defined (KMK_HELPERS) 1105 1115 strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
Note:
See TracChangeset
for help on using the changeset viewer.