-
-
Save effigies/183898aa6ef047eb8ef86f7e63f5528a to your computer and use it in GitHub Desktop.
Nipype import profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import psutil | |
import time | |
from importlib import import_module | |
P = psutil.Process() | |
def fingerprint(): | |
return {'modules': set(sys.modules), | |
'time': time.time(), | |
'memory': P.memory_info().vms / (1024 ** 2)} | |
fingerprints = [] | |
def load_module(*modules): | |
for module in modules: | |
import_module(module) | |
fingerprints.append((modules[0], fingerprint())) | |
for modules in (['sys'], | |
['numpy'], | |
['scipy', 'scipy.stats', 'scipy.optimize'], | |
['matplotlib'], | |
['nibabel'], | |
['networkx'], | |
['traits', 'traits.api'], | |
['pandas'], | |
['bids'], | |
['boto', 'boto.s3.connection'], | |
['paramiko'], | |
['nipype']): | |
load_module(*modules) | |
def diff_fingerprint(y, x): | |
return {'modules': y['modules'] - x['modules'], | |
'time': y['time'] - x['time'], | |
'memory': y['memory'] - x['memory']} | |
diffs = [ | |
(y[0], diff_fingerprint(y[1], x[1])) | |
for y, x in zip(fingerprints[1:], fingerprints[:-1])] | |
diffs.append(('Final', diff_fingerprint(fingerprints[-1][1], fingerprints[0][1]))) | |
for name, diff in diffs: | |
print("{}: {} modules; {:.02f}ms, {:.01f}MiB".format(name, len(diff['modules']), | |
diff['time'] * 1000, | |
diff['memory'])) | |
from pprint import pprint | |
pprint(diffs[-2][1]['modules']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numpy: 136 modules; 86.40ms, 115.6MiB | |
scipy: 263 modules; 272.23ms, 33.9MiB | |
matplotlib: 59 modules; 69.02ms, 4.1MiB | |
nibabel: 217 modules; 448.00ms, 21.4MiB | |
networkx: 236 modules; 119.20ms, 10.1MiB | |
traits: 36 modules; 21.03ms, 1.3MiB | |
pandas: 217 modules; 185.67ms, 25.8MiB | |
bids: 331 modules; 221.89ms, 18.3MiB | |
boto: 68 modules; 33.02ms, 4.0MiB | |
paramiko: 100 modules; 66.72ms, 2.1MiB | |
nipype: 53 modules; 37.30ms, 3.0MiB | |
Final: 1716 modules; 1560.49ms, 239.7MiB | |
{'_sqlite3', | |
'faulthandler', | |
'fcntl', | |
'future', | |
'future.standard_library', | |
'future.utils', | |
'nipype', | |
'nipype.external', | |
'nipype.external.cloghandler', | |
'nipype.external.due', | |
'nipype.external.portalocker', | |
'nipype.info', | |
'nipype.interfaces', | |
'nipype.interfaces.base', | |
'nipype.interfaces.base.core', | |
'nipype.interfaces.base.specs', | |
'nipype.interfaces.base.support', | |
'nipype.interfaces.base.traits_extension', | |
'nipype.interfaces.io', | |
'nipype.interfaces.utility', | |
'nipype.interfaces.utility.base', | |
'nipype.interfaces.utility.csv', | |
'nipype.interfaces.utility.wrappers', | |
'nipype.pipeline', | |
'nipype.pipeline.engine', | |
'nipype.pipeline.engine.base', | |
'nipype.pipeline.engine.nodes', | |
'nipype.pipeline.engine.utils', | |
'nipype.pipeline.engine.workflows', | |
'nipype.pkg_info', | |
'nipype.refs', | |
'nipype.utils', | |
'nipype.utils.config', | |
'nipype.utils.filemanip', | |
'nipype.utils.functions', | |
'nipype.utils.logger', | |
'nipype.utils.misc', | |
'nipype.utils.onetime', | |
'nipype.utils.provenance', | |
'nipype.utils.subprocess', | |
'nipype.utils.tmpdirs', | |
'packaging', | |
'packaging.__about__', | |
'packaging._structures', | |
'packaging.version', | |
'prov', | |
'prov.constants', | |
'prov.identifier', | |
'prov.model', | |
'prov.serializers', | |
'six.moves.urllib.parse', | |
'sqlite3', | |
'sqlite3.dbapi2'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment