Skip to content

Instantly share code, notes, and snippets.

@nvdv
Last active October 5, 2016 09:48
Show Gist options
  • Save nvdv/40960e333187eaaf562a288613a3f981 to your computer and use it in GitHub Desktop.
Save nvdv/40960e333187eaaf562a288613a3f981 to your computer and use it in GitHub Desktop.
How profilers work - summary deterministic
def print_summary(stats, total_time):
print('Total time: %f s' % total_time)
for f_name in stats:
func_time = 0
for caller in stats[f_name]:
func_time += stats[f_name][caller]
percentage = float(func_time) / total_time
print('Function: %s, caller: %s, function run time: %f s, percentage: %f %%' % (
f_name, caller, func_time, 100 * percentage))
print_summary(stats, total_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment