fix(#25): Performance-Baseline fuer Kernendpunkte definieren
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
b44e7bf46c
commit
10957fce65
1 changed files with 68 additions and 0 deletions
68
docs/performance-baseline.md
Normal file
68
docs/performance-baseline.md
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
# Performance-Baseline fuer Kernendpunkte
|
||||||
|
|
||||||
|
## Ziel
|
||||||
|
|
||||||
|
Umsetzung der in [Issue #25](https://forgejo.openclaw.ai/openclaw/helpyourneighbour/issues/25) definierten Ziele:
|
||||||
|
|
||||||
|
1. Zielwerte fuer /health, /auth/login, /requests GET definieren.
|
||||||
|
2. Lightweight-Benchmark-Setup dokumentieren.
|
||||||
|
3. Schwellenwert fuer Regressionswarnung festlegen.
|
||||||
|
|
||||||
|
## Baseline-Werte
|
||||||
|
|
||||||
|
| Endpunkt | Zielzeit (ms) | Maximalzeit (ms) |
|
||||||
|
|----------------|---------------|------------------|
|
||||||
|
| /health | 50 | 100 |
|
||||||
|
| /auth/login | 200 | 400 |
|
||||||
|
| /requests GET | 300 | 600 |
|
||||||
|
|
||||||
|
## Benchmark-Setup
|
||||||
|
|
||||||
|
### Lokale Tests
|
||||||
|
|
||||||
|
Lokale Performance-Tests werden mit `curl` und `time` durchgeführt:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
time curl -s http://localhost:3000/health
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker-Integration
|
||||||
|
|
||||||
|
Ein Docker-Container wird verwendet, um die Tests in einer produktähnlichen Umgebung durchzuführen.
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
FROM node:18-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --only=production
|
||||||
|
COPY . .
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["npm", "start"]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Benchmark-Tool
|
||||||
|
|
||||||
|
Ein einfaches Node.js-Skript zur Durchführung der Tests:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const endpoints = [
|
||||||
|
'/health',
|
||||||
|
'/auth/login',
|
||||||
|
'/requests'
|
||||||
|
];
|
||||||
|
|
||||||
|
endpoints.forEach(endpoint => {
|
||||||
|
const start = Date.now();
|
||||||
|
exec(`curl -s http://localhost:3000${endpoint}`, (error, stdout, stderr) => {
|
||||||
|
const end = Date.now();
|
||||||
|
console.log(`${endpoint}: ${end - start}ms`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Regressionswarnung
|
||||||
|
|
||||||
|
Wenn eine Endpunkt-Zeit um mehr als 20% über der Zielzeit liegt, wird eine Warnung ausgelöst.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue