-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·81 lines (71 loc) · 1.75 KB
/
build
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
minbench=1
maxbench=5
a=$1
function init_b() {
rm src/*
}
function b1() {
echo nocode.rs without emscripten
cp Cargo1.toml Cargo.toml
build_x nocode.rs b1
}
function b2() {
echo hellowasm.rs without emscripten
cp Cargo1.toml Cargo.toml
build_x hellowasm.rs b2
}
function b3() {
echo futures_loop.rs without emscripten
cp Cargo2.toml Cargo.toml
build_x futures_loop.rs b3
}
function b4() {
echo loop_from_js.rs without emscripten
cp Cargo2.toml Cargo.toml
build_x loop_from_js.rs b4
}
function b5() {
echo inline_futures_loop.rs without emscripten
cp Cargo2.toml Cargo.toml
build_x inline_futures_loop.rs b5
}
function build_x() {
init_b
cp msrc/$1 src/lib.rs
cp msrc/mods/* src/
cargo build --target wasm32-unknown-unknown --release
cp target/wasm32-unknown-unknown/release/wasm_benchmark.wasm bin/$2.wasm
wasm-bindgen bin/$2.wasm --out-dir bin/ --no-typescript --target no-modules --remove-producers-section --remove-name-section --no-demangle
wasm-opt -Oz bin/$2_bg.wasm -o bin/$2_bg.wasm
}
function bn() {
echo "build benchmark '$1'"
case $1 in
1) b1;;
2) b2;;
3) b3;;
4) b4;;
5) b5;;
*) echo error: fatal input error;;
esac
}
if [[ $# -eq 0 ]]; then
echo error: needing at least one argument
else
case $1 in
all)
echo bench all
for i in $(seq $minbench $maxbench); do
bn $i
done
;;
*)
if (($minbench<=$a && $a<=$maxbench)); then
bn $a
else
echo "error: needing number argument in the range of 1..$maxbench or 'all'"
fi
;;
esac
fi