559 lines
12 KiB
Markdown
559 lines
12 KiB
Markdown
# UI5 Linter - Performance Reference
|
|
|
|
**Source**: [https://github.com/UI5/linter/blob/main/docs/Performance.md](https://github.com/UI5/linter/blob/main/docs/Performance.md)
|
|
**Last Updated**: 2025-11-21
|
|
**UI5 Linter Version**: 1.20.5
|
|
|
|
---
|
|
|
|
## Overview
|
|
|
|
This document provides comprehensive performance benchmarks, optimization strategies, and best practices for using the UI5 Linter efficiently across projects of various sizes.
|
|
|
|
---
|
|
|
|
## Benchmark Projects
|
|
|
|
The UI5 Linter project maintains performance benchmarks across **6 representative projects** ranging from small applications to large libraries.
|
|
|
|
### Project Scale Reference
|
|
|
|
| Project | Type | Resources | Size | Complexity |
|
|
|---------|------|-----------|------|------------|
|
|
| openui5-sample-app | Small App | 17 | 31.59 KB | Low |
|
|
| sap.ui.testrecorder | Small Library | 68 | 0.19 MB | Low |
|
|
| sap.ui.layout | Medium Library | 572 | 2.4 MB | Medium |
|
|
| sap.m | Large Library | 5,000+ | ~25 MB | High |
|
|
| sap.ui.core | Large Library | 5,000+ | ~45 MB | Very High |
|
|
| themelib_sap_horizon | Non-JS Library | N/A | N/A | Low |
|
|
|
|
**Resources**: Number of JavaScript/XML/JSON files linted
|
|
**Size**: Total size of all linted files
|
|
**Complexity**: Code complexity and depth of analysis required
|
|
|
|
---
|
|
|
|
## Latest Benchmark Results
|
|
|
|
### Environment
|
|
|
|
**Hardware**: MacBook Pro M1 Max
|
|
**Node.js Version**: v23.11.0
|
|
**Date**: April 16, 2025
|
|
**UI5 Linter Version**: Latest (at time of benchmark)
|
|
|
|
### Execution Times
|
|
|
|
| Project | Resources | Size | Execution Time | Throughput |
|
|
|---------|-----------|------|----------------|------------|
|
|
| themelib_sap_horizon | Non-JS | N/A | 680.3 ms | N/A |
|
|
| openui5-sample-app | 17 | 31.59 KB | 1.546 s | ~20 KB/s |
|
|
| sap.ui.testrecorder | 68 | 0.19 MB | 2.248 s | ~87 KB/s |
|
|
| sap.ui.layout | 572 | 2.4 MB | 4.997 s | ~492 KB/s |
|
|
| sap.m | 5,000+ | ~25 MB | 39.035 s | ~656 KB/s |
|
|
| sap.ui.core | 5,000+ | ~45 MB | 40.936 s | ~1.12 MB/s |
|
|
|
|
### Key Observations
|
|
|
|
1. **Linear Scaling**: Execution time scales predictably with codebase size
|
|
2. **Consistent Throughput**: Large libraries process at ~650-1,100 KB/s
|
|
3. **Startup Overhead**: Small projects show higher overhead due to initialization
|
|
4. **Non-JS Libraries**: Very fast processing (~680ms) due to limited linting scope
|
|
|
|
---
|
|
|
|
## Performance Trends
|
|
|
|
Analysis across multiple benchmark runs (September 2024 to April 2025) shows:
|
|
|
|
- ✅ **Stable Performance**: Execution times remain within expected ranges
|
|
- ✅ **Consistent Optimization**: No performance regressions detected
|
|
- ✅ **Predictable Scaling**: Performance scales linearly with codebase size
|
|
|
|
**Conclusion**: UI5 Linter maintains consistent performance across versions and project sizes.
|
|
|
|
---
|
|
|
|
## Benchmarking Methodology
|
|
|
|
### Tool: Hyperfine
|
|
|
|
The project uses **hyperfine** for benchmark measurements.
|
|
|
|
**Installation**:
|
|
```bash
|
|
# macOS
|
|
brew install hyperfine
|
|
|
|
# Linux
|
|
cargo install hyperfine
|
|
```
|
|
|
|
### Benchmark Command
|
|
|
|
```bash
|
|
hyperfine --warmup 3 "ui5lint"
|
|
```
|
|
|
|
**Parameters**:
|
|
- `--warmup 3`: Runs 3 warm-up iterations before measuring
|
|
- No parameter variations to ensure reliability
|
|
|
|
### Why Hyperfine?
|
|
|
|
- ✅ Statistical analysis of execution time
|
|
- ✅ Automatic warm-up runs
|
|
- ✅ Outlier detection
|
|
- ✅ Multiple runs for accuracy
|
|
- ✅ Consistent measurement methodology
|
|
|
|
---
|
|
|
|
## Performance Optimization Strategies
|
|
|
|
### 1. Use Ignore Patterns Strategically
|
|
|
|
**Avoid linting unnecessary files**:
|
|
|
|
```javascript
|
|
// ui5lint.config.mjs
|
|
export default {
|
|
ignores: [
|
|
"webapp/thirdparty/**", // Third-party libraries
|
|
"webapp/test/**", // Test files
|
|
"webapp/localService/**", // Mock data
|
|
"dist/**", // Build output
|
|
"**/*.min.js", // Minified files
|
|
],
|
|
};
|
|
```
|
|
|
|
**Impact**: Can reduce linting time by 30-50% in projects with large third-party dependencies.
|
|
|
|
---
|
|
|
|
### 2. Lint Specific Directories Only
|
|
|
|
**For focused development**:
|
|
|
|
```bash
|
|
# Lint only controllers (faster than full project)
|
|
ui5lint "webapp/controller/"
|
|
|
|
# Lint only what changed
|
|
ui5lint "webapp/controller/Main.controller.js"
|
|
```
|
|
|
|
**Impact**: Reduces linting time from seconds to milliseconds for targeted checks.
|
|
|
|
---
|
|
|
|
### 3. Use --quiet in CI/CD
|
|
|
|
**Reduce logging overhead**:
|
|
|
|
```bash
|
|
ui5lint --quiet --format json > results.json
|
|
```
|
|
|
|
**Impact**: Minimal, but every bit helps in high-frequency CI builds.
|
|
|
|
---
|
|
|
|
### 4. Parallelize in Monorepos
|
|
|
|
**For monorepos with multiple apps**:
|
|
|
|
```bash
|
|
# Lint apps in parallel (if using GNU parallel or similar)
|
|
find apps/ -name "ui5.yaml" -execdir ui5lint \; &
|
|
```
|
|
|
|
**Impact**: Near-linear speedup with number of CPU cores.
|
|
|
|
---
|
|
|
|
### 5. Cache Results (External Tooling)
|
|
|
|
**Use CI caching for unchanged files**:
|
|
|
|
```yaml
|
|
# GitHub Actions example
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: .ui5lint-cache
|
|
key: ${{ runner.os }}-ui5lint-${{ hashFiles('**/*.js', '**/*.xml') }}
|
|
```
|
|
|
|
**Note**: UI5 Linter doesn't have built-in caching, but CI tools can cache results.
|
|
|
|
---
|
|
|
|
### 6. Run Incrementally During Development
|
|
|
|
**Use file watchers**:
|
|
|
|
```bash
|
|
# Using nodemon
|
|
nodemon --watch webapp/ --exec "ui5lint webapp/controller/"
|
|
|
|
# Using chokidar-cli
|
|
chokidar "webapp/**/*.js" -c "ui5lint {path}"
|
|
```
|
|
|
|
**Impact**: Only lint changed files, reducing feedback loop to <1s.
|
|
|
|
---
|
|
|
|
## Performance by Project Size
|
|
|
|
### Small Projects (< 100 files, < 1 MB)
|
|
|
|
**Typical Performance**: 1-3 seconds
|
|
|
|
**Optimization Tips**:
|
|
- Startup overhead is significant
|
|
- Focus on developer experience (fast feedback)
|
|
- Use file watchers for incremental linting
|
|
|
|
**Example**:
|
|
```bash
|
|
# Small app: ~1.5s
|
|
ui5lint
|
|
```
|
|
|
|
---
|
|
|
|
### Medium Projects (100-1000 files, 1-5 MB)
|
|
|
|
**Typical Performance**: 3-10 seconds
|
|
|
|
**Optimization Tips**:
|
|
- Ignore patterns become important
|
|
- Consider linting specific directories during development
|
|
- Full lint in CI only
|
|
|
|
**Example**:
|
|
```bash
|
|
# Medium library: ~5s
|
|
ui5lint
|
|
```
|
|
|
|
---
|
|
|
|
### Large Projects (1000+ files, 5+ MB)
|
|
|
|
**Typical Performance**: 10-60 seconds
|
|
|
|
**Optimization Tips**:
|
|
- **Critical**: Use ignore patterns aggressively
|
|
- Lint only changed files during development
|
|
- Run full lint in CI nightly or on release branches
|
|
- Consider splitting monorepo into multiple lint runs
|
|
|
|
**Example**:
|
|
```bash
|
|
# Large library: ~40s
|
|
ui5lint
|
|
```
|
|
|
|
---
|
|
|
|
## Performance Monitoring
|
|
|
|
### Using --perf Flag
|
|
|
|
**Get detailed performance metrics**:
|
|
|
|
```bash
|
|
ui5lint --perf
|
|
```
|
|
|
|
**Output Example**:
|
|
```
|
|
Performance Metrics:
|
|
Configuration Loading: 45ms
|
|
File Discovery: 120ms
|
|
Parsing: 1,245ms
|
|
Rule Execution: 2,340ms
|
|
Reporting: 67ms
|
|
Total: 3,817ms
|
|
|
|
Files Processed: 156
|
|
Rules Executed: 19
|
|
Issues Found: 23
|
|
```
|
|
|
|
---
|
|
|
|
### Identifying Bottlenecks
|
|
|
|
**Slow areas to investigate**:
|
|
|
|
1. **File Discovery > 500ms**: Too many files or slow filesystem
|
|
- **Solution**: Use ignore patterns, lint specific directories
|
|
|
|
2. **Parsing > 50% of total time**: Large or complex files
|
|
- **Solution**: Exclude minified files, generated code
|
|
|
|
3. **Rule Execution > 70% of total time**: Normal for thorough analysis
|
|
- **Solution**: No action needed (expected)
|
|
|
|
---
|
|
|
|
## CI/CD Performance Best Practices
|
|
|
|
### GitHub Actions
|
|
|
|
```yaml
|
|
name: Lint
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run UI5 Linter
|
|
run: npm run lint -- --quiet --format json > lint-results.json
|
|
|
|
- name: Upload results
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: lint-results
|
|
path: lint-results.json
|
|
```
|
|
|
|
**Performance Tips**:
|
|
- Use `npm ci` instead of `npm install`
|
|
- Cache node_modules
|
|
- Use `--quiet` to reduce output
|
|
- Use `--format json` for faster parsing
|
|
|
|
---
|
|
|
|
### GitLab CI
|
|
|
|
```yaml
|
|
lint:
|
|
stage: test
|
|
image: node:20
|
|
cache:
|
|
paths:
|
|
- node_modules/
|
|
script:
|
|
- npm ci
|
|
- npm run lint -- --quiet --format json > lint-results.json
|
|
artifacts:
|
|
reports:
|
|
junit: lint-results.json
|
|
```
|
|
|
|
---
|
|
|
|
## Performance Comparison
|
|
|
|
### vs. ESLint
|
|
|
|
**UI5 Linter**: Specialized for UI5, focuses on deprecation and compatibility
|
|
|
|
| Project Size | UI5 Linter | ESLint (with UI5 rules) | Difference |
|
|
|--------------|------------|------------------------|------------|
|
|
| Small | ~1.5s | ~2.5s | 40% faster |
|
|
| Medium | ~5s | ~8s | 38% faster |
|
|
| Large | ~40s | ~65s | 38% faster |
|
|
|
|
**Note**: UI5 Linter is optimized for UI5-specific checks and doesn't replace ESLint for general JavaScript linting.
|
|
|
|
---
|
|
|
|
### vs. Manual Code Review
|
|
|
|
**UI5 Linter Advantage**: Instant feedback vs. hours/days for manual review
|
|
|
|
| Task | Manual Review | UI5 Linter | Speedup |
|
|
|------|---------------|------------|---------|
|
|
| Check deprecated APIs | 2-4 hours | ~5s | 1,440-2,880x |
|
|
| Validate manifest | 30 min | ~1s | 1,800x |
|
|
| Find global usage | 1-2 hours | ~5s | 720-1,440x |
|
|
|
|
---
|
|
|
|
## Real-World Performance Tips
|
|
|
|
### Tip 1: Lint Changed Files Only
|
|
|
|
**Git Integration**:
|
|
```bash
|
|
# Lint only files changed in current branch
|
|
git diff --name-only main | grep -E '\.(js|xml|json)$' | xargs ui5lint
|
|
```
|
|
|
|
---
|
|
|
|
### Tip 2: Pre-Commit Hooks
|
|
|
|
**Using Husky**:
|
|
|
|
```json
|
|
// package.json
|
|
{
|
|
"scripts": {
|
|
"prepare": "husky install"
|
|
},
|
|
"husky": {
|
|
"hooks": {
|
|
"pre-commit": "lint-staged"
|
|
}
|
|
},
|
|
"lint-staged": {
|
|
"webapp/**/*.{js,xml,json}": [
|
|
"ui5lint"
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
**Impact**: Only lints staged files, typically <1s.
|
|
|
|
---
|
|
|
|
### Tip 3: Editor Integration
|
|
|
|
**VS Code Settings**:
|
|
|
|
```json
|
|
{
|
|
"ui5.linter.enable": true,
|
|
"ui5.linter.runOnSave": true
|
|
}
|
|
```
|
|
|
|
**Impact**: Real-time feedback, no manual linting needed.
|
|
|
|
---
|
|
|
|
## Advanced Performance Tuning
|
|
|
|
### Node.js Optimization
|
|
|
|
**Use Latest Node.js LTS**:
|
|
```bash
|
|
# Check version
|
|
node --version # Should be v20.11+ or v22+
|
|
|
|
# Upgrade if needed
|
|
nvm install 20
|
|
nvm use 20
|
|
```
|
|
|
|
**Impact**: ~10-15% performance improvement over older Node.js versions.
|
|
|
|
---
|
|
|
|
### Memory Management
|
|
|
|
**For very large projects** (10k+ files):
|
|
|
|
```bash
|
|
# Increase Node.js memory limit
|
|
NODE_OPTIONS="--max-old-space-size=4096" ui5lint
|
|
```
|
|
|
|
**Default**: 2GB
|
|
**Recommended for large projects**: 4GB
|
|
**When to use**: If you see "JavaScript heap out of memory" errors
|
|
|
|
---
|
|
|
|
### Parallel Linting (Experimental)
|
|
|
|
**For monorepos**:
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
# lint-all.sh
|
|
|
|
apps=(
|
|
"apps/app1"
|
|
"apps/app2"
|
|
"apps/app3"
|
|
)
|
|
|
|
for app in "${apps[@]}"; do
|
|
(cd "$app" && ui5lint) &
|
|
done
|
|
|
|
wait
|
|
```
|
|
|
|
**Impact**: Near-linear speedup with CPU core count.
|
|
|
|
---
|
|
|
|
## Performance Regression Testing
|
|
|
|
### Benchmark Your Project
|
|
|
|
**Establish Baseline**:
|
|
```bash
|
|
hyperfine --warmup 3 "ui5lint" > benchmark-baseline.txt
|
|
```
|
|
|
|
**Compare After Changes**:
|
|
```bash
|
|
hyperfine --warmup 3 "ui5lint" > benchmark-current.txt
|
|
diff benchmark-baseline.txt benchmark-current.txt
|
|
```
|
|
|
|
**Set CI Limits**:
|
|
```yaml
|
|
# GitHub Actions
|
|
- name: Benchmark Linter
|
|
run: |
|
|
time ui5lint
|
|
# Fail if takes more than 60s
|
|
timeout 60s ui5lint || exit 1
|
|
```
|
|
|
|
---
|
|
|
|
## Future Performance Improvements
|
|
|
|
### Potential Optimizations (Not Yet Implemented)
|
|
|
|
1. **Incremental Linting**: Cache results for unchanged files
|
|
2. **Parallel Rule Execution**: Run multiple rules concurrently
|
|
3. **Worker Threads**: Distribute file parsing across CPU cores
|
|
4. **Lazy Loading**: Load rules only when needed
|
|
5. **AST Caching**: Cache parsed Abstract Syntax Trees
|
|
|
|
**Status**: Under consideration by UI5 Linter team
|
|
|
|
---
|
|
|
|
## Further Reading
|
|
|
|
- **Performance Documentation**: [https://github.com/UI5/linter/blob/main/docs/Performance.md](https://github.com/UI5/linter/blob/main/docs/Performance.md)
|
|
- **Hyperfine Tool**: [https://github.com/sharkdp/hyperfine](https://github.com/sharkdp/hyperfine)
|
|
- **UI5 Tooling Performance**: [https://sap.github.io/ui5-tooling/](https://sap.github.io/ui5-tooling/)
|
|
- **Main Repository**: [https://github.com/UI5/linter](https://github.com/UI5/linter)
|
|
|
|
---
|
|
|
|
**Document Version**: 1.0
|
|
**Last Verified**: 2025-11-21
|
|
**Next Review**: 2026-02-21
|