def run_with_profile(runsnake=False, dump=False):
    import cProfile
    import pstats
    filename = "orm2010.profile"

    if os.path.exists("orm2010.profile"):
        os.remove("orm2010.profile")

    def status(msg):
        print(msg)

    cProfile.runctx('runit(status)', globals(), locals(), filename)
    stats = pstats.Stats(filename)

    counts_by_methname = dict((key[2], stats.stats[key][0]) for key in stats.stats)

    print("SQLA Version: %s" % __version__)
    print("Total calls %d" % stats.total_calls)
    print("Total cpu seconds: %.2f" % stats.total_tt)
    print('Total execute calls: %d' \
        % counts_by_methname["<method 'execute' of 'sqlite3.Cursor' "
                             "objects>"])
    print('Total executemany calls: %d' \
        % counts_by_methname.get("<method 'executemany' of 'sqlite3.Cursor' "
                             "objects>", 0))

    if dump:
        stats.sort_stats('time', 'calls')
        stats.print_stats()

    if runsnake:
        os.system("runsnake %s" % filename)
dataset/ETHPy150Open zzzeek/sqlalchemy/test/perf/orm2010.py/run_with_profile/original