1*5e3eaea3SApple OSS Distributions#!/bin/sh 2*5e3eaea3SApple OSS Distributions 3*5e3eaea3SApple OSS DistributionsEXECUTABLES="exit.nodyld \ 4*5e3eaea3SApple OSS Distributions exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \ 5*5e3eaea3SApple OSS Distributions exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \ 6*5e3eaea3SApple OSS Distributions exit.nopie exit.pie" 7*5e3eaea3SApple OSS Distributions 8*5e3eaea3SApple OSS DistributionsRUN=run 9*5e3eaea3SApple OSS DistributionsPRODUCT=`sw_vers -productName` 10*5e3eaea3SApple OSS DistributionsCOUNT= 11*5e3eaea3SApple OSS Distributions 12*5e3eaea3SApple OSS Distributions# params are: record_perf_data(metric, unit, value, description) 13*5e3eaea3SApple OSS Distributionsrecord_perf_data() { 14*5e3eaea3SApple OSS Distributions local METRIC=$1 15*5e3eaea3SApple OSS Distributions local UNIT=$2 16*5e3eaea3SApple OSS Distributions local DATA=$3 17*5e3eaea3SApple OSS Distributions local DESCRIPTION=$4 18*5e3eaea3SApple OSS Distributions echo "{ \"version\" : \"1.0\", \"measurements\" : {\"$METRIC\": {\"description\" : \"$DESCRIPTION\", \"names\":[\"$METRIC\"], \"units\" : [\"$UNIT\"], \"data\" : [$DATA] }}}" 19*5e3eaea3SApple OSS Distributions} 20*5e3eaea3SApple OSS Distributions 21*5e3eaea3SApple OSS DistributionsPERFDATA_DIR=$BATS_TMP_DIR 22*5e3eaea3SApple OSS Distributionsif [ "${PERFDATA_DIR}" = "" ]; then 23*5e3eaea3SApple OSS Distributions PERFDATA_DIR=/tmp/ 24*5e3eaea3SApple OSS Distributionsfi 25*5e3eaea3SApple OSS Distributions 26*5e3eaea3SApple OSS Distributionscase "$PRODUCT" in 27*5e3eaea3SApple OSS Distributions "Watch OS") 28*5e3eaea3SApple OSS Distributions COUNT=500 29*5e3eaea3SApple OSS Distributions ;; 30*5e3eaea3SApple OSS Distributions "iPhone OS") 31*5e3eaea3SApple OSS Distributions COUNT=1000 32*5e3eaea3SApple OSS Distributions ;; 33*5e3eaea3SApple OSS Distributions "Mac OS X") 34*5e3eaea3SApple OSS Distributions COUNT=6000 35*5e3eaea3SApple OSS Distributions ;; 36*5e3eaea3SApple OSS Distributions *) 37*5e3eaea3SApple OSS Distributions COUNT=1000 38*5e3eaea3SApple OSS Distributions ;; 39*5e3eaea3SApple OSS Distributionsesac 40*5e3eaea3SApple OSS Distributions 41*5e3eaea3SApple OSS Distributionsfor i in ${EXECUTABLES}; do 42*5e3eaea3SApple OSS Distributions echo "Running $i" 43*5e3eaea3SApple OSS Distributions for j in `jot $(sysctl -n hw.ncpu) 1`; do 44*5e3eaea3SApple OSS Distributions printf "\t%dx\t" $j 45*5e3eaea3SApple OSS Distributions METRIC_NAME="${i}_${j}x" 46*5e3eaea3SApple OSS Distributions TIMEOUT=` /usr/bin/time ./${RUN} $j $((${COUNT}/$j)) ./$i 2>&1` 47*5e3eaea3SApple OSS Distributions echo ${TIMEOUT} 48*5e3eaea3SApple OSS Distributions REALTIME=`echo ${TIMEOUT} | awk '{ print $1 }'` 49*5e3eaea3SApple OSS Distributions TOTALTIME=`echo ${TIMEOUT} | awk '{ print $3 + $5 }'` 50*5e3eaea3SApple OSS Distributions record_perf_data "${METRIC_NAME}_real" "s" $REALTIME "Real time in seconds. Lower is better. This may have variance based on load on system" > ${PERFDATA_DIR}/${METRIC_NAME}_real.perfdata 51*5e3eaea3SApple OSS Distributions record_perf_data "${METRIC_NAME}_sys" "s" $TOTALTIME "User + Sys time in seconds. Lower is better." > /tmp/${METRIC_NAME}_sys.perfdata 52*5e3eaea3SApple OSS Distributions if [ $? -ne 0 ]; then 53*5e3eaea3SApple OSS Distributions echo "Failed $i, exit status $?" 54*5e3eaea3SApple OSS Distributions exit 1 55*5e3eaea3SApple OSS Distributions fi 56*5e3eaea3SApple OSS Distributions done 57*5e3eaea3SApple OSS Distributionsdone 58