UNPKG

supamend

Version:

Pluggable DevSecOps Security Scanner with 10+ scanners and multiple reporting channels

45 lines 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MetricsCollector = void 0; class MetricsCollector { constructor() { this.metrics = []; } startScan() { const scanId = Date.now().toString(); const startTime = performance.now(); return { scanId, startTime }; } endScan(scanId, startTime, scannersUsed, issuesFound) { const scanDuration = performance.now() - startTime; const metrics = { scanDuration, scannersUsed, issuesFound, memoryUsage: process.memoryUsage(), timestamp: new Date() }; this.metrics.push(metrics); // Keep only last 100 metrics if (this.metrics.length > 100) { this.metrics.shift(); } } getMetrics() { return [...this.metrics]; } getAverageMetrics() { if (this.metrics.length === 0) return {}; const avg = this.metrics.reduce((acc, m) => ({ scanDuration: acc.scanDuration + m.scanDuration, issuesFound: acc.issuesFound + m.issuesFound }), { scanDuration: 0, issuesFound: 0 }); return { scanDuration: avg.scanDuration / this.metrics.length, issuesFound: avg.issuesFound / this.metrics.length }; } } exports.MetricsCollector = MetricsCollector; //# sourceMappingURL=metrics.js.map