Sophie

Sophie

distrib > Mageia > 6 > x86_64 > by-pkgid > 09408f3c1571cbb746da49a1d2f22702 > files > 2731

python-twisted-17.5.0-1.mga6.x86_64.rpm

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Helper stuff for benchmarks.
"""
from __future__ import print_function

import gc
gc.disable()
print('Disabled GC')

def timeit(func, iter = 1000, *args, **kwargs):
    """
    timeit(func, iter = 1000 *args, **kwargs) -> elapsed time
    
    calls func iter times with args and kwargs, returns time elapsed
    """

    from time import time as currentTime
    r = range(iter)
    t = currentTime()
    for i in r:
        func(*args, **kwargs)
    return currentTime() - t