]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/libMicro/benchDS.sh
xnu-4570.20.62.tar.gz
[apple/xnu.git] / tools / tests / libMicro / benchDS.sh
CommitLineData
6d2010ae
A
1#!/bin/sh
2#
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms
7# of the Common Development and Distribution License
8# (the "License"). You may not use this file except
9# in compliance with the License.
10#
11# You can obtain a copy of the license at
12# src/OPENSOLARIS.LICENSE
13# or http://www.opensolaris.org/os/licensing.
14# See the License for the specific language governing
15# permissions and limitations under the License.
16#
17# When distributing Covered Code, include this CDDL
18# HEADER in each file and include the License file at
19# usr/src/OPENSOLARIS.LICENSE. If applicable,
20# add the following below this CDDL HEADER, with the
21# fields enclosed by brackets "[]" replaced with your
22# own identifying information: Portions Copyright [yyyy]
23# [name of copyright owner]
24#
25# CDDL HEADER END
26#
27
28#
29# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
30# Use is subject to license terms.
31#
32
33function usage {
34 echo "Usage"
35 echo "$0 [-l] [-h] <#-of-users> nodename [test match pattern]"
36 echo "-l : disable libinfo L1 cache"
37 echo "-h : Help. This option displays information on how to run the script. "
38 echo "[test match pattern] : This option runs only the test that is specified"
39 echo
40 echo "You must have set up users, groups, and SACLs with od_account_create"
41 echo "with the same number of user accounts."
42 echo "Supply a pattern to match to run a subset of tests"
43 exit 1
44}
45
46# default to libinfo cache enabled
47L1CACHE="1"
48
49while getopts "lh" OPT_LIST
50do
51 case $OPT_LIST in
52 l) L1CACHE="0";; # to run the libmicro tests with l1cache disabled
53 h) usage;;
54 *) usage;;
55 esac
56done
57
58shift `expr $OPTIND - 1`
59
60if [ $# -lt 2 -o $# -gt 3 ]; then
61 usage
62fi
63
64tattle="./tattle"
65
66bench_version=0.4.0
67libmicro_version=`$tattle -V`
68
69case $libmicro_version in
70$bench_version)
71 ;;
72*)
73 echo "ERROR: libMicro version doesn't match 'bench' script version"
74 exit 1
75esac
76
77TMPROOT=/private/tmp/libmicro.$$
78VARROOT=/private/var/tmp/libmicro.$$
79mkdir -p $TMPROOT
80mkdir -p $VARROOT
81trap "rm -rf $TMPROOT $VARROOT && exit" 0 2
82
83TFILE=$TMPROOT/data
84IFILE=$TMPROOT/ifile
85TDIR1=$TMPROOT/0/1/2/3/4/5/6/7/8/9
86TDIR2=$TMPROOT/1/2/3/4/5/6/7/8/9/0
87VFILE=$VARROOT/data
88VDIR1=$VARROOT/0/1/2/3/4/5/6/7/8/9
89VDIR2=$VARROOT/1/2/3/4/5/6/7/8/9/0
90
91OPTS="-E -C 200 -L -S -W"
92
93dd if=/dev/zero of=$TFILE bs=1024k count=10 2>/dev/null
94dd if=/dev/zero of=$VFILE bs=1024k count=10 2>/dev/null
95mkdir -p $TDIR1 $TDIR2
96mkdir -p $VDIR1 $VDIR2
97
98touch $IFILE
99/usr/bin/touch /private/var/tmp/lmbench
100
101
102# produce benchmark header for easier comparisons
103
104hostname=`uname -n`
105
106if [ -f /usr/sbin/psrinfo ]; then
107 p_count=`psrinfo|wc -l`
108 p_mhz=`psrinfo -v | awk '/operates/{print $6 "MHz"; exit }'`
109 p_type=`psrinfo -vp 2>/dev/null | awk '{if (NR == 3) {print $0; exit}}'`
110 p_ipaddr=`getent hosts $hostname | awk '{print $1}'`
111fi
112
113if [ -f /proc/cpuinfo ]; then
114 p_count=`egrep processor /proc/cpuinfo | wc -l`
115 p_mhz=`awk -F: '/cpu MHz/{printf("%5.0f00Mhz\n",$2/100); exit}' /proc/cpuinfo`
116 p_type=`awk -F: '/model name/{print $2; exit}' /proc/cpuinfo`
117 p_ipaddr=`getent hosts $hostname | awk '{print $1}'`
118else
119## Mac OS X specific stuff
120# first, get ugly output, in case pretty output isn't available
121#
122 p_count=`sysctl -n hw.physicalcpu`
123 p_mhz=`sysctl -n hw.cpufrequency`
124 p_type=`sysctl -n hw.model`
125
126if [ -x /usr/sbin/system_profiler ]; then
127 # <rdar://4655981> requires this hunk of work-around
128 # grep the XML for the characteristic we need. The key appears twice, so grep for the useful key (with 'string')
129 # use sed to strip off the <string></string> and the tabs in front of the string. So much work for so little result.
130 #
131 p_mhz=`system_profiler -xml -detailLevel mini SPHardwareDataType | \
132 grep -A1 current_processor_speed | grep string | \
133 sed -E 's/<string>(.+)<\/string>/\1/' | sed 's- --g'`
134 p_type=`system_profiler -xml -detailLevel mini SPHardwareDataType | \
135 grep -A1 cpu_type | grep string | \
136 sed -E 's/<string>(.+)<\/string>/\1/' | sed 's- --g'`
137fi
138
139# look for en0 (usually ethernet) if that isn't there try en1 (usually wireless) else give up
140 p_ipaddr=`ipconfig getpacket en0 | grep yiaddr | tr "= " "\n" | grep [0-9]`
141 if [ ! $p_ipaddr ]; then
142 p_ipaddr=`ipconfig getpacket en1 | grep yiaddr | tr "= " "\n" | grep [0-9]`
143 elif [ ! $p_ipaddr ]; then
144 p_ipaddr="unknown"
145 fi
146fi
147
148printf "\n\n!Libmicro_#: %30s\n" $libmicro_version
149printf "!Options: %30s\n" "$OPTS"
150printf "!Machine_name: %30s\n" "$hostname"
151printf "!OS_name: %30s\n" `uname -s`
152printf "!OS_release: %30s\n" `sw_vers -productVersion`
153printf "!OS_build: %30.18s\n" "`sw_vers -buildVersion`"
154printf "!Processor: %30s\n" `arch`
155printf "!#CPUs: %30s\n" $p_count
156printf "!CPU_MHz: %30s\n" "$p_mhz"
157printf "!CPU_NAME: %30s\n" "$p_type"
158printf "!IP_address: %30s\n" "$p_ipaddr"
159printf "!Run_by: %30s\n" $LOGNAME
160printf "!Date: %30s\n" "`date '+%D %R'`"
161printf "!Compiler: %30s\n" `$tattle -c`
162printf "!Compiler Ver.:%30s\n" "`$tattle -v`"
163printf "!sizeof(long): %30s\n" `$tattle -s`
164printf "!extra_CFLAGS: %30s\n" "`$tattle -f`"
165printf "!TimerRes: %30s\n\n\n" "`$tattle -r`"
166
167bin_dir="$TMPROOT/bin"
168
169mkdir -p $bin_dir
170cp bin-*/exec_bin $bin_dir/$A
171
172cp ./apple/bin-*/posix_spawn_bin $bin_dir/$A
173
174newline=0
175
176# We commonly want to adjust this script for the number of users
177# and configuration of the accounts and configuration being tested.
178#
179# Users:
180NUSERS=$1
181NODENAME=$2
182UID_BASE=5000
183UID_END=`expr $UID_BASE + $NUSERS - 1`
184USER_PREFIX=od_test_
185#
186# Groups:
187GID_ALL_USERS=1211
188GID_NO_USERS=1212
189GROUP_BASE=od_test_group
190#
191# getaddrinfo on hosts:
192HOST_BASE=sfs0
193HOST_RANGE=1-8
194
195#
3e170ce0
A
196# Everything below the while loop is input for the while loop if
197# you have any tests which can't run in the while loop, put
6d2010ae
A
198# them above this comment
199#
200while read A B
201do
202 # $A contains the command, $B contains the arguments
203 # we echo blank lines and comments
3e170ce0
A
204 # we skip anything which fails to match *$1* (useful if
205 # we only want to test one case, but a nasty hack)
6d2010ae
A
206
207 case $A in
208 \#*)
209 echo "$A $B"
210 newline=1
211 continue
212 ;;
213
214 "")
215 if [ $newline -eq 1 ]
216 then
217 newline=0
218 echo
219 echo
220 fi
221
222 continue
223 ;;
224
225 *$3*)
226 ;;
227
228 *)
229 continue
230 ;;
231 esac
232
233 if [ ! -f $bin_dir/$A ]
234 then
235 cp bin-*/$A $bin_dir/$A
236 fi
237
238 echo
239
240 (cd $TMPROOT && eval "bin/$A $B")
241
242 echo
243 echo
244done <<.
245
246# -P <# procs>
247# -T <# threads> - exclusive!
248
249# mbr_check_service_membership()
250mbr_check_service_membership $OPTS -N "mbr_check_service_membership" -s libMicro -u ${USER_PREFIX} -r ${NUSERS}
251mbr_check_service_membership $OPTS -N "mbr_check_service_membership_t2" -T 2 -s libMicro -u ${USER_PREFIX} -r ${NUSERS}
252mbr_check_service_membership $OPTS -N "mbr_check_service_membership_t4" -T 4 -s libMicro -u ${USER_PREFIX} -r ${NUSERS}
253mbr_check_service_membership $OPTS -N "mbr_check_service_membership_p2" -P 2 -s libMicro -u ${USER_PREFIX} -r ${NUSERS}
254mbr_check_service_membership $OPTS -N "mbr_check_service_membership_p4" -P 4 -s libMicro -u ${USER_PREFIX} -r ${NUSERS}
255
256# getpwnam()
257getpwnam $OPTS -N "getpwnam" -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
258getpwnam $OPTS -N "getpwnam_t2" -T 2 -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
259getpwnam $OPTS -N "getpwnam_p2" -P 2 -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
260
261# mbr_check_membership()
262mbr_check_membership $OPTS -N "mbr_check_membership" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS}
263mbr_check_membership $OPTS -N "mbr_check_membership_t2" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 2
264mbr_check_membership $OPTS -N "mbr_check_membership_t4" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 4
265mbr_check_membership $OPTS -N "mbr_check_membership_p2" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 2
266mbr_check_membership $OPTS -N "mbr_check_membership_p4" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 4
267
268# getpwuid()
269getpwuid $OPTS -N "getpwuid" -l ${L1CACHE} -u ${UID_BASE}-${UID_END}
270getpwuid $OPTS -N "getpwuid_t2" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -T 2
271getpwuid $OPTS -N "getpwuid_t4" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -T 4
272getpwuid $OPTS -N "getpwuid_p2" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -P 2
273getpwuid $OPTS -N "getpwuid_p4" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -P 4
274
275# getgrgid()
276getgrgid $OPTS -N "getgrgid" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS}
277getgrgid $OPTS -N "getgrgid_t2" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 2
278getgrgid $OPTS -N "getgrgid_t4" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 4
279getgrgid $OPTS -N "getgrgid_p2" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 2
280getgrgid $OPTS -N "getgrgid_p4" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 4
281
282# getpwent()
283getpwent $OPTS -N "getpwent" -l ${L1CACHE}
284getpwent $OPTS -N "getpwent_t2" -l ${L1CACHE} -T 2
285getpwent $OPTS -N "getpwent_t4" -l ${L1CACHE} -T 4
286getpwent $OPTS -N "getpwent_p2" -l ${L1CACHE} -P 2
287getpwent $OPTS -N "getpwent_p4" -l ${L1CACHE} -P 4
288
289# getgrent()
290getgrent $OPTS -N "getgrent" -l ${L1CACHE}
291getgrent $OPTS -N "getgrent_t2" -l ${L1CACHE} -T 2
292getgrent $OPTS -N "getgrent_t4" -l ${L1CACHE} -T 4
293getgrent $OPTS -N "getgrent_p2" -l ${L1CACHE} -P 2
294getgrent $OPTS -N "getgrent_p4" -l ${L1CACHE} -P 4
295
296# getaddrinfo() host
297#getaddrinfo_host $OPTS -N "getaddrinfo_host" -r ${HOST_RANGE} -h ${HOST_BASE}%d
298#getaddrinfo_host $OPTS -N "getaddrinfo_host_t2" -r ${HOST_RANGE} -h ${HOST_BASE}%d -T 2
299#getaddrinfo_host $OPTS -N "getaddrinfo_host_t4" -r ${HOST_RANGE} -h ${HOST_BASE}%d -T 4
300#getaddrinfo_host $OPTS -N "getaddrinfo_host_p2" -r ${HOST_RANGE} -h ${HOST_BASE}%d -P 2
301#getaddrinfo_host $OPTS -N "getaddrinfo_host_p4" -r ${HOST_RANGE} -h ${HOST_BASE}%d -P 4
302
303# getaddrinfo() port
304getaddrinfo_port $OPTS -N "getaddrinfo_port" -l ${L1CACHE}
305getaddrinfo_port $OPTS -N "getaddrinfo_port_t2" -l ${L1CACHE} -T 2
306getaddrinfo_port $OPTS -N "getaddrinfo_port_t4" -l ${L1CACHE} -T 4
307getaddrinfo_port $OPTS -N "getaddrinfo_port_p2" -l ${L1CACHE} -P 2
308getaddrinfo_port $OPTS -N "getaddrinfo_port_p4" -l ${L1CACHE} -P 4
309
310# getgrnam()
311getgrnam $OPTS -N "getgrnam" -l ${L1CACHE} -g ${GROUP_BASE} -r 2
312getgrnam $OPTS -N "getgrnam_t2" -l ${L1CACHE} -T 2 -g ${GROUP_BASE} -r 2
313getgrnam $OPTS -N "getgrnam_t4" -l ${L1CACHE} -T 4 -g ${GROUP_BASE} -r 2
314getgrnam $OPTS -N "getgrnam_p2" -l ${L1CACHE} -P 2 -g ${GROUP_BASE} -r 2
315getgrnam $OPTS -N "getgrnam_p4" -l ${L1CACHE} -P 4 -g ${GROUP_BASE} -r 2
316
317# ODQueryCreateWithNode()
318od_query_create_with_node $OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u" -c 50 -r ${NUSERS} -t u -B 50 -n ${NODENAME}
319od_query_create_with_node $OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_t2" -T 2 -c 50 -r ${NUSERS} -t u -B 50 -n ${NODENAME}
320od_query_create_with_node $OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_t4" -T 4 -c 50 -r ${NUSERS} -t u -B 50 -n ${NODENAME}
321od_query_create_with_node $OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_p2" -P 2 -c 50 -r ${NUSERS} -t u -B 50 -n ${NODENAME}
322od_query_create_with_node $OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_p4" -P 4 -c 50 -r ${NUSERS} -t u -B 50 -n ${NODENAME}
323
324.