diff --git a/codecs/hqx/Dockerfile b/codecs/hqx/Dockerfile index 1142b581..e48f73b2 100644 --- a/codecs/hqx/Dockerfile +++ b/codecs/hqx/Dockerfile @@ -14,5 +14,10 @@ RUN rustup install nightly && \ cargo install wasm-pack COPY --from=0 /opt/wabt /opt/wabt -ENV PATH="/opt/wabt/bin:${PATH}" + +RUN mkdir /opt/binaryen && \ + curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1 + +ENV PATH="/opt/binaryen:/opt/wabt/bin:${PATH}" + WORKDIR /src diff --git a/codecs/hqx/build.sh b/codecs/hqx/build.sh index 413db29d..fd06ec21 100755 --- a/codecs/hqx/build.sh +++ b/codecs/hqx/build.sh @@ -8,6 +8,8 @@ echo "=============================================" ( rustup run nightly \ wasm-pack build --target no-modules + mv pkg/squooshhqx_bg.wasm pkg/squooshhqx_bg.unopt.wasm + wasm-opt -Os --no-validation pkg/squooshhqx_bg.unopt.wasm -o pkg/squooshhqx_bg.wasm wasm-strip pkg/squooshhqx_bg.wasm rm pkg/.gitignore ) diff --git a/codecs/hqx/loading_benchmark.js b/codecs/hqx/loading_benchmark.js new file mode 100644 index 00000000..ea9624ec --- /dev/null +++ b/codecs/hqx/loading_benchmark.js @@ -0,0 +1,11 @@ +// THIS IS NOT A NODE SCRIPT +// This is a d8 script. Please install jsvu[1] and install v8. +// Then run `npm run --silent benchmark`. +// [1]: https://github.com/GoogleChromeLabs/jsvu + +async function init() { + const start = Date.now(); + const module = await WebAssembly.compile(readbuffer("pkg/squooshhqx_bg.wasm")); + print(`${Date.now()/1000 - start/1000}`); +} +init().catch(e => console.error(e.stack)); \ No newline at end of file diff --git a/codecs/hqx/pkg/squooshhqx_bg.wasm b/codecs/hqx/pkg/squooshhqx_bg.wasm index b180905b..f986ea0b 100644 Binary files a/codecs/hqx/pkg/squooshhqx_bg.wasm and b/codecs/hqx/pkg/squooshhqx_bg.wasm differ