import time
import math


def run_time(t1, name="", is_print=True):
    """Performance test function, test run time.

    :param t1: Set the time of the breakpoint
    :param name: Set the name of the print
    :param is_print: True, Whether to print
    :return: Printed string content

    >>> t1 = time.time()
    # test function
    >>> run_time(t1, 'name')
    """

    d = time.time() - t1
    min_d = math.floor(d / 60)
    sec_d = d % 60
    hor_d = math.floor(min_d / 60)

    if name != "":
        name = " ( " + name + " )"

    if hor_d > 0:
        v_str = '[ Run Time{3} ] is : {2} hours {0} min {1:.4f} s'.format(min_d, sec_d, hor_d, name)
    else:
        v_str = '[ Run Time{2} ] is : {0} min {1:.4f} s'.format(min_d, sec_d, name)

    if is_print:
        print(v_str)
    return v_str