Skip to content

Instantly share code, notes, and snippets.

@iht
Last active November 22, 2020 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iht/ced8c3431940b3795a69b33e64f8fb26 to your computer and use it in GitHub Desktop.
Save iht/ced8c3431940b3795a69b33e64f8fb26 to your computer and use it in GitHub Desktop.
Find all the external functions called by my code
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