Skip to content

Compute Size (Manual) #7

Compute Size (Manual)

Compute Size (Manual) #7

name: Compute Size (Manual)
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
path: emscripten-glfw
- name: Checkout emscripten
uses: actions/checkout@v4
with:
repository: emscripten-core/emsdk
path: emscripten
- name: Install Emscripten
working-directory: ${{github.workspace}}/emscripten
run: |
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
emcc -v
- name: Compiling with library_glfw.js
working-directory: ${{github.workspace}}/emscripten-glfw
run: |
source ${{github.workspace}}/emscripten/emsdk_env.sh
mkdir build-with-library_glfw
emcc --version
emcc -sUSE_GLFW=3 examples/example_minimal/main.cpp -O2 -o build-with-library_glfw/index.html
ls -l build-with-library_glfw
js_size=$(stat --format="%s" build-with-library_glfw/index.js)
wasm_size=$(stat --format="%s" build-with-library_glfw/index.wasm)
total_size=$((js_size + wasm_size))
echo "js:$js_size, wasm:$wasm_size, total: $total_size"
echo "TOTAL_SIZE_LIBRARY_GLFW=$total_size" >> $GITHUB_ENV
- name: Compiling with contrib.glfw3
working-directory: ${{github.workspace}}/emscripten-glfw
run: |
source ${{github.workspace}}/emscripten/emsdk_env.sh
mkdir build-with-port
emcc --version
emcc --use-port=contrib.glfw3 examples/example_minimal/main.cpp -O2 -o build-with-port/index.html
ls -l build-with-port
js_size=$(stat --format="%s" build-with-port/index.js)
wasm_size=$(stat --format="%s" build-with-port/index.wasm)
total_size=$((js_size + wasm_size))
delta=$(echo "scale=2; $total_size / $TOTAL_SIZE_LIBRARY_GLFW" | bc)
echo "js:$js_size, wasm:$wasm_size, total: $total_size | ${delta}x"
- name: Compiling with contrib.glfw3 (small)
working-directory: ${{github.workspace}}/emscripten-glfw
run: |
source ${{github.workspace}}/emscripten/emsdk_env.sh
mkdir build-with-port-small
emcc --version
emcc --use-port=contrib.glfw3:disableWarning=true:disableMultiWindow=true:disableJoystick=true examples/example_minimal/main.cpp -O2 -o build-with-port-small/index.html
ls -l build-with-port-small
js_size=$(stat --format="%s" build-with-port-small/index.js)
wasm_size=$(stat --format="%s" build-with-port-small/index.wasm)
total_size=$((js_size + wasm_size))
echo "js:$js_size, wasm:$wasm_size, total: $total_size"
delta=$(echo "scale=2; $total_size / $TOTAL_SIZE_LIBRARY_GLFW" | bc)
echo "js:$js_size, wasm:$wasm_size, total: $total_size | ${delta}x"