Staging
v0.5.1
https://foss.heptapod.net/mercurial/hgview
Revision e9b175105622c37e84d19806dc98af8cb559062a authored by David Douard on 27 May 2009, 05:03:01 UTC, committed by David Douard on 27 May 2009, 05:03:01 UTC
1 parent d91c3b5
Raw File
Tip revision: e9b175105622c37e84d19806dc98af8cb559062a authored by David Douard on 27 May 2009, 05:03:01 UTC
Refactored a bit the manifest viewer
Tip revision: e9b1751
decorators.py
# -*- coding: utf-8 -*-

import time

def timeit(f):
    """Decorator used to time the execution of a function"""
    def timefunc(*args, **kwargs):
        """wrapper"""
        t1 = time.time()
        t2 = time.clock()
        res = f(*args, **kwargs)
        t3 = time.clock()
        t4 = time.time()
        print "%s: %.2fms (time) %.2fms (clock)" % (f.func_name, 1000*(t3 - t2), 1000*(t4 - t1))
        return res
    return timefunc
back to top