parameters: (fn, min_samples=10, max_samples=100, max_time_in_sec=10.0)
return_statement: return np.array(t) / 1e9
docstring: Measure time to run fn. Returns the elapsed time each run.
docstring_summary: Measure time to run fn. Returns the elapsed time each run.
docstring_tokens: Measure time to run fn . Returns the elapsed time each run .
function: def measure_time(fn, min_samples=10, max_samples=100, max_time_in_sec=10.0):
      """Measure time to run fn. Returns the elapsed time each run."""
      from time import perf_counter_ns
      t = []
      for i in range(max_samples):
          if sum(t) / 1e9 >= max_time_in_sec and i >= min_samples:
              break
          t.append(-perf_counter_ns())
          try:
              ans = fn()
          except Exception as e:
              print(e)
              return np.array([np.nan])
          t[-1] += perf_counter_ns()
          del ans
      print('.', end='')
      return np.array(t) / 1e9
function_tokens: def measure_time ( fn , min_samples = 10 , max_samples = 100 , max_time_in_sec = 10.0 ) : from time import perf_counter_ns t = [ ] for i in range ( max_samples ) : if sum ( t ) / 1e9 >= max_time_in_sec and i >= min_samples : break t . append ( - perf_counter_ns ( ) ) try : ans = fn ( ) except Exception as e : print ( e ) return np . array ( [ np . nan ] ) t [ - 1 ] += perf_counter_ns ( ) del ans print ( '.' , end = '' ) return np . array ( t ) / 1e9