#!/opt/cloudlinux/venv/bin/python3 # # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 2008-2016 California Institute of Technology. # Copyright (c) 2016-2023 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - https://github.com/uqfoundation/dill/blob/master/LICENSE ''' build profile graph for the given instance running: $ get_gprof <args> <instance> executes: gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png where: <args> are arguments for gprof2dot, such as "-n 5 -e 5" <instance> is code to create the instance to profile <type> is the class of the instance (i.e. type(instance)) For example: $ get_gprof -n 5 -e 1 "import numpy; numpy.array([1,2])" will create 'ndarray.call.png' with the profile graph for numpy.array([1,2]), where '-n 5' eliminates nodes below 5% threshold, similarly '-e 1' eliminates edges below 1% threshold ''' import sys # grab args for gprof2dot args = sys.argv[1:-1] args = ' '.join(args) # last arg builds the object obj = sys.argv[-1] obj = obj.split(';') # multi-line prep for generating an instance for line in obj[:-1]: exec(line) # one-line generation of an instance obj = eval(obj[-1]) # get object 'name' objtype = type(obj) name = getattr(objtype, '__name__', getattr(objtype, '__class__', objtype)) # profile dumping an object import dill import os import cProfile #name = os.path.splitext(os.path.basename(__file__))[0] cProfile.run("dill.dumps(obj)", filename="%s.prof" % name) msg = "gprof2dot -f pstats %s %s.prof | dot -Tpng -o %s.call.png" % (args, name, name) os.system(msg) # get stats f_prof = "%s.prof" % name import pstats stats = pstats.Stats(f_prof, stream=sys.stdout) stats.strip_dirs().sort_stats('cumtime') stats.print_stats(20) #XXX: save to file instead of print top 20? os.remove(f_prof)
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Activate.ps1 | File | 8.82 KB | 0644 |
|
activate | File | 1.65 KB | 0644 |
|
activate.csh | File | 913 B | 0644 |
|
activate.fish | File | 2.14 KB | 0644 |
|
alembic | File | 229 B | 0755 |
|
chardetect | File | 237 B | 0755 |
|
cl_sysctl | File | 4.51 KB | 0755 |
|
clcpapi | File | 3.64 KB | 0755 |
|
coverage | File | 231 B | 0755 |
|
coverage-3.11 | File | 231 B | 0755 |
|
coverage3 | File | 231 B | 0755 |
|
cpanel-dbmapping | File | 3.83 KB | 0755 |
|
da_suid_caller.py | File | 686 B | 0644 |
|
detect-requirements | File | 238 B | 0755 |
|
dodgy | File | 224 B | 0755 |
|
epylint | File | 235 B | 0755 |
|
f2py | File | 232 B | 0755 |
|
f2py3 | File | 232 B | 0755 |
|
f2py3.11 | File | 232 B | 0755 |
|
flake8 | File | 230 B | 0755 |
|
futurize | File | 231 B | 0755 |
|
get_gprof | File | 1.84 KB | 0755 |
|
get_objgraph | File | 1.63 KB | 0755 |
|
isort | File | 225 B | 0755 |
|
isort-identify-imports | File | 259 B | 0755 |
|
jsonschema | File | 229 B | 0755 |
|
lvestats_config_reader.py | File | 1.12 KB | 0644 |
|
mako-render | File | 229 B | 0755 |
|
normalizer | File | 260 B | 0755 |
|
pasteurize | File | 233 B | 0755 |
|
pip | File | 237 B | 0755 |
|
pip3 | File | 237 B | 0755 |
|
pip3.11 | File | 237 B | 0755 |
|
plesk_suid_caller.py | File | 905 B | 0644 |
|
prospector | File | 229 B | 0755 |
|
py.test | File | 237 B | 0755 |
|
pycodestyle | File | 228 B | 0755 |
|
pydocstyle | File | 229 B | 0755 |
|
pyflakes | File | 227 B | 0755 |
|
pylint | File | 233 B | 0755 |
|
pylint-config | File | 249 B | 0755 |
|
pyreverse | File | 239 B | 0755 |
|
pysemver | File | 225 B | 0755 |
|
pytest | File | 237 B | 0755 |
|
python | File | 15.59 KB | 0755 |
|
python3 | File | 15.59 KB | 0755 |
|
python3.11 | File | 15.59 KB | 0755 |
|
raven | File | 235 B | 0755 |
|
symilar | File | 235 B | 0755 |
|
tap | File | 223 B | 0755 |
|
tappy | File | 223 B | 0755 |
|
undill | File | 603 B | 0755 |
|
virtualenv | File | 254 B | 0755 |
|