Update simple wasi test

extensions
Volodymyr Shymanskyy 3 years ago
parent 8291bdb162
commit 5552888bc2

@ -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="<interpreter>", 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))

@ -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

Binary file not shown.

Binary file not shown.

@ -1,65 +0,0 @@
#include <stdio.h>
#include <assert.h>
#include <time.h>
#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;
}

Binary file not shown.
Loading…
Cancel
Save