@@ -206,7 +206,7 @@ def test_normalize_string(self):
206206            ("test_string" , "test-string" ),
207207            ("test string" , "test-string" ),
208208            ("test--string" , "test-string" ),
209-             ("test (private)" , "test(private) " ),
209+             ("test   (private)" , "test" ),
210210            ("test@#$%^&*" , "test-" ),
211211        ]
212212
@@ -335,6 +335,97 @@ def test_filter_public_result(self):
335335        result  =  self .fetcher ._filter_public_result (private_list , public_list )
336336        self .assertEqual (result , expected )
337337
338+     def  test_filter_results (self ):
339+         """Test filter_results method with various filter combinations.""" 
340+         # Create test data 
341+         test_data  =  [
342+             {
343+                 "info" : {
344+                     "model" : "llama3" ,
345+                     "backend" : "qlora" ,
346+                     "device" : "iphone-15-pro-max" ,
347+                     "arch" : "ios-17" ,
348+                 },
349+                 "rows" : [{"metric_1" : 1.0 }],
350+             },
351+             {
352+                 "info" : {
353+                     "model" : "llama3" ,
354+                     "backend" : "spinquant" ,
355+                     "device" : "iphone-15-pro-max" ,
356+                     "arch" : "ios-17" ,
357+                 },
358+                 "rows" : [{"metric_1" : 2.0 }],
359+             },
360+             {
361+                 "info" : {
362+                     "model" : "mv3" ,
363+                     "backend" : "xnnpack-q8" ,
364+                     "device" : "samsung-galaxy-s22-5g" ,
365+                     "arch" : "android-13" ,
366+                 },
367+                 "rows" : [{"metric_1" : 3.0 }],
368+             },
369+             {
370+                 "info" : {
371+                     "model" : "mv3" ,
372+                     "backend" : "qnn-q8" ,
373+                     "device" : "samsung-galaxy-s22-5g" ,
374+                     "arch" : "android-13" ,
375+                 },
376+                 "rows" : [{"metric_1" : 4.0 }],
377+             },
378+         ]
379+ 
380+         # Test with no filters 
381+         empty_filters  =  self .module .BenchmarkFilters (
382+             models = None , backends = None , devices = None 
383+         )
384+         result  =  self .fetcher .filter_results (test_data , empty_filters )
385+         self .assertEqual (result , test_data )
386+ 
387+         # Test with model filter 
388+         model_filters  =  self .module .BenchmarkFilters (
389+             models = ["llama3" ], backends = None , devices = None 
390+         )
391+         result  =  self .fetcher .filter_results (test_data , model_filters )
392+         self .assertEqual (len (result ), 2 )
393+         self .assertTrue (all (item ["info" ]["model" ] ==  "llama3"  for  item  in  result ))
394+ 
395+         # Test with backend filter 
396+         backend_filters  =  self .module .BenchmarkFilters (
397+             models = None , backends = ["qlora" , "qnn-q8" ], devices = None 
398+         )
399+         result  =  self .fetcher .filter_results (test_data , backend_filters )
400+         self .assertEqual (len (result ), 2 )
401+         self .assertTrue (
402+             all (item ["info" ]["backend" ] in  ["qlora" , "qnn-q8" ] for  item  in  result )
403+         )
404+ 
405+         # Test with device filter 
406+         device_filters  =  self .module .BenchmarkFilters (
407+             models = None , backends = None , devices = ["samsung-galaxy-s22-5g" ]
408+         )
409+         result  =  self .fetcher .filter_results (test_data , device_filters )
410+         self .assertEqual (len (result ), 2 )
411+         self .assertTrue (
412+             all ("samsung-galaxy-s22-5g"  in  item ["info" ]["device" ] for  item  in  result )
413+         )
414+ 
415+         # Test with combined filters (And logic fails) 
416+         combined_filters  =  self .module .BenchmarkFilters (
417+             models = ["llama3" ], backends = ["xnnpack-q8" ], devices = None 
418+         )
419+         result  =  self .fetcher .filter_results (test_data , combined_filters )
420+         self .assertEqual (len (result ), 0 )
421+ 
422+         # Test with combined filters (And logic success) 
423+         combined_filters  =  self .module .BenchmarkFilters (
424+             models = ["llama3" ], backends = None , devices = ["iphone-15-pro-max" ]
425+         )
426+         result  =  self .fetcher .filter_results (test_data , combined_filters )
427+         self .assertEqual (len (result ), 2 )
428+ 
338429    @patch ( 
339430        "get_benchmark_analysis_data.ExecutorchBenchmarkFetcher._fetch_execu_torch_data"  
340431    ) 
@@ -442,7 +533,7 @@ def test_run_with_failure_report(self, mock_fetch):
442533                "arch" : "ios-17.4.3" ,
443534                "aws_type" : "private" ,
444535                "backend" : "qlora" ,
445-                 "device" : "iphone-15-pro-max(private) " ,
536+                 "device" : "iphone-15-pro-max" ,
446537                "model" : "llama3" ,
447538            },
448539            "rows" : [
@@ -475,6 +566,76 @@ def test_run_no_data(self, mock_fetch):
475566        self .assertEqual (self .fetcher .matching_groups , {})
476567        mock_fetch .assert_called_once_with ("2025-06-01T00:00:00" , "2025-06-02T00:00:00" )
477568
569+     @patch ( 
570+         "get_benchmark_analysis_data.ExecutorchBenchmarkFetcher._fetch_execu_torch_data"  
571+     ) 
572+     def  test_run_with_filters (self , mock_fetch ):
573+         """Test run method with filters.""" 
574+         # Setup mock data 
575+         mock_data  =  [
576+             {
577+                 "groupInfo" : {
578+                     "model" : "llama3" ,
579+                     "backend" : "qlora" ,
580+                     "device" : "Iphone 15 pro max (private)" ,
581+                     "arch" : "ios_17" ,
582+                 },
583+                 "rows" : [{"metric_1" : 1.0 }],
584+             },
585+             {
586+                 "groupInfo" : {
587+                     "model" : "mv3" ,
588+                     "backend" : "xnnpack_q8" ,
589+                     "device" : "s22_5g (private)" ,
590+                     "arch" : "android_13" ,
591+                 },
592+                 "rows" : [{"metric_1" : 2.0 }],
593+             },
594+             {
595+                 "groupInfo" : {
596+                     "model" : "mv3" ,
597+                     "backend" : "xnnpack_q8" ,
598+                     "device" : "s22_5g" ,
599+                     "arch" : "android_13" ,
600+                 },
601+                 "rows" : [{"metric_1" : 3.0 }],
602+             },
603+         ]
604+         mock_fetch .return_value  =  mock_data 
605+ 
606+         # Create filters for llama3 model only 
607+         filters  =  self .module .BenchmarkFilters (
608+             models = ["llama3" ], backends = None , devices = None 
609+         )
610+         # Run the method with filters 
611+         self .fetcher .run ("2025-06-01T00:00:00" , "2025-06-02T00:00:00" , filters )
612+         result  =  self .fetcher .get_result ()
613+         print ("result1" , result )
614+ 
615+         # Verify results - should only have llama3 in private results 
616+         self .assertEqual (len (result ["private" ]), 1 )
617+         self .assertEqual (result ["private" ][0 ]["info" ]["model" ], "llama3" )
618+ 
619+         # Public results should be empty since there's no matching table_name 
620+         self .assertEqual (result ["public" ], [])
621+ 
622+         # Test with backend filter 
623+         filters  =  self .module .BenchmarkFilters (
624+             models = None , backends = ["xnnpack-q8" ], devices = None 
625+         )
626+         self .fetcher .run ("2025-06-01T00:00:00" , "2025-06-02T00:00:00" , filters )
627+         result  =  self .fetcher .get_result ()
628+ 
629+         print ("result" , result )
630+ 
631+         # Verify results - should only have xnnpack-q8 in private results 
632+         self .assertEqual (len (result ["private" ]), 1 )
633+         self .assertEqual (result ["private" ][0 ]["info" ]["backend" ], "xnnpack-q8" )
634+ 
635+         # Public results should have the matching xnnpack-q8 entry 
636+         self .assertEqual (len (result ["public" ]), 1 )
637+         self .assertEqual (result ["public" ][0 ]["info" ]["backend" ], "xnnpack-q8" )
638+ 
478639    def  test_to_dict (self ):
479640        """Test to_dict method.""" 
480641        # Setup test data 
0 commit comments