]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/execperf/test.sh
xnu-7195.81.3.tar.gz
[apple/xnu.git] / tools / tests / execperf / test.sh
CommitLineData
6d2010ae
A
1#!/bin/sh
2
3EXECUTABLES="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
8RUN=run
9PRODUCT=`sw_vers -productName`
10COUNT=
11
4bd07ac2
A
12# params are: record_perf_data(metric, unit, value, description)
13function 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
21PERFDATA_DIR=$BATS_TMP_DIR
22if [ "${PERFDATA_DIR}" == "" ]; then
23 PERFDATA_DIR=/tmp/
24fi
25
6d2010ae 26case "$PRODUCT" in
490019cf
A
27 "Watch OS")
28 COUNT=500
29 ;;
6d2010ae
A
30 "iPhone OS")
31 COUNT=1000
32 ;;
490019cf
A
33 "Mac OS X")
34 COUNT=6000
35 ;;
6d2010ae 36 *)
490019cf 37 COUNT=1000
6d2010ae
A
38 ;;
39esac
40
fe8ab488
A
41for 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
4bd07ac2
A
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
6d2010ae
A
52 if [ $? -ne 0 ]; then
53 echo "Failed $i, exit status $?"
54 exit 1
55 fi
56 done
57done