Pazpar2 1.4.4-2 for squeeze
[pazpar2-moved-to-github.git] / perf / bash / client_timed.sh
1 #!/bin/bash
2 OF=$1
3 if test -z "$OF"; then
4         OF=1
5 fi
6
7 PORT=$2
8 if test -z "$PORT"; then
9         PORT=9004
10 fi
11
12 SERVICE=$3
13 if test -z "$SERVICE"; then
14         SERVICE=perf_t
15 fi
16
17 RECORDS=40
18 QUERY=100
19 NUM=20
20 H="http://localhost:${PORT}/search.pz2"
21
22 declare -i MAX_WAIT=2
23 /usr/bin/time --format "$OF, init, %e" wget -q -O ${TMP_DIR}$OF.init.xml "$H/?command=init&service=${SERVICE}&extra=$OF" 2> ${TMP_DIR}$OF.init.time
24 S=`xsltproc get_session.xsl $OF.init.xml`
25 /usr/bin/time --format "$OF, search, %e" wget -q -O ${TMP_DIR}$OF.search.xml "$H?command=search&query=${QUERY}&session=$S" 2> ${TMP_DIR}$OF.search.time
26
27 let r=0
28 DO_DISPLAY=true
29 while [ ${DO_DISPLAY} ] ; do
30     SLEEP=$[ ($RANDOM % $MAX_WAIT ) ]
31     echo "show in $SLEEP"
32     sleep $SLEEP
33     /usr/bin/time --format "$OF, show2, %e" wget -q -O ${TMP_DIR}$OF.show.$r.xml "$H?command=show&session=$S&start=$r&num=${NUM}&block=1" 2>> ${TMP_DIR}$OF.show.time
34     AC=`xsltproc get_activeclients.xsl ${OF}.show.$r.xml`
35     if [ "$AC" != "0" ] ; then 
36         echo "Active clients: ${AC}" 
37 #    else
38 #       DO_DISPLAY=false
39 #       break
40     fi
41     let r=$r+$NUM
42     if [ $r -ge $RECORDS ] ; then 
43         DO_DISPLAY=false
44         break;
45     fi
46 done
47 /usr/bin/time --format "$OF, termlist, %e" wget -q -O ${TMP_DIR}$OF.termlist.$r.xml "$H?command=termlist&session=$S&name=xtargets%2Csubject%2Cauthor" 2>> ${TMP_DIR}$OF.termlist.time