Created
May 25, 2019 09:54
-
-
Save cinek810/dadc19678db48f31109686142872b092 to your computer and use it in GitHub Desktop.
Enable profiling for setup module
This file contains hidden or 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
--- ansible_module_setup.py.bak 2019-05-25 09:51:33.891203596 +0000 | |
+++ ansible_module_setup.py 2019-05-25 09:53:31.361990970 +0000 | |
@@ -159,6 +159,11 @@ | |
# rename namespace_name to root_key? | |
namespace = PrefixFactNamespace(namespace_name='ansible', | |
prefix='ansible_') | |
+ #Enable profiling of interesting code | |
+ import cProfile, pstats | |
+ prof=cProfile.Profile() | |
+ prof.enable() | |
+ | |
fact_collector = \ | |
ansible_collector.get_ansible_collector(all_collector_classes=all_collector_classes, | |
@@ -170,7 +175,13 @@ | |
facts_dict = fact_collector.collect(module=module) | |
- module.exit_json(ansible_facts=facts_dict) | |
+ #Disable profiling and print results | |
+ prof.disable() | |
+ ps = pstats.Stats(prof).sort_stats('cumulative') | |
+ ps.print_stats() | |
+ | |
+ # Don't print result - we're only interested in getting execution statistics | |
+ # module.exit_json(ansible_facts=facts_dict) | |
if __name__ == '__main__': |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment