-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.sh
executable file
·143 lines (98 loc) · 3.01 KB
/
profile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
#
# Copyright (C) 2021 Ilya Entin
#
#usage:
# './profile.sh' in the server directory
SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
echo "SCRIPT_DIR:" $SCRIPT_DIR
PRJ_DIR=$SCRIPT_DIR
echo "PRJ_DIR:" $PRJ_DIR
UP_DIR=$(dirname $SCRIPT_DIR)
echo "UP_DIR:" $UP_DIR
mkdir -p $UP_DIR/Fifos
for (( c=1; c<=5; c++ ))
do
mkdir -p $UP_DIR/Client$c
done
for (( c=1; c<=5; c++ ))
do
cd $UP_DIR/Client$c
ln -sf $SCRIPT_DIR/data .
cp $SCRIPT_DIR/scripts/runShortSessions.sh .
cp /$SCRIPT_DIR/client_src/ClientOptions.json .
done
for (( c=1; c<=5; c++ ))
do
if [[ $(($c%2)) -eq 0 ]]
then
cd $UP_DIR/Client$c;sed -i 's/"ClientType" : "TCP"/"ClientType" : "FIFO"/' ClientOptions.json
fi
done
CLIENT_DIR2=$UP_DIR/Client2
echo "CLIENT_DIR2:" $CLIENT_DIR2
CLIENT_DIR3=$UP_DIR/Client3
echo "CLIENT_DIR3:" $CLIENT_DIR3
pkill serverX
pkill clientX
set -e
trap EXIT SIGHUP SIGINT SIGTERM
date
cd $PRJ_DIR
make cleanall
COMMUNICATION_TYPE=$(grep "ClientType" $UP_DIR/Client2/ClientOptions.json)
if [[ "$COMMUNICATION_TYPE" == *"TCP"* ]]
then
FIRST_CLIENT_PROFILE=$PRJ_DIR/profiles/profile_client_tcp.txt
else
FIRST_CLIENT_PROFILE=$PRJ_DIR/profiles/profile_client_fifo.txt
fi
COMMUNICATION_TYPE=$(grep "ClientType" $UP_DIR/Client3/ClientOptions.json)
if [[ "$COMMUNICATION_TYPE" == *"TCP"* ]]
then
SECOND_CLIENT_PROFILE=$PRJ_DIR/profiles/profile_client_tcp.txt
else
SECOND_CLIENT_PROFILE=$PRJ_DIR/profiles/profile_client_fifo.txt
fi
if [ "$FIRST_CLIENT_PROFILE" = "$SECOND_CLIENT_PROFILE" ]
then
echo "Clients must have different communication types";
exit;
fi
echo "FIRST_CLIENT_PROFILE is $FIRST_CLIENT_PROFILE"
echo "SECOND_CLIENT_PROFILE is $SECOND_CLIENT_PROFILE"
# Build profile binaries.
NUMBER_CORES=$(nproc)
make -j$NUMBER_CORES PROFILE=1
# Start the server.
$PRJ_DIR/serverX&
sleep 2
cp -f $PRJ_DIR/clientX $CLIENT_DIR2
cp -f $PRJ_DIR/clientX $CLIENT_DIR3
date
# Start tcp or fifo client.
# The directory Client2 must exist and have a copy of ClientOptions.json, and the link to SCRIPT_DIR/data directory.
cd $CLIENT_DIR2
sed -i 's/"MaxNumberTasks" : 0/"MaxNumberTasks" : 1000/' $CLIENT_DIR2/ClientOptions.json
./clientX > /dev/null&
cd $UP_DIR/Client3
sed -i 's/"MaxNumberTasks" : 0/"MaxNumberTasks" : 1000/' $CLIENT_DIR3/ClientOptions.json
./clientX > /dev/null
sleep 2
sed -i 's/"MaxNumberTasks" : 1000/"MaxNumberTasks" : 0/' $CLIENT_DIR2/ClientOptions.json
sed -i 's/"MaxNumberTasks" : 1000/"MaxNumberTasks" : 0/' $CLIENT_DIR3/ClientOptions.json
date
pkill serverX
sleep 2
cd $SCRIPT_DIR
gprof -b serverX gmon.out > profiles/profile_server.txt
( cd $CLIENT_DIR2; gprof -b clientX gmon.out > $FIRST_CLIENT_PROFILE )
( cd $CLIENT_DIR3; gprof -b clientX gmon.out > $SECOND_CLIENT_PROFILE )
# These directories are not under git and gmon.out must be removed 'manually'
# in order not to distort the results of the next run.
( cd $SCRIPT_DIR; rm -f gmon.out )
( cd $CLIENT_DIR2; rm -f gmon.out )
( cd $CLIENT_DIR3; rm -f gmon.out )
cd $PRJ_DIR
make cleanall
date