- Create benchmark test suites for critical operations: - Node loading performance - Database query performance - Search operations performance - Validation performance - MCP tool execution performance - Add GitHub Actions workflow for benchmark tracking: - Runs on push to main and PRs - Uses github-action-benchmark for historical tracking - Comments on PRs with performance results - Alerts on >10% performance regressions - Stores results in GitHub Pages - Create benchmark infrastructure: - Custom Vitest benchmark configuration - JSON reporter for CI results - Result formatter for github-action-benchmark - Performance threshold documentation - Add supporting utilities: - SQLiteStorageService for benchmark database setup - MCPEngine wrapper for testing MCP tools - Test factories for generating benchmark data - Enhanced NodeRepository with benchmark methods - Document benchmark system: - Comprehensive benchmark guide in docs/BENCHMARKS.md - Performance thresholds in .github/BENCHMARK_THRESHOLDS.md - README for benchmarks directory - Integration with existing test suite The benchmark system will help monitor performance over time and catch regressions before they reach production. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { bench, describe } from 'vitest';
|
|
import { NodeLoader } from '../../src/loaders/node-loader';
|
|
import { NodeRepository } from '../../src/database/node-repository';
|
|
import { SQLiteStorageService } from '../../src/services/sqlite-storage-service';
|
|
import path from 'path';
|
|
|
|
describe('Node Loading Performance', () => {
|
|
let loader: NodeLoader;
|
|
let repository: NodeRepository;
|
|
let storage: SQLiteStorageService;
|
|
|
|
beforeAll(() => {
|
|
storage = new SQLiteStorageService(':memory:');
|
|
repository = new NodeRepository(storage);
|
|
loader = new NodeLoader(repository);
|
|
});
|
|
|
|
afterAll(() => {
|
|
storage.close();
|
|
});
|
|
|
|
bench('loadPackage - n8n-nodes-base', async () => {
|
|
await loader.loadPackage('n8n-nodes-base');
|
|
}, {
|
|
iterations: 5,
|
|
warmupIterations: 2,
|
|
warmupTime: 1000,
|
|
time: 5000
|
|
});
|
|
|
|
bench('loadPackage - @n8n/n8n-nodes-langchain', async () => {
|
|
await loader.loadPackage('@n8n/n8n-nodes-langchain');
|
|
}, {
|
|
iterations: 5,
|
|
warmupIterations: 2,
|
|
warmupTime: 1000,
|
|
time: 5000
|
|
});
|
|
|
|
bench('loadNodesFromPath - single file', async () => {
|
|
const testPath = path.join(process.cwd(), 'node_modules/n8n-nodes-base/dist/nodes/HttpRequest');
|
|
await loader.loadNodesFromPath(testPath, 'n8n-nodes-base');
|
|
}, {
|
|
iterations: 100,
|
|
warmupIterations: 10,
|
|
warmupTime: 500,
|
|
time: 3000
|
|
});
|
|
|
|
bench('parsePackageJson', async () => {
|
|
const packageJsonPath = path.join(process.cwd(), 'node_modules/n8n-nodes-base/package.json');
|
|
await loader['parsePackageJson'](packageJsonPath);
|
|
}, {
|
|
iterations: 1000,
|
|
warmupIterations: 100,
|
|
warmupTime: 100,
|
|
time: 2000
|
|
});
|
|
}); |