-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_profiling
executable file
·101 lines (76 loc) · 2.98 KB
/
run_profiling
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
#!/bin/bash
# Convenience script to execute distributed paddles with a server and two hosts using profiling.
# Press any key to start the clients after the server has started.
# Press again any key to kill the processes.
# hp2ps is used to render profiling graphs, see $SERVER_PS, $CLIENTA_PS and $CLIENTB_PS for results.
# To build the applicaion with profiling, enable ghc-options "-prof" and "-fprof-auto" in distributed-frp-dunai.cabal
# Also the file cabal.project.local may be modified to contain the following line
# profiling: True
# PATH_EXE needs to point to the exes built by Cabal.
# Profiling in Haskell does not support specifying output files.
# Running a profiled program called x always writes its output to x.hp.
# The workaround used here is to execute different copies of the executable.
cabal new-build
PATH_EXE=dist-newstyle/build/x86_64-linux/ghc-8.2.2/distributed-frp-dunai-0.1.0.0/x/distributed-paddles/build/distributed-paddles/
# The executables
DEFAULT=distributed-paddles
SERVER=distributed-paddlesS
CLIENTA=distributed-paddlesA
CLIENTB=distributed-paddlesB
# Paths of executables
DEFAULT_PATH=${PATH_EXE}${DEFAULT}
SERVER_PATH=${PATH_EXE}${SERVER}
CLIENTA_PATH=${PATH_EXE}${CLIENTA}
CLIENTB_PATH=${PATH_EXE}${CLIENTB}
# Paths of hp files
SERVER_HP=distributed-paddlesS.hp
CLIENTA_HP=distributed-paddlesA.hp
CLIENTB_HP=distributed-paddlesB.hp
# Paths of prof files
SERVER_PROF=distributed-paddlesS.prof
CLIENTA_PROF=distributed-paddlesA.prof
CLIENTB_PROF=distributed-paddlesB.prof
# Files to contain the profiling graphs
SERVER_PS=distributed-paddlesS.ps
CLIENTA_PS=distributed-paddlesA.ps
CLIENTB_PS=distributed-paddlesB.ps
# Available options: https://downloads.haskell.org/~ghc/7.4.1/docs/html/users_guide/prof-heap.html#rts-options-heap-prof
# -hc : cost-centre stack
# -hm : module containing the code
# -hd : closure description (constructor name)
# -hy : by type description
# -hr : retainer set
# -hb : biography
PROFILE=-hc
# Create the executables
cp $DEFAULT_PATH $SERVER_PATH
cp $DEFAULT_PATH $CLIENTA_PATH
cp $DEFAULT_PATH $CLIENTB_PATH
echo $SERVER_PATH
# run Server
echo "Starting the server"
./$SERVER_PATH +RTS -p -s $PROFILE -RTS --host --ip 127.0.0.1 --p 3000 --name name -t | sed "s/^/[Server] /" &
# run Clients
read -n 1 -s -r -p $'Press any key to start clients\n'
PORT=3001
echo "Starting client 1 on port $PORT"
./$CLIENTA_PATH +RTS -p -s $PROFILE -RTS --ip 127.0.0.1 --p $PORT --name name --s 127.0.0.1:3000:0 --nick 1 | sed "s/^/[Client1] /" &
PORT=3002
./$CLIENTB_PATH +RTS -p -s $PROFILE -RTS --ip 127.0.0.1 --p $PORT --name name --s 127.0.0.1:3000:0 --nick 2 | sed "s/^/[Client2] /" &
read -n 1 -s -r -p $'Press any key to exit\n'
kill -SIGINT %1
kill -SIGINT %2
kill -SIGINT %3
# convert hp to ps
hp2ps -e8in -c $SERVER_HP
hp2ps -e8in -c $CLIENTA_HP
hp2ps -e8in -c $CLIENTB_HP
rm $SERVER_HP
rm $CLIENTA_HP
rm $CLIENTB_HP
profiterole $SERVER_PROF
profiteur $SERVER_PROF
profiterole $CLIENTA_PROF
profiteur $CLIENTA_PROF
profiterole $CLIENTB_PROF
profiteur $CLIENTB_PROF