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

Function parse_arguments

Tools/inspection/benchmark_external_inspection.py:315–368  ·  view source on GitHub ↗

Parse command line arguments

()

Source from the content-addressed store, hash-verified

313
314
315def parse_arguments():
316 """Parse command line arguments"""
317 # Build the code examples description
318 examples_desc = "\n".join(
319 [f" {name}: {info['description']}" for name, info in CODE_EXAMPLES.items()]
320 )
321
322 parser = argparse.ArgumentParser(
323 description="Benchmark get_stack_trace() performance",
324 formatter_class=argparse.RawDescriptionHelpFormatter,
325 epilog=f"""
326Examples:
327 %(prog)s # Run basic benchmark for 10 seconds (default)
328 %(prog)s --duration 30 # Run basic benchmark for 30 seconds
329 %(prog)s -d 60 # Run basic benchmark for 60 seconds
330 %(prog)s --code deep_static # Run deep static call stack benchmark
331 %(prog)s --code deep_static -d 30 # Run deep static benchmark for 30 seconds
332
333Available code examples:
334{examples_desc}
335 """,
336 color=True,
337 )
338
339 parser.add_argument(
340 "--duration",
341 "-d",
342 type=int,
343 default=10,
344 help="Benchmark duration in seconds (default: 10)",
345 )
346
347 parser.add_argument(
348 "--code",
349 "-c",
350 choices=list(CODE_EXAMPLES.keys()),
351 default="basic",
352 help="Code example to benchmark (default: basic)",
353 )
354
355 parser.add_argument(
356 "--threads",
357 choices=["all", "main", "only_active"],
358 default="all",
359 help="Which threads to include in the benchmark (default: all)",
360 )
361
362 parser.add_argument(
363 "--blocking",
364 action="store_true",
365 help="Stop all threads before sampling for consistent snapshots",
366 )
367
368 return parser.parse_args()
369
370
371def create_target_process(temp_file, code_example="basic"):

Callers 1

mainFunction · 0.85

Calls 6

parse_argsMethod · 0.95
listClass · 0.85
joinMethod · 0.45
itemsMethod · 0.45
add_argumentMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…