Staging
v0.8.1
https://foss.heptapod.net/mercurial/hgview
Revision f7b025328483ac81039d4c921afbb9c690cea67a authored by Nicolas Chauvat on 28 May 2009, 13:26:08 UTC, committed by Nicolas Chauvat on 28 May 2009, 13:26:08 UTC
1 parent fa34d81
Raw File
Tip revision: f7b025328483ac81039d4c921afbb9c690cea67a authored by Nicolas Chauvat on 28 May 2009, 13:26:08 UTC
began to get hgqv back into hgview
Tip revision: f7b0253
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