compat-wireless: add -t argument for time statistics
authorLuis R. Rodriguez <mcgrof@frijolero.org>
Mon, 30 Apr 2012 20:38:34 +0000 (13:38 -0700)
committerLuis R. Rodriguez <mcgrof@frijolero.org>
Mon, 30 Apr 2012 20:38:34 +0000 (13:38 -0700)
Using -t is the equilavent of doing:

time ckmake; time ckmake | egrep "real|user|sys"

This is useful to test compiling accross kernel twice,
once under the assumption that ccache may likely be cleared,
the other with ccache fresh.

This will yield this output:

mcgrof@tux ~/compat (git::master)$ ckmake -t
Trying kernel                  3.4.0-030400rc1-generic [OK]
Trying kernel                  3.3.0-030300rc2-generic [OK]
Trying kernel                     3.2.2-030202-generic [OK]
Trying kernel                    3.1.10-030110-generic [OK]
Trying kernel                    3.0.18-030018-generic [OK]
Trying kernel                  2.6.39-02063904-generic [OK]
Trying kernel                  2.6.38-02063808-generic [OK]
Trying kernel                  2.6.37-02063706-generic [OK]
Trying kernel                  2.6.36-02063604-generic [OK]
Trying kernel                  2.6.35-02063512-generic [OK]
Trying kernel                  2.6.34-02063410-generic [OK]
Trying kernel                  2.6.33-02063305-generic [OK]
Trying kernel                  2.6.32-02063255-generic [OK]
Trying kernel                  2.6.31-02063113-generic [OK]
Trying kernel                  2.6.30-02063010-generic [OK]
Trying kernel                  2.6.29-02062906-generic [OK]
Trying kernel                  2.6.28-02062810-generic [OK]
Trying kernel                    2.6.27-020627-generic [OK]
Trying kernel                    2.6.26-020626-generic [OK]
Trying kernel                    2.6.25-020625-generic [OK]
Trying kernel                    2.6.24-020624-generic [OK]

real 1m19.326s
user 1m18.740s
sys 0m22.360s

real 1m18.411s
user 1m15.330s
sys 0m21.960s

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
bin/ckmake

index 56e1ec1ad7274bfc8b17d1818fe41adc185705be..d89d0677076ca95c8263e43e3b97a59cff04a4a3 100755 (executable)
@@ -25,6 +25,7 @@ UNDERLINE="\033[02m"
 KERNEL_DIR="/lib/modules"
 KLIBS=""
 LOG="ckmake.log"
+TIME="0"
 
 LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
 case $LSB_RED_ID in
@@ -39,8 +40,6 @@ case $LSB_RED_ID in
        ;;
 esac
 
-nice make clean 2>&1 > $LOG
-
 function tee_color_split()
 {
        while read; do
@@ -56,27 +55,61 @@ function log_try_kernel()
        echo -en "${NORMAL}"
 }
 
-for i in $KLIBS; do
-       KERNEL=$(basename $i)
-       DIR=${i}/build/
-       echo -e "--------------------------------------------" >> $LOG
+function usage()
+{
+       echo -e "Usage: $0 [-t]"
+       echo -e "-t   will run: 'time ckmake; time ckmake' account for"
+       echo -e "     benchmark how long it takes to compile without ccache"
+       echo -e "     and a run after cache kicks in"
+}
+
+if [[ $# -gt 1 ]]; then
+       usage
+       exit 1
+fi
 
-       if [[ ! -d $DIR ]]; then
-               continue
+if [[ $# -eq 1 ]]; then
+       if [[ $1 != "-t" ]]; then
+               usage
+               exit 1
        fi
+       TIME="1"
+fi
 
-       # We cannot use tee_color_split() as bash read only spits
-       # out output when a newline comes in. We can modif IFS but
-       # I am still not sure how to do this properly.
-       log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
-       log_try_kernel $KERNEL
-
-       ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG
-       if [[ $? -eq 0 ]]; then
-               echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
-       else
-               echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
-       fi
+function run_ckmake()
+{
+       for i in $KLIBS; do
+               KERNEL=$(basename $i)
+               DIR=${i}/build/
+               echo -e "--------------------------------------------" >> $LOG
+
+               if [[ ! -d $DIR ]]; then
+                       continue
+               fi
+
+               # We cannot use tee_color_split() as bash read only spits
+               # out output when a newline comes in. We can modif IFS but
+               # I am still not sure how to do this properly.
+               log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG
+               log_try_kernel $KERNEL
+
+               ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG
+               if [[ $? -eq 0 ]]; then
+                       echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split
+               else
+                       echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split
+               fi
+
+               nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG
+       done
+}
+
+nice make clean 2>&1 > $LOG
+
+if [[ $TIME != "1" ]]; then
+       run_ckmake
+       exit 0
+fi
 
-       nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG
-done
+time $0
+time $0 | egrep "real|user|sys"