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