Skip to content
Snippets Groups Projects
Commit 93067d0d authored by Todd Gamblin's avatar Todd Gamblin
Browse files

Add profile option to spack script.

parent 457f2d1d
Branches
No related tags found
No related merge requests found
...@@ -58,14 +58,16 @@ parser = argparse.ArgumentParser( ...@@ -58,14 +58,16 @@ parser = argparse.ArgumentParser(
description='Spack: the Supercomputing PACKage Manager.') description='Spack: the Supercomputing PACKage Manager.')
parser.add_argument('-V', '--version', action='version', parser.add_argument('-V', '--version', action='version',
version="%s" % spack.spack_version) version="%s" % spack.spack_version)
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', parser.add_argument('-v', '--verbose', action='store_true',
help="Print additional output during builds") help="Print additional output during builds")
parser.add_argument('-d', '--debug', action='store_true', dest='debug', parser.add_argument('-d', '--debug', action='store_true',
help="Write out debug logs during compile") help="Write out debug logs during compile")
parser.add_argument('-k', '--insecure', action='store_true', dest='insecure', parser.add_argument('-k', '--insecure', action='store_true',
help="Do not check ssl certificates when downloading archives.") help="Do not check ssl certificates when downloading archives.")
parser.add_argument('-m', '--mock', action='store_true', dest='mock', parser.add_argument('-m', '--mock', action='store_true',
help="Use mock packages instead of real ones.") help="Use mock packages instead of real ones.")
parser.add_argument('-p', '--profile', action='store_true',
help="Profile execution using cProfile.")
# each command module implements a parser() function, to which we pass its # each command module implements a parser() function, to which we pass its
# subparser for setup. # subparser for setup.
...@@ -85,6 +87,7 @@ if len(sys.argv) == 1: ...@@ -85,6 +87,7 @@ if len(sys.argv) == 1:
# actually parse the args. # actually parse the args.
args = parser.parse_args() args = parser.parse_args()
def main():
# Set up environment based on args. # Set up environment based on args.
tty.set_verbose(args.verbose) tty.set_verbose(args.verbose)
tty.set_debug(args.debug) tty.set_debug(args.debug)
...@@ -124,3 +127,9 @@ elif isinstance(return_val, int): ...@@ -124,3 +127,9 @@ elif isinstance(return_val, int):
sys.exit(return_val) sys.exit(return_val)
else: else:
tty.die("Bad return value from command %s: %s" % (args.command, return_val)) tty.die("Bad return value from command %s: %s" % (args.command, return_val))
if args.profile:
import cProfile
cProfile.run('main()', sort='tottime')
else:
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment