Last active
November 22, 2020 00:21
-
-
Save iht/ced8c3431940b3795a69b33e64f8fb26 to your computer and use it in GitHub Desktop.
Find all the external functions called by my code
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
def find_external_functions(key, stats): | |
output = {} | |
for k,v in stats.items(): | |
_, _, _, _, d = v | |
if key in d: | |
output[k] = v | |
return output | |
# Let's assume that we want to find all the code called from mykeys[1] | |
external_stats = find_external_functions(mykeys[1], stats_dict) | |
percall = {} | |
for k,v in external_stats.items(): | |
_, ncalls, _, cumtime, _ = v | |
avg_time = cumtime/ncalls | |
percall[k] = avg_time | |
sorted(percall.items(), key=lambda x: x[1], reverse=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment