-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathefficiencyAnalysis.sh
More file actions
executable file
·56 lines (47 loc) · 1.83 KB
/
efficiencyAnalysis.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.83 KB
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
#!/bin/bash
# Script to test server efficiency.
# Usage: ./efficiencyAnalysis.sh
# Ensure the server is running
if ! pgrep -f "dserver" > /dev/null; then
echo "Error: The server is not running. Please start the server manually before running this script."
exit 1
fi
ITERATIONS=20
CONSULTS=10
SEARCH_KEYWORD="praia"
LOG_FILE="efficiency_results.log"
echo "Efficiency Analysis Results" > "$LOG_FILE"
echo "----------------------------------------" >> "$LOG_FILE"
echo "Iterations: $ITERATIONS" >> "$LOG_FILE"
echo "Files: $CONSULTS" >> "$LOG_FILE"
# Test 1: Consulting
START_TIME=$(date +%s.%N)
for ((i = i; i <= ITERATIONS; i++)); do
for ((j = 500; j <= CONSULTS + 500; j++)); do
./bin/dclient -c $j > /dev/null 2>&1
done
done
END_TIME=$(date +%s.%N)
# Calculate elapsed time for Test 1
TEST1_TIME=$(echo "$END_TIME - $START_TIME" | bc)
echo "Total Consulting Time: $TEST1_TIME seconds" >> "$LOG_FILE"
echo "----------------------------------------" >> "$LOG_FILE"
# Test 2: Searching with different processes
# Search with default processes
START_TIME=$(date +%s.%N)
./bin/dclient -s "$SEARCH_KEYWORD" > /dev/null 2>&1
END_TIME=$(date +%s.%N)
TEST2_TIME=$(echo "$END_TIME - $START_TIME" | bc)
echo "Total Time for '/bin/dclient -s $SEARCH_KEYWORD': $TEST2_TIME seconds" >> "$LOG_FILE"
# Search with 10 processes
START_TIME=$(date +%s.%N)
./bin/dclient -s "$SEARCH_KEYWORD" 10 > /dev/null 2>&1
END_TIME=$(date +%s.%N)
TEST2_TIME=$(echo "$END_TIME - $START_TIME" | bc)
echo "Total Time for '/bin/dclient -s $SEARCH_KEYWORD 10': $TEST2_TIME seconds" >> "$LOG_FILE"
# Search with 100 processes
START_TIME=$(date +%s.%N)
./bin/dclient -s "$SEARCH_KEYWORD" 100 > /dev/null 2>&1
END_TIME=$(date +%s.%N)
TEST2_TIME=$(echo "$END_TIME - $START_TIME" | bc)
echo "Total Time for '/bin/dclient -s $SEARCH_KEYWORD 100': $TEST2_TIME seconds" >> "$LOG_FILE"