From e8ae4b17bb1b17ac30730f940568f713ebe1cded Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 28 Oct 2013 10:56:16 +0100 Subject: build-time: benchmark compile times This script stores compile times while compiling a kernel. It was used to determine the temperature performance after changing thermal paste. --- build-time | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100755 build-time (limited to 'build-time') diff --git a/build-time b/build-time new file mode 100755 index 0000000..19d26b8 --- /dev/null +++ b/build-time @@ -0,0 +1,149 @@ +#!/bin/bash +# Watch CPU temperature while compiling +# +# Author: Peter Wu +# Created: 2013-07-31 + +GITREPO=${GITREPO:-$HOME/Linux-src/linux} +SRCDIR=${SRCDIR:-/tmp/linux-src} +BUILDDIR=${BUILDDIR:-/tmp/linux-build} +LOGDIR=${LOGDIR:-.} + +for arg; do + # Clear all arguments in order to print usage message. + case $arg in + --help|-h) + set -- + break + ;; + esac + if ! [[ $arg -gt 0 ]]; then + echo "Invalid number: $arg" >&2 + exit 1 + fi +done + +if [ $# -lt 2 ]; then + cat <&2 + echo "Create the 'version' file in the SRCDIR directory" >&2 + echo "or specify a different target SRCDIR." >&2 + exit 1 + fi + rm -rf "$SRCDIR" + mkdir "$SRCDIR" + if ! (cd "$GITREPO" && git describe) > "$SRCDIR/version"; then + echo "$GITREPO is not a git repo? Aborting!" >&2 + exit 1 + fi + (cd "$GITREPO" && time git archive HEAD) | tar x -C "$SRCDIR" +fi +cat "$SRCDIR/version" + +mk() { + make -C "$SRCDIR" O="$BUILDDIR" "$@" +} + +get_temps() { + cat /sys/devices/platform/coretemp.0/temp*_input | + tr '\n' '\t' | sed 's/\t$/\n/' +} + +temp_logger() { + local name=$1 + mkdir -p "$LOGDIR" + while sleep 1; do + get_temps + done > "$LOGDIR/$name" +} + +run() { + local tag jobs sec1 sec2 logpid templog + + tag=$1 + jobs=$2 + templog="temps-$tag-$jobs" + + rm -rf "$BUILDDIR" + mkdir "$BUILDDIR" + + mk defconfig >/dev/null 2>&1 + + echo + echo "Running $tag-$jobs" + temp_logger "$templog" & logpid=$! + time { + sec1=$(date +%s) + mk -j$jobs bzImage modules >/dev/null 2>&1 + sec2=$(date +%s) + echo "jobs=$jobs secs=$((sec2-sec1))" + echo -n "loadavg: " + cut -d\ -f1-3 /proc/loadavg + } 2>&1 + kill $logpid; wait $logpid 2>/dev/null + + # Very simple statistics + echo "Temperature (min / avg / max):" + awk ' + { + for (i=0; i $i) min[i] = $i; + } + count++; + } + END { + for (i in sum) { + avg = sum[i] / count; + print min[i] / 1000, "/", avg, "/", max[i] / 1000 + } + } + ' "$LOGDIR/$templog" +} + +resdir="res-$(date +%Y%m%d-%H%M%S)" +mkdir -v "$resdir" +cd "$resdir" + +trials=$1; shift +for ((trial_no=1; trial_no<=trials; trial_no++)); do + for jobs; do + run $trial_no $jobs + done +done + +#rm -rf "$BUILDDIR" "$SRCDIR" -- cgit v1.2.1