Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
prompt-toolkit / eventloop / utils.py
Size: Mime:
from __future__ import unicode_literals
import time

__all__ = (
    'TimeIt',
)


class TimeIt(object):
    """
    Context manager that times the duration of the code body.
    The `duration` attribute will contain the execution time in seconds.
    """
    def __init__(self):
        self.duration = None

    def __enter__(self):
        self.start = time.time()
        return self

    def __exit__(self, *args):
        self.end = time.time()
        self.duration = self.end - self.start