VirtualBox

Changeset 1918 in kBuild for trunk/src


Ignore:
Timestamp:
Oct 23, 2008 9:27:11 PM (17 years ago)
Author:
bird
Message:

kmk: New switch --print-stats which will print variable, file, strcache, allocation and heap statistics.

Location:
trunk/src/kmk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.am

    r1915 r1918  
    138138        -DCONFIG_WITH_COMMANDS_FUNC \
    139139        -DCONFIG_PRETTY_COMMAND_PRINTING \
     140        -DCONFIG_WITH_PRINT_STATS_SWITCH \
    140141        \
    141142        -DKBUILD_HOST=\"$(BUILD_TARGET)\" \
  • trunk/src/kmk/Makefile.kmk

    r1915 r1918  
    168168        CONFIG_WITH_COMMANDS_FUNC \
    169169        CONFIG_PRETTY_COMMAND_PRINTING \
     170        CONFIG_WITH_PRINT_STATS_SWITCH \
    170171        \
    171172        KBUILD_HOST=\"$(KBUILD_TARGET)\" \
  • trunk/src/kmk/file.c

    r1915 r1918  
    12591259}
    12601260
     1261#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     1262void
     1263print_file_stats (void)
     1264{
     1265  fputs (_("\n# files hash-table stats:\n# "), stdout);
     1266  hash_print_stats (&files, stdout);
     1267  fputs ("\n", stdout);
     1268}
     1269#endif
     1270
    12611271
    12621272/* Verify the integrity of the data base of files.  */
  • trunk/src/kmk/main.c

    r1915 r1918  
    8383void verify_file_data_base (void);
    8484
     85#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     86void print_variable_stats (void);
     87void print_file_stats (void);
     88#endif
     89
    8590#if defined HAVE_WAITPID || defined HAVE_WAIT3
    8691# define HAVE_WAIT_NOHANG
     
    172177
    173178int pretty_command_printing;
     179#endif
     180
     181#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     182/* Nonzero means to print internal statistics before exiting. */
     183
     184int print_stats_flag;
    174185#endif
    175186
     
    476487       "pretty-command-printing" },
    477488#endif
     489#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     490    { CHAR_MAX+11, flag, (char *) &print_stats_flag, 1, 1, 1, 0, 0,
     491       "print-stats" },
     492#endif
    478493#ifdef KMK
    479     { CHAR_MAX+11, positive_int, (char *) &process_priority, 1, 1, 0,
     494    { CHAR_MAX+12, positive_int, (char *) &process_priority, 1, 1, 0,
    480495      (char *) &process_priority, (char *) &process_priority, "priority" },
    481     { CHAR_MAX+12, positive_int, (char *) &process_affinity, 1, 1, 0,
     496    { CHAR_MAX+14, positive_int, (char *) &process_affinity, 1, 1, 0,
    482497      (char *) &process_affinity, (char *) &process_affinity, "affinity" },
    483498#endif
     
    490505      "no-keep-going" },
    491506#if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
    492     { CHAR_MAX+14, flag, (char *) &make_expensive_statistics, 1, 1, 1, 0, 0,
     507    { CHAR_MAX+15, flag, (char *) &make_expensive_statistics, 1, 1, 1, 0, 0,
    493508       "statistics" },
    494509#endif
     
    36533668  printf (_("\n# Finished Make data base on %s\n"), ctime (&when));
    36543669}
     3670#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     3671
     3672static void
     3673print_stats ()
     3674{
     3675  time_t when;
     3676
     3677  when = time ((time_t *) 0);
     3678  printf (_("\n# Make statistics, printed on %s"), ctime (&when));
     3679
     3680  print_variable_stats ();
     3681  print_file_stats ();
     3682# ifndef CONFIG_WITH_STRCACHE2
     3683  strcache_print_stats ("#");
     3684# else
     3685  strcache2_print_stats_all ("#");
     3686# endif
     3687# ifdef CONFIG_WITH_ALLOC_CACHES
     3688  alloccache_print_all ();
     3689# endif
     3690  print_heap_stats ();
     3691
     3692  when = time ((time_t *) 0);
     3693  printf (_("\n# Finished Make statistics on %s\n"), ctime (&when));
     3694}
     3695#endif
    36553696
    36563697static void
     
    37343775      if (print_data_base_flag)
    37353776        print_data_base ();
     3777
     3778#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     3779      if (print_stats_flag)
     3780        print_stats ();
     3781#endif
    37363782
    37373783#ifdef NDEBUG /* bird: Don't waste time on debug sanity checks.  */
  • trunk/src/kmk/make.h

    r1915 r1918  
    433433void *xrealloc (void *, unsigned int);
    434434char *xstrdup (const char *);
     435#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     436void print_heap_stats (void);
     437#endif
    435438char *find_next_token (const char **, unsigned int *);
    436439char *next_token (const char *);
  • trunk/src/kmk/misc.c

    r1876 r1918  
    2222#ifdef CONFIG_WITH_VALUE_LENGTH
    2323# include <assert.h>
     24#endif
     25#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     26# ifdef __APPLE__
     27#  include <malloc/malloc.h>
     28# endif
    2429#endif
    2530
     
    13261331
    13271332#endif /* CONFIG_WITH_ALLOC_CACHES */
     1333
     1334#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     1335/* Print heap statistics if supported by the platform. */
     1336void print_heap_stats (void)
     1337{
     1338  /* Darwin / Mac OS X */
     1339# ifdef __APPLE__
     1340  malloc_statistics_t s;
     1341
     1342  malloc_zone_statistics (NULL, &s);
     1343  printf (_("\n# CRT Heap: %zu bytes in use, in %u block, avg %zu bytes/block\n"),
     1344          s.size_in_use, s.blocks_in_use, s.size_in_use / s.blocks_in_use);
     1345  printf (_("#           %zu bytes max in use (high water mark)\n"),
     1346          s.max_size_in_use);
     1347  printf (_("#           %zu bytes reserved,  %zu bytes free (estimate)\n"),
     1348          s.size_allocated, s.size_allocated - s.size_in_use);
     1349# endif /* __APPLE__ */
     1350
     1351  /* Darwin Libc sources indicates that something like this may be
     1352     found in GLIBC, however, it's not in any current one...  */
     1353# if 0 /* ??? */
     1354  struct mstats m;
     1355
     1356  m = mstats();
     1357  printf (_("\n# CRT Heap: %zu blocks / %zu bytes in use,  %zu blocks / %zu bytes free\n"),
     1358          m.chunks_used, m.bytes_used, m.chunks_free, m.bytes_free);
     1359  printf (_("#           %zu bytes reserved\n"),
     1360          m.bytes_total);
     1361# endif /* ??? */
     1362
     1363   /* XVID2/XPG mallinfo (displayed per GLIBC documentation).  */
     1364# if 0 && defined(__GLIBC__) /* XXX: finish on linux, check older glibc versions. */
     1365  struct mallinfo m;
     1366
     1367  m = mallinfo();
     1368  printf (_("\n# CRT Heap: %d bytes in use,  %d bytes free\n"),
     1369          m.uordblks, s.fordblks);
     1370
     1371  printf (_("#           # free chunks=%d,  # fastbin blocks=%d\n"),
     1372          m.ordblks, m.smblks);
     1373  printf (_("#           # mapped regions=%d,  space in mapped regions=%d\n"),
     1374          m.hblks, m.hblkhd);
     1375  printf (_("#           non-mapped space allocated from system=%d\n"),
     1376          m.arena);
     1377  printf (_("#           maximum total allocated space=%d\n"),
     1378          m.usmblks);
     1379  printf (_("#           top-most releasable space=%d\n"),
     1380          m.keepcost);
     1381# endif /* __GLIBC__ */
     1382
     1383  /* XXX: windows */
     1384}
     1385#endif /* CONFIG_WITH_PRINT_STATS_SWITCH */
     1386
  • trunk/src/kmk/variable.c

    r1915 r1918  
    22932293}
    22942294
     2295#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
     2296void
     2297print_variable_stats (void)
     2298{
     2299  fputs (_("\n# Global variable hash-table stats:\n# "), stdout);
     2300  hash_print_stats (&global_variable_set.table, stdout);
     2301  fputs ("\n", stdout);
     2302}
     2303#endif
    22952304
    22962305/* Print all the local variables of FILE.  */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette