UNPKG

@re-shell/cli

Version:

Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja

255 lines (254 loc) 6.96 kB
import { EventEmitter } from 'events'; export interface LoadTestConfig { scenarios: LoadScenario[]; maxApps?: number; maxFiles?: number; maxDependencies?: number; concurrent?: boolean; workers?: number; generateReport?: boolean; captureMetrics?: boolean; simulateRealWorld?: boolean; progressiveLoad?: boolean; } export interface LoadScenario { name: string; description?: string; type: 'workspace' | 'build' | 'dependency' | 'file' | 'mixed'; load: LoadProfile; operations: LoadOperation[]; expectations?: LoadExpectation[]; timeout?: number; } export interface LoadProfile { apps: number; filesPerApp?: number; dependenciesPerApp?: number; sharedDependencies?: number; fileSize?: FileSizeDistribution; complexity?: 'low' | 'medium' | 'high'; growth?: GrowthPattern; } export interface FileSizeDistribution { small: number; medium: number; large: number; xlarge: number; } export interface GrowthPattern { type: 'linear' | 'exponential' | 'random'; rate: number; interval: number; } export interface LoadOperation { type: 'create' | 'read' | 'update' | 'delete' | 'build' | 'analyze' | 'search'; target: 'app' | 'file' | 'dependency' | 'workspace'; parallel?: boolean; count?: number; pattern?: string; } export interface LoadExpectation { metric: 'time' | 'memory' | 'cpu' | 'io'; operation?: string; threshold: number; unit: 'ms' | 's' | 'mb' | 'gb' | 'percent'; } export interface LoadTestResult { scenario: string; success: boolean; metrics: LoadMetrics; operations: OperationResult[]; violations: ExpectationViolation[]; profile: ResourceProfile; timestamp: Date; } export interface LoadMetrics { totalTime: number; setupTime: number; executionTime: number; teardownTime: number; throughput: number; peakMemory: number; avgMemory: number; peakCpu: number; avgCpu: number; ioOperations: number; errors: number; } export interface OperationResult { operation: string; count: number; totalTime: number; avgTime: number; minTime: number; maxTime: number; errors: number; throughput: number; } export interface ExpectationViolation { expectation: string; actual: number; expected: number; difference: number; percentage: number; } export interface ResourceProfile { memory: ResourceTimeline; cpu: ResourceTimeline; io: ResourceTimeline; handles: ResourceTimeline; } export interface ResourceTimeline { samples: ResourceSample[]; peak: number; average: number; trend: 'stable' | 'increasing' | 'decreasing'; } export interface ResourceSample { timestamp: number; value: number; operation?: string; } export interface LoadTestReport { summary: LoadTestSummary; results: LoadTestResult[]; analysis: LoadAnalysis; recommendations: string[]; charts?: LoadChartData; timestamp: Date; } export interface LoadTestSummary { totalScenarios: number; passed: number; failed: number; totalOperations: number; totalDuration: number; maxLoad: { apps: number; files: number; dependencies: number; }; performance: { fastest: string; slowest: string; mostMemory: string; mostCpu: string; }; } export interface LoadAnalysis { scalability: ScalabilityAnalysis; bottlenecks: Bottleneck[]; trends: TrendAnalysis; limits: ResourceLimits; } export interface ScalabilityAnalysis { linear: boolean; breakpoint?: number; degradation?: DegradationProfile; recommendation: string; } export interface DegradationProfile { startPoint: number; rate: number; cause: 'memory' | 'cpu' | 'io' | 'unknown'; } export interface Bottleneck { operation: string; resource: 'memory' | 'cpu' | 'io' | 'time'; impact: 'high' | 'medium' | 'low'; description: string; suggestion: string; } export interface TrendAnalysis { memoryTrend: 'stable' | 'linear' | 'exponential'; cpuTrend: 'stable' | 'linear' | 'exponential'; performanceTrend: 'stable' | 'degrading' | 'improving'; } export interface ResourceLimits { maxApps: number; maxFiles: number; maxDependencies: number; maxConcurrent: number; constraints: string[]; } export interface LoadChartData { performanceOverTime: ChartSeries[]; resourceUsage: ChartSeries[]; throughput: ChartSeries[]; scalability: ChartSeries[]; } export interface ChartSeries { name: string; data: Array<{ x: number; y: number; }>; unit: string; } export declare class LoadTesting extends EventEmitter { private config; private results; private workspaceDir; private resourceMonitor; private resourceSamples; constructor(config: LoadTestConfig); run(): Promise<LoadTestReport>; private runScenario; private setupScenario; private createApps; private createApp; private createFiles; private generateDependencies; private generateFileContent; private getFileSize; private generateSimpleContent; private generateMediumContent; private generateComplexContent; private createDependencies; private createMockDependency; private applyGrowthPattern; private executeOperations; private executeOperation; private performCreate; private performRead; private performUpdate; private performDelete; private performBuild; private performAnalyze; private performSearch; private startResourceMonitoring; private stopResourceMonitoring; private collectMetrics; private collectResourceProfile; private analyzeTrend; private checkExpectations; private getTimeMetric; private getMemoryMetric; private getCpuMetric; private getIoMetric; private prepareWorkspace; private teardownScenario; private cleanup; private generateReport; private generateSummary; private calculateMaxLoad; private analyzePerformance; private analyzeResults; private analyzeScalability; private checkLinearScaling; private findBreakpoint; private identifyBottlenecks; private analyzeTrends; private calculateLimits; private generateRecommendations; private generateCharts; private saveReport; private formatSummary; private createEmptyMetrics; private createEmptyProfile; private createEmptyTimeline; private wait; } export declare function createLoadScenario(name: string, type: LoadScenario['type'], load: LoadProfile, operations: LoadOperation[]): LoadScenario; export declare function createLoadProfile(apps: number, options?: Partial<LoadProfile>): LoadProfile; export declare function runLoadTests(scenarios: LoadScenario[], config?: Partial<LoadTestConfig>): Promise<LoadTestReport>;