-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example: add allocations example for benchmarking kernel changes (#26)
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
WASI_SDK_PATH?=../../wasi-sdk | ||
|
||
.PHONY: allocations | ||
allocations: | ||
$(WASI_SDK_PATH)/bin/clang -target wasm32-unknown-unknown -nostdlib -Wl,--no-entry -Wl,--export=allocations -O2 -g -o allocations.wasm allocations.c | ||
|
||
run: allocations | ||
extism call ./allocations.wasm allocations --loop 100 --wasi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#define EXTISM_IMPLEMENTATION | ||
#include "../../extism-pdk.h" | ||
|
||
uint64_t count = 0; | ||
|
||
int32_t EXTISM_EXPORTED_FUNCTION(allocations) { | ||
|
||
for (int i = 0; i < 10000; i++) { | ||
ExtismHandle h = extism_alloc(i + 10); | ||
if (i % 3 == 0) { | ||
extism_free(h); | ||
} | ||
} | ||
|
||
return 0; | ||
} |