commit 82b440cf195f62b009b88532baca1d2815d7dd1d
parent aae3121d1e31b1d40ea088f0107a409793a6e4b4
Author: William Casarin <jb55@jb55.com>
Date: Fri, 23 Jul 2021 12:01:26 -0700
wasi bench
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/bench.c b/src/bench.c
@@ -6,7 +6,8 @@
#include "io.h"
#include "wasm.h"
-static int bench_wasm(unsigned char *wasm, unsigned long len, int times)
+static int bench_wasm(unsigned char *wasm, unsigned long len, int times,
+ int argc, const char **argv)
{
struct wasm_parser p;
struct wasm_interp interp;
@@ -26,6 +27,8 @@ static int bench_wasm(unsigned char *wasm, unsigned long len, int times)
}
interp.errors.enabled = 0;
+ setup_wasi(&interp, argc, argv);
+
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t1);
for (i = 0; i < times; i++) {
if (!interp_wasm_module(&interp)) {
@@ -51,14 +54,19 @@ int main(int argc, char *argv[])
const char *code_file;
size_t len;
int times;
+ int args = 0;
- if (argc >= 2)
+ if (argc >= 2) {
+ args++;
code_file = argv[1];
+ }
else
code_file = "wasm/hello.wasm";
- if (argc >= 3)
+ if (argc >= 3) {
+ args++;
times = atoi(argv[2]);
+ }
else
times = 10000;
@@ -67,7 +75,7 @@ int main(int argc, char *argv[])
return 1;
}
fprintf(stderr, "executing %s %d times\n", code_file, times);
- if (!bench_wasm(wasm_data, len, times)) {
+ if (!bench_wasm(wasm_data, len, times, argc-args, ((const char**)argv)+args)) {
return 2;
}