forked from bytecodealliance/wasm-parallel-gzip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (49 loc) · 1.98 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Build a WebAssembly benchmark for parallel compression and decompression (eventually).
PIGZ_WASM=pigz/pigz.wasm
ZLIB_WASM=zlib/libz.wasm.a
WASI_SDK_CC=wasi-sdk/bin/clang
WASMTIME=wasmtime/src/target/release/wasmtime
WAMR=wasm-micro-runtime/src/build/iwasm
PLATFORM?=linux
# Compile and link the various WebAssembly objects and the Wasmtime engine to run them. Important
# variables:
# - WASI_SDK_DIR: modify the location of the wasi-sdk version to something other than the retrieved
# one
# - CC: modify the location of Clang used to build the artifacts, default: $WASI_SDK_DIR/bin/clang
# - DEBUG: when set, enables symbols everywhere (`-g`) and optional logging in pigz.
build: $(PIGZ_WASM) $(WASMTIME)
$(PIGZ_WASM): $(WASI_SDK_CC)
make -C pigz
$(ZLIB_WASM): $(WASI_SDK_CC)
make -C zlib
$(WASI_SDK_CC):
make -C wasi-sdk PLATFORM=$(PLATFORM)
$(WASMTIME):
make -C wasmtime
$(WAMR):
make -C wasm-micro-runtime PLATFORM=$(PLATFORM)
clean:
make -C wasi-sdk clean
make -C zlib clean
make -C pigz clean
make -C wasmtime clean
make -C wasm-micro-runtime clean
rm -f random.*
# Run the pigz WebAssembly binary as a CLI application using Wasmtime (or WASM micro runtime);
# this is not meant to be a highly-accurate benchmarking setup but rather a quick check
# that things work. Because pigz will remove the original file, we keep an `.original.bin` copy
# around for replicatability.
NUM_THREADS ?= 1
benchmark: random.bin $(PIGZ_WASM) $(WASMTIME)
@rm -f random.bin.gz
time $(WASMTIME) --dir . --wasm-features=threads --wasi-modules=experimental-wasi-threads \
$(PIGZ_WASM) -- -p $(NUM_THREADS) /random.bin
@gzip --decompress --stdout random.bin.gz >/dev/null
benchmark.wamr: random.bin $(PIGZ_WASM) $(WAMR)
@rm -f random.bin.gz
time $(WAMR) --max-threads=$(shell echo ${NUM_THREADS}+1 | bc) --dir=. $(PIGZ_WASM) -p $(NUM_THREADS) /random.bin
@gzip --decompress --stdout random.bin.gz >/dev/null
random.bin: random.original.bin
@cp $< $@
random.original.bin:
head -c 104857600 </dev/urandom >$@ # 100M