]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/execperf/test.sh
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tools / tests / execperf / test.sh
1 #!/bin/sh
2
3 EXECUTABLES="exit.nodyld \
4 exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \
5 exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \
6 exit.nopie exit.pie"
7
8 RUN=run
9 PRODUCT=`sw_vers -productName`
10 COUNT=
11
12 # params are: record_perf_data(metric, unit, value, description)
13 function record_perf_data() {
14 local METRIC=$1
15 local UNIT=$2
16 local DATA=$3
17 local DESCRIPTION=$4
18 echo "{ \"version\" : \"1.0\", \"measurements\" : {\"$METRIC\": {\"description\" : \"$DESCRIPTION\", \"names\":[\"$METRIC\"], \"units\" : [\"$UNIT\"], \"data\" : [$DATA] }}}"
19 }
20
21 PERFDATA_DIR=$BATS_TMP_DIR
22 if [ "${PERFDATA_DIR}" == "" ]; then
23 PERFDATA_DIR=/tmp/
24 fi
25
26 case "$PRODUCT" in
27 "Watch OS")
28 COUNT=500
29 ;;
30 "iPhone OS")
31 COUNT=1000
32 ;;
33 "Mac OS X")
34 COUNT=6000
35 ;;
36 *)
37 COUNT=1000
38 ;;
39 esac
40
41 for i in ${EXECUTABLES}; do
42 echo "Running $i"
43 for j in `jot $(sysctl -n hw.ncpu) 1`; do
44 printf "\t%dx\t" $j
45 METRIC_NAME="${i}_${j}x"
46 TIMEOUT=` /usr/bin/time ./${RUN} $j $((${COUNT}/$j)) ./$i 2>&1`
47 echo ${TIMEOUT}
48 REALTIME=`echo ${TIMEOUT} | awk '{ print $1 }'`
49 TOTALTIME=`echo ${TIMEOUT} | awk '{ print $3 + $5 }'`
50 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 record_perf_data "${METRIC_NAME}_sys" "s" $TOTALTIME "User + Sys time in seconds. Lower is better." > /tmp/${METRIC_NAME}_sys.perfdata
52 if [ $? -ne 0 ]; then
53 echo "Failed $i, exit status $?"
54 exit 1
55 fi
56 done
57 done