def _profile(f = None):
    import resource 
    def cpu():
        return (resource.getrusage(resource.RUSAGE_SELF).ru_utime +
                resource.getrusage(resource.RUSAGE_SELF).ru_stime)

    from cProfile import Profile
    prof = Profile(cpu)
    try:
        prof = prof.runctx("_dispatch(f)", globals(), locals())
    except __HOLE__:
        pass    

    import pstats
    stats = pstats.Stats(prof)
    stats.strip_dirs()
    stats.sort_stats('time')
    stats.print_stats(20)
dataset/ETHPy150Open concurrence/concurrence/lib/concurrence/core.py/_profile