-improve indentation, reduce duplication of PIDs in core's neighbour map
[oweals/gnunet.git] / src / scalarproduct / perf_scalarproduct.sh
1 #!/bin/bash
2 # Computes a simple scalar product, with configurable vector size.
3 #
4 # Some results (wall-clock for Alice+Bob, single-core, i7):
5 # SIZE   2048-H(s)  2048-O(s)    1024-O(s)
6 #  25     10          14            3
7 #  50     17          21            5
8 # 100     32          39            7
9 # 200                 77           13
10 # 400                149           23
11 # 800                304           32
12 # Configure benchmark size:
13 SIZE=1600
14 #
15 # Construct input vectors:
16 INPUTALICE="-k CCC -e '"
17 INPUTBOB="-k CCC -e '"
18 for X in `seq 1 $SIZE`
19 do
20   INPUTALICE="${INPUTALICE}A${X},$X;"
21   INPUTBOB="${INPUTBOB}A${X},$X;"
22 done
23 INPUTALICE="${INPUTALICE}BC,-20000;RO,1000;FL,100;LOL,24;'"
24 INPUTBOB="${INPUTBOB}AB,10;RO,3;FL,3;LOL,-1;'"
25
26 # necessary to make the testing prefix deterministic, so we can access the config files
27 PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
28
29 # where can we find the peers config files?
30 CFGALICE="-c $PREFIX/0/config"
31 CFGBOB="-c $PREFIX/1/config"
32
33 # launch two peers in line topology non-interactively
34 #
35 # interactive mode would terminate the test immediately
36 # because the rest of the script is already in stdin,
37 # thus redirecting stdin does not suffice)
38 #GNUNET_FORCE_LOG=';;;;ERROR'
39 #GNUNET_FORCE_LOG='scalarproduct*;;;;DEBUG/cadet-api*;;;;DEBUG'
40 GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
41 PID=$!
42 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
43 echo "Waiting for peers to start..."
44 sleep 5
45 # get Bob's peer ID, necessary for Alice
46 PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
47
48 echo "Running problem of size $SIZE"
49 gnunet-scalarproduct $CFGBOB $INPUTBOB &
50 time RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
51 gnunet-statistics $CFGALICE -s core | grep "bytes encrypted"
52 gnunet-statistics $CFGBOB -s core | grep "bytes encrypted"
53
54 echo "Terminating testbed..."
55 # terminate the testbed
56 kill $PID
57