@himorishige/noren-devtools
Version:
Development and testing tools for Noren PII detection library
84 lines (83 loc) • 2.31 kB
TypeScript
/**
* Performance benchmark system for continuous optimization
* Streamlined implementation with unified statistical analysis and reporting
*/
import type { Registry } from '@himorishige/noren-core';
import { type SummaryStats } from './stats-common.js';
export interface PerformanceResult {
operation: string;
duration: number;
memoryPeak: number;
memoryDelta: number;
throughput: number;
inputSize: number;
outputSize: number;
timestamp: number;
}
export interface BenchmarkConfig {
test_cases: Array<{
id: string;
name: string;
text: string;
expected_pii_count?: number;
}>;
iterations: number;
warmup_runs?: number;
memory_monitoring?: boolean;
timeout_ms?: number;
}
export interface BenchmarkTestCaseResult {
testCase: {
id: string;
name: string;
};
results: PerformanceResult[];
summary: SummaryStats;
}
export interface BenchmarkSummary {
operation: string;
totalRuns: number;
duration: SummaryStats;
throughput: number;
memoryEfficiency: number;
errorRate?: number;
textSizeCorrelation: number;
}
export declare class BenchmarkTextGenerator {
private static readonly PII_PATTERNS;
private static readonly NORMAL_WORDS;
generateText(targetSize: number, piiDensity: number): string;
generateJson(targetSize: number, piiDensity: number): string;
}
export declare class MemoryMonitor {
private initialMemory;
private peakMemory;
private intervalId?;
start(): void;
stop(): {
peak: number;
delta: number;
};
}
export declare class PrecisionTimer {
private startTime;
constructor();
stop(): number;
}
export declare class BenchmarkRunner {
runBenchmark(operation: string, registry: Registry, testCases: BenchmarkConfig['test_cases'], options: {
iterations: number;
warmupRuns?: number;
memoryMonitoring?: boolean;
}): Promise<{
summary: BenchmarkSummary;
testCaseResults: BenchmarkTestCaseResult[];
}>;
private runSingleTest;
private printBenchmarkReport;
}
export declare const BENCHMARK_CONFIGS: {
readonly quick: BenchmarkConfig;
readonly standard: BenchmarkConfig;
readonly comprehensive: BenchmarkConfig;
};