-
PostgreSQL Database Running
# Ensure your DATABASE_URL is set export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/disciplr_test"
-
Dependencies Installed
npm install
-
Migrations Applied
npm run migrate:latest
npm run test:perf# Vaults endpoint
npm test -- src/tests/performance/vaults.perf.test.ts
# Transactions endpoint
npm test -- src/tests/performance/transactions.perf.test.ts
# Analytics endpoints
npm test -- src/tests/performance/analytics.perf.test.tsnpm test -- src/tests/helpers/performanceHelpers.test.tsOK Vaults list (no pagination): 245ms
OK Vaults list (with pagination): 198ms
OK Vaults list (with sorting): 267ms
OK Vaults list (with filtering): 223ms
OK Vaults list (combined operations): 289ms
OK Transactions list (first page): 312ms
OK Transactions list (cursor pagination): 298ms
OK Transactions list (with filter): 334ms
OK Transactions list (date range filter): 356ms
OK Transactions list (by vault): 287ms
OK Transactions deep pagination (10 pages): 2145ms
OK Analytics summary: 45ms
OK Analytics overview: 38ms
OK Analytics vaults: 42ms
OK Analytics vault-specific: 41ms
OK Analytics milestone trends: 156ms
OK Analytics behavior: 134ms
OK Analytics milestone trends (weekly): 178ms
Performance test "vaults_list_no_pagination" failed:
Response time 3456ms exceeded threshold 2000ms.
Response time: 3456ms
- < 500ms: Excellent
- 500-1000ms: Good
- 1000-2000ms: Acceptable (within threshold)
- > 2000ms: Needs investigation
Error: Unable to acquire a connection
Solution: Start PostgreSQL and verify DATABASE_URL
Error: relation "vaults" does not exist
Solution: Run npm run migrate:latest
Response time 3456ms exceeded threshold 2000ms
Solution:
- Check database indexes with
EXPLAIN ANALYZE - Review query patterns for N+1 problems
- Consider adjusting thresholds if environment is consistently slower
If tests are consistently failing or passing with too much margin:
- Edit the shared budget table in
src/tests/helpers/performanceHelpers.ts - Adjust thresholds:
const thresholds = getPerformanceBudget('transactions.combinedSortFilter', { maxResponseTime: 950, maxQueryCount: 5, })
- Document changes in
docs/performance-testing.md
Performance tests emit structured JSON logs:
{
"level": "info",
"event": "performance.smoke_test",
"test": "vaults_list_no_pagination",
"responseTime": 245,
"queryCount": 3,
"passed": true,
"violations": [],
"timestamp": "2026-04-25T10:30:00.000Z"
}Use these logs to:
- Track performance trends over time
- Set up alerts for threshold violations
- Identify performance regressions in CI
To verify indexes are being used:
EXPLAIN ANALYZE
SELECT * FROM vaults
WHERE creator_id = 'user-123'
ORDER BY created_at DESC
LIMIT 20;Look for:
- OK:
Index Scan,Index Only Scan, orBitmap Index Scan - Investigate:
Seq Scanon high-cardinality list queries
Tests run automatically in CI:
- name: Run performance smoke tests
run: npm run test:perf
env:
NODE_ENV: test- Increase Jest timeout in test files
- Reduce dataset size for local development
- Check database connection performance
- Run with
--maxWorkers=1to avoid resource contention - Increase thresholds by 10-20%
- Check for background processes affecting performance
- Reduce dataset sizes in test files
- Ensure proper cleanup in
afterAllhooks - Check for memory leaks in application code
See docs/performance-testing.md for:
- Detailed architecture
- Best practices
- Security considerations
- Adding new performance tests
- Advanced troubleshooting
| Command | Purpose |
|---|---|
npm run test:perf |
Run all performance tests |
npm test -- --testPathPattern=performance |
Alternative way to run perf tests |
npm run migrate:latest |
Apply database migrations |
npm run migrate:status |
Check migration status |
For issues or questions:
- Check
docs/performance-testing.md - Review test output and logs
- Validate database indexes
- Check CI logs for environment-specific issues