code: def timed(func, setup="pass", limit=None):
      """Adaptively measure execution time of a function."""
      timer = timeit.Timer(func, setup=setup)
      repeat, number = 3, 1
  
      for i in range(1, 10):
          if timer.timeit(number) >= 0.2:
              break
          elif limit is not None and number >= limit:
              break
          else:
              number *= 10
  
      time = min(timer.repeat(repeat, number)) / number
  
      if time > 0.0:
          order = min(-int(math.floor(math.log10(time)) // 3), 3)
      else:
          order = 3
  
      return (number, time, time * _scales[order], _units[order])
  
imports: import timeit
  import math
label_desc: Use image node_id 1 for calling a global function with example usage: timed(func, setup, limit) and returns: number,  time,  unknown,  _units