def run(self, func, key, logger, *args, **kwargs):
        """Profile a function and store its information."""

        start_time = datetime.now()
        value = func(*args, **kwargs)
        end_time = datetime.now()
        this_time = ms_from_timedelta(end_time - start_time)
        values = {
            'args': args,
            'kwargs': kwargs,
            'count': 0,
            'hits': 0,
            'time': 0.0
        }
        row = self.grouped.setdefault(key, {}).setdefault(func.__name__, values)
        row['count'] += 1
        row['time'] += this_time
        if value is not None:
            row['hits'] += 1

        self.calls.setdefault(key, []).append({
            'func': func,
            'args': args,
            'kwargs': kwargs,
            'time': this_time,
            'hit': value is not None,
            #'stack': [s[1:] for s in inspect.stack()[2:]],
        })
        row = self.summary.setdefault(key, {'count': 0, 'time': 0.0, 'hits': 0})
        row['count'] += 1
        row['time'] += this_time
        if value is not None:
            row['hits'] += 1

        if logger:
            logger.debug('%s("%s") %s (%s)', func.__name__, args[0], 'Miss' if value is None else 'Hit', row['hits'], duration=this_time)

        return value
dataset/ETHPy150Open dcramer/django-devserver/devserver/utils/stats.py/StatCollection.run/original