consolidate reclaim attribute lib
[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)      ECC-2^20-H(s)  ECC-2^28-H(s)
6 #  25     10          14            3              2               29
7 #  50     17          21            5              2               29
8 # 100     32          39            7              2               29
9 # 200                 77           13              3               30
10 # 400                149           23             OOR              31
11 # 800                304           32             OOR              33
12
13 # Bandwidth (including set intersection):
14 #              RSA-2048       ECC
15 # 800:         3846 kb       70 kb
16 # Configure benchmark size:
17 SIZE=800
18 #
19 # Construct input vectors:
20 INPUTALICE="-k CCC -e '"
21 INPUTBOB="-k CCC -e '"
22 for X in `seq 1 $SIZE`
23 do
24   INPUTALICE="${INPUTALICE}A${X},$X;"
25   INPUTBOB="${INPUTBOB}A${X},$X;"
26 done
27 INPUTALICE="${INPUTALICE}BC,-20000;RO,1000;FL,100;LOL,24;'"
28 INPUTBOB="${INPUTBOB}AB,10;RO,3;FL,3;LOL,-1;'"
29
30 # necessary to make the testing prefix deterministic, so we can access the config files
31 PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
32
33 # where can we find the peers config files?
34 CFGALICE="-c $PREFIX/0/config"
35 CFGBOB="-c $PREFIX/1/config"
36
37 # launch two peers in line topology non-interactively
38 #
39 # interactive mode would terminate the test immediately
40 # because the rest of the script is already in stdin,
41 # thus redirecting stdin does not suffice)
42 #GNUNET_FORCE_LOG=';;;;ERROR'
43 #GNUNET_FORCE_LOG='scalarproduct*;;;;DEBUG/cadet-api*;;;;DEBUG'
44 GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 &
45 PID=$!
46 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
47 echo "Waiting for peers to start..."
48 sleep 5
49 # get Bob's peer ID, necessary for Alice
50 PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
51
52 echo "Running problem of size $SIZE"
53 gnunet-scalarproduct $CFGBOB $INPUTBOB &
54 time RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
55 gnunet-statistics $CFGALICE -s core | grep "bytes encrypted"
56 gnunet-statistics $CFGBOB -s core | grep "bytes encrypted"
57
58 echo "Terminating testbed..."
59 # terminate the testbed
60 kill $PID