diff --git a/test/run-wasi-test.py b/test/run-wasi-test.py index 25dfa95..ef16f7a 100755 --- a/test/run-wasi-test.py +++ b/test/run-wasi-test.py @@ -4,8 +4,8 @@ # Usage: # ./run-wasi-test.py # ./run-wasi-test.py --exec ../custom_build/wasm3 --timeout 120 -# ./run-wasi-test.py --exec "wasmer run --dir=." -# +# ./run-wasi-test.py --exec "wasmer run --mapdir=/:." --separate-args +# ./run-wasi-test.py --exec "wasmer run --mapdir=/:. wasm3.wasm --" --fast import argparse import sys @@ -24,6 +24,7 @@ from pprint import pprint parser = argparse.ArgumentParser() parser.add_argument("--exec", metavar="", default="../build/wasm3") +parser.add_argument("--separate-args", action='store_true') # use "--" separator for wasmer, wasmtime parser.add_argument("--timeout", type=int, default=120) parser.add_argument("--fast", action='store_true') @@ -82,7 +83,7 @@ commands_full = [ "name": "Brotli", "stdin": "./benchmark/brotli/alice29.txt", "wasm": "./benchmark/brotli/brotli.wasm", - "args": ["-c"], + "args": ["-c", "-f"], "expect_sha1": "8eacda4b80fc816cad185330caa7556e19643dff" }, { "name": "CoreMark", @@ -134,7 +135,7 @@ commands_fast = [ "name": "Brotli", "stdin": "./benchmark/brotli/alice29_small.txt", "wasm": "./benchmark/brotli/brotli.wasm", - "args": ["-c"], + "args": ["-c", "-f"], "expect_sha1": "0e8af02a7207c0c617d7d38eed92853c4a619987" } ] @@ -143,11 +144,6 @@ def fail(msg): print(f"{ansi.FAIL}FAIL:{ansi.ENDC} {msg}") stats.failed += 1 - -args_sep = None -if "wasmer" in args.exec or "wasmtime" in args.exec: - args_sep = "--" - commands = commands_fast if args.fast else commands_full for cmd in commands: @@ -157,8 +153,8 @@ for cmd in commands: command = args.exec.split(' ') command.append(cmd['wasm']) if "args" in cmd: - if args_sep: - command.append(args_sep) + if args.separate_args: + command.append("--") command.extend(cmd['args']) command = list(map(str, command)) diff --git a/test/wasi/README.md b/test/wasi/README.md index fac188c..56ae6c1 100644 --- a/test/wasi/README.md +++ b/test/wasi/README.md @@ -1,15 +1,8 @@ ## Compile ```sh -wasicc -O3 test.c -o test.wasm -wasm-opt -O3 test.wasm -o test-opt.wasm -wasm-strip test-opt.wasm -``` - -```sh -wasicc -O3 test_native_vs_raw.c -o test_native_vs_raw.wasm -Wl,--allow-undefined-file=wasm_api.syms -wasm-opt -O3 test_native_vs_raw.wasm -o test_native_vs_raw.wasm -wasm-strip test_native_vs_raw.wasm +wasicc -g -O0 -Wl,--stack-first test.c -o test.wasm +wasm-opt --strip-debug -Os test.wasm -o test-opt.wasm ``` ## Run diff --git a/test/wasi/test-opt.wasm b/test/wasi/test-opt.wasm index 96a7255..fc6ea7c 100644 Binary files a/test/wasi/test-opt.wasm and b/test/wasi/test-opt.wasm differ diff --git a/test/wasi/test.wasm b/test/wasi/test.wasm index 1f30600..af39e62 100755 Binary files a/test/wasi/test.wasm and b/test/wasi/test.wasm differ diff --git a/test/wasi/test_native_vs_raw.c b/test/wasi/test_native_vs_raw.c deleted file mode 100644 index 8cd00a5..0000000 --- a/test/wasi/test_native_vs_raw.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include - -#include "wasm_api.h" - -/* - * Result: "Raw" calls are ~2x faster than native arg "pushers". - * - * WARNING: this benchmark no longer works. - * Native calls were removed along with wasm3_native_sum. - * It may be useful in future when we implement libffi calls, etc. - */ - -static inline -double get_time() { - struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); - return ts.tv_sec * 1000.0 + ts.tv_nsec / 1000000.0; -} - -int main(int argc, char **argv) -{ - const unsigned cycles = (argc > 1) ? atol(argv[1]) : 10000000; - double beg, end; - - printf("Validation...\n"); - fflush(stdout); - - // validate - assert(wasm3_raw_sum(10, 20, 30, 40) == 10 + 20 + 30 + 40); - assert(wasm3_native_sum(10, 20, 30, 40) == 10 + 20 + 30 + 40); - - printf("Warm-up...\n"); - fflush(stdout); - - beg = get_time(); - for (unsigned i = 0; i < cycles/10; i++) { - wasm3_raw_sum(10, 20, 30, 40); - wasm3_native_sum(10, 20, 30, 40); - } - - printf("Running test...\n"); - fflush(stdout); - - // actual test - beg = get_time(); - for (unsigned i = 0; i < cycles; i++) { - wasm3_raw_sum(1, 2, 3, 4); - } - end = get_time(); - const double time_raw = (end - beg); - - beg = get_time(); - for (unsigned i = 0; i < cycles; i++) { - wasm3_native_sum(1, 2, 3, 4); - } - end = get_time(); - const double time_native = (end - beg); - - printf("Native: %.3f ms\n", time_native); - printf("Raw: %.3f ms\n", time_raw); - - printf("Native/Raw: %.3f\n", time_native/time_raw); - return 0; -} diff --git a/test/wasi/test_native_vs_raw.wasm b/test/wasi/test_native_vs_raw.wasm deleted file mode 100755 index 5c0f325..0000000 Binary files a/test/wasi/test_native_vs_raw.wasm and /dev/null differ