def parse_timing(timing, limit):
    "Parse timing."
    if timing.endswith('ms'):
        value = float(timing[:-2]) * 1e-3
    elif timing.endswith('us'):
        value = float(timing[:-2]) * 1e-6
    else:
        assert timing.endswith('s')
        value = float(timing[:-1])
    return 0.0 if value > limit else value
dataset/ETHPy150Open grantjenks/python-diskcache/tests/plot.py/parse_timing/original