1*4882a593Smuzhiyun#!/bin/bash 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# Copyright (c) 2011, Intel Corporation. 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-or-later 6*4882a593Smuzhiyun# 7*4882a593Smuzhiyun# DESCRIPTION 8*4882a593Smuzhiyun# This script runs BB_CMD (typically building core-image-sato) for all 9*4882a593Smuzhiyun# combincations of BB_RANGE and PM_RANGE values. It saves off all the console 10*4882a593Smuzhiyun# logs, the buildstats directories, and creates a bb-pm-runtime.dat file which 11*4882a593Smuzhiyun# can be used to postprocess the results with a plotting tool, spreadsheet, etc. 12*4882a593Smuzhiyun# Before running this script, it is recommended that you pre-download all the 13*4882a593Smuzhiyun# necessary sources by performing the BB_CMD once manually. It is also a good 14*4882a593Smuzhiyun# idea to disable cron to avoid runtime variations caused by things like the 15*4882a593Smuzhiyun# locate process. Be sure to sanitize the dat file prior to post-processing as 16*4882a593Smuzhiyun# it may contain error messages or bad runs that should be removed. 17*4882a593Smuzhiyun# 18*4882a593Smuzhiyun# AUTHORS 19*4882a593Smuzhiyun# Darren Hart <dvhart@linux.intel.com> 20*4882a593Smuzhiyun# 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun# The following ranges are appropriate for a 4 core system with 8 logical units 23*4882a593Smuzhiyun# Use leading 0s to ensure all digits are the same string length, this results 24*4882a593Smuzhiyun# in nice log file names and columnar dat files. 25*4882a593SmuzhiyunBB_RANGE="04 05 06 07 08 09 10 11 12 13 14 15 16" 26*4882a593SmuzhiyunPM_RANGE="04 05 06 07 08 09 10 11 12 13 14 15 16" 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunDATADIR="bb-matrix-$$" 29*4882a593SmuzhiyunBB_CMD="bitbake core-image-minimal" 30*4882a593SmuzhiyunRUNTIME_LOG="$DATADIR/bb-matrix.dat" 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun# See TIME(1) for a description of the time format parameters 33*4882a593Smuzhiyun# The following all report 0: W K r s t w 34*4882a593SmuzhiyunTIME_STR="%e %S %U %P %c %w %R %F %M %x" 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun# Prepare the DATADIR 37*4882a593Smuzhiyunmkdir $DATADIR 38*4882a593Smuzhiyunif [ $? -ne 0 ]; then 39*4882a593Smuzhiyun echo "Failed to create $DATADIR." 40*4882a593Smuzhiyun exit 1 41*4882a593Smuzhiyunfi 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun# Add a simple header 44*4882a593Smuzhiyunecho "BB PM $TIME_STR" > $RUNTIME_LOG 45*4882a593Smuzhiyunfor BB in $BB_RANGE; do 46*4882a593Smuzhiyun for PM in $PM_RANGE; do 47*4882a593Smuzhiyun RUNDIR="$DATADIR/$BB-$PM-build" 48*4882a593Smuzhiyun mkdir $RUNDIR 49*4882a593Smuzhiyun BB_LOG=$RUNDIR/$BB-$PM-bitbake.log 50*4882a593Smuzhiyun date 51*4882a593Smuzhiyun echo "BB=$BB PM=$PM Logging to $BB_LOG" 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun echo -n " Preparing the work directory... " 54*4882a593Smuzhiyun rm -rf pseudodone tmp sstate-cache tmp-eglibc &> /dev/null 55*4882a593Smuzhiyun echo "done" 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun # Export the variables under test and run the bitbake command 58*4882a593Smuzhiyun # Strip any leading zeroes before passing to bitbake 59*4882a593Smuzhiyun export BB_NUMBER_THREADS=$(echo $BB | sed 's/^0*//') 60*4882a593Smuzhiyun export PARALLEL_MAKE="-j $(echo $PM | sed 's/^0*//')" 61*4882a593Smuzhiyun /usr/bin/time -f "$BB $PM $TIME_STR" -a -o $RUNTIME_LOG $BB_CMD &> $BB_LOG 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun echo " $(tail -n1 $RUNTIME_LOG)" 64*4882a593Smuzhiyun cp -a tmp/buildstats $RUNDIR/$BB-$PM-buildstats 65*4882a593Smuzhiyun done 66*4882a593Smuzhiyundone 67