import time


def measure_execution_time(method):
    def timed(*args, **kw):
        ts = time.time()
        result = method(*args, **kw)
        te = time.time()
        if 'log_time' in kw:
            name = kw.get('log_name', method.__name__.upper())
            kw['log_time'][name] = int((te - ts) * 1000)
        else:
            print('%r took %2.2f ms' % (method.__name__, (te - ts) * 1000))
            return result

    return timed
    
    
 
@measure_execution_time
def your_method():
	your magic stuff
   	
The magic piece of code

Performance is usually important when doing heave-lifting in any programming language. A cool way of measuring it is to have an easy to use tool that you attach to your method/function and it provides you additional information without any implementation cost.

```measure_execution_time``` is designed to be used as a decorator that provides this info.

If attaching it to your method/function the following outcome will result

'your_method' took 316.44 ms