Skip to content

Commit

Permalink
Add compare scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohn123 committed Dec 6, 2024
1 parent 62e108c commit 5c55d81
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions result_compare/compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np
import os

results_folder = "results"
baseline_file = "baseline_dp_O3"

def read_result(file_path):
with open(file_path, 'r') as file:
data = file.read()
matrix = np.array([list(map(int, row.split(','))) for row in data.strip().split('\n')])
return matrix

baseline_matrix = read_result(os.path.join(results_folder, baseline_file))
print(f"Baseline file is {baseline_file}")

# Loop through all files in the results folder (excluding the baseline file)
for filename in sorted(os.listdir(results_folder)):

# Construct the full path of the current result file
file_path = os.path.join(results_folder, filename)

# Read the current result file into a NumPy array
result_matrix = read_result(file_path)

# Compare the result matrix with the baseline matrix
if np.array_equal(result_matrix, baseline_matrix):
print(f"File {filename} matches the baseline.")
#else:
# print(f"File {filename} does NOT match the baseline.")

9 changes: 9 additions & 0 deletions result_compare/generate_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

for file in ../build/bin/*; do
# extract filename from path
filename=$(basename $file)

echo -e "\tRunning $filename"
$file "results/$filename"
done

0 comments on commit 5c55d81

Please sign in to comment.