@@ -241,11 +241,11 @@ def run_master(iterations, target_module, cpu=0, csv_path=None, clear_cache=True
241241 final_messages = []
242242
243243 if fail_threshold is not None :
244- if p99_time > fail_threshold :
245- final_messages .append (f"FAILURE: P99 import time ({ p99_time :.2f} ms) exceeds the failure threshold ({ fail_threshold } ms)." )
244+ if p50_time > fail_threshold :
245+ final_messages .append (f"FAILURE: Median import time ({ p50_time :.2f} ms) exceeds the failure threshold ({ fail_threshold } ms)." )
246246 exit_code = 1
247247 else :
248- final_messages .append (f"SUCCESS: P99 import time ({ p99_time :.2f} ms) is within the failure threshold ({ fail_threshold } ms)." )
248+ final_messages .append (f"SUCCESS: Median import time ({ p50_time :.2f} ms) is within the failure threshold ({ fail_threshold } ms)." )
249249
250250 if diff_baseline :
251251 if os .path .exists (diff_baseline ):
@@ -255,22 +255,22 @@ def run_master(iterations, target_module, cpu=0, csv_path=None, clear_cache=True
255255 next (reader ) # skip header
256256 for row in reader :
257257 baseline_times .append (float (row [1 ]))
258- _ , _ , baseline_p99 = _calculate_percentiles (baseline_times )
259- diff = p99_time - baseline_p99
258+ baseline_p50 , _ , _ = _calculate_percentiles (baseline_times )
259+ diff = p50_time - baseline_p50
260260
261261 diff_msg = (
262262 f"--- Diff vs Baseline ---\n "
263- f"Baseline P99 : { baseline_p99 :.2f} ms\n "
264- f"Current P99 : { p99_time :.2f} ms\n "
265- f"Difference: { diff :+.2f} ms"
263+ f"Baseline Median : { baseline_p50 :.2f} ms\n "
264+ f"Current Median : { p50_time :.2f} ms\n "
265+ f"Difference: { diff :+.2f} ms"
266266 )
267267 final_messages .append (diff_msg )
268268
269- relative_diff_threshold = 0.15 * baseline_p99
269+ relative_diff_threshold = 0.15 * baseline_p50
270270 if diff > diff_threshold and diff > relative_diff_threshold :
271271 final_messages .append (
272272 f"FAILURE: Import time regression of { diff :.2f} ms exceeds both the absolute threshold ({ diff_threshold } ms) "
273- f"and the relative threshold ({ relative_diff_threshold :.2f} ms, 15% of baseline P99 )."
273+ f"and the relative threshold ({ relative_diff_threshold :.2f} ms, 15% of baseline Median )."
274274 )
275275 exit_code = 1
276276 else :
@@ -379,8 +379,9 @@ def find_module_from_package(pkg):
379379 if files :
380380 init_files = [str (f ) for f in files if str (f ).endswith ('__init__.py' ) and '__pycache__' not in str (f ) and not str (f ).startswith ('tests/' )]
381381 if init_files :
382- shortest_init = min (init_files , key = lambda p : len (p .split ('/' )))
383- parts = shortest_init .split ('/' )[:- 1 ]
382+ from pathlib import Path
383+ shortest_init = min (init_files , key = lambda p : len (Path (p ).parts ))
384+ parts = Path (shortest_init ).parent .parts
384385 mod = '.' .join (parts )
385386 if importlib .util .find_spec (mod ):
386387 return mod
@@ -429,9 +430,9 @@ def find_module_from_package(pkg):
429430 parser .add_argument ("--cprofile" , action = "store_true" , help = "Run cProfile" )
430431 parser .add_argument ("--mprofile" , action = "store_true" , help = "Run tracemalloc memory snapshot" )
431432 parser .add_argument ("--keep-pycache" , action = "store_true" , help = "Preserve __pycache__ and allow bytecode execution (Default: False, script automatically sweeps __pycache__ for true cold-starts)" )
432- parser .add_argument ("--fail-threshold" , type = float , help = "Fail the profiling if the P99 time exceeds this threshold (in ms)." )
433+ parser .add_argument ("--fail-threshold" , type = float , help = "Fail the profiling if the Median time exceeds this threshold (in ms)." )
433434 parser .add_argument ("--diff-baseline" , help = "Path to a baseline CSV file to compare against." )
434- parser .add_argument ("--diff-threshold" , type = float , default = 100.0 , help = "Fail if P99 time exceeds baseline P99 by this many ms." )
435+ parser .add_argument ("--diff-threshold" , type = float , default = 100.0 , help = "Fail if Median time exceeds baseline Median by this many ms." )
435436 parser .add_argument ("--worker" , action = "store_true" , help = argparse .SUPPRESS )
436437
437438 args = parser .parse_args ()
0 commit comments