@@ -6,7 +6,7 @@ if [ $# -lt 1 ]; then
6
6
fi
7
7
8
8
# Check if necessary commands are available
9
- commands=(" perf" " strip" " /usr/bin/time" " lscpu" )
9
+ commands=(" perf" " strip" " /usr/bin/time" " lscpu" " sha256sum " )
10
10
for cmd in " ${commands[@]} " ; do
11
11
if ! command -v $cmd & > /dev/null; then
12
12
echo " $cmd could not be found. Please install $cmd and try again."
@@ -28,9 +28,20 @@ ARCH_FLAGS=("-march=x86-64" "-march=x86-64-v2" "-march=x86-64-v3" "-march=x86-64
28
28
CPU_MODEL=$( lscpu | grep " Model name" | awk -F: ' {print $2}' | xargs)
29
29
VIRTUALIZATION=$( lscpu | grep " Virtualization" | awk -F: ' {print $2}' | xargs)
30
30
VIRT_TYPE=$( lscpu | grep " Hypervisor vendor" | awk -F: ' {print $2}' | xargs)
31
+ SHA=$( sha256sum " $SOURCE_FILE " | awk ' {print $1}' )
31
32
32
33
# CSV header
33
- echo " Timestamp,Compiler,Version,Optimization,Architecture,Additional Flags,CPU Model,Virtualization,Virtualization Type,File Size (bytes),Stripped Size (bytes),Run,Time (ms),RAM Usage (KB),Cycles,Cache References,Cache Misses,Cache Miss Ratio,Instructions,Instructions Per Cycle,Branches,Branch Misses,Branch Miss Ratio" > $OUTPUT_FILE
34
+ HEADER=" Timestamp,Compiler,Version,Optimization,Architecture,Additional Flags,CPU Model,Virtualization,Virtualization Type,SHA,File Size (bytes),Stripped Size (bytes),Time (ms),RAM Usage (KB),Cycles,Cache References,Cache Misses,Cache Miss Ratio,Instructions,Instructions Per Cycle,Branches,Branch Misses,Branch Miss Ratio"
35
+
36
+ # Check if the header exists and matches
37
+ if [ -f " $OUTPUT_FILE " ]; then
38
+ existing_header=$( head -n 1 " $OUTPUT_FILE " )
39
+ if [ " $existing_header " != " $HEADER " ]; then
40
+ echo " $HEADER " > " $OUTPUT_FILE "
41
+ fi
42
+ else
43
+ echo " $HEADER " > " $OUTPUT_FILE "
44
+ fi
34
45
35
46
# Function to extract and clean perf metrics
36
47
extract_perf_metrics () {
@@ -80,7 +91,7 @@ for compiler in "${COMPILERS[@]}"; do
80
91
metrics=$( extract_perf_metrics " $( cat perf_output.txt) " )
81
92
82
93
timestamp=$( date +" %Y-%m-%d %H:%M:%S" )
83
- echo " $timestamp ,$compiler ,$compiler_version ,$opt ,$arch ,\" $ADDITIONAL_FLAGS \" ,\" $CPU_MODEL \" ,\" $VIRTUALIZATION \" ,\" $VIRT_TYPE \" ,$ file_size ,$stripped_size ,$i , $ execution_time ,$ram_usage ,$metrics " >> $OUTPUT_FILE
94
+ echo " $timestamp ,$compiler ,$compiler_version ,$opt ,$arch ,\" $ADDITIONAL_FLAGS \" ,\" $CPU_MODEL \" ,\" $VIRTUALIZATION \" ,\" $VIRT_TYPE \" ,\" $SHA \" , $ file_size ,$stripped_size ,$execution_time ,$ram_usage ,$metrics " >> " $OUTPUT_FILE "
84
95
done
85
96
done
86
97
done
0 commit comments