Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 7b973fb3c8298f606d9b435aff551ab6 > files > 2740

python2-twisted-19.2.1-1.1.mga7.armv7hl.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