Skip to content

Commit eca0237

Browse files
committed
chore: Add access token there
1 parent d4f2af8 commit eca0237

File tree

1 file changed

+77
-15
lines changed

1 file changed

+77
-15
lines changed

.github/workflows/performance.yml

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Build project
4242
run: yarn build
4343

44-
- name: Run performance benchmarks
44+
- name: Run performance benchmarks with assertions
4545
run: |
4646
echo "Running wcwidth performance tests..."
4747
node -e "
@@ -57,11 +57,29 @@ jobs:
5757
5858
const end = performance.now();
5959
const avgTime = (end - start) / iterations;
60+
const totalTime = end - start;
61+
6062
console.log(\`wcwidth: \${avgTime.toFixed(6)}ms per call\`);
61-
console.log(\`Total time: \${(end - start).toFixed(2)}ms for \${iterations} calls\`);
63+
console.log(\`Total time: \${totalTime.toFixed(2)}ms for \${iterations} calls\`);
64+
65+
// Performance assertions
66+
const MAX_AVG_TIME = 0.0001; // 0.1 microseconds per call
67+
const MAX_TOTAL_TIME = 200; // 200ms for 1M calls
68+
69+
if (avgTime > MAX_AVG_TIME) {
70+
console.error(\`❌ wcwidth performance degraded! Average time \${avgTime.toFixed(6)}ms exceeds limit of \${MAX_AVG_TIME}ms\`);
71+
process.exit(1);
72+
}
73+
74+
if (totalTime > MAX_TOTAL_TIME) {
75+
console.error(\`❌ wcwidth total time \${totalTime.toFixed(2)}ms exceeds limit of \${MAX_TOTAL_TIME}ms\`);
76+
process.exit(1);
77+
}
78+
79+
console.log('✅ wcwidth performance within acceptable limits');
6280
"
6381
64-
- name: Run wcswidth performance tests
82+
- name: Run wcswidth performance tests with assertions
6583
run: |
6684
echo "Running wcswidth performance tests..."
6785
node -e "
@@ -83,11 +101,29 @@ jobs:
83101
84102
const end = performance.now();
85103
const avgTime = (end - start) / (iterations * testStrings.length);
104+
const totalTime = end - start;
105+
86106
console.log(\`wcswidth: \${avgTime.toFixed(6)}ms per call\`);
87-
console.log(\`Total time: \${(end - start).toFixed(2)}ms for \${iterations * testStrings.length} calls\`);
107+
console.log(\`Total time: \${totalTime.toFixed(2)}ms for \${iterations * testStrings.length} calls\`);
108+
109+
// Performance assertions
110+
const MAX_AVG_TIME = 0.001; // 1 microsecond per call
111+
const MAX_TOTAL_TIME = 1000; // 1 second for all calls
112+
113+
if (avgTime > MAX_AVG_TIME) {
114+
console.error(\`❌ wcswidth performance degraded! Average time \${avgTime.toFixed(6)}ms exceeds limit of \${MAX_AVG_TIME}ms\`);
115+
process.exit(1);
116+
}
117+
118+
if (totalTime > MAX_TOTAL_TIME) {
119+
console.error(\`❌ wcswidth total time \${totalTime.toFixed(2)}ms exceeds limit of \${MAX_TOTAL_TIME}ms\`);
120+
process.exit(1);
121+
}
122+
123+
console.log('✅ wcswidth performance within acceptable limits');
88124
"
89125
90-
- name: Memory usage test
126+
- name: Memory usage test with assertions
91127
run: |
92128
echo "Testing memory usage..."
93129
node -e "
@@ -112,22 +148,48 @@ jobs:
112148
};
113149
114150
console.log('Memory increase:', memoryIncrease);
151+
152+
// Memory assertions
153+
const MAX_HEAP_INCREASE = 10 * 1024 * 1024; // 10MB
154+
const MAX_EXTERNAL_INCREASE = 5 * 1024 * 1024; // 5MB
155+
156+
if (memoryIncrease.heapUsed > MAX_HEAP_INCREASE) {
157+
console.error(\`❌ Memory leak detected! Heap increase \${(memoryIncrease.heapUsed / 1024 / 1024).toFixed(2)}MB exceeds limit of \${MAX_HEAP_INCREASE / 1024 / 1024}MB\`);
158+
process.exit(1);
159+
}
160+
161+
if (memoryIncrease.external > MAX_EXTERNAL_INCREASE) {
162+
console.error(\`❌ External memory increase \${(memoryIncrease.external / 1024 / 1024).toFixed(2)}MB exceeds limit of \${MAX_EXTERNAL_INCREASE / 1024 / 1024}MB\`);
163+
process.exit(1);
164+
}
165+
166+
console.log('✅ Memory usage within acceptable limits');
115167
"
116168
117-
- name: Bundle size check
169+
- name: Bundle size check with assertions
118170
run: |
119171
echo "Checking bundle size..."
120-
du -h dist/index.js
172+
BUNDLE_SIZE=$(du -b dist/index.js | cut -f1)
173+
echo "Bundle size: $BUNDLE_SIZE bytes"
174+
175+
# Bundle size assertions
176+
MAX_BUNDLE_SIZE=50000 # 50KB
177+
178+
if [ "$BUNDLE_SIZE" -gt "$MAX_BUNDLE_SIZE" ]; then
179+
echo "❌ Bundle size $BUNDLE_SIZE bytes exceeds limit of $MAX_BUNDLE_SIZE bytes"
180+
exit 1
181+
fi
182+
183+
echo "✅ Bundle size within acceptable limits"
184+
121185
echo "Number of lines in dist:"
122186
find dist -name "*.js" -exec wc -l {} \;
123187
124188
- name: Performance regression check
125189
run: |
126-
echo "Checking for performance regressions..."
127-
# This would typically compare against baseline metrics
128-
# For now, we'll just log the current performance
129-
echo "Performance metrics logged above"
130-
echo "Consider setting up performance monitoring with tools like:"
131-
echo "- GitHub Actions performance tracking"
132-
echo "- Bundle size monitoring"
133-
echo "- Runtime performance baselines"
190+
echo "✅ All performance tests passed!"
191+
echo "Performance metrics are within acceptable limits:"
192+
echo "- wcwidth: < 0.1μs per call"
193+
echo "- wcswidth: < 1μs per call"
194+
echo "- Memory: < 10MB heap increase"
195+
echo "- Bundle: < 50KB"

0 commit comments

Comments
 (0)