On 12/04/10 17:51, Eric Blake wrote: > On 04/11/2010 03:31 AM, Jim Meyering wrote: >> 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. > > $[] is not portable; $(()) is the POSIX-preferred variant that even more > shells support. And we already make a lot of assumptions in maint.mk > that maintainers have a POSIX shell (that is, I seriously doubt that > Solaris /bin/sh would work with maint.mk), in part because we are also > guaranteed that GNU make is running if maint.mk is even in use. > > I haven't looked closely at the patch yet, for possible improvements, > but I am pleased with the idea of listing elapsed times (it will > probably show up even more on cygwin to help expose places where > reducing the number of forks makes sense).
$(()) and $[] work on ints only, which I suppose could be hacked like: ts1=$(printf "%.2f\n" $(date +%s.%N) | tr -d .) sleep 1.5 ts2=$(printf "%.2f\n" $(date +%s.%N) | tr -d .) echo $(($ts2 - $ts1)) | sed 's/\(..\)$/.\1/' I noticed with `make syntax-check -j1` the start and end times are interspersed, while with -j2 they're separated, which is fine, just an observation. Also in the -j>1 case all elapsed times are much greater due to the way make is processed. cheers, Pádraig.
