KERNEL_DIR="/lib/modules"
KLIBS=""
LOG="ckmake.log"
+TIME="0"
LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
case $LSB_RED_ID in
;;
esac
-nice make clean 2>&1 > $LOG
-
function tee_color_split()
{
while read; do
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"