Changeset 1925 in kBuild
- Timestamp:
- Oct 24, 2008 3:32:21 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r1918 r1925 176 176 kmk_DEFS.amd64 = CONFIG_WITH_OPTIMIZATION_HACKS 177 177 kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT 178 kmk_DEFS.debug = CONFIG_WITH_MAKE_STATS 178 179 179 180 kmk_SOURCES = \ 180 181 main.c \ 182 kbuild.c \ 181 183 read.c \ 182 184 expreval.c \ … … 202 204 version.c \ 203 205 vpath.c \ 204 remote-stub.c \ 205 kbuild.c 206 remote-stub.c 206 207 207 208 # -
trunk/src/kmk/hash.c
r1915 r1925 488 488 100.0 * (double) ht->ht_fill / (double) ht->ht_size); 489 489 fprintf (out_FILE, _("Rehash=%d, "), ht->ht_rehashes); 490 MAKE_STATS( 490 491 fprintf (out_FILE, _("Collisions=%ld/%ld=%.0f%%"), ht->ht_collisions, ht->ht_lookups, 491 492 (ht->ht_lookups 492 493 ? (100.0 * (double) ht->ht_collisions / (double) ht->ht_lookups) 493 494 : 0)); 495 ); 494 496 } 495 497 -
trunk/src/kmk/make.h
r1918 r1925 196 196 #endif 197 197 198 #ifdef CONFIG_WITH_MAKE_STATS 199 extern long make_stats_allocations; 200 extern unsigned long make_stats_allocated; 201 extern unsigned long make_stats_allocated_sum; 202 extern unsigned long make_stats_ht_lookups; 203 extern unsigned long make_stats_ht_collisions; 204 205 # ifdef __APPLE__ 206 # include <malloc/malloc.h> 207 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_size(ptr) 208 209 # elif defined(__linux__) /* glibc */ 210 # include <malloc.h> 211 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_usable_size(ptr) 212 213 # elif defined(_MSC_VER) || defined(__OS2__) 214 # define SIZE_OF_HEAP_BLOCK(ptr) _msize(ptr) 215 216 # else 217 # include <stdlib.h> 218 # define SIZE_OF_HEAP_BLOCK(ptr) 0 219 #endif 220 221 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP) 222 # define free xfree 223 extern void xfree (void *); 224 # endif 225 226 # define MAKE_STATS_3(expr) do { expr; } while (0) 227 # define MAKE_STATS_2(expr) do { expr; } while (0) 228 # define MAKE_STATS(expr) do { expr; } while (0) 229 #else 230 # define MAKE_STATS_3(expr) do { } while (0) 231 # define MAKE_STATS_2(expr) do { } while (0) 232 # define MAKE_STATS(expr) do { } while (0) 233 #endif 234 235 198 236 #ifndef CHAR_BIT 199 237 # define CHAR_BIT 8 … … 514 552 struct alloccache_free_ent *free_head; 515 553 unsigned int size; 516 unsigned int alloc_count;517 554 unsigned int total_count; 555 unsigned long alloc_count; 556 unsigned long free_count; 518 557 const char *name; 519 558 struct alloccache *next; … … 545 584 else 546 585 f = alloccache_alloc_grow (cache); 547 cache->alloc_count++;586 MAKE_STATS(cache->alloc_count++;); 548 587 return f; 549 588 } … … 573 612 f->next = cache->free_head; 574 613 cache->free_head = f; 575 cache->alloc_count--;614 MAKE_STATS(cache->free_count++;); 576 615 } 577 616 … … 855 894 #endif /* __EMX__ (bird) */ 856 895 857 #ifdef CONFIG_WITH_MAKE_STATS858 extern long make_stats_allocations;859 extern unsigned long make_stats_allocated;860 extern unsigned long make_stats_allocated_sum;861 extern unsigned long make_stats_ht_lookups;862 extern unsigned long make_stats_ht_collisions;863 864 # ifdef __APPLE__865 # include <malloc/malloc.h>866 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_size(ptr)867 868 # elif defined(__linux__) /* glibc */869 # include <malloc.h>870 # define SIZE_OF_HEAP_BLOCK(ptr) malloc_usable_size(ptr)871 872 # elif defined(_MSC_VER) || defined(__OS2__)873 # define SIZE_OF_HEAP_BLOCK(ptr) _msize(ptr)874 875 # else876 # include <stdlib.h>877 # define SIZE_OF_HEAP_BLOCK(ptr) 0878 #endif879 880 # if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)881 # define free xfree882 extern void xfree (void *);883 # endif884 885 # define MAKE_STATS_3(expr) do { expr; } while (0)886 # define MAKE_STATS_2(expr) do { expr; } while (0)887 # define MAKE_STATS(expr) do { expr; } while (0)888 #else889 # define MAKE_STATS_3(expr) do { } while (0)890 # define MAKE_STATS_2(expr) do { } while (0)891 # define MAKE_STATS(expr) do { } while (0)892 #endif893 894 896 #ifdef CONFIG_WITH_IF_CONDITIONALS 895 897 extern int expr_eval_if_conditionals(char *line, const struct floc *flocp); -
trunk/src/kmk/misc.c
r1918 r1925 1224 1224 cache->free_head = NULL; 1225 1225 cache->size = act_size; 1226 cache->total_count = 0; 1226 1227 cache->alloc_count = 0; 1227 cache-> total_count= 0;1228 cache->free_count = 0; 1228 1229 cache->name = name; 1229 1230 cache->grow_arg = grow_arg; … … 1257 1258 if (eat->free_head) 1258 1259 { 1260 unsigned int eat_in_use = eat->alloc_count - eat->free_count; 1261 unsigned int dst_in_use = cache->alloc_count - cache->free_count; 1259 1262 if (!cache->free_head) 1260 1263 cache->free_head = eat->free_head; 1261 else if (eat->total_count - eat ->alloc_count < cache->total_count - cache->alloc_count)1264 else if (eat->total_count - eat_in_use < cache->total_count - dst_ins_use) 1262 1265 { 1263 1266 struct alloccache_free_ent *last = eat->free_head; … … 1287 1290 /* and statistics */ 1288 1291 cache->alloc_count += eat->alloc_count; 1289 cache-> total_count += eat->total_count;1292 cache->free_count += eat->free_count; 1290 1293 #else 1291 1294 /* and statistics */ 1292 1295 cache->alloc_count += eat->alloc_count; 1293 cache->total_count += eat->alloc_count; 1294 #endif 1296 cache->free_count += eat->free_count; 1297 #endif 1298 cache->total_count += eat->total_count; 1295 1299 1296 1300 /* unlink and disable the eat cache */ … … 1316 1320 { 1317 1321 printf (_("\n# Alloc Cache: %s\n" 1318 "# Items: size = %-3u in-use = %-6d total = %-6u\n"), 1319 cache->name, cache->size, (int)cache->alloc_count, cache->total_count); 1322 "# Items: size = %-3u total = %-6u"), 1323 cache->name, cache->size, cache->total_count); 1324 MAKE_STATS(printf (_(" in-use = %-6lu"), 1325 cache->alloc_count - cache->free_count);); 1326 MAKE_STATS(printf (_("\n# alloc calls = %-7lu free calls = %-7lu"), 1327 cache->alloc_count, cache->free_count);); 1328 printf ("\n"); 1320 1329 } 1321 1330 -
trunk/src/kmk/strcache2.c
r1921 r1925 1266 1266 1267 1267 #ifdef STRCACHE2_USE_MASK 1268 printf (_("%s hash size = %u mask = %#x rehashed %u times lookups = %lu\n"),1269 prefix, cache->hash_size, cache->hash_mask, rehashes , cache->lookup_count);1268 printf (_("%s hash size = %u mask = %#x rehashed %u times"), 1269 prefix, cache->hash_size, cache->hash_mask, rehashes); 1270 1270 #else 1271 printf (_("%s hash size = %u div = %#x rehashed %u times lookups = %lu\n"),1272 prefix, cache->hash_size, cache->hash_div, rehashes , cache->lookup_count);1271 printf (_("%s hash size = %u div = %#x rehashed %u times"), 1272 prefix, cache->hash_size, cache->hash_div, rehashes); 1273 1273 #endif 1274 1274 if (cache->lookup_count) 1275 printf (_("%s hash collisions 1st = %lu (%u%%) 2nd = %lu (%u%%) 3rd = %lu (%u%%)\n"), 1275 printf (_("%s lookups = %lu\n" 1276 "%s hash collisions 1st = %lu (%u%%) 2nd = %lu (%u%%) 3rd = %lu (%u%%)"), 1277 prefix, cache->lookup_count, 1276 1278 prefix, 1277 1279 cache->collision_1st_count, (unsigned int)((100.0 * cache->collision_1st_count) / cache->lookup_count), 1278 1280 cache->collision_2nd_count, (unsigned int)((100.0 * cache->collision_2nd_count) / cache->lookup_count), 1279 1281 cache->collision_3rd_count, (unsigned int)((100.0 * cache->collision_3rd_count) / cache->lookup_count)); 1280 printf (_(" %s hash insert collisions = %u (%u%%)\n"),1282 printf (_("\n%s hash insert collisions = %u (%u%%)\n"), 1281 1283 prefix, cache->collision_count,(unsigned int)((100.0 * cache->collision_count) / cache->count)); 1282 1284 printf (_("%s %5u (%u%%) empty hash table slots\n"),
Note:
See TracChangeset
for help on using the changeset viewer.