summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-04-14 20:32:28 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-04-14 20:32:28 +0200
commit56b2f46fbfe37cd0c7abbe07b3e4dad460076f06 (patch)
tree10cfa1307d72cd96b7cdfc9e2d2218adb9f4396c /scripts
parent8833ae51be466686c7b5950ac8b5e598ce7012d0 (diff)
Added output-folder for benchmarking and removed the requirement on X
Diffstat (limited to 'scripts')
-rw-r--r--scripts/benchmark/benchmark.py6
-rw-r--r--scripts/benchmark/plot.py4
2 files changed, 7 insertions, 3 deletions
diff --git a/scripts/benchmark/benchmark.py b/scripts/benchmark/benchmark.py
index 85323fd1..cfc1c402 100644
--- a/scripts/benchmark/benchmark.py
+++ b/scripts/benchmark/benchmark.py
@@ -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]
diff --git a/scripts/benchmark/plot.py b/scripts/benchmark/plot.py
index 275a3ba8..0cb6d8c5 100644
--- a/scripts/benchmark/plot.py
+++ b/scripts/benchmark/plot.py
@@ -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()