-
Notifications
You must be signed in to change notification settings - Fork 5
/
srmtest.sh
executable file
·139 lines (118 loc) · 3.55 KB
/
srmtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
#
# Script to test srm performance
#
# (Note: we use bash since it honors 'echo -n', unlike sh)
# ----------------------------------------------------------------------
# Location of standard srm command (as a baseline control)
STDSRM=/usr/bin/srm
# Location of srm command we are testing
BASEDIR=`pwd`
TSTSRM="${BASEDIR}/srm"
# Location of temporary directory (warning: this directory will be wiped!)
TMPDIR="${BASEDIR}/temp"
# Strings to identify hardware & software (note: this is OS-specific)
SW_VERS="`sw_vers -productVersion` (`sw_vers -buildVersion`)"
HW_VERS="`system_profiler SPHardwareDataType | grep Name | sed 's/^[ ]*//'`"
# ----------------------------------------------------------------------
# Subroutines
TAB=" "
csh_time () {
/bin/csh -sf << EOF
time $* >& /dev/null
EOF
}
createLargeFiles () {
if [ ! -d "${TMPDIR}" ] ; then mkdir -p "${TMPDIR}" ; fi
if [ ! -f "${TMPDIR}/284mb" ] ; then
# Make a 284MB file
/bin/dd if=/dev/zero of="${TMPDIR}/284mb" bs=1k count=290816
sync
echo "Created ${TMPDIR}/284mb"
ls -la "${TMPDIR}/284mb"
fi
if [ ! -f "${TMPDIR}/100mb" ] ; then
# Make a 100MB file
/bin/dd if=/dev/zero of="${TMPDIR}/100mb" bs=1k count=102400
sync
echo "Created ${TMPDIR}/100mb"
ls -la "${TMPDIR}/100mb"
fi
}
createSmallFiles () {
if [ ! -d "${TMPDIR}" ] ; then mkdir -p "${TMPDIR}" ; fi
if [ ! -d "${TMPDIR}/smallfiles" ] ; then
# Create a directory containing many small files
# (in this case, a copy of /usr/include/sys)
/bin/cp -r /usr/include/sys "${TMPDIR}/smallfiles"
sync
echo "Created ${TMPDIR}/smallfiles"
du -h "${TMPDIR}/smallfiles"
fi
}
doForN () {
# $1 = command to execute
# $2 = string to print on first iteration
# $3 = number of times to execute command
i=1
q=${3-1}
echo -n "$2"
while [ $i -le $q ] ; do
echo -n "${TAB}"
if [ $i -gt 1 ] ; then echo -n "${TAB}${TAB}" ; fi
csh_time "$1"
i=$((i+1))
if [ ! -d "${TMPDIR}/smallfiles" ] ; then
# srm incorrectly renamed the folder [4498712]
createSmallFiles
fi
done
}
doTest () {
# $1 = command-line options
# $2 = number of times to execute command
doForN "${STDSRM}""$1" "baseline time${TAB}" "$2"
doForN "${TSTSRM}"' --bsize=4096 '"$1" "buffsize=4096${TAB}" "$2"
doForN "${TSTSRM}"' --bsize=65536 '"$1" "buffsize=65536${TAB}" "$2"
doForN "${TSTSRM}"' --bsize=131072 '"$1" "buffsize=131072${TAB}" "$2"
doForN "${TSTSRM}"' --bsize=1048576 '"$1" "buffsize=1048576" "$2"
doForN "${TSTSRM}"' --bsize=4194304 '"$1" "buffsize=4194304" "$2"
doForN "${TSTSRM}"' --bsize=8388608 '"$1" "buffsize=8388608" "$2"
}
# ----------------------------------------------------------------------
# Begin script
echo "`date`: ${HW_VERS}"
echo "`date`: Current system is ${SW_VERS}"
echo "`date`: Current directory is ${BASEDIR}"
echo "`date`: Starting tests"
if [ -d "${TMPDIR}" ] ; then rm -rf "${TMPDIR}" ; fi
createLargeFiles
createSmallFiles
echo
echo "### 1-pass tests ###"
echo
echo "file: ${TMPDIR}/284mb"
doTest ' -s -n '"${TMPDIR}/284mb" 3
echo
echo "folder: ${TMPDIR}/smallfiles"
doTest ' -s -r -f -n '"${TMPDIR}/smallfiles" 3
echo
echo "### 7-pass tests ###"
echo
echo "file: ${TMPDIR}/284mb"
doTest ' -m -n '"${TMPDIR}/284mb" 3
echo
echo "folder: ${TMPDIR}/smallfiles"
doTest ' -m -r -f -n '"${TMPDIR}/smallfiles" 3
echo
echo "### 35-pass tests ###"
echo
echo "file: ${TMPDIR}/100mb"
doTest ' -n '"${TMPDIR}/100mb" 3
echo
echo "folder: ${TMPDIR}/smallfiles"
doTest ' -r -f -n '"${TMPDIR}/smallfiles" 3
if [ -d "${TMPDIR}" ] ; then rm -rf "${TMPDIR}" ; fi
echo
echo "`date`: Completed tests"
exit 0