Changeset 2101 for trunk/src/kmk/main.c


Ignore:
Timestamp:
Nov 25, 2008, 12:35:56 AM (17 years ago)
Author:
bird
Message:

kmk: Implemented new switch --print-time. Fixes #65.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/main.c

    r2099 r2101  
    183183
    184184int print_stats_flag;
     185#endif
     186
     187#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     188/* Minimum number of seconds to report, -1 if disabled. */
     189
     190int print_time_min = -1;
     191static int default_print_time_min = -1;
     192static int no_val_print_time_min = 0;
     193static big_int make_start_ts = -1;
     194int print_time_width = 5;
    185195#endif
    186196
     
    491501       "print-stats" },
    492502#endif
     503#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     504    { CHAR_MAX+12, positive_int, (char *) &print_time_min, 1, 1, 0,
     505      (char *) &no_val_print_time_min, (char *) &default_print_time_min,
     506      "print-time" },
     507#endif
    493508#ifdef KMK
    494     { CHAR_MAX+12, positive_int, (char *) &process_priority, 1, 1, 0,
     509    { CHAR_MAX+14, positive_int, (char *) &process_priority, 1, 1, 0,
    495510      (char *) &process_priority, (char *) &process_priority, "priority" },
    496     { CHAR_MAX+14, positive_int, (char *) &process_affinity, 1, 1, 0,
     511    { CHAR_MAX+15, positive_int, (char *) &process_affinity, 1, 1, 0,
    497512      (char *) &process_affinity, (char *) &process_affinity, "affinity" },
    498513#endif
     
    505520      "no-keep-going" },
    506521#if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
    507     { CHAR_MAX+15, flag, (char *) &make_expensive_statistics, 1, 1, 1, 0, 0,
     522    { CHAR_MAX+16, flag, (char *) &make_expensive_statistics, 1, 1, 1, 0, 0,
    508523       "statistics" },
    509524#endif
     
    13131328  SetUnhandledExceptionFilter(handle_runtime_exceptions);
    13141329#endif /* !ELECTRIC_HEAP */
     1330
     1331#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     1332  make_start_ts = nano_timestamp ();
     1333#endif
    13151334
    13161335  /* start off assuming we have no shell */
     
    35663585                     make_expensive_statistics ? "1" : "0", o_default, 1);
    35673586# endif
     3587#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     3588    sprintf (val, "%u", print_time_min);
     3589    define_variable ("KMK_OPTS_PRINT_TIME", sizeof("KMK_OPTS_PRINT_TIME") - 1,
     3590                     val, o_default, 1);
     3591#endif
    35683592  }
    35693593#endif
     
    38113835      if (directory_before_chdir != 0)
    38123836        chdir (directory_before_chdir);
     3837
     3838#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     3839      if (print_time_min != -1)
     3840        {
     3841          big_int elapsed = nano_timestamp () - make_start_ts;
     3842          if (elapsed >= print_time_min * BIG_INT_C(1000000000))
     3843            {
     3844              char buf[64];
     3845              format_elapsed_nano (buf, sizeof (buf), elapsed);
     3846              message (1, _("%*s"), print_time_width, buf);
     3847            }
     3848        }
     3849#endif
    38133850
    38143851      log_working_directory (0);
Note: See TracChangeset for help on using the changeset viewer.