Skip to content

Object destructuring, this unbinding and checking (#127) #151

Object destructuring, this unbinding and checking (#127)

Object destructuring, this unbinding and checking (#127) #151

name: Performance and size
on:
push:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
run-benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: brndnmtthws/rust-action-cargo-binstall@v1
with:
packages: hyperfine
# For displaying line count in file
- name: Download scc
run: |
mkdir scc
cd scc
gh release download v3.1.0 -R boyter/scc -p '*Linux_x86_64.tar.gz' -O scc.tar.gz
tar -xf scc.tar.gz
chmod +x scc
pwd >> $GITHUB_PATH
env:
GH_TOKEN: ${{ github.token }}
- name: Build Ezno
run: cargo build --release
env:
CARGO_PROFILE_RELEASE_DEBUG: true
- name: Download files
run: |
curl https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs > react.js
- name: Run checker performance
shell: bash
run: |
echo "::info::Found specification"
# Generate a file which contains everything that Ezno currently implements
cargo run -p ezno-parser --example code_blocks_to_script ./checker/specification/specification.md ./demo.ts
echo "::group::Generated demo.ts"
cat ./demo.ts
cargo run -p ezno-parser --example parse demo.ts --timings
echo "::endgroup::"
echo "::info::Finished file generation"
echo "<details>
<summary>Input</summary>
\`\`\`ts
" >> $GITHUB_STEP_SUMMARY
lines=$(scc -c --no-cocomo -f json demo.ts | jq ".[0].Code")
echo "// $lines lines of TypeScript" >> $GITHUB_STEP_SUMMARY
cat ./demo.ts >> $GITHUB_STEP_SUMMARY
echo "\`\`\`
</details>
" >> $GITHUB_STEP_SUMMARY
echo "::info::Wrote code to summary"
echo "<details>
<summary>Diagnostics</summary>
\`\`\`" >> $GITHUB_STEP_SUMMARY
# Printing diagnostics, so turn colors off for GH Summary (also affects printing perf I think)
NO_COLOR=1
./target/release/ezno check demo.ts --timings &>> $GITHUB_STEP_SUMMARY
echo "\`\`\`
</details>
" >> $GITHUB_STEP_SUMMARY
echo "### Checking
\`\`\`shell" >> $GITHUB_STEP_SUMMARY
hyperfine -i './target/release/ezno check demo.ts' >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "::group::Comparing printing of diagnostics"
hyperfine -i './target/release/ezno check demo.ts' './target/release/ezno check demo.ts --count-diagnostics'
echo "::endgroup::"
- name: Run parser, minfier/stringer performance
shell: bash
run: |
strings=(
"https://esm.sh/v128/react-dom@18.2.0/es2022/react-dom.mjs"
"https://esm.sh/v135/typescript@5.3.3/es2022/typescript.mjs"
)
for url in "${strings[@]}"; do
curl -sS $url > input.js
echo "--- debug: $url ---"
cargo run -p ezno-parser --example parse input.js --timings --render-timings
echo "--- release: $url ---"
cargo run -p ezno-parser --release --example parse input.js --timings --render-timings
done