log_calls 0.2.4.post5, profiling the decorator's wrapper

The 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 %
In [30]:
import numpy as np

from log_calls import record_history
In [31]:
@record_history()
def f(freq, t):
    return np.sin(freq * 2 * np.pi * t)
In [32]:
ran_t = np.arange(0.0, 1.0, 1/44100, dtype=np.float32)
ran_t
Out[32]:
array([  0.00000000e+00,   2.26757365e-05,   4.53514731e-05, ...,
         9.99931931e-01,   9.99954641e-01,   9.99977291e-01], dtype=float32)

Now, naively, call f 44,100 times in a for loop:

In [33]:
for t in ran_t: 
    f(17, t)
In [29]:
# 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 ))
key: setup_stackframe_hack, time: 0.558073 (7.5 %)
key: up_to__not_enabled_call, time: 0.247157 (3.3 %)
key: setup_context_init, time: 0.091691 (1.2 %)
key: setup_context_inspect_bind, time: 1.755684 (23.4 %)
key: setup_context_post_bind, time: 0.658069 (8.8 %)
key: setup_context_kwargs_dicts, time: 2.409068 (32.2 %)
key: pre_call_handlers, time: 0.097221 (1.3 %)
key: post_call_handlers, time: 1.670122 (22.3 %)