code: def timeit_profile(stmt, number, repeat, setup,
                     profiler_factory, pickle_protocol, dump_filename, mono,
                     **_ignored):
      
      del _ignored
      globals_ = {}
      exec_(setup, globals_)
      if number is None:
          # determine number so that 0.2 <= total time < 2.0 like timeit.
          dummy_profiler = profiler_factory()
          dummy_profiler.start()
          for x in range(1, 10):
              number = 10 ** x
              t = time.time()
              for y in range(number):
                  exec_(stmt, globals_)
              if time.time() - t >= 0.2:
                  break
          dummy_profiler.stop()
          del dummy_profiler
      code = compile('for _ in range(%d): %s' % (number, stmt),
                     'STATEMENT', 'exec')
      __profile__(stmt, code, globals_, profiler_factory,
                  pickle_protocol=pickle_protocol, dump_filename=dump_filename,
                  mono=mono)
docs: Profile a Python statement like timeit.