Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / dmclock / benchmark / data_gen.sh
1 #!/bin/bash
2 config_dir="configs"
3 repeat=2 #5
4
5 # parameter check -- output_file name
6 if [ "$1" != "" ]; then
7   output_file="$1"
8 else
9   echo "Please provide the name of the output file"
10   exit
11 fi
12
13 # parameter check -- k-value
14 if [ "$2" != "" ]; then
15   k_way="$2"
16 else
17   echo "Please provide the maximum K_WAY value"
18   exit
19 fi
20
21 # parameter check --repeat
22 if [ "$3" != "" ]; then
23   repeat="$3"
24 fi
25
26 echo "k-way:$k_way, num_repeat:$repeat"
27
28 # create simulators in different directories 
29 k=2
30 while [ $k -le $k_way ]
31 do
32   mkdir "build_$k"
33   cd "build_$k"
34   rm -rf *
35   cmake -DCMAKE_BUILD_TYPE=Release -DK_WAY_HEAP=$k ../../.
36   make dmclock-sims
37   cd ..
38   
39   k=$(( $k + 1 ))
40 done
41
42 # run simulators 
43 echo '' > $output_file
44 for config in "$config_dir"/*.conf
45 do
46   k=2
47   while [ $k -le $k_way ]
48   do
49     cd "build_$k"
50     
51     # repeat same experiment
52     i=0
53     while [ $i -lt $repeat ]
54     do  
55       i=$(( $i + 1 ))
56       
57       # clear cache first
58       sync
59       #sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches'
60       #sudo sh -c 'echo 2 >/proc/sys/vm/drop_caches'
61       #sudo sh -c 'echo 3 >/proc/sys/vm/drop_caches'
62
63       # run with heap
64       msg="file_name:$k:$config"
65       echo $msg >> ../$output_file
66       echo "running $msg ..."
67       ./sim/dmc_sim -c ../$config | awk '(/average/)' >> ../$output_file
68     done # end repeat
69     cd ..
70     k=$(( $k + 1 ))
71   done # end k_way
72 done # end config
73