':rtype stats(index): output of print_stats() for the given profile.'

def stats(self, filename, sortby='cumulative'):

    sio = StringIO()
    if (sys.version_info >= (2, 5)):
        s = pstats.Stats(os.path.join(self.path, filename), stream=sio)
        s.strip_dirs()
        s.sort_stats(sortby)
        s.print_stats()
    else:
        s = pstats.Stats(os.path.join(self.path, filename))
        s.strip_dirs()
        s.sort_stats(sortby)
        oldout = sys.stdout
        try:
            sys.stdout = sio
            s.print_stats()
        finally:
            sys.stdout = oldout
    response = sio.getvalue()
    sio.close()
    return response
