-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the performance testing grading script.
(Not me procrastinating this until the night Gazprea 2 is due...)
- Loading branch information
1 parent
a938b00
commit 11a8549
Showing
6 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
============================== 415 Grading Script ============================== | ||
Author: Justin Meimar | ||
Name: grade_perf.py | ||
Desc: Dragon-runner with a config pointing to the performance tests & an | ||
executable for each compiler to be tested, when run with --mode=perf, | ||
will produce a perf.csv file. | ||
This script takes perf.csv as its input and runs the performance testing | ||
grading algorithm to return a single CSV row, indicating the perf scores | ||
for each team. | ||
The intention is that the single row be manually copy and pasted into the | ||
row output by the grade.py script. | ||
================================================================================ | ||
""" | ||
import argparse | ||
import csv | ||
import numpy as np | ||
from pathlib import Path | ||
|
||
def grade_perf(*args): | ||
""" | ||
Run the tournament for each tournament csv then average all the | ||
toolchain tables. Write all the tables including the average to | ||
the final grade_path | ||
""" | ||
|
||
if len(args) < 2: | ||
print("Must supply two arguments: <perf_csv> <output_csv>") | ||
return 1 | ||
|
||
with open(args[0], "r") as perf_csv: | ||
reader = csv.reader(perf_csv) | ||
headers = next(reader) | ||
test_data = list(reader) | ||
|
||
# test_names = [row[0] for row in test_data] | ||
raw_times = np.array([[float(x) for x in row[1:]] for row in test_data]) | ||
|
||
scores = [] | ||
for times in raw_times: | ||
fastest_time = min(times) | ||
test_scores = [fastest_time / time for time in times] | ||
scores.append(test_scores) | ||
total_scores = np.mean(scores, axis=0) | ||
|
||
print(headers[1:]) | ||
print(total_scores) | ||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"perf_csv", | ||
type=Path, | ||
nargs="+", | ||
help="Path to one or more csv files generated from grade mode" | ||
) | ||
parser.add_argument( | ||
"output_csv", | ||
type=Path, | ||
help="Path to final output csv with grades" | ||
) | ||
|
||
args = parser.parse_args() | ||
grade_perf(args.perf_csv, args.output_csv) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"testDir": "../packages/CPackage/RegularPass/", | ||
"testedExecutablePaths": { | ||
"gcc1": "/usr/bin/gcc", | ||
"gcc2": "/usr/bin/gcc", | ||
"gcc3": "/usr/bin/gcc" | ||
}, | ||
"toolchains": { | ||
"GCC-toolchain": [ | ||
{ | ||
"stepName": "compile", | ||
"executablePath": "$EXE", | ||
"arguments": ["$INPUT", "-o", "$OUTPUT"], | ||
"output": "/tmp/test.o", | ||
"allowError": true | ||
}, | ||
{ | ||
"stepName": "run", | ||
"executablePath": "$INPUT", | ||
"arguments": [], | ||
"usesInStr": true, | ||
"allowError": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ int main() { | |
return 0; | ||
} | ||
|
||
//CHECK:DivideByZeroError: | ||
//CHECK:DivideByZeroError: |