def print_timing(func, message='', iterations=1):
    def wrapper(*arg):
        results = []
        reset_queries()
        for i in xrange(iterations):
            t1 = time.time()
            x = func(*arg)
            t2 = time.time()
            results.append((t2 - t1) * 1000.0)
        res_sum = 0
        for r in results:
            res_sum += r
        median = res_sum / len(results)
        print '%s%-19s: %.0f ms, %i queries' % (
            message, func.func_name,
            median,
            len(connection.queries) / len(results)
        )
        sys.stdout.flush()
    return wrapper
dataset/ETHPy150Open chrisglass/django_polymorphic/example/pexp/management/commands/polybench.py/print_timing/original