@@ -173,7 +173,6 @@ def _clean(self) -> None:
173173 os .remove (self .report_path + ".report.json" )
174174 os .remove (self .report_path + ".report.html" )
175175
176-
177176class LighthouseRepeatRunner :
178177 """
179178 A class for running performance tests using Lighthouse, multiple times and returning
@@ -187,7 +186,7 @@ class LighthouseRepeatRunner:
187186 """
188187
189188 def __init__ (self , url : str , form_factor : str = 'mobile' , quiet : bool = True ,
190- additional_settings : List [str ] = [], repeats : int = 3 ):
189+ additional_settings : List [str ] = [], repeats : int = 3 , timings : List [ str ] = BASE_TIMINGS ):
191190 """
192191 Initialize a new LighthouseRepeatRunner object.
193192
@@ -204,7 +203,9 @@ def __init__(self, url: str, form_factor: str = 'mobile', quiet: bool = True,
204203
205204 repeats (int, optional): The number of times to repeat the Lighthouse performance test.
206205 Defaults to 3.
207-
206+
207+ timings (list, optional): A list of performance metrics to measure during the test.
208+ Defaults to BASE_TIMINGS, which includes several common metrics.
208209 """
209210
210211 # Initialize an empty list to store the Lighthouse reports from each test repeat
@@ -218,7 +219,7 @@ def __init__(self, url: str, form_factor: str = 'mobile', quiet: bool = True,
218219 progress .set_description ('Run {0}/{1}' .format (i , repeats ))
219220 reports .append (LighthouseRunner (url , form_factor = form_factor ,
220221 quiet = quiet ,
221- additional_settings = additional_settings ).report )
222+ additional_settings = additional_settings , timings = timings ).report )
222223
223224 # Calculate the average values for each performance metric across all test repeats
224225 report = namedtuple ('LighthouseAveragedReport' , 'timings, score' )
@@ -253,7 +254,7 @@ class BatchRunner:
253254 """
254255
255256 def __init__ (self , urls : List [str ], form_factors : List [str ], quiet : bool = True ,
256- additional_settings : dict = None , repeats : int = 3 ):
257+ additional_settings : dict = None , repeats : int = 3 , timings : List [ str ] = BASE_TIMINGS ):
257258 """
258259 Args:
259260 urls (list(str)): List of URLs to run Lighthouse reports on.
@@ -266,6 +267,9 @@ def __init__(self, urls: List[str], form_factors: List[str], quiet: bool = True,
266267 Defaults to None.
267268
268269 repeats (int, optional): Number of times to repeat each report. Defaults to 3.
270+
271+ timings (list, optional): A list of performance metrics to measure during the test.
272+ Defaults to BASE_TIMINGS, which includes several common metrics.
269273 """
270274
271275 # Ensure urls and form_factors are lists
@@ -286,5 +290,5 @@ def __init__(self, urls: List[str], form_factors: List[str], quiet: bool = True,
286290 # Run the Lighthouse report for this combination and append it to reports list
287291 report = LighthouseRepeatRunner (url , factor , quiet ,
288292 additional_settings ,
289- repeats ).report
293+ repeats = repeats , timings = timings ).report
290294 self .reports .append ((url , factor , report ))
0 commit comments