-running at scale...
[oweals/gnunet.git] / src / scalarproduct / perf_scalarproduct.sh
1 #!/bin/bash
2 # compute a simple scalar product
3 # payload for this test:
4 SIZE=1000
5 INPUTALICE="-k CCC -e '"
6 INPUTBOB="-k CCC -e '"
7 for X in `seq 1 $SIZE`
8 do
9   INPUTALICE="${INPUTALICE}A${X},$X;"
10   INPUTBOB="${INPUTBOB}A${X},$X;"
11 done
12 INPUTALICE="${INPUTALICE}BC,-20000;RO,1000;FL,100;LOL,24;'"
13 INPUTBOB="${INPUTBOB}AB,10;RO,3;FL,3;LOL,-1;'"
14
15 # necessary to make the testing prefix deterministic, so we can access the config files
16 PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
17
18 # where can we find the peers config files?
19 CFGALICE="-c $PREFIX/0/config"
20 CFGBOB="-c $PREFIX/1/config"
21
22 # launch two peers in line topology non-interactively
23 #
24 # interactive mode would terminate the test immediately
25 # because the rest of the script is already in stdin,
26 # thus redirecting stdin does not suffice)
27 GNUNET_FORCE_LOG=';;;;ERROR'
28 GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
29 PID=$!
30 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
31 echo "Waiting for peers to start..."
32 sleep 5
33 # get Bob's peer ID, necessary for Alice
34 PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
35
36 echo "Running problem of size $SIZE"
37 gnunet-scalarproduct $CFGBOB $INPUTBOB &
38 time RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
39
40 echo "Terminating testbed..."
41 # terminate the testbed
42 kill $PID
43