'@param f a callable; If it returns a deferred then the memory will not
be measured and the next iteration will not be started until the
deferred fires; else the memory will be measured and the next
iteration started when f returns.'

def __init__(self, f, numsamples=(2 ** 7), iterspersample=(2 ** 4), *args, **kwargs):

    self.f = f
    self.numsamples = numsamples
    self.iterspersample = iterspersample
    self.args = args
    self.kwargs = kwargs
    from twisted.internet import defer
    self.d = defer.Deferred()
