'Get format and units for data coming from profiler task.'

def format_measure(self, measure):

    if isinstance(measure, int):
        return to_text_string(measure)
    if (1e-09 < measure <= 1e-06):
        measure = u'{0:.2f}    ns'.format((measure / 1e-09))
    elif (1e-06 < measure <= 0.001):
        measure = u'{0:.2f}    us'.format((measure / 1e-06))
    elif (0.001 < measure <= 1):
        measure = u'{0:.2f}    ms'.format((measure / 0.001))
    elif (1 < measure <= 60):
        measure = u'{0:.2f}    sec'.format(measure)
    elif (60 < measure <= 3600):
        (m, s) = divmod(measure, 3600)
        if (s > 60):
            (m, s) = divmod(measure, 60)
            s = to_text_string(s).split('.')[(-1)]
        measure = u'{0:.0f}.{1:.2s}    min'.format(m, s)
    else:
        (h, m) = divmod(measure, 3600)
        if (m > 60):
            m /= 60
        measure = u'{0:.0f}h:{1:.0f}min'.format(h, m)
    return measure
