Skip to content

Commit 5c55d81

Browse files
committed
Add compare scripts.
1 parent 62e108c commit 5c55d81

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

result_compare/compare.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import numpy as np
2+
import os
3+
4+
results_folder = "results"
5+
baseline_file = "baseline_dp_O3"
6+
7+
def read_result(file_path):
8+
with open(file_path, 'r') as file:
9+
data = file.read()
10+
matrix = np.array([list(map(int, row.split(','))) for row in data.strip().split('\n')])
11+
return matrix
12+
13+
baseline_matrix = read_result(os.path.join(results_folder, baseline_file))
14+
print(f"Baseline file is {baseline_file}")
15+
16+
# Loop through all files in the results folder (excluding the baseline file)
17+
for filename in sorted(os.listdir(results_folder)):
18+
19+
# Construct the full path of the current result file
20+
file_path = os.path.join(results_folder, filename)
21+
22+
# Read the current result file into a NumPy array
23+
result_matrix = read_result(file_path)
24+
25+
# Compare the result matrix with the baseline matrix
26+
if np.array_equal(result_matrix, baseline_matrix):
27+
print(f"File {filename} matches the baseline.")
28+
#else:
29+
# print(f"File {filename} does NOT match the baseline.")
30+

result_compare/generate_results.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
for file in ../build/bin/*; do
4+
# extract filename from path
5+
filename=$(basename $file)
6+
7+
echo -e "\tRunning $filename"
8+
$file "results/$filename"
9+
done

0 commit comments

Comments
 (0)