-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test_ubuntu.sh
41 lines (37 loc) · 1.31 KB
/
run_test_ubuntu.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
#!/bin/sh
FILE_EXTENSION="$(date +"%d-%m-%Y-%T")"
OUTPUT_FILE_NAME=test_results/ubuntu/test_output_$FILE_EXTENSION.txt
TIME_FILE_NAME=test_results/ubuntu/test_duration_$FILE_EXTENSION.txt
RESOURCES_FILE_NAME=test_results/ubuntu/test_internal_resources$FILE_EXTENSION.csv
START_TIMESTAMP=$(date "+%s")
monitorResources(){
PID=$1
echo $(ps | grep $PID)
echo "Timestamp;Cpu Usage%;Memory Usage%;" > "$RESOURCES_FILE_NAME"
TOTAL="$(free -m | grep Mem | tr -s ' ' | cut -d ' ' -f 2)"
while ps -p $PID 2> /dev/null
do
logResources
done
}
logResources(){
DATETIME=$(date +"%s")
TIMESTAMP=$(($DATETIME - $START_TIMESTAMP))
echo -n "$DATETIME;" >> "$RESOURCES_FILE_NAME"
echo -n "$TIMESTAMP;" >> "$RESOURCES_FILE_NAME"
CPU_IDL=$(mpstat 1 1 | tr ' ' '\n' | tail -n 1)
echo -n "$(echo "scale = 4; (100 - $CPU_IDL) / 100" | bc);" >> "$RESOURCES_FILE_NAME"
FREE_DATA=`free -m | grep Mem`
CURRENT=`echo $FREE_DATA | cut -f3 -d' '`
TOTAL=`echo $FREE_DATA | cut -f2 -d' '`
echo "$(echo "scale = 4; $CURRENT/$TOTAL" | bc);" >> "$RESOURCES_FILE_NAME"
sleep 1
}
cd /php-src
mkdir -p test_results/ubuntu/
{ time make -j $(nproc) 1> $OUTPUT_FILE_NAME ; } 2> $TIME_FILE_NAME &
monitorResources "$!"
wait
cat "$OUTPUT_FILE_NAME"
cat "$TIME_FILE_NAME"
cat "$RESOURCES_FILE_NAME"