code: def timer(name, func, once=False) -> float:
      logger.info(f"Measuring {name}")
      t1 = perf_counter()
      res = func()
      t2 = perf_counter()
      t = t2 - t1
      repeat = 1
      if not once and t < 1.0:
          repeat = int(2.0 // t)
          logger.info(
              f"Time for {name}: {t:.3f} seconds, repeating {repeat} times"
          )
          t1 = perf_counter()
          for _ in range(repeat):
              res = func()
          t2 = perf_counter()
          t = (t2 - t1) / repeat
      logger.info(f"Time for {name}: {t:.3f} seconds")
      return res, t, repeat
  
file_path: faiss/benchs/bench_fw/utils.py
imports: from time import perf_counter
  import logging
  from multiprocessing.pool import ThreadPool
  import numpy
  import faiss
  import functools
label_desc: Use image node_id 1 for calling a global function with example usage: timer(name, func, once) and returns: res,  t,  repeat