Merge branch 'ckm' into tizen
[platform/core/test/security-tests.git] / src / test-performance-check.sh
1 #!/bin/sh
2
3 NOF_TRIES=3
4 i=$NOF_TRIES
5 ERR_FILE=error.log
6 RESULTS_FILE=results.log
7
8 SUM=0
9
10 black="\033[0;30m";
11 red="\033[0;31m";
12 green="\033[0;32m";
13 brown="\033[0;33m";
14 blue="\033[0;34m";
15 purple="\033[0;35m";
16 grey="\033[1;30m";
17 yellow="\033[1;33m";
18 default="\033[0m";
19
20
21 function echo_as_percent () {
22 full=$(( $1 / 100 ))
23 rest_full=$(( $1 % 100 ))
24 dec=$(($rest_full / 10 ))
25 rest_dec=$(($rest_full % 10 ))
26 echo "$full.$dec$rest_dec%"
27 echo "$full.$dec$rest_dec%" >> $RESULTS_FILE
28
29 }
30
31 date >> $RESULTS_FILE
32 date >> $ERR_FILE
33  
34 while [ $((i--)) -gt 0 ]
35 do
36 echo -e "$blue==============test no $i=============$default"
37
38 perf record -a -g & > /dev/null 2> /dev/null
39 sleep 1
40 security-tests-all.sh > /dev/null 2> /dev/null
41 pkill -SIGINT perf
42
43 sleep 2
44
45 echo "perf results:"
46 perf report -U -s symbol -gflat,1,caller 2>> $ERR_FILE | grep smk
47 OUTPUT=$(perf report -U -s symbol -gflat,1,caller 2>> $ERR_FILE | grep smk | sed "s:%.*$::g;s:^[ \t]::g;s:[^0-9]::g;s:^0::g;s:^0::g;s:$:+:g;$ s:+::" | tr -d "\n")
48
49 echo -e "$blue sum:"
50 echo_as_percent $(($OUTPUT))
51 echo -e "$default"
52
53 SUM=$(($SUM + $OUTPUT))
54
55 done
56 echo -e "$blue==============done============="
57 OUTPUT=$(($SUM/3))
58 echo "average:"
59 echo "average:" >> $RESULTS_FILE
60 echo_as_percent $OUTPUT
61 echo -e "$default"
62
63