# Path: MC6809/core/bechmark.py
# def run_benchmark(loops, multiply):
#     total_duration = 0
#     total_cycles = 0
#     bench_class = Test6809_Program2()
# 
#     # --------------------------------------------------------------------------
# 
#     duration, cycles = bench_class.crc16_benchmark(loops, multiply)
#     total_duration += duration
#     total_cycles += cycles
# 
#     # --------------------------------------------------------------------------
# 
#     duration, cycles = bench_class.crc32_benchmark(loops, multiply)
#     total_duration += duration
#     total_cycles += cycles
# 
#     # --------------------------------------------------------------------------
#     print("-" * 79)
#     print(
#         f"\nTotal of {loops:d} benchmak loops run in {total_duration:.2f} sec"
#         f" {locale_format_number(total_cycles)} CPU cycles."
#     )
#     print("\tavg.: %s CPU cycles/sec" % locale_format_number(total_cycles / total_duration))


import cProfile
import pstats
import sys
import MC6809
    import click
from MC6809.core.bechmark import run_benchmark
    for the legendary 6809 CPU, used in 30 years old homecomputer
    Dragon 32 and Tandy TRS-80 Color Computer (CoCo)...

    Created by Jens Diemer

    Homepage: https://github.com/6809/MC6809
    """
    pass


DEFAULT_LOOPS = 5
DEFAULT_MULTIPLY = 15
@cli.command(help="Run a MC6809 emulation benchmark")
@click.option("--loops", default=DEFAULT_LOOPS,
              help=f"How many benchmark loops should be run? (default: {DEFAULT_LOOPS:d})")
@click.option("--multiply", default=DEFAULT_MULTIPLY,
              help=f"Test data multiplier (default: {DEFAULT_MULTIPLY:d})")
def benchmark(loops, multiply):
    run_benchmark(loops, multiply)


@cli.command(help="Profile the MC6809 emulation benchmark")
@click.option("--loops", default=DEFAULT_LOOPS,
              help=f"How many benchmark loops should be run? (default: {DEFAULT_LOOPS:d})")
@click.option("--multiply", default=DEFAULT_MULTIPLY,
              help=f"Test data multiplier (default: {DEFAULT_MULTIPLY:d})")
def profile(loops, multiply):
    pr = cProfile.Profile()
    pr.enable()


# Path: MC6809/core/bechmark.py
# def run_benchmark(loops, multiply):
#     total_duration = 0
#     total_cycles = 0
#     bench_class = Test6809_Program2()
# 
#     # --------------------------------------------------------------------------
# 
#     duration, cycles = bench_class.crc16_benchmark(loops, multiply)
#     total_duration += duration
#     total_cycles += cycles
# 
#     # --------------------------------------------------------------------------
# 
#     duration, cycles = bench_class.crc32_benchmark(loops, multiply)
#     total_duration += duration
#     total_cycles += cycles
# 
#     # --------------------------------------------------------------------------
#     print("-" * 79)
#     print(
#         f"\nTotal of {loops:d} benchmak loops run in {total_duration:.2f} sec"
#         f" {locale_format_number(total_cycles)} CPU cycles."
#     )
#     print("\tavg.: %s CPU cycles/sec" % locale_format_number(total_cycles / total_duration))


# Path: MC6809/cli.py
import cProfile
import pstats
import sys
import MC6809
    import click
from MC6809.core.bechmark import run_benchmark

    for the legendary 6809 CPU, used in 30 years old homecomputer
    Dragon 32 and Tandy TRS-80 Color Computer (CoCo)...

    Created by Jens Diemer

    Homepage: https://github.com/6809/MC6809
    """
    pass


DEFAULT_LOOPS = 5
DEFAULT_MULTIPLY = 15
@cli.command(help="Run a MC6809 emulation benchmark")
@click.option("--loops", default=DEFAULT_LOOPS,
              help=f"How many benchmark loops should be run? (default: {DEFAULT_LOOPS:d})")
@click.option("--multiply", default=DEFAULT_MULTIPLY,
              help=f"Test data multiplier (default: {DEFAULT_MULTIPLY:d})")
def benchmark(loops, multiply):
    run_benchmark(loops, multiply)


@cli.command(help="Profile the MC6809 emulation benchmark")
@click.option("--loops", default=DEFAULT_LOOPS,
              help=f"How many benchmark loops should be run? (default: {DEFAULT_LOOPS:d})")
@click.option("--multiply", default=DEFAULT_MULTIPLY,
              help=f"Test data multiplier (default: {DEFAULT_MULTIPLY:d})")
def profile(loops, multiply):
    pr = cProfile.Profile()
    pr.enable()


    run_benchmark(loops, multiply)