1- import { describe , it , expect , beforeEach } from 'vitest' ;
1+ import { describe , it , expect , beforeEach , afterEach } from 'vitest' ;
22import { SearchStrategy } from '../../src/SearchStrategies/types' ;
33import { PerformanceMonitor } from '../utils/PerformanceMonitor' ;
44
@@ -20,10 +20,6 @@ describe('Performance Benchmarks', () => {
2020 let monitor : PerformanceMonitor ;
2121
2222 beforeEach ( ( ) => {
23- const matchFunction = ( text : string , criteria : string ) => {
24- return text . toLowerCase ( ) . includes ( criteria . toLowerCase ( ) ) ;
25- } ;
26-
2723 const findMatchesFunction = ( text : string , criteria : string ) => {
2824 const lowerText = text . toLowerCase ( ) ;
2925 const lowerCriteria = criteria . toLowerCase ( ) ;
@@ -47,10 +43,19 @@ describe('Performance Benchmarks', () => {
4743 return matches ;
4844 } ;
4945
50- strategy = new SearchStrategy ( matchFunction , findMatchesFunction ) ;
46+ strategy = new SearchStrategy ( findMatchesFunction ) ;
5147 monitor = new PerformanceMonitor ( ) ;
5248 } ) ;
5349
50+ afterEach ( ( ) => {
51+ if ( strategy && strategy . clearCache ) {
52+ strategy . clearCache ( ) ;
53+ }
54+ if ( monitor ) {
55+ monitor . reset ( ) ;
56+ }
57+ } ) ;
58+
5459 describe ( 'Cache Hit Rate' , ( ) => {
5560 it ( 'should achieve high cache hit rate on repeated searches' , ( ) => {
5661 for ( let i = 0 ; i < 100 ; i ++ ) {
0 commit comments