diff package_output.py @ 19:cefa7625d6cb draft

planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 2840545abeeca2dc0a6e6df138633e561d379e52
author richard-burhans
date Thu, 01 Aug 2024 18:39:46 +0000
parents 4966e095e3c3
children
line wrap: on
line diff
--- a/package_output.py	Wed Jul 31 02:40:51 2024 +0000
+++ b/package_output.py	Thu Aug 01 18:39:46 2024 +0000
@@ -4,12 +4,16 @@
 import configparser
 import json
 import os
+import resource
 import sys
 import tarfile
+import time
 import typing
 
 import bashlex
 
+RUSAGE_ATTRS: typing.Final = ["ru_utime", "ru_stime", "ru_maxrss", "ru_minflt", "ru_majflt", "ru_inblock", "ru_oublock", "ru_nvcsw", "ru_nivcsw"]
+
 
 class PackageFile:
     def __init__(
@@ -303,8 +307,13 @@
     parser = argparse.ArgumentParser()
     parser.add_argument("--tool_directory", type=str, required=True, help="tool directory")
     parser.add_argument("--format_selector", type=str, required=True, help="format selector")
+    parser.add_argument("--debug", action="store_true", help="enable debug messages")
     args = parser.parse_args()
 
+    if args.debug:
+        r_beg = resource.getrusage(resource.RUSAGE_SELF)
+        beg: int = time.monotonic_ns()
+
     lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini")
 
     config: configparser.ConfigParser = configparser.ConfigParser()
@@ -315,6 +324,14 @@
     bashCommandLineFile(lastz_command_file, config, args, package_file)
     package_file.close()
 
+    if args.debug:
+        ns: int = time.monotonic_ns() - beg
+        r_end = resource.getrusage(resource.RUSAGE_SELF)
+        print(f"package output clock time: {ns} ns", file=sys.stderr, flush=True)
+        for rusage_attr in RUSAGE_ATTRS:
+            value = getattr(r_end, rusage_attr) - getattr(r_beg, rusage_attr)
+            print(f"  package output {rusage_attr}: {value}", file=sys.stderr, flush=True)
+
 
 if __name__ == "__main__":
     main()