log_calls
0.2.4.post5, profiling the decorator's wrapperThe PROFILE
stuff is commented out in log_calls.py
. Search #~ PROFILE
in that file. The relevant numbers:
# 0.2.4.post5+ profiling (of record_history):
setup_stackframe_hack 7.5 %
up_to__not_enabled_call 3.3 %
setup_context_init 1.2 %
setup_context_inspect_bind 23.4 %
setup_context_post_bind 8.8 %
setup_context_kwargs_dicts 32.2 %
pre_call_handlers 1.3 %
post_call_handlers 22.3 %
import numpy as np
from log_calls import record_history
@record_history()
def f(freq, t):
return np.sin(freq * 2 * np.pi * t)
ran_t = np.arange(0.0, 1.0, 1/44100, dtype=np.float32)
ran_t
Now, naively, call f 44,100 times in a for
loop:
for t in ran_t:
f(17, t)
# N = len(f.profile__['setup_stackframe_hack']) # any of the keys will do
sums = {}
for key in f.profile__:
sums[key] = sum(f.profile__[key])
total = sum([sums[k] for k in sums])
for key in f.profile__:
print("key: %s, time: %2.6f (%3.1f %%)" % (key, sums[key], 100*sums[key]/total ))