Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0d7fc6

Browse files
authoredMay 22, 2024··
Update run_performance_tests.sh
1 parent 32e498e commit c0d7fc6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
 

‎parallel_algorithms/run_performance_tests.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ $# -lt 1 ]; then
66
fi
77

88
# Check if necessary commands are available
9-
commands=("perf" "strip" "/usr/bin/time" "lscpu")
9+
commands=("perf" "strip" "/usr/bin/time" "lscpu" "sha256sum")
1010
for cmd in "${commands[@]}"; do
1111
if ! command -v $cmd &> /dev/null; then
1212
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
2828
CPU_MODEL=$(lscpu | grep "Model name" | awk -F: '{print $2}' | xargs)
2929
VIRTUALIZATION=$(lscpu | grep "Virtualization" | awk -F: '{print $2}' | xargs)
3030
VIRT_TYPE=$(lscpu | grep "Hypervisor vendor" | awk -F: '{print $2}' | xargs)
31+
SHA=$(sha256sum "$SOURCE_FILE" | awk '{print $1}')
3132

3233
# 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
3445

3546
# Function to extract and clean perf metrics
3647
extract_perf_metrics() {
@@ -80,7 +91,7 @@ for compiler in "${COMPILERS[@]}"; do
8091
metrics=$(extract_perf_metrics "$(cat perf_output.txt)")
8192

8293
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"
8495
done
8596
done
8697
done

0 commit comments

Comments
 (0)
Please sign in to comment.