Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > efe60a74a55b1603654f3f258ba7199d > files > 2692

python3-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