Added output-folder for benchmarking and removed the requirement on X

pull/148/head
Cedric Nugteren 2017-04-14 20:32:28 +02:00
parent 8833ae51be
commit 56b2f46fbf
2 changed files with 7 additions and 3 deletions

View File

@ -73,6 +73,7 @@ def main(argv):
parser.add_argument("-l", "--load_from_disk", action="store_true", help="Increase verbosity of the script")
parser.add_argument("-t", "--plot_title", default=None, help="The title for the plots, defaults to benchmark name")
parser.add_argument("-z", "--tight_plot", action="store_true", help="Enables tight plot layout for in paper or presentation")
parser.add_argument("-o", "--output_folder", default=os.getcwd(), help="Sets the folder for output plots (defaults to current folder)")
parser.add_argument("-v", "--verbose", action="store_true", help="Increase verbosity of the script")
cl_args = parser.parse_args(argv)
@ -89,7 +90,7 @@ def main(argv):
benchmarks = experiment["benchmarks"]
# Either run the benchmarks for this experiment or load old results from disk
json_file_name = benchmark_name.lower() + "_benchmarks.json"
json_file_name = os.path.join(cl_args.output_folder, benchmark_name.lower() + "_benchmarks.json")
if cl_args.load_from_disk and os.path.isfile(json_file_name):
print("[benchmark] Loading previous benchmark results from '" + json_file_name + "'")
with open(json_file_name) as f:
@ -114,7 +115,8 @@ def main(argv):
json.dump(results, f, sort_keys=True, indent=4)
# Retrieves the data from the benchmark settings
pdf_file_name = benchmark_name.lower() + "_plot.pdf"
file_name_suffix = "_tight" if cl_args.tight_plot else ""
pdf_file_name = os.path.join(cl_args.output_folder, benchmark_name.lower() + "_plot" + file_name_suffix + ".pdf")
titles = [utils.precision_to_letter(cl_args.precision) + b["name"].upper() + " " + b["title"] for b in benchmarks]
x_keys = [b["x_keys"] for b in benchmarks]
y_keys = [b["y_keys"] for b in benchmarks]

View File

@ -6,6 +6,8 @@
import utils
import matplotlib
matplotlib.use('Agg')
from matplotlib import rcParams
import matplotlib.pyplot as plt
@ -112,5 +114,5 @@ def plot_graphs(results, file_name, num_rows, num_cols,
leg.draw_frame(False)
# Saves the plot to disk
print("[benchmark] Saving plot to '" + file_name + "'")
fig.savefig(file_name, bbox_inches=bounding_box)
# plt.show()