Skip to content

Commit d0bd8e5

Browse files
committed
Add simple bench and refine PATH
1 parent 7c48cb0 commit d0bd8e5

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

.github/workflows/bench.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
name: Ruby ${{ matrix.ruby }}
14+
strategy:
15+
matrix:
16+
ruby:
17+
- '3.3.9'
18+
- '3.4.5'
19+
wasm_tools:
20+
- '1.236.0'
21+
hyperfine:
22+
- '1.19.0'
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby }}
30+
bundler-cache: true
31+
- name: Install wasm-tools
32+
run: |
33+
mkdir -p $HOME/.bin
34+
curl -L https://github.com/bytecodealliance/wasm-tools/releases/download/v${{ matrix.wasm_tools }}/wasm-tools-${{ matrix.wasm_tools }}-x86_64-linux.tar.gz -o wasm-tools.tar.gz
35+
tar xvzf wasm-tools.tar.gz
36+
mv wasm-tools-*-x86_64-linux/wasm-tools $HOME/.bin/wasm-tools
37+
chmod a+x $HOME/.bin/wasm-tools
38+
echo "$HOME/.bin" >> $GITHUB_PATH
39+
- name: Install Hyperfine
40+
run: |
41+
HYPERFINE_VERSION="${{ matrix.hyperfine }}"
42+
curl -LO "https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine-v${HYPERFINE_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
43+
tar xzf "hyperfine-v${HYPERFINE_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
44+
mkdir -p $HOME/.bin
45+
mv "hyperfine-v${HYPERFINE_VERSION}-x86_64-unknown-linux-gnu/hyperfine" $HOME/.bin/hyperfine
46+
chmod a+x $HOME/.bin/hyperfine
47+
- name: Version wasm-tools
48+
run: |
49+
wasm-tools --version
50+
- name: Version Hyperfine
51+
run: |
52+
hyperfine --version
53+
- name: Run the bench task
54+
run: |
55+
bundle exec rake basic_benchmark

.github/workflows/main.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,31 @@ jobs:
3030
bundler-cache: true
3131
- name: Install wasm-tools
3232
run: |
33-
mkdir -p .bin
33+
mkdir -p $HOME/.bin
3434
curl -L https://github.com/bytecodealliance/wasm-tools/releases/download/v${{ matrix.wasm_tools }}/wasm-tools-${{ matrix.wasm_tools }}-x86_64-linux.tar.gz -o wasm-tools.tar.gz
3535
tar xvzf wasm-tools.tar.gz
36-
mv wasm-tools-*-x86_64-linux/wasm-tools .bin/wasm-tools
37-
chmod a+x .bin/wasm-tools
36+
mv wasm-tools-*-x86_64-linux/wasm-tools $HOME/.bin/wasm-tools
37+
chmod a+x $HOME/.bin/wasm-tools
38+
echo "$HOME/.bin" >> $GITHUB_PATH
3839
- name: Version wasm-tools
3940
run: |
40-
export PATH=`pwd`/.bin:$PATH
4141
wasm-tools --version
4242
- name: Install wast2json
4343
run: |
44-
mkdir -p .bin
44+
mkdir -p $HOME/.bin
4545
curl -L https://github.com/WebAssembly/wabt/releases/download/${{ matrix.wabt }}/wabt-${{ matrix.wabt }}-ubuntu-20.04.tar.gz -o wabt.tar.gz
4646
tar xvzf wabt.tar.gz
47-
mv wabt-*/bin/wast2json .bin/wast2json
48-
chmod a+x .bin/wast2json
47+
mv wabt-*/bin/wast2json $HOME/.bin/wast2json
48+
chmod a+x $HOME/.bin/wast2json
4949
- name: Version wast2json
5050
run: |
51-
export PATH=`pwd`/.bin:$PATH
5251
wast2json --version
5352
- name: Run the check task
5453
run: |
55-
export PATH=`pwd`/.bin:$PATH
5654
bundle exec rake check
5755
- name: Run the test task
5856
run: |
59-
export PATH=`pwd`/.bin:$PATH
6057
bundle exec rake test
6158
- name: Run the official spec
6259
run: |
63-
export PATH=`pwd`/.bin:$PATH
6460
bundle exec rake 'spec[i32]'

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ task :spec, [:name] do |t, args|
3939
end
4040
end
4141

42+
desc "Run basic benchmark"
43+
task :basic_benchmark do
44+
sh "wasm-tools parse examples/i32_bench.wat -o examples/i32_bench.wasm"
45+
sh "hyperfine 'bundle exec wardite --yjit --no-wasi --invoke detailed_arithmetic_loop examples/i32_bench.wasm'"
46+
end
47+
4248
desc "Generate codes"
4349
task :generate do
4450
require_relative "scripts/gen_alu"

0 commit comments

Comments
 (0)