-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathanalyze_results.sh
executable file
·101 lines (89 loc) · 4.27 KB
/
analyze_results.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
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
#!/usr/bin/env bash
#
# parse_results_new.sh
#
# Parses new logs named "emulator_SMP_{N}.log" (N=1..32). Each log's final lines look like:
#
# [SEMU LOG]: Real boot time: 233.04606 seconds, called 3628365913 times semu_timer_clocksource
# [SEMU LOG]: ns_per_call = 6.26153, predict_sec = 225.41525, scale_factor = 0.04436
# [SEMU LOG]: test_total_clocksource_ns = 92301869299, real_total_clocksource_ns = 46863590994, percentage = 0.20109
# [SEMU LOG]: real_ns_per_call = 12.91589, diff_ns_per_call = 6.65436
#
# We output results_summary.txt with 11 columns in tab-delimited format:
# 1) SMP
# 2) real_boot_time
# 3) times_called
# 4) ns_per_call
# 5) predict_sec
# 6) scale_factor
# 7) total_clocksource_ns
# 8) percentage
# 9) real_ns_per_call
# 10) diff_ns_per_call
#
# We specifically remove any ANSI color codes and ensure each line is a single line, so the output doesn't break.
for TAG in $(seq 1 7); do
BASEDIR="profile-2"
LOGDIR="logs-${TAG}" # Directory containing the log files
OUTFILE="$BASEDIR/results_summary-${TAG}.txt"
# Print header (11 columns)
echo -e "SMP real_boot_time times_called ns_per_call predict_sec scale_factor total_clocksource_ns percentage real_ns_per_call diff_ns_per_call" > "$OUTFILE"
for N in $(seq 1 32); do
FILE="$BASEDIR/$LOGDIR/emulator_SMP_${N}.log"
if [[ ! -f "$FILE" ]]; then
echo "Skipping N=$N; file not found: $FILE"
continue
fi
# Initialize variables
real_boot_time=""
times_called=""
ns_per_call=""
predict_sec=""
scale_factor=""
total_clocksource_ns=""
percentage=""
real_ns_per_call=""
diff_ns_per_call=""
# A helper function to grep for a specific pattern once, strip ANSI codes, unify line
grep_single_line() {
# Usage: grep_single_line "<pattern>"
# We'll grep for this pattern, take only the first match, remove color codes, unify line
grep -m1 "$1" "$FILE" \
| sed 's/\x1b\[[0-9;]*m//g' \
| tr '\n' ' '
}
# 1) Real boot time line
# e.g. "[SEMU LOG]: Real boot time: 233.04606 seconds, called 3628365913 times semu_timer_clocksource"
line_boot="$(grep_single_line 'Real boot time:')"
if [[ -n "$line_boot" ]]; then
# extract real_boot_time, times_called
real_boot_time="$(echo "$line_boot" | sed -E 's/.*Real boot time: (-?[0-9.]+) seconds, called ([0-9]+) .*/\1/')"
times_called="$(echo "$line_boot" | sed -E 's/.*Real boot time: (-?[0-9.]+) seconds, called ([0-9]+) .*/\2/')"
fi
# 2) ns_per_call line
# e.g.: "[SEMU LOG]: ns_per_call = 6.26153, predict_sec = 225.41525, scale_factor = 0.04436"
line_nscall="$(grep_single_line 'ns_per_call =')"
if [[ -n "$line_nscall" ]]; then
ns_per_call="$(echo "$line_nscall" | sed -E 's/.*ns_per_call = (-?[0-9.]+).*/\1/')"
predict_sec="$(echo "$line_nscall" | sed -E 's/.*predict_sec = (-?[0-9.]+).*/\1/')"
scale_factor="$(echo "$line_nscall" | sed -E 's/.*scale_factor = (-?[0-9.]+).*/\1/')"
fi
# 3) total_clocksource_ns line
# e.g. "[SEMU LOG]: test_total_clocksource_ns = 92301869299, real_total_clocksource_ns = 46863590994, percentage = 0.20109"
line_totals="$(grep_single_line 'total_clocksource_ns =')"
if [[ -n "$line_totals" ]]; then
total_clocksource_ns="$(echo "$line_totals" | sed -E 's/.*total_clocksource_ns = ([0-9]+).*/\1/')"
percentage="$(echo "$line_totals" | sed -E 's/.*percentage = (-?[0-9.]+).*/\1/')"
fi
# 4) real_ns_per_call line
# e.g. "[SEMU LOG]: real_ns_per_call = 12.91589, diff_ns_per_call = 6.65436"
line_realns="$(grep_single_line 'real_ns_per_call =')"
if [[ -n "$line_realns" ]]; then
real_ns_per_call="$(echo "$line_realns" | sed -E 's/.*real_ns_per_call = (-?[0-9.]+).*/\1/')"
diff_ns_per_call="$(echo "$line_realns" | sed -E 's/.*diff_ns_per_call = (-?[0-9.]+).*/\1/')"
fi
# Print a single line with 11 columns in tab-delimited format
echo -e "${N} ${real_boot_time} ${times_called} ${ns_per_call} ${predict_sec} ${scale_factor} ${total_clocksource_ns} ${percentage} ${real_ns_per_call} ${diff_ns_per_call}" >> "$OUTFILE"
done
done
echo "Data parsed and saved to $OUTFILE."