MCPcopy Index your code
hub / github.com/python/cpython / run_baseline_benchmark

Method run_baseline_benchmark

Tools/picklebench/memory_dos_impact.py:542–580  ·  view source on GitHub ↗

Run the benchmark using the baseline Python interpreter.

(baseline_python: str, args: argparse.Namespace)

Source from the content-addressed store, hash-verified

540
541 @staticmethod
542 def run_baseline_benchmark(baseline_python: str, args: argparse.Namespace) -> Dict[str, Dict[str, Any]]:
543 """Run the benchmark using the baseline Python interpreter."""
544 # Build command to run this script with baseline Python
545 cmd = [
546 baseline_python,
547 __file__,
548 '--format', 'json',
549 '--protocol', str(args.protocol),
550 '--iterations', str(args.iterations),
551 ]
552
553 if args.sizes is not None:
554 cmd.extend(['--sizes'] + [str(s) for s in args.sizes])
555
556 if args.antagonistic:
557 cmd.append('--antagonistic')
558
559 print(f"\nRunning baseline benchmark with: {baseline_python}")
560 print(f"Command: {' '.join(cmd)}\n")
561
562 try:
563 result = subprocess.run(
564 cmd,
565 capture_output=True,
566 text=True,
567 timeout=BASELINE_BENCHMARK_TIMEOUT_SECONDS,
568 )
569
570 if result.returncode != 0:
571 print(f"Error running baseline benchmark:", file=sys.stderr)
572 print(result.stderr, file=sys.stderr)
573 sys.exit(1)
574
575 # Extract and parse JSON from output
576 return Comparator._extract_json_from_output(result.stdout)
577
578 except subprocess.TimeoutExpired:
579 print("Error: Baseline benchmark timed out", file=sys.stderr)
580 sys.exit(1)
581
582 @staticmethod
583 def calculate_change(baseline_value: float, current_value: float) -> float:

Callers 1

mainFunction · 0.80

Calls 7

strFunction · 0.85
extendMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
runMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected