Beispiel #1
0
def do_basic_benchmarks():
    runtime = Runtime()
    module, _ = runtime.instantiate_module(runtime.load_module(BASIC_WASM))
    runtime.register_module('bench', module)

    thunk_delta = _run_basic_bench(runtime, module, 'thunk', (), 10000)
    add_delta = _run_basic_bench(runtime, module, 'add',
                                 (numpy.uint32(1), numpy.uint32(2)), 10000)
    call_thunk_delta = _run_basic_bench(runtime, module, 'call_thunk',
                                        (numpy.uint32(10000), ), 1)
    call_add_delta = _run_basic_bench(
        runtime,
        module,
        'call_add',
        (numpy.uint32(10000), numpy.uint32(1), numpy.uint32(2)),
        1,
    )

    logging.info(f"wrapped thunk: {call_thunk_delta / 10000:.8f} per call")
    logging.info(f"wrapped add  : {call_add_delta / 10000:.8f} per call")

    thunk_overhead = (call_thunk_delta - thunk_delta)
    add_overhead = call_add_delta - add_delta
    logging.info(
        f"call overhead for thunk: {thunk_overhead:.4f} ({100 * thunk_overhead / thunk_delta:.2f}%)  |   {thunk_overhead / 10000:.8f} per call"
    )  # noqa: E501
    logging.info(
        f"call overhead for add  : {add_overhead:.4f} ({100 * add_overhead / add_delta:.2f}%)  |   {add_overhead / 10000:.8f} per call"
    )  # noqa: E501
Beispiel #2
0
def do_register(command: Register, module: CurrentModule,
                all_modules: AllModules, runtime: Runtime) -> None:
    if command.name is None:
        if module is None:
            raise Exception("Invariant")
        runtime.register_module(command.as_, module)
    else:
        runtime.register_module(command.as_, all_modules[command.name])
Beispiel #3
0
def test_json_fixture(fixture_path):
    runtime = Runtime()
    # module "spectest" is imported from by many tests
    runtime.register_module(
        "spectest",
        instantiate_spectest_module(runtime.store),
    )
    # module "test" is imported from by many tests
    runtime.register_module(
        "test",
        instantiate_test_module(runtime.store),
    )
    run_fixture_test(fixture_path, runtime)
Beispiel #4
0
def test_json_fixture(fixture_path, pytestconfig):
    # ensure that all numpy flags are set to raise exceptions
    numpy.seterr(all='raise')

    stop_after_command_line = pytestconfig.getoption('stop_after_command_line')
    runtime = Runtime()
    # module "spectest" is imported from by many tests
    runtime.register_module(
        "spectest",
        instantiate_spectest_module(runtime.store),
    )
    # module "test" is imported from by many tests
    runtime.register_module(
        "test",
        instantiate_test_module(runtime.store),
    )
    run_fixture_test(fixture_path, runtime, stop_after_command_line)