In [1]:
import jittermodel
from jittermodel.base import Cantilever, Transistor, Experiment
from jittermodel.plot import GeneratePlotData
from jittermodel import u
import cProfile
import pstats
def make_plot():
c1 = Cantilever()
t1 = Transistor(h=70*u.nm)
e1 = Experiment()
gpd = GeneratePlotData(c1, t1, e1, 'd', (40*u.nm, 500*u.nm))
V_g_vals = (1*u.V, 20*u.V, 40*u.V)
gpd.calc_plot_data('jitter', 'd', 'V_g', V_g_vals,
x_scale='log', n_pts=5)
In [2]:
def my_profile():
cProfile.run('make_plot()', 'unit_stats')
p = pstats.Stats('unit_stats')
p.strip_dirs()
p.sort_stats('time').print_stats(10)
In [3]:
my_profile()
We see that _corr_integrand
(3.6), coth
(2.845), and _im_dielectric
(2.155) take the vast majority of the time . We can try changing this by optimizing these functions. First, let's try removing the coth
function call, instead calling 1\tanh
.
In [22]:
my_profile()
Wow! We see that eliminating this one function call reduced the execution time by 1.6 seconds! Let's try removing some boilerplate type checking in these critical functions.
In [3]:
my_profile()
In [9]:
my_profile()
In [ ]: