Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bench: indirect call benchmark #632

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.