108 lines (88 loc) · 3.2 KB
/
performance-and-size.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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: Run checker performance
shell: bash
run: |
# 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 "::info::Finished file generation"
LINES_OF_CODE=$(scc -c --no-cocomo -f json demo.ts | jq ".[0].Code")
echo "<details>
<summary>Input</summary>
\`\`\`ts
// $LINES_OF_CODE lines of TypeScript generated from specification.md
$(cat ./demo.ts)
\`\`\`
</details>
" >> $GITHUB_STEP_SUMMARY
echo "::info::Wrote code to summary"
echo "<details>
<summary>Diagnostics</summary>
\`\`\`
$(./target/release/ezno check demo.ts --timings || true)
\`\`\`
</details>
" >> $GITHUB_STEP_SUMMARY
echo "### Checking
\`\`\`shell
$(hyperfine -i './target/release/ezno check demo.ts')
\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "::group::Comparing printing of diagnostics"
hyperfine -i './target/release/ezno check demo.ts' './target/release/ezno check demo.ts --compact-diagnostics' './target/release/ezno check demo.ts --count-diagnostics'
echo "::endgroup::"
echo "::group::cargo tree"
cargo tree
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"
)
// TODO hyperfine
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