This patch does something I've wanted for a while. It prints the elapsed time for each individual syntax-check rule.
I don't particularly like the fact that each new rule - uses a temporary .sc-start-* file in which it saves each start time - uses awk to compute the difference of two floating point numbers Initially I used "bc" to compute the difference, but that was overkill. The way I'm using awk isn't pretty, especially considering that most modern shells can do "$[end - start]", but it works. Suggestions for improvement are most welcome. Here's the patch, followed by sample output (coreutils, run with make -j17 on an 8-core i7). Notice that it prints each rule names twice now. First, when it is started, and again but with elapsed time when it completes. >From 4f027325a74d4c45e4794d33cdb08bdc7e0d8bac Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Sun, 11 Apr 2010 10:26:52 +0200 Subject: [PATCH] maint.mk: print the elapsed time for each syntax-check rule * top/maint.mk (sc_m_rules_): Save start time in a file. (sc_z_rules_): New rules: remove temp file and print elapsed time. (local-check): Interpose the .z rules --- ChangeLog | 7 +++++++ top/maint.mk | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fdfa06..688f8c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-04-11 Jim Meyering <meyer...@redhat.com> + maint.mk: print the elapsed time for each syntax-check rule + * top/maint.mk (sc_m_rules_): Save start time in a file. + (sc_z_rules_): New rules: remove temp file and print elapsed time. + (local-check): Interpose the .z rules + +2010-04-11 Jim Meyering <meyer...@redhat.com> + maint.mk: detect_empty_lines_at_EOF_: avoid FP for an empty file * top/maint.mk (detect_empty_lines_at_EOF_): Don't confuse an empty file with one that ends in an empty line. diff --git a/top/maint.mk b/top/maint.mk index b71304d..efcce8f 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -129,8 +129,21 @@ sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules)) .PHONY: $(sc_m_rules_) $(sc_m_rules_): @echo $(patsubst sc_%.m, %, $@) - -local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available)) + @date +%s.%N > .sc-start-$(basename $@) + +# Compute and print the elapsed time for each syntax-check rule. +sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules)) +.PHONY: $(sc_z_rules_) +$(sc_z_rules_): %.z: % + @elapsed=$$(echo $$(date +%s.%N) - $$(cat .sc-start-$*) |bc); \ + rm -f .sc-start-$*; \ + printf '%.2f: $* done\n' $$elapsed + +# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper +# that computes and prints elapsed time. +local-check := \ + $(patsubst sc_%, sc_%.z, \ + $(filter-out $(local-checks-to-skip), $(local-checks-available))) syntax-check: $(local-check) # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \ -- 1.7.1.rc0.264.g94f6e GFDL_version GPL_version Wundef_boolean always_defined_macros avoid_if_before_free cast_of_alloca_return_value cast_of_argument_to_free cast_of_x_alloc_return_value changelog check-AUTHORS const_long_option copyright_check cross_check_PATH_usage_in_tests dd_O_FLAGS dd_max_sym_length error_exit_success error_message_period error_message_uppercase error_message_warn_fatal file_system immutable_NEWS m4_quote_check makefile_TAB_only_indentation makefile_at_at_check makefile_path_separator_check man_file_correlation no_exec_perl_coreutils obsolete_symbols option_desc_uppercase po_check program_name prohibit_HAVE_MBRTOWC prohibit_S_IS_definition prohibit_argmatch_without_use prohibit_assert_without_use prohibit_atoi_atof prohibit_c_ctype_without_use prohibit_canonicalize_without_use prohibit_close_stream_without_use prohibit_cvs_keyword prohibit_emacs__indent_tabs_mode__setting prohibit_empty_lines_at_EOF prohibit_error_without_use prohibit_fail_0 prohibit_getopt_without_use prohibit_hash_pjw_without_use prohibit_hash_without_use prohibit_have_config_h prohibit_ignore_value_without_use prohibit_intprops_without_use prohibit_inttostr_without_use prohibit_jm_in_m4 prohibit_long_options_without_use prohibit_openat_without_use prohibit_magic_number_exit prohibit_quote_without_use prohibit_quotearg_without_use prohibit_readlink prohibit_root_dev_ino_without_use prohibit_safe_read_without_use prohibit_signal_without_use prohibit_sleep prohibit_stat_macro_address prohibit_stat_st_blocks prohibit_strcmp prohibit_tab_based_indentation prohibit_test_minus_ao prohibit_xalloc_without_use proper_name_utf8_requires_ICONV redundant_const require_config_h require_config_h_first require_stdio_safer require_test_exit_idiom root_tests space_before_open_paren space_tab strftime_check sun_os_names system_h_headers the_the tight_scope trailing_blank two_space_separator_in_usage unmarked_diagnostics useless_cpp_parens vulnerable_makefile_CVE-2009-4029 x_sc_dist_check 0.61: sc_GPL_version done 0.62: sc_GFDL_version done 0.61: sc_Wundef_boolean done 0.62: sc_avoid_if_before_free done 0.62: sc_always_defined_macros done 0.64: sc_const_long_option done 0.63: sc_cast_of_x_alloc_return_value done 0.62: sc_cast_of_alloca_return_value done 0.64: sc_copyright_check done 0.63: sc_cast_of_argument_to_free done 0.64: sc_cross_check_PATH_usage_in_tests done 0.64: sc_changelog done 0.64: sc_dd_O_FLAGS done 0.64: sc_dd_max_sym_length done 0.65: sc_error_message_period done 0.65: sc_error_exit_success done 0.66: sc_error_message_uppercase done 0.66: sc_file_system done 0.66: sc_makefile_TAB_only_indentation done 0.66: sc_immutable_NEWS done 0.66: sc_makefile_path_separator_check done 0.66: sc_man_file_correlation done 0.66: sc_makefile_at_at_check done 0.66: sc_obsolete_symbols done 0.66: sc_m4_quote_check done 0.67: sc_option_desc_uppercase done 0.66: sc_no_exec_perl_coreutils done 0.67: sc_program_name done 0.67: sc_prohibit_S_IS_definition done 0.67: sc_prohibit_HAVE_MBRTOWC done 0.67: sc_prohibit_assert_without_use done 0.67: sc_prohibit_argmatch_without_use done 0.67: sc_prohibit_atoi_atof done 0.68: sc_prohibit_c_ctype_without_use done 0.68: sc_prohibit_canonicalize_without_use done 0.68: sc_prohibit_cvs_keyword done 0.68: sc_prohibit_emacs__indent_tabs_mode__setting done 0.68: sc_prohibit_close_stream_without_use done 0.68: sc_prohibit_empty_lines_at_EOF done 0.68: sc_prohibit_fail_0 done 0.68: sc_prohibit_getopt_without_use done 0.68: sc_prohibit_error_without_use done 0.69: sc_prohibit_have_config_h done 0.68: sc_prohibit_hash_pjw_without_use done 0.68: sc_prohibit_hash_without_use done 0.69: sc_prohibit_inttostr_without_use done 0.69: sc_prohibit_ignore_value_without_use done 0.69: sc_prohibit_intprops_without_use done 0.69: sc_prohibit_jm_in_m4 done 0.69: sc_prohibit_magic_number_exit done 0.71: sc_error_message_warn_fatal done 0.69: sc_prohibit_long_options_without_use done 0.69: sc_prohibit_openat_without_use done 0.70: sc_prohibit_quotearg_without_use done 0.70: sc_prohibit_safe_read_without_use done 0.70: sc_prohibit_root_dev_ino_without_use done 0.70: sc_prohibit_quote_without_use done 0.70: sc_prohibit_readlink done 0.70: sc_prohibit_signal_without_use done 0.70: sc_prohibit_stat_macro_address done 0.70: sc_prohibit_stat_st_blocks done 0.70: sc_prohibit_strcmp done 0.70: sc_prohibit_tab_based_indentation done 0.71: sc_prohibit_xalloc_without_use done 0.70: sc_prohibit_sleep done 0.71: sc_prohibit_test_minus_ao done 0.71: sc_proper_name_utf8_requires_ICONV done 0.71: sc_require_config_h done 0.71: sc_redundant_const done 0.71: sc_space_tab done 0.71: sc_strftime_check done 0.71: sc_root_tests done 0.71: sc_system_h_headers done 0.71: sc_the_the done 0.71: sc_require_stdio_safer done 0.71: sc_trailing_blank done 0.72: sc_unmarked_diagnostics done 0.71: sc_two_space_separator_in_usage done 0.72: sc_vulnerable_makefile_CVE-2009-4029 done 0.72: sc_useless_cpp_parens done 0.71: sc_sun_os_names done 0.72: sc_x_sc_dist_check done 0.81: sc_tight_scope done 0.87: sc_require_config_h_first done 0.93: sc_check-AUTHORS done 1.12: sc_require_test_exit_idiom done 1.27: sc_space_before_open_paren done 1.99: sc_po_check done