forked from michetti/holychat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_experiment.sh
executable file
·63 lines (51 loc) · 1.64 KB
/
run_experiment.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
#!/bin/bash
LOG_DIR=~/workspace
CLIENT_LOG_DIR=~/workspace
CLIENT_PATH=~/workspace/ajaxChat
NUM_EXPERIMENTS=1
((TOTAL_EXPERIMENTS=($NUM_EXPERIMENTS*8)))
function log {
echo [ `date '+%d/%m/%Y %X'` ] $1
}
function get_time {
date --utc --date "$(date '+%Y-%m-%d %H:%M:%S')" +%s
}
if [ ! -d $LOG_DIR ]; then
echo "No log dir found"
exit 1
fi
COUNTER=1
EXPERIMENT_COUNTER=1
GLOBAL_START_TIME=$(get_time)
#Message size
for ms in 50 100; do
# Client number
for cn in 2 4; do
#Behavior (random or regular)
for be in 0 1; do
for((i=1; i<=$NUM_EXPERIMENTS; i++)); do
log "Starting experiment $COUNTER of $TOTAL_EXPERIMENTS"
START_TIME=$(get_time)
#Start the server
node holychat.js > $LOG_DIR"/server_aj_"$EXPERIMENT_COUNTER"_"$i"_"$ms"_"$cn"_"$be".csv" &
SERVER_PID=$!
sleep 2
#Start the client remotely
ssh $CLIENT_URL "cd $CLIENT_PATH && node benchmark.js $cn 5 $ms 200 400 $be > $CLIENT_LOG_DIR/client_aj_"$EXPERIMENT_COUNTER"_"$i"_"$ms"_"$cn"_"$be".csv"
sleep 2
END_TIME=$(get_time)
#Kill the server
kill $SERVER_PID
sleep 2
((TOTAL_TIME=($END_TIME-$START_TIME)))
log "Execution time: $TOTAL_TIME seconds"
let COUNTER++
done
let EXPERIMENT_COUNTER++
done
done
done
GLOBAL_END_TIME=$(get_time)
((GLOBAL_TOTAL_TIME=($GLOBAL_END_TIME-$GLOBAL_START_TIME)))
log "======= TOTAL EXECUTION TIME: $GLOBAL_TOTAL_TIME"