Skip to content

Commit

Permalink
bench: indirect call benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Nov 3, 2020
1 parent 90ced51 commit 70e1e94
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/benchmarks/micro/icall_hash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdint.h>

#define WASM_EXPORT __attribute__((visibility("default")))

static uint64_t fnv1(uint64_t state, uint64_t input)
{
return (state ^ input) * 0x100000001b3;
}

static uint64_t threeab(uint64_t state, uint64_t input)
{
return (3 * state) + input;
}

typedef uint64_t (*hashfn)(uint64_t state, uint64_t input);

static hashfn fns[] = {fnv1, threeab};

WASM_EXPORT unsigned icall(unsigned steps)
{
uint64_t input = 0x1234567890abcdef;

uint64_t state = 0xcbf29ce484222325;
for (unsigned i = 0; i < steps; i++)
state = fns[i % 2](state, input);
return state;
}
7 changes: 7 additions & 0 deletions test/benchmarks/micro/icall_hash.inputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1000_steps
icall
i:i
1000

3242341221

Binary file added test/benchmarks/micro/icall_hash.wasm
Binary file not shown.

0 comments on commit 70e1e94

Please sign in to comment.