def profiler(func, n):
  prof = cProfile.Profile()
  prof = prof.runctx((func.__name__, n) % '%s(%d)', globals(), locals())
  stats = pstats.Stats(prof)
  stats.strip_dirs()
  stats.sort_stats('time')  # 'time', 'cumulative' or 'calls'
  stats.print_stats(20)  # Arg: how many to print (optional)
  # Uncomment (and tweak) the following calls for more details.
  # stats.print_callees(100)
  # stats.print_callers(100)
dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/tests/kobench.py/profiler/swapped operands of `%`