def extract_stats_from_uartlog(uartlogpath):
    """ read a uartlog and get sim perf results """
    elapsed_time = -1
    sim_speed = -1
    cycles = -1
    with open(uartlogpath, 'r') as f:
        readlines = f.readlines()
    for line in readlines:
        if "time elapsed:" in line and "simulation speed" in line:
            elapsed_time = float(line.split()[2])
            sim_speed = float(line.split()[7])
            if line.split()[8] != "MHz":
                if line.split()[8] == "KHz":
                    sim_speed /= 1000.0
                else:
                    # i forget if this will print 0.xxx MHz or switch to KHz or something else
                    # so just to be safe...
                    print("ERR: unknown sim rate units")
                    exit(1)
        if "*** PASSED ***" in line:
            cycles = float(line.split()[4])
    return [elapsed_time, sim_speed, cycles]