Skip to content

Commit

Permalink
Use WebAssembly.compileStreaming
Browse files Browse the repository at this point in the history
With WebAssembly.compileStreaming, compilation completes 40 ms faster than WebAssembly.compile.
  • Loading branch information
ledsun authored and kateinoigakukun committed Oct 29, 2023
1 parent 3e371ec commit 0b3ab52
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DefaultRubyVM } from "./browser";

export const main = async (pkg: { name: string; version: string }) => {
const response = await fetch(
const response = fetch(
`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`,
);
const buffer = await response.arrayBuffer();
const module = await WebAssembly.compile(buffer);
const module = await WebAssembly.compileStreaming(response);
const { vm } = await DefaultRubyVM(module);

vm.printVersion();
Expand Down

0 comments on commit 0b3ab52

Please sign in to comment.