Patch obj so calls to given methods are timed

    >>> class C(object):
    ...     def m1(self):
    ...         return 'ok'
    ...
    ...     def m2(self, arg):
    ...         return arg
    ...
    >>> c = C()
    >>> time_methods(c, ['m1', 'm2'])
    >>> c.m1()
    'ok'
    >>> c.m2('ok')
    'ok'
    >>> c = C()
    >>> time_methods(c, ['m1'], 'mymetrics')

def time_methods(obj, methods, prefix=None):
    """
    Patch obj so calls to given methods are timed

    >>> class C(object):
    ...     def m1(self):
    ...         return 'ok'
    ...
    ...     def m2(self, arg):
    ...         return arg
    ...
    >>> c = C()
    >>> time_methods(c, ['m1', 'm2'])
    >>> c.m1()
    'ok'
    >>> c.m2('ok')
    'ok'
    >>> c = C()
    >>> time_methods(c, ['m1'], 'mymetrics')
    """
    if prefix:
        prefix = prefix + '.'
    else:
        prefix = ''

    for method in methods:
        current_method = getattr(obj, method)
        new_method = timed(prefix)(current_method)
        setattr(obj, method, new_method)