maint.mk: print the elapsed time for each syntax-check rule
authorJim Meyering <meyering@redhat.com>
Sun, 11 Apr 2010 08:26:52 +0000 (10:26 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 11 Apr 2010 09:19:13 +0000 (11:19 +0200)
* 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
top/maint.mk

index 1fdfa06..688f8c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-04-11  Jim Meyering  <meyering@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  <meyering@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.
index b71304d..bc62fa3 100644 (file)
@@ -129,8 +129,23 @@ 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: %
+       @end=$$(date +%s.%N);                                           \
+       start=$$(cat .sc-start-$*);                                     \
+       rm -f .sc-start-$*;                                             \
+       awk -v s=$$start -v e=$$end                                     \
+         'END {printf "%.2f: $* done\n", e - s}' < /dev/null
+
+# 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>'         \