Run wasm-opt on hqx module

This commit is contained in:
Surma
2019-06-19 00:25:09 +01:00
parent fbaa282f07
commit 26e9a848dd
4 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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
)

View File

@ -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));

Binary file not shown.