Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / histogram / benchmark / run_benchmarks.py
index 439c439..db10550 100755 (executable)
@@ -1,5 +1,13 @@
 #!/usr/bin/env python3
+
+# Copyright Hans Dembinski 2019
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
 """
+This script runs the benchmarks on previous versions of this library to track changes
+in performance.
+
 Run this from a special build directory that uses the benchmark folder as root
 
     cd my_build_dir
@@ -78,13 +86,22 @@ def run(results, comments, hash, update):
 def main():
     commits, comments = get_commits()
 
-    parser = argparse.ArgumentParser()
-    parser.add_argument("first", type=str, nargs="?", default=commits[0])
-    parser.add_argument("last", type=str, nargs="?", default=commits[-1])
-    parser.add_argument("-f", action="store_true")
+    parser = argparse.ArgumentParser(description=__doc__,
+                                     formatter_class=argparse.RawDescriptionHelpFormatter)
+    parser.add_argument("first", type=str, default="begin",
+                        help="first commit in range, special value `begin` is allowed")
+    parser.add_argument("last", type=str, default="end",
+                        help="last commit in range, special value `end` is allowed")
+    parser.add_argument("-f", action="store_true",
+                        help="override previous results")
 
     args = parser.parse_args()
 
+    if args.first == "begin":
+        args.first = commits[0]
+    if args.last == "end":
+        args.last = commits[-1]
+
     with shelve.open("benchmark_results") as results:
         a = commits.index(args.first)
         b = commits.index(args.last)