]> arthur.barton.de Git - bup.git/commitdiff
Enable --profile for built-in subcommands
authorRob Browning <rlb@defaultvalue.org>
Wed, 2 Dec 2020 07:12:19 +0000 (01:12 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 6 Mar 2021 18:29:38 +0000 (12:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/cmd/bup

index 27276ad0a0b40f0df36b318467c1dd675fd4bfb1..ebe52a034bc015fb73c601926bb785e44aa2cbf1 100755 (executable)
@@ -257,7 +257,13 @@ def filter_output(src_out, src_err, dest_out, dest_err):
 def run_subcmd(module, args):
 
     if module:
-        return module.main(args)
+        if do_profile:
+            import cProfile
+            f = compile('module.main(args)', __file__, 'exec')
+            cProfile.runctx(f, globals(), locals())
+        else:
+            module.main(args)
+        return
 
     c = (do_profile and [sys.executable, b'-m', b'cProfile'] or []) + args
     if not (fix_stdout or fix_stderr):