File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ def read_file_contents(self, paths: list) -> list:
62
62
63
63
def regex_scan (self , file_contents : list ) -> dict :
64
64
"""Scan file(s) content."""
65
+ import time
66
+ from billiard import Pool
67
+ start_time = time .time ()
68
+
65
69
# Use a ProcessPool for CPU-bound regex
66
70
with ProcessPoolExecutor (max_workers = self .cpu ) as cpu_executor :
67
71
@@ -70,6 +74,18 @@ def regex_scan(self, file_contents: list) -> dict:
70
74
self .pattern_matcher ,
71
75
file_contents ,
72
76
)
77
+ endtime = time .time ()
78
+ print (f"Execution ProcPool time: { endtime - start_time :.2f} seconds" )
79
+
80
+ with Pool (processes = self .cpu ) as cpu_pool :
81
+ # Use billiard's map to distribute file_contents to self.pattern_matcher
82
+ results = cpu_pool .map (
83
+ self .pattern_matcher ,
84
+ file_contents ,
85
+ )
86
+ endtime = time .time ()
87
+ print (f"Execution Billiard time: { endtime - start_time :.2f} seconds" )
88
+ start_time = time .time ()
73
89
74
90
# Compile findings
75
91
self .add_finding (results )
You can’t perform that action at this time.
0 commit comments