Exemplo n.º 1
0
def benchmark():

    os = version()
    ver = python_version()
    txnc = len(UBXMESSAGES)
    txnt = txnc * CYCLES

    print(
        f"\nOperating system: {os}",
        f"\nPython version: {ver}",
        f"\npyubx2 version: {pyubx2ver}",
        f"\nTest cycles: {CYCLES:,}",
        f"\nTxn per cycle: {txnc:,}",
    )

    start = datetime.now()
    print(f"\nBenchmark test started at {start} ...")
    for n in range(CYCLES):
        for i, msg in enumerate(UBXMESSAGES):
            res = UBXReader.parse(msg)
    end = datetime.now()
    print(f"Benchmark test ended at {end}.")
    duration = (end - start).total_seconds()

    print(
        f"\n{txnt:,} messages processed in {duration:,.3f} seconds = {txnt/duration:,.2f} txns/second.\n"
    )
Exemplo n.º 2
0
def benchmark(**kwargs) -> float:
    """
    pyubx2 Performance benchmark test.

    :param int cycles: (kwarg) number of test cycles (10,000)
    :returns: benchmark as transactions/second
    :rtype: float
    :raises: UBXStreamError
    """

    cyc = int(kwargs.get("cycles", 10000))
    txnc = len(UBXMESSAGES)
    txnt = txnc * cyc

    print(
        f"\nOperating system: {osver()}",
        f"\nPython version: {python_version()}",
        f"\npyubx2 version: {ubxver}",
        f"\nTest cycles: {cyc:,}",
        f"\nTxn per cycle: {txnc:,}",
    )

    start = datetime.now()
    print(f"\nBenchmark test started at {start}")
    for i in range(cyc):
        progbar(i, cyc)
        for msg in UBXMESSAGES:
            _ = UBXReader.parse(msg)
    end = datetime.now()
    print(f"Benchmark test ended at {end}.")
    duration = (end - start).total_seconds()
    rate = round(txnt / duration, 2)

    print(
        f"\n{txnt:,} messages processed in {duration:,.3f} seconds = {rate:,.2f} txns/second.\n"
    )

    return rate