#
# patch "ChangeLog"
# from [4aeefa2d2b08378898fdaa41918aa9b13af33557]
# to [a30affd9f6b476e1875c0b8616d6cd9c4f2d8468]
#
# patch "contrib/monoprof.sh"
# from [ba14875386baabc9acae0fc1b8a5e2e88fea2144]
# to [5b9e3de82d81d3f3290d4a16f91fcebbacee0989]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,8 @@
+2005-05-06 Timothy Brownawell
+
+ * contrib/monoprof.sh: Add profiling test for "netsync large file".
+ Add options to only run specific profile tests.
+
2005-05-11 Joel Reed
* contrib/monotone.zsh_completion: add zsh completion contrib.
--- contrib/monoprof.sh
+++ contrib/monoprof.sh
@@ -1,11 +1,20 @@
#!/bin/bash
#Timothy Brownawell
-#Arguments:
-# --build Rebuild monotone before profiling.
-# --update Run "monotone update" before building. Implies --build
-# --pull Run "monotone pull" before update. Implies --update, --build
-# --append x Append ".x" to the profile directory name
+print_help()
+{
+cat < ${PDIR}/profile-${SHORTNAME}
${SUDO} opcontrol --shutdown
hilights ${PDIR}/profile-${SHORTNAME} >${PDIR}/hilights-${SHORTNAME}
- rm ${DATADIR}/test.db ${DATADIR}/test-serve.db
-
- echo "Serve net.venge.monotone :" >>${PDIR}/timing
+ echo -e "\nServe net.venge.monotone :" >>${PDIR}/timing
cat ${TIME_SERVER} >>${PDIR}/timing
echo -e "\nPull net.venge.monotone :" >>${PDIR}/timing
cat ${TIME_CLIENT} >>${PDIR}/timing
-
rm ${TIME_SERVER} ${TIME_CLIENT}
+
+ rm ${DATADIR}/test.db ${DATADIR}/test-serve.db
}
-#The next 3 use the same working copy and database.
TESTS="${TESTS} test_commit"
test_commit()
{
@@ -138,29 +147,21 @@
--db=${DATADIR}/test.db commit \
--message="Commit message."
profend
-}
-
-TESTS="${TESTS} test_minor_commit"
-test_minor_commit()
-{
- local RUNTIME=$(tempfile)
- local TESTNAME="Commit a small patch (${KPATCH}) to the kernel"
- local SHORTNAME="commit"
+ RUNTIME=$(tempfile)
+ TESTNAME="Commit a small patch (${KPATCH}) to the kernel"
+ SHORTNAME="commitpatch"
+
bzip2 -dc ${DATADIR}/${KPATCH} | patch -p1 >/dev/null
profstart
${TIME} -o ${RUNTIME} ${MONOTONE} --branch=linux-kernel \
--db=${DATADIR}/test.db commit --message="Commit #2"
profend
-}
-
-TESTS="${TESTS} test_unchanged_commit"
-test_unchanged_commit()
-{
- local RUNTIME=$(tempfile)
- local TESTNAME="Recommit the kernel without changes"
- local SHORTNAME="commitsame"
+ RUNTIME=$(tempfile)
+ TESTNAME="Recommit the kernel without changes"
+ SHORTNAME="commitsame"
+
profstart
${TIME} -o ${RUNTIME} ${MONOTONE} --branch=linux-kernel \
--db=${DATADIR}/test.db commit --message="no change"
@@ -188,6 +189,62 @@
rm ${DATADIR}/test.db
}
+#Based on tests/t_netsync_largish_file.at
+TESTS="${TESTS} test_bigfile"
+test_bigfile()
+{
+ local TIME_SERVER=$(tempfile);
+ local TIME_CLIENT=$(tempfile);
+ local RUNTIME=$(tempfile)
+ local TESTNAME=""#"Netsync a big file."
+ local SHORTNAME=""#"bigfile"
+#setup:
+ pushd ${DATADIR}
+ cp ${EMPTYDB} test.db
+ cp ${EMPTYDB} test2.db
+ ${MONOTONE} --db=test.db setup testdir
+ pushd testdir
+ awk -- 'BEGIN{srand(5253);for(a=0;a<32*1024*1024;a+=20)printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256,rand()*256);}' > largish
+ ${MONOTONE} add largish
+
+ TESTNAME="Commit a big file"
+ SHORTNAME="bigfile-commit"
+ profstart
+ ${MONOTONE} commit --branch=bigfile --message="log message" \
+ --db=${DATADIR}/test.db
+ profend
+
+ TESTNAME="Netsync a big file"
+ SHORTNAME="bigfile-sync"
+ profstart
+#run:
+ ${TIME} -o ${TIME_SERVER} ${MONOTONE} --db=${DATADIR}/test.db \
+ --ticker=none --quiet serve localhost bigfile &
+ sleep 5 #wait for server to be ready
+ ${TIME} -o ${TIME_CLIENT} ${MONOTONE} --db=${DATADIR}/test2.db \
+ pull localhost bigfile
+ #If we kill the time process, we don't get our statistics.
+ kill $(ps -Af|grep 'monotone.*serve\ localhost' | \
+ grep -v time | awk '{print $2}')
+
+ #profend
+ opcontrol --dump
+ opstack ${MONOTONE} > ${PDIR}/profile-${SHORTNAME}
+ ${SUDO} opcontrol --shutdown
+ hilights ${PDIR}/profile-${SHORTNAME} >${PDIR}/hilights-${SHORTNAME}
+ echo -e "\nServe an uncompressible 32MB file :" >>${PDIR}/timing
+ cat ${TIME_SERVER} >>${PDIR}/timing
+ echo -e "\nPull an uncompressible 32MB file :" >>${PDIR}/timing
+ cat ${TIME_CLIENT} >>${PDIR}/timing
+
+ rm ${TIME_SERVER} ${TIME_CLIENT}
+#cleanup:
+ popd
+ rm -rf testdir/
+ rm test.db test2.db
+ popd
+}
+
#TESTS="${TESTS} test_name"
#test_name()
#{
@@ -207,13 +264,16 @@
run_tests()
{
local PDIR=${PROFDIR}/${VERSION}${APPEND}
- [ -d ${PDIR} ] && (echo "Already profiled this version.";
- echo "If you've made changes since then, use --append" ;
- echo "to place the new results in a new directory."; exit 1)
+ if [ -d ${PDIR} ] && [ ${OVERWRITE} = "false" ] ; then
+ echo "Already profiled this version." >&2
+ echo "If you've made changes since then use --append" >&2
+ echo "to place the new results in a new directory," >&2
+ echo "or specify --overwrite." >&2
+ exit 1
+ fi
mkdir -p ${PDIR}
export LD_PRELOAD=${DBG_LIB}
echo "Profiling..."
- rm -f ${PDIR}/timing
${SUDO} opcontrol --separate=lib --callgraph=10 \
--image=${MONOTONE} --no-vmlinux
for i in ${TESTS}; do
@@ -221,7 +281,7 @@
done
chmod -R a+rX ${PDIR}
echo "Monotone version: ${VERSION}"
- cat <(echo -e "Timing for each run:\n") ${PROFDIR}/${VERSION}$1/timing
+ cat <(echo -e "Timing for each run:") ${PROFDIR}/${VERSION}$1/timing
}
BEGINTIME=$(date +%s)
@@ -230,14 +290,19 @@
UPDATE=false
PULL=false
APPEND=""
+RESTRICT=""
+OVERWRITE=false
while ! [ $# -eq 0 ] ; do
case "$1" in
- --build) BUILD=true ;;
- --update) UPDATE=true ; BUILD=true ;;
- --pull) PULL=true ; UPDATE=true ; BUILD=true ;;
- --append) shift; APPEND=".$1" ;;
- *) ;;
+ --build) BUILD=true;;
+ --update) UPDATE=true; BUILD=true;;
+ --pull) PULL=true; UPDATE=true; BUILD=true;;
+ --append) shift; APPEND=".$1";;
+ --list) for i in ${TESTS}; do echo -e "\t$i"; done; exit 0;;
+ --overwrite) OVERWRITE="true";;
+ --help) print_help; exit 0;;
+ *) RESTRICT="${RESTRICT} $1";;
esac
shift
done
@@ -253,7 +318,9 @@
make || ( echo -e "Build failed.\nNot profiling." >&2 ; exit 1 )
fi
popd
-
+if ! [ "${RESTRICT}" = "" ] ; then
+ TESTS="${RESTRICT}"
+fi
run_tests
TOTALTIME=$(($(date +%s)-${BEGINTIME}))
ELAPSED=$((${TOTALTIME}/60)):$((${TOTALTIME}%60))