title: Uncertain Runtime of Jupyter Notebook
body: <p>I have been working on some code for computing a stochastic function. I have written the code in Cython, but when I analyze the run-time of the code in the cell I get runtimes that are not constant, but grossly vary. More specifically, one iteration of the code gave a runtime of 0.95s but now gives a 4s runtime for the same iteration. Any guidance in understanding this phenomenon would be very much appreciated. I am currently using Windows 1.5 8th Gen.</p>
  <p>The code is provided below:</p>
  <pre><code>%%cython
  cimport numpy as nc
  from libc.math cimport log, sqrt, pi, cos
  
  from random import uniform
  
  def Stochastic(double h, long T, nc.ndarray prime_list) -&gt; double:
      assert T &lt; 10000000000, 'Our prime list does not exceed the value 10^10'
      
      cdef double ret_val = 0.0
      cdef long p = 0
      cdef double upper = 2 * pi
      
      # filter the primes up to and including the value of T
      cdef nc.ndarray primes = prime_list[prime_list &lt;= T]
      
      # iterate over the primes using the specified model 
      for p in primes: 
          ret_val += ( 1/sqrt(p) * cos(uniform(0, upper) - h*log(p)) )
          
      return ret_val
  </code></pre>
  <p>With execution in another cell</p>
  <pre><code>T_val = int(1e6)
  prime_num = 'Externally read prime list from txt file'
  x = np.arange(-1,1,1/np.round(np.log(T_val)))
  
  start_time = default_timer()
  [[Stochastic(h=i, T=T_val, prime_list=prime_num) for i in x]]
  print(default_timer() - start_time)
  </code></pre>
  <p>Runtimes have been 0.95, 4.6, 2.5, etc</p>