-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_test.sh
executable file
·65 lines (49 loc) · 1.5 KB
/
load_test.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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: ./load_test.sh <server_port>"
exit 1
fi
# # Configuration
SERVER_IP="127.0.0.1" # Replace with actual server IP
PORT=$1 # Replace with actual port number
MAX_CLIENTS=10
MAX_COMMANDS=10
DIR="results"
results_file="$DIR/results.txt"
temp_file="$DIR/durations.txt"
if [ ! -d "results" ]; then
mkdir results
fi
# Results file
> "$results_file"
# Temporary file to store durations
> "$temp_file"
for ((clients=1; clients<=MAX_CLIENTS; clients++)); do
start_time=$(date +%s)
# Run clients in parallel and capture durations
for ((i=1; i<=$clients; i++)); do
(
# Simulate client interactions
./client "$SERVER_IP" "$PORT" < "input/inp_$i.txt"
# sleep 1
) &
done
wait
end_time=$(date +%s.%N)
total_time=$(echo "$end_time - $start_time" | bc)
# echo "$total_time" >> "$temp_file"
total_requests=$(echo "$clients*($MAX_COMMANDS+1)" | bc)
throughput=$(echo "$total_requests/$total_time" | bc -l)
echo "$clients $total_requests $throughput $total_time" >> "$results_file"
# sleep 5
# total_time=0
# while read -r line
# do
# total_time=$(echo "$total_time + $line" | bc -l)
# done < "$temp_file"
# echo "total: $total_time"
# echo "$clients $total_time" >> "$results_file"
done
# echo "python3 ./$DIR/plot.py ./$results_file"
python3 ./$DIR/plot.py ./$results_file
echo "Benchmark complete. Results in $results_file"