Add sampling configuration options to a parser.
(parser)
| 350 | |
| 351 | |
| 352 | def _add_sampling_options(parser): |
| 353 | """Add sampling configuration options to a parser.""" |
| 354 | sampling_group = parser.add_argument_group("Sampling configuration") |
| 355 | sampling_group.add_argument( |
| 356 | "-r", |
| 357 | "--sampling-rate", |
| 358 | type=_parse_sampling_rate, |
| 359 | default="1khz", |
| 360 | metavar="RATE", |
| 361 | dest="sample_interval_usec", |
| 362 | help="sampling rate (e.g., 10000, 10khz, 10k)", |
| 363 | ) |
| 364 | sampling_group.add_argument( |
| 365 | "-d", |
| 366 | "--duration", |
| 367 | type=int, |
| 368 | default=None, |
| 369 | metavar="SECONDS", |
| 370 | help="Sampling duration (default: run to completion)", |
| 371 | ) |
| 372 | sampling_group.add_argument( |
| 373 | "-a", |
| 374 | "--all-threads", |
| 375 | action="store_true", |
| 376 | help="Sample all threads in the process instead of just the main thread", |
| 377 | ) |
| 378 | sampling_group.add_argument( |
| 379 | "--realtime-stats", |
| 380 | action="store_true", |
| 381 | help="Print real-time sampling statistics (Hz, mean, min, max) during profiling", |
| 382 | ) |
| 383 | sampling_group.add_argument( |
| 384 | "--native", |
| 385 | action="store_true", |
| 386 | help='Include artificial "<native>" frames to denote calls to non-Python code', |
| 387 | ) |
| 388 | sampling_group.add_argument( |
| 389 | "--no-gc", |
| 390 | action="store_false", |
| 391 | dest="gc", |
| 392 | help='Don\'t include artificial "<GC>" frames to denote active garbage collection', |
| 393 | ) |
| 394 | sampling_group.add_argument( |
| 395 | "--opcodes", |
| 396 | action="store_true", |
| 397 | help="Gather bytecode opcode information for instruction-level profiling " |
| 398 | "(shows which bytecode instructions are executing, including specializations).", |
| 399 | ) |
| 400 | sampling_group.add_argument( |
| 401 | "--async-aware", |
| 402 | action="store_true", |
| 403 | help="Enable async-aware profiling (uses task-based stack reconstruction)", |
| 404 | ) |
| 405 | sampling_group.add_argument( |
| 406 | "--subprocesses", |
| 407 | action="store_true", |
| 408 | help="Also profile subprocesses. Each subprocess gets its own profiler and output file.", |
| 409 | ) |
searching dependent graphs…