Fix: missing "fs" to template variable
[lttng-ci.git] / scripts / babeltrace-benchmark / benchmark.py
index f43830a9c3f5b782113aadbc1718e94fc400e4d1..c31f87b0a219587404711a536678167d4f0bbc8f 100644 (file)
@@ -39,6 +39,17 @@ BENCHMARK_TYPES = ["dummy", "text"]
 DEFAULT_BUCKET = "lava"
 
 
+def json_type(string):
+    """
+    Argpase type for json args.
+    We expect a base dictionary.
+    """
+    passed_json = json.loads(string)
+    if not isinstance(passed_json, dict):
+        msg = "%r is not a dict" % string
+        raise argparse.ArgumentTypeError(msg)
+    return passed_json
+
 def graph_get_color(branch):
     """
     Get the color matching the branch.
@@ -186,6 +197,7 @@ def plot_raw_value(branch, benchmark_type, x_data, y_data, labels, latest_values
     plt.ylabel("User + system time (s)")
     plt.xlabel("Latest commits")
     plt.legend()
+    plt.grid(True)
 
     # Put tick on the right side
     ax.tick_params(labeltop=False, labelright=True)
@@ -193,7 +205,10 @@ def plot_raw_value(branch, benchmark_type, x_data, y_data, labels, latest_values
     plt.tight_layout()
     return
 
-def plot_delta_between_point(branch, benchmark_type, x_data, y_data, labels, latest_values):
+
+def plot_delta_between_point(
+    branch, benchmark_type, x_data, y_data, labels, latest_values
+):
     """
     Plot the graph of delta between each sequential commit.
     """
@@ -218,10 +233,14 @@ def plot_delta_between_point(branch, benchmark_type, x_data, y_data, labels, lat
 
     ax = plt.gca()
     plt.xticks(x_data, labels, rotation=90, family="monospace")
-    plt.title(graph_get_title(branch, benchmark_type) + " Delta to previous commit", fontweight="bold")
+    plt.title(
+        graph_get_title(branch, benchmark_type) + " Delta to previous commit",
+        fontweight="bold",
+    )
     plt.ylabel("Seconds")
     plt.xlabel("Latest commits")
     plt.legend()
+    plt.grid(True)
 
     # Put tick on the right side
     ax.tick_params(labeltop=False, labelright=True)
@@ -229,6 +248,7 @@ def plot_delta_between_point(branch, benchmark_type, x_data, y_data, labels, lat
     plt.tight_layout()
     return
 
+
 def plot_ratio(branch, benchmark_type, x_data, y_data, labels, latest_values):
     """
     Plot the graph using a ratio using first point as reference (0%).
@@ -281,6 +301,7 @@ def plot_ratio(branch, benchmark_type, x_data, y_data, labels, latest_values):
     plt.ylabel("Ratio")
     plt.xlabel("Latest commits")
     plt.legend()
+    plt.grid(True)
 
     # Put tick on the right side
     ax.tick_params(labeltop=False, labelright=True)
@@ -288,6 +309,7 @@ def plot_ratio(branch, benchmark_type, x_data, y_data, labels, latest_values):
     plt.tight_layout()
     return
 
+
 def generate_graph(branches, report_name, git_path):
 
     # The PDF document
@@ -348,7 +370,9 @@ def generate_graph(branches, report_name, git_path):
             pdf_pages.savefig(fig)
 
             fig = plt.figure(figsize=(width, 8.27), dpi=100)
-            plot_delta_between_point(branch, b_type, x_data, y_data, labels, latest_values)
+            plot_delta_between_point(
+                branch, b_type, x_data, y_data, labels, latest_values
+            )
             pdf_pages.savefig(fig)
 
     pdf_pages.close()
@@ -410,9 +434,19 @@ def main():
     parser.add_argument(
         "--repo-path", help="The location of the git repo to use.", required=True
     )
+    parser.add_argument(
+        "--overwrite-branches-cutoff",
+        help="A dictionary of the form {"
+        "'branch_name': 'commit_hash_cutoff',...}. Allow custom graphing and"
+        "jobs generation.",
+        required=False, type=json_type
+    )
 
     args = parser.parse_args()
 
+    if args.overwrite_branches_cutoff:
+        bt_branches = args.overwrite_branches_cutoff
+
     if not os.path.exists(args.repo_path):
         print("Repository location does not exists.")
         return 1
This page took 0.026681 seconds and 4 git commands to generate.